Address review comments

This commit is contained in:
Frank Tang 2020-09-03 14:02:17 -07:00 committed by Rick Waldron
parent 4f8ee98d26
commit 7a4a637574
8 changed files with 25 additions and 32 deletions

View File

@ -12,7 +12,8 @@ info: |
13. Let granularity be ? GetOption(options, "granularity", "string", « "grapheme", "word", "sentence" », "grapheme").
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
6. If type is "string", then
a. Let value be ? ToString(value).
features: [Intl.Segmenter, Symbol]
---*/

View File

@ -19,8 +19,8 @@ info: |
8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
GetOption ( options, property, type, values, fallback )
1. Let value be ? Get(options, property).
6. If type is "string", then
a. Let value be ? ToString(value).
...
features: [Intl.Segmenter, Symbol]
---*/

View File

@ -31,7 +31,7 @@ const localeMatchers = [
];
localeMatchers.forEach(localeMatcher => {
const obj = new Intl.Segmenter();
const obj = new Intl.Segmenter(undefined, { localeMatcher });
assert(obj instanceof Intl.Segmenter, `instanceof check - ${localeMatcher}`);
assert.sameValue(Object.getPrototypeOf(obj), Intl.Segmenter.prototype, `proto check - ${localeMatcher}`);

View File

@ -16,10 +16,6 @@ info: |
...
GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
3. Let proto be ? Get(constructor, "prototype").
4. If Type(proto) is not Object, then
a. Let realm be ? GetFunctionRealm(constructor).
b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
5. Return proto.
features: [Intl.Segmenter, Reflect, Proxy]
---*/

View File

@ -24,9 +24,9 @@ info: |
features: [cross-realm, Reflect, Symbol, Intl.Segmenter]
---*/
var other = $262.createRealm().global;
var newTarget = new other.Function();
var sgm;
const other = $262.createRealm().global;
const newTarget = new other.Function();
let sgm;
newTarget.prototype = undefined;
sgm = Reflect.construct(Intl.Segmenter, [], newTarget);

View File

@ -5,9 +5,8 @@ esid: sec-%segmentsprototype%.containing
description: Verifies the branding check for the "segment" function of the %Segments.prototype%.containing.
info: |
%Segments.prototype%.containing ( index )
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2020 Language Specification, 11th edition, clause 17, or successor.
Every built-in function object, including constructors, that is not identified as an anonymous function has a name property whose value is a String. Unless otherwise specified, this value is the name that is given to the function in this specification.
Unless otherwise specified, the name property of a built-in function object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
1. Let segments be the this value.
2. Perform ? RequireInternalSlot(segments, [[SegmentsSegmenter]]).
features: [Intl.Segmenter]
---*/

View File

@ -37,19 +37,17 @@ granularities.forEach(
const segmenter = new Intl.Segmenter(undefined, {granularity});
inputs.forEach(function(input) {
const segment = segmenter.segment(input);
let msg = "granularity: " + granularity + " input: " + input;
let msg = `granularity: ${granularity} input: ${input}`;
const first = segment.containing(0);
assert.sameValue(0, first.index,
msg + " containing(0) index");
assert.sameValue(input, first.input,
msg + " containing(0) input");
assert.sameValue(0, first.index, `${msg} containing(0) index`);
assert.sameValue(input, first.input, `${msg} containing(0) input`);
assert.sameValue(false, first.segment == input,
msg + " containing(0) segment");
`${msg} containing(0) segment`);
const last = segment.containing(input.length - 1);
msg += " containing(" + input.length - 1 + ") "
assert.sameValue(true, last.index > 0, msg + " index > 0");
assert.sameValue(true, last.index < input.length, msg + " index");
assert.sameValue(input, last.input, msg + " input");
assert.sameValue(false, last.segment == input, msg + " segment");
msg += ` containing(${input.length - 1}) `
assert.sameValue(true, last.index > 0, `${msg} index > 0`);
assert.sameValue(true, last.index < input.length, `${msg} index`);
assert.sameValue(input, last.input, `${msg} input`);
assert.sameValue(false, last.segment == input, `${msg} segment`);
});
});

View File

@ -42,14 +42,13 @@ other_granularities.forEach(
const segment = segmenter.segment(input);
for (let index = 0; index < input.length; index++) {
const result = segment.containing(index);
const msg = "granularity: " + granularity + " input: " + input +
" containing(" + index + ") ";
assert.sameValue(true, result.index >= 0, msg + "index >= 0");
assert.sameValue(true, result.index < input.length,
msg + "index < " + input.length);
assert.sameValue("string", typeof result.input, msg + "input");
const msg =
`granularity: ${granularity} input: ${input} containing(${index})`;
assert.sameValue(true, result.index >= 0, `${msg} index >= 0`);
assert.sameValue(true, result.index < input.length, `${msg} index`);
assert.sameValue("string", typeof result.input, `${msg} input`);
assert.sameValue(undefined, result.isWordLike,
msg + "isWordLike should be undefined");
`${msg} isWordLike should be undefined`);
}
});
});