-
-
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.
Update test suite and implement Set.union (#1692)
- Loading branch information
Showing
8 changed files
with
164 additions
and
73 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
using Jint.Native; | ||
|
||
namespace Jint.Runtime | ||
namespace Jint.Runtime; | ||
|
||
internal static class CommonProperties | ||
{ | ||
internal static class CommonProperties | ||
{ | ||
internal static readonly JsString Arguments = JsString.CachedCreate("arguments"); | ||
internal static readonly JsString Caller = JsString.CachedCreate("caller"); | ||
internal static readonly JsString Callee = JsString.CachedCreate("callee"); | ||
internal static readonly JsString Constructor = JsString.CachedCreate("constructor"); | ||
internal static readonly JsString Eval = JsString.CachedCreate("eval"); | ||
internal static readonly JsString Infinity = JsString.CachedCreate("Infinity"); | ||
internal static readonly JsString Length = JsString.CachedCreate("length"); | ||
internal static readonly JsString Name = JsString.CachedCreate("name"); | ||
internal static readonly JsString Prototype = JsString.CachedCreate("prototype"); | ||
internal static readonly JsString Size = JsString.CachedCreate("size"); | ||
internal static readonly JsString Next = JsString.CachedCreate("next"); | ||
internal static readonly JsString Done = JsString.CachedCreate("done"); | ||
internal static readonly JsString Value = JsString.CachedCreate("value"); | ||
internal static readonly JsString Return = JsString.CachedCreate("return"); | ||
internal static readonly JsString Set = JsString.CachedCreate("set"); | ||
internal static readonly JsString Get = JsString.CachedCreate("get"); | ||
internal static readonly JsString Writable = JsString.CachedCreate("writable"); | ||
internal static readonly JsString Enumerable = JsString.CachedCreate("enumerable"); | ||
internal static readonly JsString Configurable = JsString.CachedCreate("configurable"); | ||
internal static readonly JsString Stack = JsString.CachedCreate("stack"); | ||
internal static readonly JsString Message = JsString.CachedCreate("message"); | ||
} | ||
internal static readonly JsString Arguments = JsString.CachedCreate("arguments"); | ||
internal static readonly JsString Callee = JsString.CachedCreate("callee"); | ||
internal static readonly JsString Caller = JsString.CachedCreate("caller"); | ||
internal static readonly JsString Configurable = JsString.CachedCreate("configurable"); | ||
internal static readonly JsString Constructor = JsString.CachedCreate("constructor"); | ||
internal static readonly JsString Done = JsString.CachedCreate("done"); | ||
internal static readonly JsString Enumerable = JsString.CachedCreate("enumerable"); | ||
internal static readonly JsString Eval = JsString.CachedCreate("eval"); | ||
internal static readonly JsString Get = JsString.CachedCreate("get"); | ||
internal static readonly JsString Has = JsString.CachedCreate("has"); | ||
internal static readonly JsString Infinity = JsString.CachedCreate("Infinity"); | ||
internal static readonly JsString Keys = JsString.CachedCreate("keys"); | ||
internal static readonly JsString Length = JsString.CachedCreate("length"); | ||
internal static readonly JsString Message = JsString.CachedCreate("message"); | ||
internal static readonly JsString Name = JsString.CachedCreate("name"); | ||
internal static readonly JsString Next = JsString.CachedCreate("next"); | ||
internal static readonly JsString Prototype = JsString.CachedCreate("prototype"); | ||
internal static readonly JsString Return = JsString.CachedCreate("return"); | ||
internal static readonly JsString Set = JsString.CachedCreate("set"); | ||
internal static readonly JsString Size = JsString.CachedCreate("size"); | ||
internal static readonly JsString Stack = JsString.CachedCreate("stack"); | ||
internal static readonly JsString Value = JsString.CachedCreate("value"); | ||
internal static readonly JsString Writable = JsString.CachedCreate("writable"); | ||
} |
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 |
---|---|---|
@@ -1,50 +1,58 @@ | ||
namespace Jint.Runtime | ||
namespace Jint.Runtime; | ||
|
||
internal sealed class OrderedSet<T> | ||
{ | ||
internal sealed class OrderedSet<T> | ||
{ | ||
internal readonly List<T> _list; | ||
private readonly HashSet<T> _set; | ||
internal List<T> _list; | ||
private HashSet<T> _set; | ||
|
||
public OrderedSet(IEqualityComparer<T> comparer) | ||
{ | ||
_list = new List<T>(); | ||
_set = new HashSet<T>(comparer); | ||
} | ||
public OrderedSet(IEqualityComparer<T> comparer) | ||
{ | ||
_list = new List<T>(); | ||
_set = new HashSet<T>(comparer); | ||
} | ||
|
||
public T this[int index] | ||
public T this[int index] | ||
{ | ||
get => _list[index]; | ||
set | ||
{ | ||
get => _list[index]; | ||
set | ||
if (_set.Add(value)) | ||
{ | ||
if (_set.Add(value)) | ||
{ | ||
_list[index] = value; | ||
} | ||
_list[index] = value; | ||
} | ||
} | ||
} | ||
|
||
public void Add(T item) | ||
public OrderedSet<T> Clone() | ||
{ | ||
return new OrderedSet<T>(EqualityComparer<T>.Default) | ||
{ | ||
if (_set.Add(item)) | ||
{ | ||
_list.Add(item); | ||
} | ||
} | ||
_set = new HashSet<T>(this._set, this._set.Comparer), | ||
_list = new List<T>(this._list) | ||
}; | ||
} | ||
|
||
public void Clear() | ||
public void Add(T item) | ||
{ | ||
if (_set.Add(item)) | ||
{ | ||
_list.Clear(); | ||
_set.Clear(); | ||
_list.Add(item); | ||
} | ||
} | ||
|
||
public void Clear() | ||
{ | ||
_list.Clear(); | ||
_set.Clear(); | ||
} | ||
|
||
public bool Contains(T item) => _set.Contains(item); | ||
public bool Contains(T item) => _set.Contains(item); | ||
|
||
public int Count => _list.Count; | ||
public int Count => _list.Count; | ||
|
||
public bool Remove(T item) | ||
{ | ||
_set.Remove(item); | ||
return _list.Remove(item); | ||
} | ||
public bool Remove(T item) | ||
{ | ||
_set.Remove(item); | ||
return _list.Remove(item); | ||
} | ||
} |