-
-
Notifications
You must be signed in to change notification settings - Fork 547
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,320 additions
and
102 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Xunit; | ||
|
||
namespace Jint.Tests.Test262.BuiltIns | ||
{ | ||
public class ArrayBufferTests : Test262Test | ||
{ | ||
[Theory(DisplayName = "built-ins\\ArrayBuffer")] | ||
[MemberData(nameof(SourceFiles), "built-ins\\ArrayBuffer", false)] | ||
[MemberData(nameof(SourceFiles), "built-ins\\ArrayBuffer", true, Skip = "Skipped")] | ||
protected void RunTest(SourceFile sourceFile) | ||
{ | ||
RunTestInternal(sourceFile); | ||
} | ||
} | ||
} |
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,15 @@ | ||
using Xunit; | ||
|
||
namespace Jint.Tests.Test262.BuiltIns | ||
{ | ||
public class DataViewTests : Test262Test | ||
{ | ||
[Theory(DisplayName = "built-ins\\DataView")] | ||
[MemberData(nameof(SourceFiles), "built-ins\\DataView", false)] | ||
[MemberData(nameof(SourceFiles), "built-ins\\DataView", true, Skip = "Skipped")] | ||
protected void RunTest(SourceFile sourceFile) | ||
{ | ||
RunTestInternal(sourceFile); | ||
} | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
Jint.Tests.Test262/BuiltIns/StringIteratorPrototypeTests.cs
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using Jint.Collections; | ||
using Jint.Native.DataView; | ||
using Jint.Native.Function; | ||
using Jint.Native.Object; | ||
using Jint.Native.Symbol; | ||
using Jint.Runtime; | ||
using Jint.Runtime.Descriptors; | ||
using Jint.Runtime.Interop; | ||
|
||
namespace Jint.Native.ArrayBuffer | ||
{ | ||
/// <summary> | ||
/// https://tc39.es/ecma262/#sec-properties-of-the-arraybuffer-constructor | ||
/// </summary> | ||
public sealed class ArrayBufferConstructor : FunctionInstance, IConstructor | ||
{ | ||
private static readonly JsString _functionName = new("ArrayBuffer"); | ||
|
||
internal ArrayBufferConstructor( | ||
Engine engine, | ||
Realm realm, | ||
FunctionPrototype functionPrototype, | ||
ObjectPrototype objectPrototype) | ||
: base(engine, realm, _functionName) | ||
{ | ||
_prototype = functionPrototype; | ||
PrototypeObject = new ArrayBufferPrototype(engine, realm, this, objectPrototype); | ||
_length = new PropertyDescriptor(1, PropertyFlag.Configurable); | ||
_prototypeDescriptor = new PropertyDescriptor(PrototypeObject, PropertyFlag.AllForbidden); | ||
} | ||
|
||
public ArrayBufferPrototype PrototypeObject { get; } | ||
|
||
protected override void Initialize() | ||
{ | ||
const PropertyFlag lengthFlags = PropertyFlag.Configurable; | ||
var properties = new PropertyDictionary(1, checkExistingKeys: false) | ||
{ | ||
["isView"] = new PropertyDescriptor(new PropertyDescriptor(new ClrFunctionInstance(Engine, "isView", IsView, 1, lengthFlags), PropertyFlag.Configurable | PropertyFlag.Writable)), | ||
}; | ||
SetProperties(properties); | ||
|
||
var symbols = new SymbolDictionary(1) | ||
{ | ||
[GlobalSymbolRegistry.Species] = new GetSetPropertyDescriptor(get: new ClrFunctionInstance(Engine, "get [Symbol.species]", Species, 0, lengthFlags), set: Undefined,PropertyFlag.Configurable), | ||
}; | ||
SetSymbols(symbols); | ||
} | ||
|
||
/// <summary> | ||
/// https://tc39.es/ecma262/#sec-arraybuffer.isview | ||
/// </summary> | ||
private static JsValue IsView(JsValue thisObject, JsValue[] arguments) | ||
{ | ||
var arg = arguments.At(0); | ||
return arg is DataViewInstance; | ||
} | ||
|
||
/// <summary> | ||
/// https://tc39.es/ecma262/#sec-get-arraybuffer-@@species | ||
/// </summary> | ||
private static JsValue Species(JsValue thisObject, JsValue[] arguments) | ||
{ | ||
return thisObject; | ||
} | ||
|
||
public override JsValue Call(JsValue thisObject, JsValue[] arguments) | ||
{ | ||
ExceptionHelper.ThrowTypeError(_realm, "Constructor ArrayBuffer requires 'new'"); | ||
return Undefined; | ||
} | ||
|
||
public ObjectInstance Construct(JsValue[] arguments, JsValue newTarget) | ||
{ | ||
if (newTarget.IsUndefined()) | ||
{ | ||
ExceptionHelper.ThrowTypeError(_realm); | ||
} | ||
|
||
var byteLength = TypeConverter.ToIndex(_realm, arguments.At(0)); | ||
return AllocateArrayBuffer(newTarget, byteLength); | ||
} | ||
|
||
internal ArrayBufferInstance AllocateArrayBuffer(JsValue constructor, uint byteLength) | ||
{ | ||
var obj = OrdinaryCreateFromConstructor( | ||
constructor, | ||
static intrinsics => intrinsics.ArrayBuffer.PrototypeObject, | ||
static (engine, realm, state) => new ArrayBufferInstance(engine, (uint) ((JsNumber) state)._value), | ||
JsNumber.Create(byteLength)); | ||
|
||
return obj; | ||
} | ||
} | ||
} |
Oops, something went wrong.