-
-
Notifications
You must be signed in to change notification settings - Fork 560
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make JsSet public * Some code review changes * Use intrinsics to construct, add public API test, IEnumerable, SetDelete => Remove --------- Co-authored-by: Marko Lahma <[email protected]>
- Loading branch information
Showing
7 changed files
with
84 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using FluentAssertions; | ||
using Jint.Native; | ||
|
||
namespace Jint.Tests.Runtime; | ||
|
||
public class SetTests | ||
{ | ||
[Fact] | ||
public void ConConstructSet() | ||
{ | ||
var engine = new Engine(); | ||
|
||
var set = engine.Intrinsics.Set.Construct(); | ||
set.Add(42); | ||
set.Add("foo"); | ||
set.Size.Should().Be(2); | ||
|
||
set.Should().ContainInOrder(42, "foo"); | ||
|
||
set.Has(42).Should().BeTrue(); | ||
set.Has("foo").Should().BeTrue(); | ||
set.Has(24).Should().BeFalse(); | ||
|
||
engine.SetValue("s", set); | ||
engine.Evaluate("s.size").Should().Be((JsNumber) 2); | ||
engine.Evaluate("s.has(42)").Should().Be(JsBoolean.True); | ||
engine.Evaluate("s.has('foo')").Should().Be(JsBoolean.True); | ||
engine.Evaluate("s.has(24)").Should().Be(JsBoolean.False); | ||
|
||
set.Remove(42).Should().BeTrue(); | ||
set.Has(42).Should().BeFalse(); | ||
engine.Evaluate("s.has(42)").Should().Be(JsBoolean.False); | ||
engine.Evaluate("s.size").Should().Be((JsNumber) 1); | ||
|
||
set.Clear(); | ||
set.Should().BeEmpty(); | ||
set.Size.Should().Be(0); | ||
engine.Evaluate("s.size").Should().Be((JsNumber) 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters