Skip to content

Commit

Permalink
Merge branch 'main' into remove-jshint-conf
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglinmike committed Apr 1, 2022
2 parents c03a4f8 + 926b096 commit ee752cf
Show file tree
Hide file tree
Showing 205 changed files with 5,247 additions and 271 deletions.
4 changes: 4 additions & 0 deletions features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ ShadowRealm
# https://github.com/tc39/proposal-array-find-from-last
array-find-from-last

# Array.prototype.groupBy & Array.prototype.groupByToMap
# https://github.com/tc39/proposal-array-grouping
array-grouping

# Intl.DurationFormat
# https://github.com/tc39/proposal-intl-duration-format
Intl.DurationFormat
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (C) 2022 Microsoft. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.prototype-@@unscopables
description: >
Initial value of `Symbol.unscopables` property
info: |
22.1.3.32 Array.prototype [ @@unscopables ]
...
7. Perform CreateDataProperty(unscopableList, "findLast", true).
8. Perform CreateDataProperty(unscopableList, "findLastIndex", true).
...
includes: [propertyHelper.js]
features: [Symbol.unscopables, array-find-from-last]
---*/

var unscopables = Array.prototype[Symbol.unscopables];

assert.sameValue(Object.getPrototypeOf(unscopables), null);

assert.sameValue(unscopables.findLast, true, '`findLast` property value');
verifyEnumerable(unscopables, 'findLast');
verifyWritable(unscopables, 'findLast');
verifyConfigurable(unscopables, 'findLast');

assert.sameValue(unscopables.findLastIndex, true, '`findLastIndex` property value');
verifyEnumerable(unscopables, 'findLastIndex');
verifyWritable(unscopables, 'findLastIndex');
verifyConfigurable(unscopables, 'findLastIndex');
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (C) 2022 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.prototype-@@unscopables
description: >
Initial value of `Symbol.unscopables` property
info: |
22.1.3.32 Array.prototype [ @@unscopables ]
...
10. Perform ! CreateDataPropertyOrThrow(unscopableList, "groupBy", true).
11. Perform ! CreateDataPropertyOrThrow(unscopableList, "groupByToMap", true).
...
includes: [propertyHelper.js]
features: [Symbol.unscopables, array-grouping]
---*/

var unscopables = Array.prototype[Symbol.unscopables];

assert.sameValue(Object.getPrototypeOf(unscopables), null);

assert.sameValue(unscopables.groupBy, true, '`groupBy` property value');
verifyEnumerable(unscopables, 'groupBy');
verifyWritable(unscopables, 'groupBy');
verifyConfigurable(unscopables, 'groupBy');

assert.sameValue(unscopables.groupByToMap, true, '`groupByToMap` property value');
verifyEnumerable(unscopables, 'groupByToMap');
verifyWritable(unscopables, 'groupByToMap');
verifyConfigurable(unscopables, 'groupByToMap');
42 changes: 9 additions & 33 deletions test/built-ins/Array/prototype/Symbol.unscopables/value.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,16 @@ info: |
4. Perform CreateDataProperty(unscopableList, "fill", true).
5. Perform CreateDataProperty(unscopableList, "find", true).
6. Perform CreateDataProperty(unscopableList, "findIndex", true).
7. Perform CreateDataProperty(unscopableList, "findLast", true).
8. Perform CreateDataProperty(unscopableList, "findLastIndex", true).
9. Perform CreateDataProperty(unscopableList, "flat", true).
10. Perform CreateDataProperty(unscopableList, "flatMap", true).
11. Perform ! CreateDataPropertyOrThrow(unscopableList, "groupBy", true).
12. Perform ! CreateDataPropertyOrThrow(unscopableList, "groupByToMap", true).
13. Perform CreateDataProperty(unscopableList, "includes", true).
14. Perform CreateDataProperty(unscopableList, "keys", true).
15. Perform CreateDataProperty(unscopableList, "values", true).
16. Assert: Each of the above calls returns true.
17. Return unscopableList.
7. Perform CreateDataProperty(unscopableList, "flat", true).
8. Perform CreateDataProperty(unscopableList, "flatMap", true).
9. Perform CreateDataProperty(unscopableList, "includes", true).
10. Perform CreateDataProperty(unscopableList, "keys", true).
11. Perform CreateDataProperty(unscopableList, "values", true).
12. Assert: Each of the above calls returns true.
13. Return unscopableList.
includes: [propertyHelper.js]
features: [Symbol.unscopables, array-find-from-last]
features: [Symbol.unscopables]
---*/

var unscopables = Array.prototype[Symbol.unscopables];
Expand Down Expand Up @@ -57,17 +54,6 @@ verifyEnumerable(unscopables, 'findIndex');
verifyWritable(unscopables, 'findIndex');
verifyConfigurable(unscopables, 'findIndex');


assert.sameValue(unscopables.findLast, true, '`findLast` property value');
verifyEnumerable(unscopables, 'findLast');
verifyWritable(unscopables, 'findLast');
verifyConfigurable(unscopables, 'findLast');

assert.sameValue(unscopables.findLastIndex, true, '`findLastIndex` property value');
verifyEnumerable(unscopables, 'findLastIndex');
verifyWritable(unscopables, 'findLastIndex');
verifyConfigurable(unscopables, 'findLastIndex');

assert.sameValue(unscopables.flat, true, '`flat` property value');
verifyEnumerable(unscopables, 'flat');
verifyWritable(unscopables, 'flat');
Expand All @@ -78,16 +64,6 @@ verifyEnumerable(unscopables, 'flatMap');
verifyWritable(unscopables, 'flatMap');
verifyConfigurable(unscopables, 'flatMap');

assert.sameValue(unscopables.groupBy, true, '`groupBy` property value');
verifyEnumerable(unscopables, 'groupBy');
verifyWritable(unscopables, 'groupBy');
verifyConfigurable(unscopables, 'groupBy');

assert.sameValue(unscopables.groupByToMap, true, '`groupByToMap` property value');
verifyEnumerable(unscopables, 'groupByToMap');
verifyWritable(unscopables, 'groupByToMap');
verifyConfigurable(unscopables, 'groupByToMap');

assert.sameValue(unscopables.includes, true, '`includes` property value');
verifyEnumerable(unscopables, 'includes');
verifyWritable(unscopables, 'includes');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (C) 2022 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-wrapped-function-exotic-objects-call-thisargument-argumentslist
description: >
WrappedFunctionCreate throws a TypeError the target is a revoked proxy.
info: |
WrappedFunctionCreate ( callerRealm: a Realm Record, Target: a function object, )
1. Let target be F.[[WrappedTargetFunction]].
2. Assert: IsCallable(target) is true.
3. Let callerRealm be F.[[Realm]].
4. NOTE: Any exception objects produced after this point are associated with callerRealm.
5. Let targetRealm be ? GetFunctionRealm(target).
...
GetFunctionRealm ( obj )
...
3. If obj is a Proxy exotic object, then
a. If obj.[[ProxyHandler]] is null, throw a TypeError exception.
...
features: [ShadowRealm]
---*/

assert.sameValue(
typeof ShadowRealm.prototype.evaluate,
'function',
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);

const r = new ShadowRealm();

const fn = r.evaluate(`
globalThis.revocable = Proxy.revocable(() => {}, {});
globalThis.revocable.proxy;
`);
r.evaluate('revocable.revoke()');
assert.throws(TypeError, () => fn());
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright (C) 2022 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-wrappedfunctioncreate
description: >
WrappedFunctionCreate throws a TypeError if the accessing target's property may throw.
info: |
WrappedFunctionCreate ( callerRealm: a Realm Record, Target: a function object, )
...
7. Let result be CopyNameAndLength(wrapped, Target).
...
CopyNameAndLength ( F: a function object, Target: a function object, optional prefix: a String, optional argCount: a Number, )
...
3. Let targetHasLength be ? HasOwnProperty(Target, "length").
4. If targetHasLength is true, then
a. Let targetLen be ? Get(Target, "length").
...
6. Let targetName be ? Get(Target, "name").
features: [ShadowRealm]
---*/

assert.sameValue(
typeof ShadowRealm.prototype.evaluate,
'function',
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);

const r = new ShadowRealm();

assert.throws(TypeError, () => r.evaluate(`
const revocable = Proxy.revocable(() => {}, {});
revocable.revoke();
revocable.proxy;
`), 'TypeError on wrapping a revoked callable proxy');

assert.throws(TypeError, () => r.evaluate(`
const fn = () => {};
Object.defineProperty(fn, 'name', {
get() {
throw new Error();
},
});
fn;
`), 'TypeError on wrapping a fn with throwing name accessor');

assert.throws(TypeError, () => r.evaluate(`
const fn = () => {};
Object.defineProperty(fn, 'length', {
get() {
throw new Error();
},
});
fn;
`), 'TypeError on wrapping a fn with throwing length accessor');

assert.throws(TypeError, () => r.evaluate(`
const proxy = new Proxy(() => {}, {
getOwnPropertyDescriptor(target, key) {
throw new Error();
},
});
proxy;
`), 'TypeError on wrapping a callable proxy with throwing getOwnPropertyDescriptor trap');
42 changes: 17 additions & 25 deletions test/built-ins/String/prototype/localeCompare/15.5.4.9_CE.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
// Copyright 2012 Norbert Lindenberg. All rights reserved.
// Copyright 2012 Mozilla Corporation. All rights reserved.
// Copyright 2013 Microsoft Corporation. All rights reserved.
// Copyright (C) 2022 Richard Gibson. All rights reserved.
// This code is governed by the license found in the LICENSE file.

/*---
es5id: 15.5.4.9_CE
description: >
Tests that String.prototype.localeCompare returns 0 when
comparing Strings that are considered canonically equivalent by
the Unicode standard.
author: Norbert Lindenberg
String.prototype.localeCompare must return 0 when
comparing Strings that are considered canonically equivalent by
the Unicode Standard.
esid: sec-string.prototype.localecompare
info: |
String.prototype.localeCompare ( _that_ [ , _reserved1_ [ , _reserved2_ ] ] )
This function must treat Strings that are canonically equivalent
according to the Unicode standard as identical and must return `0`
when comparing Strings that are considered canonically equivalent.
---*/

// pairs with characters not in Unicode 3.0 are commented out
Expand Down Expand Up @@ -49,26 +55,12 @@ var pairs = [
// ["\uD87E\uDC2B", "北"]
];

// Detect whether we are using locale-sensitive comparisons or a bitwise comparison
if ("a".localeCompare("Z") < 0) {
// We are using locale-sensitive comparison, so all pairs should be canonically equivalent
var i;
for (i = 0; i < pairs.length; i++) {
var pair = pairs[i];
if (pair[0].localeCompare(pair[1]) !== 0) {
throw new Test262Error("String.prototype.localeCompare considers " + pair[0] + " (" + toU(pair[0]) +
") ≠ " + pair[1] + " (" + toU(pair[1]) + ").");
}
}
} else {
// We are using bitwise comparison, so all pairs should not be equivalent
var i;
for (i = 0; i < pairs.length; i++) {
var pair = pairs[i];
if (pair[0].localeCompare(pair[1]) === 0) {
throw new Test262Error("String.prototype.localeCompare considers " + pair[0] + " (" + toU(pair[0]) +
") = " + pair[1] + " (" + toU(pair[1]) + ").");
}
var i;
for (i = 0; i < pairs.length; i++) {
var pair = pairs[i];
if (pair[0].localeCompare(pair[1]) !== 0) {
throw new Test262Error("String.prototype.localeCompare considers " + pair[0] + " (" + toU(pair[0]) +
") ≠ " + pair[1] + " (" + toU(pair[1]) + ").");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright (C) 2022 Igalia S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.calendar.prototype.dateadd
description: >
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
that is not supported) is used as a PlainDate
features: [Temporal, arrow-function]
---*/

const invalidStrings = [
// invalid ISO strings:
"",
"invalid iso8601",
"2020-01-00",
"2020-01-32",
"2020-02-30",
"2021-02-29",
"2020-00-01",
"2020-13-01",
"2020-01-01T",
"2020-01-01T25:00:00",
"2020-01-01T01:60:00",
"2020-01-01T01:60:61",
"2020-01-01junk",
"2020-01-01T00:00:00junk",
"2020-01-01T00:00:00+00:00junk",
"2020-01-01T00:00:00+00:00[UTC]junk",
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
"02020-01-01",
"2020-001-01",
"2020-01-001",
"2020-01-01T001",
"2020-01-01T01:001",
"2020-01-01T01:01:001",
// valid, but forms not supported in Temporal:
"2020-W01-1",
"2020-001",
"+0002020-01-01",
// valid, but this calendar must not exist:
"2020-01-01[u-ca=notexist]",
// may be valid in other contexts, but insufficient information for PlainDate:
"2020-01",
"+002020-01",
"01-01",
"2020-W01",
"P1Y",
"-P12Y",
// valid, but outside the supported range:
"-999999-01-01",
"+999999-01-01",
];
const instance = new Temporal.Calendar("iso8601");
for (const arg of invalidStrings) {
assert.throws(
RangeError,
() => instance.dateAdd(arg),
`"${arg}" should not be a valid ISO string for a PlainDate`
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ features: [Temporal, arrow-function]
const calendar = new Temporal.Calendar("iso8601");
const date = new Temporal.PlainDate(2000, 5, 2, calendar);
const duration = new Temporal.Duration(3, 3, 0, 3);
assert.throws(RangeError,
() => calendar.dateAdd(date, duration, { overflow: "other string" }),
"Value for overflow not one of the allowed string values");
const badOverflows = ["", "CONSTRAIN", "balance", "other string", "constra\u0131n", "reject\0"];
for (const overflow of badOverflows) {
assert.throws(
RangeError,
() => calendar.dateAdd(date, duration, { overflow }),
`invalid overflow ("${overflow}")`
);
}
Loading

0 comments on commit ee752cf

Please sign in to comment.