-
-
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.
Update ArrayBuffer, DataView and TypedArray related tests (#926)
- Loading branch information
Showing
1,042 changed files
with
16,540 additions
and
2,734 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
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
24 changes: 24 additions & 0 deletions
24
Jint.Tests.Test262/test/built-ins/ArrayBuffer/is-a-constructor.js
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,24 @@ | ||
// Copyright (C) 2020 Rick Waldron. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-ecmascript-standard-built-in-objects | ||
description: > | ||
The ArrayBuffer constructor implements [[Construct]] | ||
info: | | ||
IsConstructor ( argument ) | ||
The abstract operation IsConstructor takes argument argument (an ECMAScript language value). | ||
It determines if argument is a function object with a [[Construct]] internal method. | ||
It performs the following steps when called: | ||
If Type(argument) is not Object, return false. | ||
If argument has a [[Construct]] internal method, return true. | ||
Return false. | ||
includes: [isConstructor.js] | ||
features: [Reflect.construct, ArrayBuffer] | ||
---*/ | ||
|
||
assert.sameValue(isConstructor(ArrayBuffer), true, 'isConstructor(ArrayBuffer) must return true'); | ||
new ArrayBuffer(); | ||
|
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
29 changes: 29 additions & 0 deletions
29
Jint.Tests.Test262/test/built-ins/ArrayBuffer/isView/not-a-constructor.js
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,29 @@ | ||
// Copyright (C) 2020 Rick Waldron. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-ecmascript-standard-built-in-objects | ||
description: > | ||
ArrayBuffer.isView does not implement [[Construct]], is not new-able | ||
info: | | ||
ECMAScript Function Objects | ||
Built-in function objects that are not identified as constructors do not | ||
implement the [[Construct]] internal method unless otherwise specified in | ||
the description of a particular function. | ||
sec-evaluatenew | ||
... | ||
7. If IsConstructor(constructor) is false, throw a TypeError exception. | ||
... | ||
includes: [isConstructor.js] | ||
features: [Reflect.construct, ArrayBuffer, arrow-function] | ||
---*/ | ||
|
||
assert.sameValue(isConstructor(ArrayBuffer.isView), false, 'isConstructor(ArrayBuffer.isView) must return false'); | ||
|
||
assert.throws(TypeError, () => { | ||
new ArrayBuffer.isView(); | ||
}, '`new ArrayBuffer.isView()` throws TypeError'); | ||
|
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
22 changes: 22 additions & 0 deletions
22
Jint.Tests.Test262/test/built-ins/ArrayBuffer/options-maxbytelength-diminuitive.js
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,22 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-arraybuffer-constructor | ||
description: | | ||
Invoked with an options object whose `maxByteLength` property is less than | ||
the length. | ||
info: | | ||
ArrayBuffer( length [ , options ] ) | ||
1. If NewTarget is undefined, throw a TypeError exception. | ||
2. Let byteLength be ? ToIndex(length). | ||
3. Let requestedMaxByteLength be ? GetArrayBufferMaxByteLengthOption(options). | ||
4. If requestedMaxByteLength is empty, then | ||
a. [...] | ||
5. If byteLength > requestedMaxByteLength, throw a RangeError exception. | ||
features: [resizable-arraybuffer] | ||
---*/ | ||
|
||
assert.throws(RangeError, function() { | ||
new ArrayBuffer(1, {maxByteLength: 0}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
Jint.Tests.Test262/test/built-ins/ArrayBuffer/options-maxbytelength-excessive.js
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,28 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-arraybuffer-constructor | ||
description: | | ||
Invoked with an options object whose `maxByteLength` property exceeds the | ||
maximum length value | ||
info: | | ||
ArrayBuffer( length [ , options ] ) | ||
1. If NewTarget is undefined, throw a TypeError exception. | ||
2. Let byteLength be ? ToIndex(length). | ||
3. Let requestedMaxByteLength be ? GetArrayBufferMaxByteLengthOption(options). | ||
[...] | ||
1.1.5 GetArrayBufferMaxByteLengthOption ( options ) | ||
1. If Type(options) is not Object, return empty. | ||
2. Let maxByteLength be ? Get(options, "maxByteLength"). | ||
3. If maxByteLength is undefined, return empty. | ||
4. Return ? ToIndex(maxByteLength). | ||
features: [resizable-arraybuffer] | ||
---*/ | ||
|
||
assert.throws(RangeError, function() { | ||
// Math.pow(2, 53) = 9007199254740992 | ||
new ArrayBuffer(0, { maxByteLength: 9007199254740992 }); | ||
}); |
25 changes: 25 additions & 0 deletions
25
Jint.Tests.Test262/test/built-ins/ArrayBuffer/options-maxbytelength-negative.js
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,25 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-arraybuffer-constructor | ||
description: Invoked with an options object whose `maxByteLength` property is negative | ||
info: | | ||
ArrayBuffer( length [ , options ] ) | ||
1. If NewTarget is undefined, throw a TypeError exception. | ||
2. Let byteLength be ? ToIndex(length). | ||
3. Let requestedMaxByteLength be ? GetArrayBufferMaxByteLengthOption(options). | ||
[...] | ||
1.1.5 GetArrayBufferMaxByteLengthOption ( options ) | ||
1. If Type(options) is not Object, return empty. | ||
2. Let maxByteLength be ? Get(options, "maxByteLength"). | ||
3. If maxByteLength is undefined, return empty. | ||
4. Return ? ToIndex(maxByteLength). | ||
features: [resizable-arraybuffer] | ||
---*/ | ||
|
||
assert.throws(RangeError, function() { | ||
new ArrayBuffer(0, { maxByteLength: -1 }); | ||
}); |
45 changes: 45 additions & 0 deletions
45
Jint.Tests.Test262/test/built-ins/ArrayBuffer/options-maxbytelength-object.js
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,45 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-arraybuffer-constructor | ||
description: | | ||
Invoked with an options object whose `maxByteLength` property cannot be | ||
coerced to a primitive value | ||
info: | | ||
ArrayBuffer( length [ , options ] ) | ||
1. If NewTarget is undefined, throw a TypeError exception. | ||
2. Let byteLength be ? ToIndex(length). | ||
3. Let requestedMaxByteLength be ? GetArrayBufferMaxByteLengthOption(options). | ||
[...] | ||
1.1.5 GetArrayBufferMaxByteLengthOption ( options ) | ||
1. If Type(options) is not Object, return empty. | ||
2. Let maxByteLength be ? Get(options, "maxByteLength"). | ||
3. If maxByteLength is undefined, return empty. | ||
4. Return ? ToIndex(maxByteLength). | ||
features: [resizable-arraybuffer] | ||
---*/ | ||
|
||
var log = []; | ||
var options = { | ||
maxByteLength: { | ||
toString: function() { | ||
log.push('toString'); | ||
return {}; | ||
}, | ||
valueOf: function() { | ||
log.push('valueOf'); | ||
return {}; | ||
} | ||
} | ||
}; | ||
|
||
assert.throws(TypeError, function() { | ||
new ArrayBuffer(0, options); | ||
}); | ||
|
||
assert.sameValue(log.length, 2); | ||
assert.sameValue(log[0], 'valueOf'); | ||
assert.sameValue(log[1], 'toString'); |
29 changes: 29 additions & 0 deletions
29
Jint.Tests.Test262/test/built-ins/ArrayBuffer/options-maxbytelength-poisoned.js
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,29 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-arraybuffer-constructor | ||
description: Invoked with an options object whose `maxByteLength` property throws | ||
info: | | ||
ArrayBuffer( length [ , options ] ) | ||
1. If NewTarget is undefined, throw a TypeError exception. | ||
2. Let byteLength be ? ToIndex(length). | ||
3. Let requestedMaxByteLength be ? GetArrayBufferMaxByteLengthOption(options). | ||
[...] | ||
1.1.5 GetArrayBufferMaxByteLengthOption ( options ) | ||
1. If Type(options) is not Object, return empty. | ||
2. Let maxByteLength be ? Get(options, "maxByteLength"). | ||
features: [resizable-arraybuffer] | ||
---*/ | ||
|
||
var options = { | ||
get maxByteLength() { | ||
throw new Test262Error(); | ||
} | ||
}; | ||
|
||
assert.throws(Test262Error, function() { | ||
new ArrayBuffer(0, options); | ||
}); |
24 changes: 24 additions & 0 deletions
24
Jint.Tests.Test262/test/built-ins/ArrayBuffer/options-maxbytelength-undefined.js
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,24 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-arraybuffer-constructor | ||
description: Invoked with an options object whose `maxByteLength` property is undefined | ||
info: | | ||
ArrayBuffer( length [ , options ] ) | ||
1. If NewTarget is undefined, throw a TypeError exception. | ||
2. Let byteLength be ? ToIndex(length). | ||
3. Let requestedMaxByteLength be ? GetArrayBufferMaxByteLengthOption(options). | ||
4. If requestedMaxByteLength is empty, then | ||
a. Return ? AllocateArrayBuffer(NewTarget, byteLength). | ||
1.1.5 GetArrayBufferMaxByteLengthOption ( options ) | ||
1. If Type(options) is not Object, return empty. | ||
2. Let maxByteLength be ? Get(options, "maxByteLength"). | ||
3. If maxByteLength is undefined, return empty. | ||
features: [resizable-arraybuffer] | ||
---*/ | ||
|
||
assert.sameValue(new ArrayBuffer(0, {}).resizable, false); | ||
assert.sameValue(new ArrayBuffer(0, {maxByteLength: undefined}).resizable, false); |
27 changes: 27 additions & 0 deletions
27
Jint.Tests.Test262/test/built-ins/ArrayBuffer/options-non-object.js
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,27 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-arraybuffer-constructor | ||
description: Invoked with a non-object value for options | ||
info: | | ||
ArrayBuffer( length [ , options ] ) | ||
1. If NewTarget is undefined, throw a TypeError exception. | ||
2. Let byteLength be ? ToIndex(length). | ||
3. Let requestedMaxByteLength be ? GetArrayBufferMaxByteLengthOption(options). | ||
4. If requestedMaxByteLength is empty, then | ||
a. Return ? AllocateArrayBuffer(NewTarget, byteLength). | ||
1.1.5 GetArrayBufferMaxByteLengthOption ( options ) | ||
1. If Type(options) is not Object, return empty. | ||
features: [resizable-arraybuffer] | ||
---*/ | ||
|
||
assert.sameValue(new ArrayBuffer(0, null).resizable, false, 'null'); | ||
assert.sameValue(new ArrayBuffer(0, true).resizable, false, 'boolean'); | ||
assert.sameValue(new ArrayBuffer(0, Symbol(3)).resizable, false, 'symbol'); | ||
assert.sameValue(new ArrayBuffer(0, 1n).resizable, false, 'bigint'); | ||
assert.sameValue(new ArrayBuffer(0, 'string').resizable, false, 'string'); | ||
assert.sameValue(new ArrayBuffer(0, 9).resizable, false, 'number'); | ||
assert.sameValue(new ArrayBuffer(0, undefined).resizable, false, 'undefined'); |
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
Oops, something went wrong.