Fix various bugs in test cases (#1988)

This commit is contained in:
André Bargull 2018-12-05 12:48:28 -08:00 committed by Leo Balter
parent ce8ea46c31
commit b62dae4fff
13 changed files with 38 additions and 35 deletions

View File

@ -17,7 +17,7 @@ async #m() { return 42; }
//- constructor //- constructor
assert.sameValue(this.#m.name, '#m', 'function name inside constructor'); assert.sameValue(this.#m.name, '#m', 'function name inside constructor');
ctorPromise = this.#m().then(value => { ctorPromise = this.#m().then(value => {
assert.sameValue(this.#m(), 42, 'already defined in the ctor'); assert.sameValue(value, 42, 'already defined in the ctor');
}, $DONE); }, $DONE);
//- assertions //- assertions

View File

@ -7,7 +7,7 @@ description: >
features: [Array.prototype.flatMap] features: [Array.prototype.flatMap]
---*/ ---*/
assert(Array.prototype.flatMap); assert.sameValue(typeof Array.prototype.flatMap, "function");
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
[].flatMap({}); [].flatMap({});

View File

@ -15,10 +15,10 @@ info: |
9.1.12 [[OwnPropertyKeys]] ( ) 9.1.12 [[OwnPropertyKeys]] ( )
1. Let keys be a new empty List. 1. Let keys be a new empty List.
2. For each own property key P of O that is an integer index, in ascending 2. For each own property key P of O that is an array index, in ascending
numeric index order numeric index order
a. Add P as the last element of keys. a. Add P as the last element of keys.
3. For each own property key P of O that is a String but is not an integer 3. For each own property key P of O that is a String but is not an array
index, in property creation order index, in property creation order
a. Add P as the last element of keys. a. Add P as the last element of keys.
4. For each own property key P of O that is a Symbol, in property creation 4. For each own property key P of O that is a Symbol, in property creation
@ -36,18 +36,22 @@ var o1 = {
[Number.MAX_SAFE_INTEGER]: true, [Number.MAX_SAFE_INTEGER]: true,
[Symbol.for('z')]: true, [Symbol.for('z')]: true,
12345678901: true, 12345678901: true,
4294967294: true,
4294967295: true,
}; };
var result = Reflect.ownKeys(o1); var result = Reflect.ownKeys(o1);
assert.sameValue(result.length, 7); assert.sameValue(result.length, 9);
assert.sameValue(result[0], '1'); assert.sameValue(result[0], '1');
assert.sameValue(result[1], '12345678900'); assert.sameValue(result[1], '4294967294');
assert.sameValue(result[2], '12345678901'); assert.sameValue(result[2], '12345678900');
assert.sameValue(result[3], String(Number.MAX_SAFE_INTEGER)); assert.sameValue(result[3], 'b');
assert.sameValue(result[4], 'b'); assert.sameValue(result[4], 'a');
assert.sameValue(result[5], 'a'); assert.sameValue(result[5], String(Number.MAX_SAFE_INTEGER));
assert.sameValue(result[6], Symbol.for('z')); assert.sameValue(result[6], '12345678901');
assert.sameValue(result[7], '4294967295');
assert.sameValue(result[8], Symbol.for('z'));
var o2 = {}; var o2 = {};
@ -58,15 +62,19 @@ o2.a = true;
o2[Number.MAX_SAFE_INTEGER] = true; o2[Number.MAX_SAFE_INTEGER] = true;
o2[Symbol.for('z')] = true; o2[Symbol.for('z')] = true;
o2[12345678901] = true; o2[12345678901] = true;
o2[4294967294] = true;
o2[4294967295] = true;
result = Reflect.ownKeys(o2); result = Reflect.ownKeys(o2);
assert.sameValue(result.length, 7); assert.sameValue(result.length, 9);
assert.sameValue(result[0], '1'); assert.sameValue(result[0], '1');
assert.sameValue(result[1], '12345678900'); assert.sameValue(result[1], '4294967294');
assert.sameValue(result[2], '12345678901'); assert.sameValue(result[2], '12345678900');
assert.sameValue(result[3], String(Number.MAX_SAFE_INTEGER)); assert.sameValue(result[3], 'b');
assert.sameValue(result[4], 'b'); assert.sameValue(result[4], 'a');
assert.sameValue(result[5], 'a'); assert.sameValue(result[5], String(Number.MAX_SAFE_INTEGER));
assert.sameValue(result[6], Symbol.for('z')); assert.sameValue(result[6], '12345678901');
assert.sameValue(result[7], '4294967295');
assert.sameValue(result[8], Symbol.for('z'));

View File

@ -7,7 +7,7 @@ description: Checks handling of valid values for the numeric option to the Relat
info: | info: |
SetNumberFormatUnitOptions ( intlObj, options ) SetNumberFormatUnitOptions ( intlObj, options )
6. Let currencyDisplay be ? GetOption(options, "currencyDisplay", "string", « "code", "symbol", "narrowSymbol", "name" », "symbol"). 6. Let currencyDisplay be ? GetOption(options, "currencyDisplay", "string", « "code", "symbol", "narrow-symbol", "name" », "symbol").
11. If style is "currency", then 11. If style is "currency", then
f. Set intlObj.[[CurrencyDisplay]] to currencyDisplay. f. Set intlObj.[[CurrencyDisplay]] to currencyDisplay.
@ -16,8 +16,8 @@ features: [Intl.NumberFormat-unified]
const validOptions = [ const validOptions = [
[undefined, "symbol"], [undefined, "symbol"],
["narrowSymbol", "narrowSymbol"], ["narrow-symbol", "narrow-symbol"],
[{ toString() { return "narrowSymbol"; } }, "narrowSymbol"], [{ toString() { return "narrow-symbol"; } }, "narrow-symbol"],
]; ];
for (const [validOption, expected] of validOptions) { for (const [validOption, expected] of validOptions) {

View File

@ -20,7 +20,7 @@ const validOptions = [
]; ];
for (const [validOption, expected] of validOptions) { for (const [validOption, expected] of validOptions) {
const nf = new Intl.NumberFormat([], {"style": validOption}); const nf = new Intl.NumberFormat([], {"style": validOption, "unit": "generic"});
const resolvedOptions = nf.resolvedOptions(); const resolvedOptions = nf.resolvedOptions();
assert.sameValue(resolvedOptions.style, expected); assert.sameValue(resolvedOptions.style, expected);
} }

View File

@ -25,7 +25,7 @@ const tests = [
]; ];
for (const [input, position] of tests) { for (const [input, position] of tests) {
assert.sameValue(iter.following(0 | input), false); assert.sameValue(iter.following(input), false);
assert.sameValue(iter.position, position, String(input)); assert.sameValue(iter.position, position, String(input));
} }

View File

@ -14,9 +14,5 @@ for (const granularity of ["grapheme", "word", "sentence", "line"]) {
assert.sameValue(typeof iter.position, "number"); assert.sameValue(typeof iter.position, "number");
assert.sameValue(iter.position, 0); assert.sameValue(iter.position, 0);
if (granularity === "grapheme") { assert.sameValue(iter.breakType, undefined);
assert.sameValue(iter.breakType, undefined);
} else {
assert.sameValue(typeof iter.breakType, "string");
}
} }

View File

@ -23,13 +23,12 @@ const tests = [
]; ];
for (const [input, position] of tests) { for (const [input, position] of tests) {
assert.sameValue(iter.preceding(0 | input), false); assert.sameValue(iter.preceding(input), false);
assert.sameValue(iter.position, position, String(input)); assert.sameValue(iter.position, position, String(input));
} }
assert.throws(RangeError, () => iter.preceding("ABC")); assert.throws(RangeError, () => iter.preceding("ABC"));
assert.throws(RangeError, () => iter.preceding(null)); assert.throws(RangeError, () => iter.preceding(null));
assert.throws(RangeError, () => iter.preceding(1.4));
assert.throws(RangeError, () => iter.preceding(-3)); assert.throws(RangeError, () => iter.preceding(-3));
// 1.5.3.3 %SegmentIteratorPrototype%.preceding( [ from ] ) // 1.5.3.3 %SegmentIteratorPrototype%.preceding( [ from ] )

View File

@ -29,6 +29,6 @@ for (const text of [
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean "법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
]) { ]) {
const iter = seg.segment(text); const iter = seg.segment(text);
assert(["soft", "hard"].includes(iter.breakType), iter.breakType); assert.sameValue(undefined, iter.breakType);
assert.sameValue(0, iter.position); assert.sameValue(0, iter.position);
} }

View File

@ -29,6 +29,6 @@ for (const text of [
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean "법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
]) { ]) {
const iter = seg.segment(text); const iter = seg.segment(text);
assert(["sep", "term"].includes(iter.breakType), iter.breakType); assert.sameValue(undefined, iter.breakType);
assert.sameValue(0, iter.position); assert.sameValue(0, iter.position);
} }

View File

@ -29,6 +29,6 @@ for (const text of [
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean "법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
]) { ]) {
const iter = seg.segment(text); const iter = seg.segment(text);
assert(["word", "none"].includes(iter.breakType), iter.breakType); assert.sameValue(undefined, iter.breakType);
assert.sameValue(0, iter.position); assert.sameValue(0, iter.position);
} }

View File

@ -99,7 +99,7 @@ var C = class {
assert.sameValue(this.#m.name, '#m', 'function name inside constructor'); assert.sameValue(this.#m.name, '#m', 'function name inside constructor');
ctorPromise = this.#m().then(value => { ctorPromise = this.#m().then(value => {
assert.sameValue(this.#m(), 42, 'already defined in the ctor'); assert.sameValue(value, 42, 'already defined in the ctor');
}, $DONE); }, $DONE);
} }

View File

@ -98,7 +98,7 @@ class C {
assert.sameValue(this.#m.name, '#m', 'function name inside constructor'); assert.sameValue(this.#m.name, '#m', 'function name inside constructor');
ctorPromise = this.#m().then(value => { ctorPromise = this.#m().then(value => {
assert.sameValue(this.#m(), 42, 'already defined in the ctor'); assert.sameValue(value, 42, 'already defined in the ctor');
}, $DONE); }, $DONE);
} }