mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
IntegerIndexedElementSet ( O, index, value )
This commit is contained in:
parent
47be1e83e2
commit
5f299199c6
test/built-ins/TypedArrayConstructors/internals/Set
BigInt
bigint-tobigint64.jsbigint-tobiguint64.jsboolean-tobigint.jsdetached-buffer-key-is-not-numeric-index.jsdetached-buffer-key-is-symbol.jsdetached-buffer-realm.jsdetached-buffer.jsindexed-value.jskey-is-minus-zero.jskey-is-not-canonical-index.jskey-is-not-integer.jskey-is-not-numeric-index-set-throws.jskey-is-not-numeric-index.jskey-is-out-of-bounds.jskey-is-symbol.jsnull-tobigint.jsnumber-tobigint.jsstring-nan-tobigint.jsstring-tobigint.jssymbol-tobigint.jstonumber-value-detached-buffer.jstonumber-value-throws.jsundefined-tobigint.js
conversion-operation-consistent-nan.jsconversion-operation.jsdetached-buffer-key-is-not-numeric-index.jsdetached-buffer-key-is-symbol.jsdetached-buffer-realm.jsdetached-buffer.jsindexed-value.jskey-is-minus-zero.jskey-is-not-canonical-index.jskey-is-not-integer.jskey-is-not-numeric-index-set-throws.jskey-is-not-numeric-index.jskey-is-out-of-bounds.jskey-is-symbol.jstonumber-value-detached-buffer.jstonumber-value-throws.js@ -67,44 +67,34 @@ info: |
|
||||
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
// 2n ** 64n + 2n
|
||||
// 2n ** 63n + 2n
|
||||
// -(2n ** 63n) - 2n
|
||||
// -(2n ** 64n) - 2n
|
||||
// 2n - 2n ** 63n
|
||||
// 2n ** 63n - 2
|
||||
var vals = [
|
||||
18446744073709551618n, // 2n ** 64n + 2n
|
||||
9223372036854775810n, // 2n ** 63n + 2n
|
||||
18446744073709551618n,
|
||||
9223372036854775810n,
|
||||
2n,
|
||||
0n,
|
||||
-2n,
|
||||
-9223372036854775810n, // -(2n ** 63n) - 2n
|
||||
-18446744073709551618n, // -(2n ** 64n) - 2n
|
||||
-9223372036854775810n,
|
||||
-18446744073709551618n
|
||||
];
|
||||
|
||||
var typedArray = new BigInt64Array(1);
|
||||
|
||||
typedArray[0] = vals[0];
|
||||
assert.sameValue(typedArray[0], 2n,
|
||||
"ToBigInt64(2n ** 64n + 2n) => 2n");
|
||||
|
||||
assert.sameValue(typedArray[0], 2n, 'The value of typedArray[0] is 2n');
|
||||
typedArray[0] = vals[1];
|
||||
assert.sameValue(typedArray[0], -9223372036854775806n, // 2n - 2n ** 63n
|
||||
"ToBigInt64(2n ** 63n + 2n) => -9223372036854775806n");
|
||||
|
||||
assert.sameValue(typedArray[0], -9223372036854775806n, 'The value of typedArray[0] is -9223372036854775806n');
|
||||
typedArray[0] = vals[2];
|
||||
assert.sameValue(typedArray[0], 2n,
|
||||
"ToBigInt64(2n) => 2n");
|
||||
|
||||
assert.sameValue(typedArray[0], 2n, 'The value of typedArray[0] is 2n');
|
||||
typedArray[0] = vals[3];
|
||||
assert.sameValue(typedArray[0], 0n,
|
||||
"ToBigInt64(0n) => 0n");
|
||||
|
||||
assert.sameValue(typedArray[0], 0n, 'The value of typedArray[0] is 0n');
|
||||
typedArray[0] = vals[4];
|
||||
assert.sameValue(typedArray[0], -2n,
|
||||
"ToBigInt64( -2n) => -2n");
|
||||
|
||||
assert.sameValue(typedArray[0], -2n, 'The value of typedArray[0] is -2n');
|
||||
typedArray[0] = vals[5];
|
||||
assert.sameValue(typedArray[0], 9223372036854775806n, // 2n ** 63n - 2
|
||||
"ToBigInt64( -(2n ** 64n) - 2n) => 9223372036854775806n");
|
||||
|
||||
assert.sameValue(typedArray[0], 9223372036854775806n, 'The value of typedArray[0] is 9223372036854775806n');
|
||||
typedArray[0] = vals[6];
|
||||
assert.sameValue(typedArray[0], -2n,
|
||||
"ToBigInt64( -(2n ** 64n) - 2n) => -2n");
|
||||
|
||||
assert.sameValue(typedArray[0], -2n, 'The value of typedArray[0] is -2n');
|
||||
|
@ -67,43 +67,36 @@ info: |
|
||||
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
// 2n ** 64n + 2n
|
||||
// 2n ** 63n + 2n
|
||||
// -(2n ** 63n) - 2n
|
||||
// -(2n ** 64n) - 2n
|
||||
// 2n ** 63n + 2n
|
||||
// 2n ** 64n - 2n
|
||||
// 2n ** 63n - 2n
|
||||
// 2n ** 64n - 2n
|
||||
var vals = [
|
||||
18446744073709551618n, // 2n ** 64n + 2n
|
||||
9223372036854775810n, // 2n ** 63n + 2n
|
||||
18446744073709551618n,
|
||||
9223372036854775810n,
|
||||
2n,
|
||||
0n,
|
||||
-2n,
|
||||
-9223372036854775810n, // -(2n ** 63n) - 2n
|
||||
-18446744073709551618n, // -(2n ** 64n) - 2n
|
||||
-9223372036854775810n,
|
||||
-18446744073709551618n
|
||||
];
|
||||
|
||||
var typedArray = new BigUint64Array(1);
|
||||
|
||||
typedArray[0] = vals[0];
|
||||
assert.sameValue(typedArray[0], 2n,
|
||||
"ToBigUint64(2n ** 64n + 2n) => 2n");
|
||||
|
||||
assert.sameValue(typedArray[0], 2n, 'The value of typedArray[0] is 2n');
|
||||
typedArray[0] = vals[1];
|
||||
assert.sameValue(typedArray[0], 9223372036854775810n, // 2n ** 63n + 2n
|
||||
"ToBigUint64(2n ** 63n + 2n) => 9223372036854775810");
|
||||
|
||||
assert.sameValue(typedArray[0], 9223372036854775810n, 'The value of typedArray[0] is 9223372036854775810n');
|
||||
typedArray[0] = vals[2];
|
||||
assert.sameValue(typedArray[0], 2n,
|
||||
"ToBigUint64(2n) => 2n");
|
||||
|
||||
assert.sameValue(typedArray[0], 2n, 'The value of typedArray[0] is 2n');
|
||||
typedArray[0] = vals[3];
|
||||
assert.sameValue(typedArray[0], 0n,
|
||||
"ToBigUint64(0n) => 0n");
|
||||
|
||||
assert.sameValue(typedArray[0], 0n, 'The value of typedArray[0] is 0n');
|
||||
typedArray[0] = vals[4];
|
||||
assert.sameValue(typedArray[0], 18446744073709551614n, // 2n ** 64n - 2n
|
||||
"ToBigUint64( -2n) => 18446744073709551614n");
|
||||
|
||||
assert.sameValue(typedArray[0], 18446744073709551614n, 'The value of typedArray[0] is 18446744073709551614n');
|
||||
typedArray[0] = vals[5];
|
||||
assert.sameValue(typedArray[0], 9223372036854775806n, // 2n ** 63n - 2n
|
||||
"ToBigUint64( -(2n ** 63n) - 2n) => 9223372036854775806n");
|
||||
|
||||
assert.sameValue(typedArray[0], 9223372036854775806n, 'The value of typedArray[0] is 9223372036854775806n');
|
||||
typedArray[0] = vals[6];
|
||||
assert.sameValue(typedArray[0], 18446744073709551614n, // 2n ** 64n - 2n
|
||||
"ToBigUint64( -(2n ** 64n) - 2n) => 18446744073709551614n");
|
||||
assert.sameValue(typedArray[0], 18446744073709551614n, 'The value of typedArray[0] is 18446744073709551614n');
|
||||
|
@ -50,12 +50,10 @@ info: |
|
||||
includes: [testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var typedArray = new TA(2);
|
||||
typedArray[0] = false;
|
||||
typedArray[1] = true;
|
||||
|
||||
assert.sameValue(typedArray[0], 0n, "False converts to BigInt");
|
||||
assert.sameValue(typedArray[1], 1n, "True converts to BigInt");
|
||||
assert.sameValue(typedArray[0], 0n, 'The value of typedArray[0] is 0n');
|
||||
assert.sameValue(typedArray[1], 1n, 'The value of typedArray[1] is 1n');
|
||||
});
|
||||
|
@ -16,11 +16,15 @@ info: |
|
||||
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
|
||||
features: [BigInt, Reflect, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42n, 43n]);
|
||||
var sample = new TA(2);
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
|
||||
assert.sameValue(Reflect.set(sample, "foo", "test262"), true);
|
||||
assert.sameValue(sample.foo, "test262");
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, 'foo', 'test262'),
|
||||
true,
|
||||
'Reflect.set(sample, "foo", "test262") must return true'
|
||||
);
|
||||
|
||||
assert.sameValue(sample.foo, 'test262', 'The value of sample.foo is "test262"');
|
||||
});
|
||||
|
@ -14,13 +14,17 @@ info: |
|
||||
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
|
||||
features: [BigInt, Symbol, Reflect, TypedArray]
|
||||
---*/
|
||||
|
||||
var s = Symbol("1");
|
||||
var s = Symbol('1');
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42n, 43n]);
|
||||
var sample = new TA(2);
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
|
||||
assert.sameValue(Reflect.set(sample, s, "test262"), true);
|
||||
assert.sameValue(sample[s], "test262");
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, s, 'test262'),
|
||||
true,
|
||||
'Reflect.set(sample, "Symbol(\\"1\\")", "test262") must return true'
|
||||
);
|
||||
|
||||
assert.sameValue(sample[s], 'test262', 'The value of sample[s] is "test262"');
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*---
|
||||
esid: sec-integer-indexed-exotic-objects-set-p-v-receiver
|
||||
description: >
|
||||
Returns false if key has a numeric index and object has a detached
|
||||
Returns false if Throws a TypeError if key has a numeric index and object has a detached
|
||||
buffer (honoring the Realm of the current execution context)
|
||||
info: |
|
||||
9.4.5.5 [[Set]] ( P, V, Receiver)
|
||||
@ -15,7 +15,7 @@ info: |
|
||||
i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||
...
|
||||
|
||||
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
||||
IntegerIndexedElementSet ( O, index, value )
|
||||
|
||||
Assert: O is an Integer-Indexed exotic object.
|
||||
Assert: Type(index) is Number.
|
||||
@ -23,17 +23,15 @@ info: |
|
||||
Otherwise, let numValue be ? ToNumber(value).
|
||||
Let buffer be O.[[ViewedArrayBuffer]].
|
||||
If IsDetachedBuffer(buffer) is true, return false.
|
||||
If ! IsValidIntegerIndex(O, index) is false, return false.
|
||||
|
||||
...
|
||||
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
|
||||
features: [BigInt, cross-realm, TypedArray]
|
||||
---*/
|
||||
var other = $262.createRealm().global;
|
||||
|
||||
let other = $262.createRealm().global;
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var OtherTA = other[TA.name];
|
||||
var sample = new OtherTA(1);
|
||||
let OtherTA = other[TA.name];
|
||||
let sample = new OtherTA(1);
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
sample[0] = 0n;
|
||||
assert.sameValue(sample[0], undefined, 'The value of sample[0] is expected to equal `undefined`');
|
||||
assert.sameValue(sample[0] = 1n, false, '`sample[0] = 1n` is false');
|
||||
});
|
||||
|
@ -3,18 +3,18 @@
|
||||
/*---
|
||||
esid: sec-integer-indexed-exotic-objects-set-p-v-receiver
|
||||
description: >
|
||||
Returns false if key has a numeric index and object has a detached buffer
|
||||
Returns true when setting the value of any CanonicalNumericIndexString if buffer is detached.
|
||||
info: |
|
||||
9.4.5.5 [[Set]] ( P, V, Receiver)
|
||||
[[Set]] ( P, V, Receiver)
|
||||
|
||||
...
|
||||
2. If Type(P) is String, then
|
||||
a. Let numericIndex be ! CanonicalNumericIndexString(P).
|
||||
b. If numericIndex is not undefined, then
|
||||
i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||
If Type(P) is String, then
|
||||
Let numericIndex be ! CanonicalNumericIndexString(P).
|
||||
If numericIndex is not undefined, then
|
||||
Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||
...
|
||||
|
||||
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
||||
IntegerIndexedElementSet ( O, index, value )
|
||||
|
||||
Assert: O is an Integer-Indexed exotic object.
|
||||
Assert: Type(index) is Number.
|
||||
@ -22,13 +22,12 @@ info: |
|
||||
Otherwise, let numValue be ? ToNumber(value).
|
||||
Let buffer be O.[[ViewedArrayBuffer]].
|
||||
If IsDetachedBuffer(buffer) is true, return false.
|
||||
If ! IsValidIntegerIndex(O, index) is false, return false.
|
||||
|
||||
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42n]);
|
||||
let sample = new TA([42n]);
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
assert.sameValue(sample[0] = 1n, false, '`sample[0] = 1n` is false');
|
||||
assert.sameValue(sample['1.1'] = 1n, false, '`sample["1.1"] = 1n` is false');
|
||||
@ -37,8 +36,8 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert.sameValue(sample['1'] = 1n, false, '`sample["1"] = 1n` is false');
|
||||
assert.sameValue(sample['2'] = 1n, false, '`sample["2"] = 1n` is false');
|
||||
|
||||
var obj = {
|
||||
valueOf: function() {
|
||||
let obj = {
|
||||
valueOf() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
};
|
||||
|
@ -23,21 +23,20 @@ includes: [testBigIntTypedArray.js]
|
||||
features: [BigInt, Reflect, TypedArray]
|
||||
---*/
|
||||
|
||||
var proto = TypedArray.prototype;
|
||||
var throwDesc = {
|
||||
let proto = TypedArray.prototype;
|
||||
let throwDesc = {
|
||||
set: function() {
|
||||
throw new Test262Error("OrdinarySet was called! Ref: 9.1.9.1 3.b.i");
|
||||
throw new Test262Error('OrdinarySet was called!');
|
||||
}
|
||||
};
|
||||
Object.defineProperty(proto, "0", throwDesc);
|
||||
Object.defineProperty(proto, "1", throwDesc);
|
||||
|
||||
Object.defineProperty(proto, '0', throwDesc);
|
||||
Object.defineProperty(proto, '1', throwDesc);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42n, 43n]);
|
||||
|
||||
assert.sameValue(Reflect.set(sample, "0", 1n), true, "sample[0]");
|
||||
assert.sameValue(sample[0], 1n, "sample[0] value is set");
|
||||
|
||||
assert.sameValue(Reflect.set(sample, "1", 42n), true, "sample[1]");
|
||||
assert.sameValue(sample[1], 42n, "sample[1] value is set");
|
||||
let sample = new TA(2);
|
||||
assert.sameValue(Reflect.set(sample, '0', 1n), true, 'Reflect.set(sample, "0", 1n) must return true');
|
||||
assert.sameValue(sample[0], 1n, 'The value of sample[0] is 1n');
|
||||
assert.sameValue(Reflect.set(sample, '1', 42n), true, 'Reflect.set(sample, "1", 42n) must return true');
|
||||
assert.sameValue(sample[1], 42n, 'The value of sample[1] is 42n');
|
||||
});
|
||||
|
@ -22,10 +22,8 @@ info: |
|
||||
includes: [testBigIntTypedArray.js]
|
||||
features: [BigInt, Reflect, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42n]);
|
||||
|
||||
assert.sameValue(Reflect.set(sample, "-0", 1n), false, "-0");
|
||||
assert.sameValue(sample.hasOwnProperty("-0"), false, "has no property [-0]");
|
||||
assert.sameValue(Reflect.set(sample, '-0', 1n), false, 'Reflect.set("new TA([42n])", "-0", 1n) must return false');
|
||||
assert.sameValue(sample.hasOwnProperty('-0'), false, 'sample.hasOwnProperty("-0") must return false');
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*---
|
||||
esid: sec-integer-indexed-exotic-objects-set-p-v-receiver
|
||||
description: >
|
||||
Use OrginarySet if numeric key is not a CanonicalNumericIndex
|
||||
Use OrdinarySet if numeric key is not a CanonicalNumericIndex
|
||||
info: |
|
||||
9.4.5.5 [[Set]] ( P, V, Receiver)
|
||||
|
||||
@ -16,43 +16,34 @@ info: |
|
||||
includes: [testBigIntTypedArray.js]
|
||||
features: [BigInt, Reflect, TypedArray]
|
||||
---*/
|
||||
|
||||
var keys = [
|
||||
"1.0",
|
||||
"+1",
|
||||
"1000000000000000000000",
|
||||
"0.0000001"
|
||||
];
|
||||
var keys = ['1.0', '+1', '1000000000000000000000', '0.0000001'];
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
keys.forEach(function(key) {
|
||||
var sample = new TA([42n]);
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, key, "ecma262"),
|
||||
Reflect.set(sample, key, 'ecma262'),
|
||||
true,
|
||||
"Return true setting a new property [" + key + "]"
|
||||
'Reflect.set("new TA([42n])", key, "ecma262") must return true'
|
||||
);
|
||||
assert.sameValue(sample[key], "ecma262");
|
||||
|
||||
assert.sameValue(sample[key], 'ecma262', 'The value of sample[key] is "ecma262"');
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, key, "es3000"),
|
||||
Reflect.set(sample, key, 'es3000'),
|
||||
true,
|
||||
"Return true setting a value to a writable property [" + key + "]"
|
||||
'Reflect.set("new TA([42n])", key, "es3000") must return true'
|
||||
);
|
||||
assert.sameValue(sample[key], "es3000");
|
||||
|
||||
assert.sameValue(sample[key], 'es3000', 'The value of sample[key] is "es3000"');
|
||||
|
||||
Object.defineProperty(sample, key, {
|
||||
writable: false,
|
||||
value: undefined
|
||||
});
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, key, 42),
|
||||
false,
|
||||
"Return false setting a value to a non-writable property [" + key + "]"
|
||||
);
|
||||
assert.sameValue(
|
||||
sample[key], undefined, "non-writable [" + key + "] is preserved"
|
||||
);
|
||||
|
||||
assert.sameValue(Reflect.set(sample, key, 42), false, 'Reflect.set("new TA([42n])", key, 42) must return false');
|
||||
assert.sameValue(sample[key], undefined, 'The value of sample[key] is expected to equal `undefined`');
|
||||
});
|
||||
});
|
||||
|
@ -22,17 +22,16 @@ info: |
|
||||
includes: [testBigIntTypedArray.js]
|
||||
features: [BigInt, Reflect, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42n]);
|
||||
assert.sameValue(Reflect.set(sample, '1.1', 1n), false, 'Reflect.set("new TA([42n])", "1.1", 1n) must return false');
|
||||
|
||||
assert.sameValue(Reflect.set(sample, "1.1", 1n), false, "1.1");
|
||||
assert.sameValue(Reflect.set(sample, "0.0001", 1n), false, "0.0001");
|
||||
|
||||
assert.sameValue(sample.hasOwnProperty("1.1"), false, "has no property [1.1]");
|
||||
assert.sameValue(
|
||||
sample.hasOwnProperty("0.0001"),
|
||||
Reflect.set(sample, '0.0001', 1n),
|
||||
false,
|
||||
"has no property [0.0001]"
|
||||
'Reflect.set("new TA([42n])", "0.0001", 1n) must return false'
|
||||
);
|
||||
|
||||
assert.sameValue(sample.hasOwnProperty('1.1'), false, 'sample.hasOwnProperty("1.1") must return false');
|
||||
assert.sameValue(sample.hasOwnProperty('0.0001'), false, 'sample.hasOwnProperty("0.0001") must return false');
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*---
|
||||
esid: sec-integer-indexed-exotic-objects-set-p-v-receiver
|
||||
description: >
|
||||
Returns abrupt from OrginarySet when key is not a numeric index
|
||||
Returns abrupt from OrdinarySet when key is not a numeric index
|
||||
info: |
|
||||
9.4.5.5 [[Set]] ( P, V, Receiver)
|
||||
|
||||
@ -34,7 +34,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample.test262 = 1;
|
||||
});
|
||||
}, '`sample.test262 = 1` throws Test262Error');
|
||||
|
||||
assert.sameValue(sample.test262, undefined);
|
||||
assert.sameValue(sample.test262, undefined, 'The value of sample.test262 is expected to equal `undefined`');
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*---
|
||||
esid: sec-integer-indexed-exotic-objects-set-p-v-receiver
|
||||
description: >
|
||||
Use OrginarySet if key is not a CanonicalNumericIndex
|
||||
Use OrdinarySet if key is not a CanonicalNumericIndex
|
||||
info: |
|
||||
9.4.5.5 [[Set]] ( P, V, Receiver)
|
||||
|
||||
@ -16,32 +16,30 @@ info: |
|
||||
includes: [testBigIntTypedArray.js]
|
||||
features: [BigInt, Reflect, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42n]);
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, "test262", "ecma262"),
|
||||
Reflect.set(sample, 'test262', 'ecma262'),
|
||||
true,
|
||||
"Return true setting a new property"
|
||||
'Reflect.set("new TA([42n])", "test262", "ecma262") must return true'
|
||||
);
|
||||
assert.sameValue(sample.test262, "ecma262");
|
||||
|
||||
assert.sameValue(sample.test262, 'ecma262', 'The value of sample.test262 is "ecma262"');
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, "test262", "es3000"),
|
||||
Reflect.set(sample, 'test262', 'es3000'),
|
||||
true,
|
||||
"Return true setting a value to a writable property"
|
||||
'Reflect.set("new TA([42n])", "test262", "es3000") must return true'
|
||||
);
|
||||
assert.sameValue(sample.test262, "es3000");
|
||||
|
||||
Object.defineProperty(sample, "foo", {
|
||||
assert.sameValue(sample.test262, 'es3000', 'The value of sample.test262 is "es3000"');
|
||||
|
||||
Object.defineProperty(sample, 'foo', {
|
||||
writable: false,
|
||||
value: undefined
|
||||
});
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, "foo", 42),
|
||||
false,
|
||||
"Return false setting a value to a non-writable property"
|
||||
);
|
||||
assert.sameValue(sample.foo, undefined);
|
||||
|
||||
assert.sameValue(Reflect.set(sample, 'foo', 42), false, 'Reflect.set("new TA([42n])", "foo", 42) must return false');
|
||||
assert.sameValue(sample.foo, undefined, 'The value of sample.foo is expected to equal `undefined`');
|
||||
});
|
||||
|
@ -23,15 +23,12 @@ info: |
|
||||
includes: [testBigIntTypedArray.js]
|
||||
features: [BigInt, Reflect, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42n]);
|
||||
|
||||
assert.sameValue(Reflect.set(sample, "-1", 1n), false, "-1");
|
||||
assert.sameValue(Reflect.set(sample, "1", 1n), false, "1");
|
||||
assert.sameValue(Reflect.set(sample, "2", 1n), false, "2");
|
||||
|
||||
assert.sameValue(sample.hasOwnProperty("-1"), false, "has no property [-1]");
|
||||
assert.sameValue(sample.hasOwnProperty("1"), false, "has no property [1]");
|
||||
assert.sameValue(sample.hasOwnProperty("2"), false, "has no property [2]");
|
||||
assert.sameValue(Reflect.set(sample, '-1', 1n), false, 'Reflect.set("new TA([42n])", "-1", 1n) must return false');
|
||||
assert.sameValue(Reflect.set(sample, '1', 1n), false, 'Reflect.set("new TA([42n])", "1", 1n) must return false');
|
||||
assert.sameValue(Reflect.set(sample, '2', 1n), false, 'Reflect.set("new TA([42n])", "2", 1n) must return false');
|
||||
assert.sameValue(sample.hasOwnProperty('-1'), false, 'sample.hasOwnProperty("-1") must return false');
|
||||
assert.sameValue(sample.hasOwnProperty('1'), false, 'sample.hasOwnProperty("1") must return false');
|
||||
assert.sameValue(sample.hasOwnProperty('2'), false, 'sample.hasOwnProperty("2") must return false');
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*---
|
||||
esid: sec-integer-indexed-exotic-objects-set-p-v-receiver
|
||||
description: >
|
||||
Use OrginarySet if key is a Symbol
|
||||
Use OrdinarySet if key is a Symbol
|
||||
info: |
|
||||
9.4.5.5 [[Set]] ( P, V, Receiver)
|
||||
|
||||
@ -14,35 +14,38 @@ info: |
|
||||
includes: [testBigIntTypedArray.js]
|
||||
features: [BigInt, Reflect, Symbol, TypedArray]
|
||||
---*/
|
||||
|
||||
var s1 = Symbol("1");
|
||||
var s2 = Symbol("2");
|
||||
var s1 = Symbol('1');
|
||||
var s2 = Symbol('2');
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42n]);
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, s1, "ecma262"),
|
||||
Reflect.set(sample, s1, 'ecma262'),
|
||||
true,
|
||||
"Return true setting a new property"
|
||||
'Reflect.set("new TA([42n])", "Symbol(\\"1\\")", "ecma262") must return true'
|
||||
);
|
||||
assert.sameValue(sample[s1], "ecma262");
|
||||
|
||||
assert.sameValue(sample[s1], 'ecma262', 'The value of sample[s1] is "ecma262"');
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, s1, "es3000"),
|
||||
Reflect.set(sample, s1, 'es3000'),
|
||||
true,
|
||||
"Return true setting a value to a writable property"
|
||||
'Reflect.set("new TA([42n])", "Symbol(\\"1\\")", "es3000") must return true'
|
||||
);
|
||||
assert.sameValue(sample[s1], "es3000");
|
||||
|
||||
assert.sameValue(sample[s1], 'es3000', 'The value of sample[s1] is "es3000"');
|
||||
|
||||
Object.defineProperty(sample, s2, {
|
||||
writable: false,
|
||||
value: undefined
|
||||
});
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, s2, 42),
|
||||
false,
|
||||
"Return false setting a value to a non-writable property"
|
||||
'Reflect.set("new TA([42n])", "Symbol(\\"2\\")", 42) must return false'
|
||||
);
|
||||
assert.sameValue(sample[s2], undefined);
|
||||
|
||||
assert.sameValue(sample[s2], undefined, 'The value of sample[s2] is expected to equal `undefined`');
|
||||
});
|
||||
|
@ -56,6 +56,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
typedArray[0] = null;
|
||||
}, "abrupt completion from Null");
|
||||
}, '`typedArray[0] = null` throws TypeError');
|
||||
|
||||
});
|
||||
|
@ -56,30 +56,30 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
typedArray[0] = 1;
|
||||
}, "abrupt completion from Number: 1");
|
||||
}, '`typedArray[0] = 1` throws TypeError');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
typedArray[0] = Math.pow(2, 63);
|
||||
}, "abrupt completion from Number: 2**63");
|
||||
}, '`typedArray[0] = Math.pow(2, 63)` throws TypeError');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
typedArray[0] = +0;
|
||||
}, "abrupt completion from Number: +0");
|
||||
}, '`typedArray[0] = +0` throws TypeError');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
typedArray[0] = -0;
|
||||
}, "abrupt completion from Number: -0");
|
||||
}, '`typedArray[0] = -0` throws TypeError');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
typedArray[0] = Infinity;
|
||||
}, "abrupt completion from Number: Infinity");
|
||||
}, '`typedArray[0] = Infinity` throws TypeError');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
typedArray[0] = -Infinity;
|
||||
}, "abrupt completion from Number: -Infinity");
|
||||
}, '`typedArray[0] = -Infinity` throws TypeError');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
typedArray[0] = NaN;
|
||||
}, "abrupt completion from Number: NaN");
|
||||
}, '`typedArray[0] = NaN` throws TypeError');
|
||||
|
||||
});
|
||||
|
@ -60,6 +60,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
typedArray[0] = "definately not a number";
|
||||
}, "StringToBigInt(prim) == NaN");
|
||||
}, '`typedArray[0] = "definately not a number"` throws SyntaxError');
|
||||
|
||||
});
|
||||
|
@ -60,30 +60,26 @@ info: |
|
||||
includes: [testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var typedArray = new TA(1);
|
||||
|
||||
typedArray[0] = '';
|
||||
assert.sameValue(typedArray[0], 0n);
|
||||
|
||||
assert.sameValue(typedArray[0], 0n, 'The value of typedArray[0] is 0n');
|
||||
typedArray[0] = '1';
|
||||
assert.sameValue(typedArray[0], 1n);
|
||||
assert.sameValue(typedArray[0], 1n, 'The value of typedArray[0] is 1n');
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
typedArray[0] = '1n';
|
||||
}, "A StringNumericLiteral may not include a BigIntLiteralSuffix.");
|
||||
}, '`typedArray[0] = "1n"` throws SyntaxError');
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
typedArray[0] = "Infinity";
|
||||
}, "Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow Infinity..");
|
||||
typedArray[0] = 'Infinity';
|
||||
}, '`typedArray[0] = "Infinity"` throws SyntaxError');
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
typedArray[0] = "1.1";
|
||||
}, "Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow... decimal points...");
|
||||
typedArray[0] = '1.1';
|
||||
}, '`typedArray[0] = "1.1"` throws SyntaxError');
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
typedArray[0] = "1e7";
|
||||
}, "Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow... exponents...");
|
||||
|
||||
typedArray[0] = '1e7';
|
||||
}, '`typedArray[0] = "1e7"` throws SyntaxError');
|
||||
});
|
||||
|
@ -58,6 +58,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
typedArray[0] = s;
|
||||
}, "abrupt completion from Symbol");
|
||||
}, '`typedArray[0] = s` throws TypeError');
|
||||
|
||||
});
|
||||
|
@ -4,9 +4,8 @@
|
||||
/*---
|
||||
esid: sec-integer-indexed-exotic-objects-set-p-v-receiver
|
||||
description: >
|
||||
Setting a typed array element to a value that, when converted to the typed
|
||||
array element type, detaches the typed array's underlying buffer, should
|
||||
throw a TypeError and not modify the typed array.
|
||||
Setting a typed array element to a value that, when converted to the typed
|
||||
array element type, detaches the typed array's underlying buffer, should return false.
|
||||
info: |
|
||||
9.4.5.5 [[Set]] ( P, V, Receiver)
|
||||
|
||||
@ -19,28 +18,26 @@ info: |
|
||||
|
||||
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
||||
|
||||
...
|
||||
15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue).
|
||||
16. Return true.
|
||||
Assert: O is an Integer-Indexed exotic object.
|
||||
Assert: Type(index) is Number.
|
||||
If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
|
||||
Otherwise, let numValue be ? ToNumber(value).
|
||||
Let buffer be O.[[ViewedArrayBuffer]].
|
||||
If IsDetachedBuffer(buffer) is true, return false.
|
||||
|
||||
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
|
||||
features: [BigInt, Reflect, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var ta = new TA([17n]);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Reflect.set(ta, 0, {
|
||||
valueOf: function() {
|
||||
$DETACHBUFFER(ta.buffer);
|
||||
return 42n;
|
||||
}
|
||||
});
|
||||
},
|
||||
"detaching a ArrayBuffer during setting an element of a typed array " +
|
||||
"viewing it should throw");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
ta[0];
|
||||
let ta = new TA(1);
|
||||
let result = Reflect.set(ta, 0, {
|
||||
valueOf() {
|
||||
$DETACHBUFFER(ta.buffer);
|
||||
return 42n;
|
||||
}
|
||||
});
|
||||
|
||||
assert.sameValue(result, false);
|
||||
assert.sameValue(ta[0], false);
|
||||
});
|
||||
|
@ -14,45 +14,46 @@ info: |
|
||||
i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||
...
|
||||
|
||||
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
||||
IntegerIndexedElementSet ( O, index, value )
|
||||
|
||||
...
|
||||
3. Let numValue be ? ToNumber(value).
|
||||
Assert: O is an Integer-Indexed exotic object.
|
||||
Assert: Type(index) is Number.
|
||||
If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
|
||||
Otherwise, let numValue be ? ToNumber(value).
|
||||
...
|
||||
includes: [testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42n]);
|
||||
let sample = new TA([42n]);
|
||||
|
||||
var obj = {
|
||||
valueOf: function() {
|
||||
let obj = {
|
||||
valueOf() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample["0"] = obj;
|
||||
}, "ToNumber check with a valid index");
|
||||
sample['0'] = obj;
|
||||
}, '`sample["0"] = obj` throws Test262Error');
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample["1.1"] = obj;
|
||||
}, "ToNumber runs before ToInteger(index)");
|
||||
sample['1.1'] = obj;
|
||||
}, '`sample["1.1"] = obj` throws Test262Error');
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample["-0"] = obj;
|
||||
}, "ToNumber runs before -0 check");
|
||||
sample['-0'] = obj;
|
||||
}, '`sample["-0"] = obj` throws Test262Error');
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample["-1"] = obj;
|
||||
}, "ToNumber runs before < 0 check");
|
||||
sample['-1'] = obj;
|
||||
}, '`sample["-1"] = obj` throws Test262Error');
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample["1"] = obj;
|
||||
}, "ToNumber runs before index == length check");
|
||||
sample['1'] = obj;
|
||||
}, '`sample["1"] = obj` throws Test262Error');
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample["2"] = obj;
|
||||
}, "ToNumber runs before index > length check");
|
||||
sample['2'] = obj;
|
||||
}, '`sample["2"] = obj` throws Test262Error');
|
||||
});
|
||||
|
@ -57,6 +57,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
typedArray[0] = undefined;
|
||||
}, "abrupt completion from undefined");
|
||||
}, '`typedArray[0] = undefined` throws TypeError');
|
||||
|
||||
});
|
||||
|
@ -83,12 +83,12 @@ testWithTypedArrayConstructors(function(FA) {
|
||||
|
||||
assert(
|
||||
samples[i] !== samples[i],
|
||||
`samples (index=${idx}) produces a valid NaN (${precision} precision)`
|
||||
'The result of `(samples[i] !== samples[i])` is true'
|
||||
);
|
||||
|
||||
assert(
|
||||
controls[i] !== controls[i],
|
||||
`controls (index=${idx}) produces a valid NaN (${precision} precision)`
|
||||
'The result of `(controls[i] !== controls[i])` is true'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -47,5 +47,5 @@ testTypedArrayConversions(byteConversionValues, function(TA, value, expected, in
|
||||
|
||||
sample[0] = value;
|
||||
|
||||
assert.sameValue(sample[0], expected, value + " converts to " + expected);
|
||||
assert.sameValue(sample[0], expected, 'The value of sample[0] is expected to equal the value of expected');
|
||||
});
|
||||
|
@ -18,9 +18,13 @@ features: [Reflect, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42, 43]);
|
||||
var sample = new TA(2);
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
|
||||
assert.sameValue(Reflect.set(sample, "foo", "test262"), true);
|
||||
assert.sameValue(sample.foo, "test262");
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, "foo", "test262"),
|
||||
true,
|
||||
'Reflect.set(sample, "foo", "test262") must return true'
|
||||
);
|
||||
assert.sameValue(sample.foo, "test262", 'The value of sample.foo is "test262"');
|
||||
});
|
||||
|
@ -15,12 +15,16 @@ includes: [testTypedArray.js, detachArrayBuffer.js]
|
||||
features: [Symbol, Reflect, TypedArray]
|
||||
---*/
|
||||
|
||||
var s = Symbol("1");
|
||||
let s = Symbol("1");
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42, 43]);
|
||||
let sample = new TA(2);
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
|
||||
assert.sameValue(Reflect.set(sample, s, "test262"), true);
|
||||
assert.sameValue(sample[s], "test262");
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, s, "test262"),
|
||||
true,
|
||||
'Reflect.set(sample, "Symbol(\\"1\\")", "test262") must return true'
|
||||
);
|
||||
assert.sameValue(sample[s], "test262", 'The value of sample[s] is "test262"');
|
||||
});
|
||||
|
@ -15,26 +15,23 @@ info: |
|
||||
i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||
...
|
||||
|
||||
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
||||
IntegerIndexedElementSet ( O, index, value )
|
||||
|
||||
...
|
||||
3. Let numValue be ? ToNumber(value).
|
||||
4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
|
||||
5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
|
||||
Assert: O is an Integer-Indexed exotic object.
|
||||
Assert: Type(index) is Number.
|
||||
If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
|
||||
Otherwise, let numValue be ? ToNumber(value).
|
||||
Let buffer be O.[[ViewedArrayBuffer]].
|
||||
If IsDetachedBuffer(buffer) is true, return false.
|
||||
...
|
||||
includes: [testTypedArray.js, detachArrayBuffer.js]
|
||||
features: [cross-realm, TypedArray]
|
||||
---*/
|
||||
|
||||
var other = $262.createRealm().global;
|
||||
|
||||
let other = $262.createRealm().global;
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var OtherTA = other[TA.name];
|
||||
var sample = new OtherTA(1);
|
||||
|
||||
let OtherTA = other[TA.name];
|
||||
let sample = new OtherTA(1);
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample[0] = 0;
|
||||
});
|
||||
assert.sameValue(sample[0] = 1, false, '`sample[0] = 1` is false');
|
||||
});
|
||||
|
@ -3,63 +3,46 @@
|
||||
/*---
|
||||
esid: sec-integer-indexed-exotic-objects-set-p-v-receiver
|
||||
description: >
|
||||
Throws a TypeError if key has a numeric index and object has a detached buffer
|
||||
Returns false if key has a numeric index and object has a detached buffer
|
||||
info: |
|
||||
9.4.5.5 [[Set]] ( P, V, Receiver)
|
||||
[[Set]] ( P, V, Receiver)
|
||||
|
||||
...
|
||||
2. If Type(P) is String, then
|
||||
a. Let numericIndex be ! CanonicalNumericIndexString(P).
|
||||
b. If numericIndex is not undefined, then
|
||||
i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||
If Type(P) is String, then
|
||||
Let numericIndex be ! CanonicalNumericIndexString(P).
|
||||
If numericIndex is not undefined, then
|
||||
Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||
...
|
||||
|
||||
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
||||
IntegerIndexedElementSet ( O, index, value )
|
||||
|
||||
Assert: O is an Integer-Indexed exotic object.
|
||||
Assert: Type(index) is Number.
|
||||
If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
|
||||
Otherwise, let numValue be ? ToNumber(value).
|
||||
Let buffer be O.[[ViewedArrayBuffer]].
|
||||
If IsDetachedBuffer(buffer) is true, return false.
|
||||
|
||||
...
|
||||
3. Let numValue be ? ToNumber(value).
|
||||
4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
|
||||
5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
|
||||
...
|
||||
includes: [testTypedArray.js, detachArrayBuffer.js]
|
||||
features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42]);
|
||||
let sample = new TA([42]);
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
assert.sameValue(sample[0] = 1, false, '`sample[0] = 1` is false');
|
||||
assert.sameValue(sample['1.1'] = 1, false, '`sample[\'1.1\'] = 1` is false');
|
||||
assert.sameValue(sample['-0'] = 1, false, '`sample[\'-0\'] = 1` is false');
|
||||
assert.sameValue(sample['-1'] = 1, false, '`sample[\'-1\'] = 1` is false');
|
||||
assert.sameValue(sample['1'] = 1, false, '`sample[\'1\'] = 1` is false');
|
||||
assert.sameValue(sample['2'] = 1, false, '`sample[\'2\'] = 1` is false');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample[0] = 1;
|
||||
}, "valid numeric index");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample["1.1"] = 1;
|
||||
}, "detach buffer runs before checking for 1.1");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample["-0"] = 1;
|
||||
}, "detach buffer runs before checking for -0");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample["-1"] = 1;
|
||||
}, "detach buffer runs before checking for -1");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample["1"] = 1;
|
||||
}, "detach buffer runs before checking for key == length");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample["2"] = 1;
|
||||
}, "detach buffer runs before checking for key > length");
|
||||
|
||||
var obj = {
|
||||
valueOf: function() {
|
||||
let obj = {
|
||||
valueOf() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample["0"] = obj;
|
||||
}, "ToNumber(value) is called before detached buffer check");
|
||||
sample['0'] = obj;
|
||||
}, '`sample[\'0\'] = obj` throws Test262Error');
|
||||
});
|
||||
|
@ -23,21 +23,20 @@ includes: [testTypedArray.js]
|
||||
features: [Reflect, TypedArray]
|
||||
---*/
|
||||
|
||||
var proto = TypedArray.prototype;
|
||||
var throwDesc = {
|
||||
let proto = TypedArray.prototype;
|
||||
let throwDesc = {
|
||||
set: function() {
|
||||
throw new Test262Error("OrdinarySet was called! Ref: 9.1.9.1 3.b.i");
|
||||
throw new Test262Error('OrdinarySet was called!');
|
||||
}
|
||||
};
|
||||
Object.defineProperty(proto, "0", throwDesc);
|
||||
Object.defineProperty(proto, "1", throwDesc);
|
||||
|
||||
Object.defineProperty(proto, '0', throwDesc);
|
||||
Object.defineProperty(proto, '1', throwDesc);
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42, 43]);
|
||||
|
||||
assert.sameValue(Reflect.set(sample, "0", 1), true, "sample[0]");
|
||||
assert.sameValue(sample[0], 1, "sample[0] value is set");
|
||||
|
||||
assert.sameValue(Reflect.set(sample, "1", 42), true, "sample[1]");
|
||||
assert.sameValue(sample[1], 42, "sample[1] value is set");
|
||||
let sample = new TA(2);
|
||||
assert.sameValue(Reflect.set(sample, '0', 1), true, 'Reflect.set(sample, "0", 1) must return true');
|
||||
assert.sameValue(sample[0], 1, 'The value of sample[0] is 1');
|
||||
assert.sameValue(Reflect.set(sample, '1', 42), true, 'Reflect.set(sample, "1", 42) must return true');
|
||||
assert.sameValue(sample[1], 42, 'The value of sample[1] is 42');
|
||||
});
|
||||
|
@ -26,6 +26,6 @@ features: [Reflect, TypedArray]
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42]);
|
||||
|
||||
assert.sameValue(Reflect.set(sample, "-0", 1), false, "-0");
|
||||
assert.sameValue(sample.hasOwnProperty("-0"), false, "has no property [-0]");
|
||||
assert.sameValue(Reflect.set(sample, "-0", 1), false, 'Reflect.set(sample, "-0", 1) must return false');
|
||||
assert.sameValue(sample.hasOwnProperty("-0"), false, 'sample.hasOwnProperty("-0") must return false');
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*---
|
||||
esid: sec-integer-indexed-exotic-objects-set-p-v-receiver
|
||||
description: >
|
||||
Use OrginarySet if numeric key is not a CanonicalNumericIndex
|
||||
Use OrdinarySet if numeric key is not a CanonicalNumericIndex
|
||||
info: |
|
||||
9.4.5.5 [[Set]] ( P, V, Receiver)
|
||||
|
||||
@ -31,16 +31,16 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, key, "ecma262"),
|
||||
true,
|
||||
"Return true setting a new property [" + key + "]"
|
||||
'Reflect.set(sample, key, "ecma262") must return true'
|
||||
);
|
||||
assert.sameValue(sample[key], "ecma262");
|
||||
assert.sameValue(sample[key], "ecma262", 'The value of sample[key] is "ecma262"');
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, key, "es3000"),
|
||||
true,
|
||||
"Return true setting a value to a writable property [" + key + "]"
|
||||
'Reflect.set(sample, key, "es3000") must return true'
|
||||
);
|
||||
assert.sameValue(sample[key], "es3000");
|
||||
assert.sameValue(sample[key], "es3000", 'The value of sample[key] is "es3000"');
|
||||
|
||||
Object.defineProperty(sample, key, {
|
||||
writable: false,
|
||||
@ -49,10 +49,10 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, key, 42),
|
||||
false,
|
||||
"Return false setting a value to a non-writable property [" + key + "]"
|
||||
'Reflect.set(sample, key, 42) must return false'
|
||||
);
|
||||
assert.sameValue(
|
||||
sample[key], undefined, "non-writable [" + key + "] is preserved"
|
||||
sample[key], undefined, 'The value of sample[key] is expected to equal `undefined`'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -26,13 +26,13 @@ features: [Reflect, TypedArray]
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42]);
|
||||
|
||||
assert.sameValue(Reflect.set(sample, "1.1", 1), false, "1.1");
|
||||
assert.sameValue(Reflect.set(sample, "0.0001", 1), false, "0.0001");
|
||||
assert.sameValue(Reflect.set(sample, "1.1", 1), false, 'Reflect.set(sample, "1.1", 1) must return false');
|
||||
assert.sameValue(Reflect.set(sample, "0.0001", 1), false, 'Reflect.set(sample, "0.0001", 1) must return false');
|
||||
|
||||
assert.sameValue(sample.hasOwnProperty("1.1"), false, "has no property [1.1]");
|
||||
assert.sameValue(sample.hasOwnProperty("1.1"), false, 'sample.hasOwnProperty("1.1") must return false');
|
||||
assert.sameValue(
|
||||
sample.hasOwnProperty("0.0001"),
|
||||
false,
|
||||
"has no property [0.0001]"
|
||||
'sample.hasOwnProperty("0.0001") must return false'
|
||||
);
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*---
|
||||
esid: sec-integer-indexed-exotic-objects-set-p-v-receiver
|
||||
description: >
|
||||
Returns abrupt from OrginarySet when key is not a numeric index
|
||||
Returns abrupt from OrdinarySet when key is not a numeric index
|
||||
info: |
|
||||
9.4.5.5 [[Set]] ( P, V, Receiver)
|
||||
|
||||
@ -34,7 +34,7 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample.test262 = 1;
|
||||
});
|
||||
}, '`sample.test262 = 1` throws Test262Error');
|
||||
|
||||
assert.sameValue(sample.test262, undefined);
|
||||
assert.sameValue(sample.test262, undefined, 'The value of sample.test262 is expected to equal `undefined`');
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*---
|
||||
esid: sec-integer-indexed-exotic-objects-set-p-v-receiver
|
||||
description: >
|
||||
Use OrginarySet if key is not a CanonicalNumericIndex
|
||||
Use OrdinarySet if key is not a CanonicalNumericIndex
|
||||
info: |
|
||||
9.4.5.5 [[Set]] ( P, V, Receiver)
|
||||
|
||||
@ -23,16 +23,16 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, "test262", "ecma262"),
|
||||
true,
|
||||
"Return true setting a new property"
|
||||
'Reflect.set(sample, "test262", "ecma262") must return true'
|
||||
);
|
||||
assert.sameValue(sample.test262, "ecma262");
|
||||
assert.sameValue(sample.test262, "ecma262", 'The value of sample.test262 is "ecma262"');
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, "test262", "es3000"),
|
||||
true,
|
||||
"Return true setting a value to a writable property"
|
||||
'Reflect.set(sample, "test262", "es3000") must return true'
|
||||
);
|
||||
assert.sameValue(sample.test262, "es3000");
|
||||
assert.sameValue(sample.test262, "es3000", 'The value of sample.test262 is "es3000"');
|
||||
|
||||
Object.defineProperty(sample, "foo", {
|
||||
writable: false,
|
||||
@ -41,7 +41,7 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, "foo", 42),
|
||||
false,
|
||||
"Return false setting a value to a non-writable property"
|
||||
'Reflect.set(sample, "foo", 42) must return false'
|
||||
);
|
||||
assert.sameValue(sample.foo, undefined);
|
||||
assert.sameValue(sample.foo, undefined, 'The value of sample.foo is expected to equal `undefined`');
|
||||
});
|
||||
|
@ -27,11 +27,11 @@ features: [Reflect, TypedArray]
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42]);
|
||||
|
||||
assert.sameValue(Reflect.set(sample, "-1", 1), false, "-1");
|
||||
assert.sameValue(Reflect.set(sample, "1", 1), false, "1");
|
||||
assert.sameValue(Reflect.set(sample, "2", 1), false, "2");
|
||||
assert.sameValue(Reflect.set(sample, "-1", 1), false, 'Reflect.set(sample, "-1", 1) must return false');
|
||||
assert.sameValue(Reflect.set(sample, "1", 1), false, 'Reflect.set(sample, "1", 1) must return false');
|
||||
assert.sameValue(Reflect.set(sample, "2", 1), false, 'Reflect.set(sample, "2", 1) must return false');
|
||||
|
||||
assert.sameValue(sample.hasOwnProperty("-1"), false, "has no property [-1]");
|
||||
assert.sameValue(sample.hasOwnProperty("1"), false, "has no property [1]");
|
||||
assert.sameValue(sample.hasOwnProperty("2"), false, "has no property [2]");
|
||||
assert.sameValue(sample.hasOwnProperty("-1"), false, 'sample.hasOwnProperty("-1") must return false');
|
||||
assert.sameValue(sample.hasOwnProperty("1"), false, 'sample.hasOwnProperty("1") must return false');
|
||||
assert.sameValue(sample.hasOwnProperty("2"), false, 'sample.hasOwnProperty("2") must return false');
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*---
|
||||
esid: sec-integer-indexed-exotic-objects-set-p-v-receiver
|
||||
description: >
|
||||
Use OrginarySet if key is a Symbol
|
||||
Use OrdinarySet if key is a Symbol
|
||||
info: |
|
||||
9.4.5.5 [[Set]] ( P, V, Receiver)
|
||||
|
||||
@ -24,16 +24,16 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, s1, "ecma262"),
|
||||
true,
|
||||
"Return true setting a new property"
|
||||
'Reflect.set(sample, "Symbol(\\"1\\")", "ecma262") must return true'
|
||||
);
|
||||
assert.sameValue(sample[s1], "ecma262");
|
||||
assert.sameValue(sample[s1], "ecma262", 'The value of sample[s1] is "ecma262"');
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, s1, "es3000"),
|
||||
true,
|
||||
"Return true setting a value to a writable property"
|
||||
'Reflect.set(sample, "Symbol(\\"1\\")", "es3000") must return true'
|
||||
);
|
||||
assert.sameValue(sample[s1], "es3000");
|
||||
assert.sameValue(sample[s1], "es3000", 'The value of sample[s1] is "es3000"');
|
||||
|
||||
Object.defineProperty(sample, s2, {
|
||||
writable: false,
|
||||
@ -42,7 +42,7 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
assert.sameValue(
|
||||
Reflect.set(sample, s2, 42),
|
||||
false,
|
||||
"Return false setting a value to a non-writable property"
|
||||
'Reflect.set(sample, "Symbol(\\"2\\")", 42) must return false'
|
||||
);
|
||||
assert.sameValue(sample[s2], undefined);
|
||||
assert.sameValue(sample[s2], undefined, 'The value of sample[s2] is expected to equal `undefined`');
|
||||
});
|
||||
|
@ -4,9 +4,8 @@
|
||||
/*---
|
||||
esid: sec-integer-indexed-exotic-objects-set-p-v-receiver
|
||||
description: >
|
||||
Setting a typed array element to a value that, when converted to the typed
|
||||
array element type, detaches the typed array's underlying buffer, should
|
||||
throw a TypeError and not modify the typed array.
|
||||
Setting a typed array element to a value that, when converted to the typed
|
||||
array element type, detaches the typed array's underlying buffer, should return false.
|
||||
info: |
|
||||
9.4.5.5 [[Set]] ( P, V, Receiver)
|
||||
|
||||
@ -19,28 +18,26 @@ info: |
|
||||
|
||||
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
||||
|
||||
...
|
||||
15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue).
|
||||
16. Return true.
|
||||
Assert: O is an Integer-Indexed exotic object.
|
||||
Assert: Type(index) is Number.
|
||||
If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
|
||||
Otherwise, let numValue be ? ToNumber(value).
|
||||
Let buffer be O.[[ViewedArrayBuffer]].
|
||||
If IsDetachedBuffer(buffer) is true, return false.
|
||||
|
||||
includes: [testTypedArray.js, detachArrayBuffer.js]
|
||||
features: [Reflect, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var ta = new TA([17]);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Reflect.set(ta, 0, {
|
||||
valueOf: function() {
|
||||
$DETACHBUFFER(ta.buffer);
|
||||
return 42;
|
||||
}
|
||||
});
|
||||
},
|
||||
"detaching a ArrayBuffer during setting an element of a typed array " +
|
||||
"viewing it should throw");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
ta[0];
|
||||
let ta = new TA(1);
|
||||
let result = Reflect.set(ta, 0, {
|
||||
valueOf() {
|
||||
$DETACHBUFFER(ta.buffer);
|
||||
return 42;
|
||||
}
|
||||
});
|
||||
|
||||
assert.sameValue(result, false);
|
||||
assert.sameValue(ta[0], false);
|
||||
});
|
||||
|
@ -14,45 +14,47 @@ info: |
|
||||
i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||
...
|
||||
|
||||
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
||||
IntegerIndexedElementSet ( O, index, value )
|
||||
|
||||
...
|
||||
3. Let numValue be ? ToNumber(value).
|
||||
Assert: O is an Integer-Indexed exotic object.
|
||||
Assert: Type(index) is Number.
|
||||
If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
|
||||
Otherwise, let numValue be ? ToNumber(value).
|
||||
...
|
||||
includes: [testTypedArray.js]
|
||||
features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42]);
|
||||
let sample = new TA([42]);
|
||||
|
||||
var obj = {
|
||||
valueOf: function() {
|
||||
let obj = {
|
||||
valueOf() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample["0"] = obj;
|
||||
}, "ToNumber check with a valid index");
|
||||
}, '`sample["0"] = obj` throws Test262Error');
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample["1.1"] = obj;
|
||||
}, "ToNumber runs before ToInteger(index)");
|
||||
}, '`sample["1.1"] = obj` throws Test262Error');
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample["-0"] = obj;
|
||||
}, "ToNumber runs before -0 check");
|
||||
}, '`sample["-0"] = obj` throws Test262Error');
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample["-1"] = obj;
|
||||
}, "ToNumber runs before < 0 check");
|
||||
}, '`sample["-1"] = obj` throws Test262Error');
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample["1"] = obj;
|
||||
}, "ToNumber runs before index == length check");
|
||||
}, '`sample["1"] = obj` throws Test262Error');
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample["2"] = obj;
|
||||
}, "ToNumber runs before index > length check");
|
||||
}, '`sample["2"] = obj` throws Test262Error');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user