mirror of
https://github.com/tc39/test262.git
synced 2025-07-27 07:54:41 +02:00
Improve Intl.Segmenter coverage
This commit is contained in:
parent
18638f301f
commit
ffec772910
@ -13,6 +13,7 @@ info: |
|
|||||||
a. Let isWordLike be a Boolean value indicating whether the segment in string is "word-like" according to locale segmenter.[[Locale]].
|
a. Let isWordLike be a Boolean value indicating whether the segment in string is "word-like" according to locale segmenter.[[Locale]].
|
||||||
b. Perform ! CreateDataPropertyOrThrow(result, "isWordLike", isWordLike).
|
b. Perform ! CreateDataPropertyOrThrow(result, "isWordLike", isWordLike).
|
||||||
|
|
||||||
|
includes: [compareArray.js]
|
||||||
features: [Intl.Segmenter]
|
features: [Intl.Segmenter]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
@ -49,6 +50,7 @@ other_granularities.forEach(
|
|||||||
assert.sameValue("string", typeof result.input, `${msg} input`);
|
assert.sameValue("string", typeof result.input, `${msg} input`);
|
||||||
assert.sameValue(undefined, result.isWordLike,
|
assert.sameValue(undefined, result.isWordLike,
|
||||||
`${msg} isWordLike should be undefined`);
|
`${msg} isWordLike should be undefined`);
|
||||||
|
assert.compareArray(Object.getOwnPropertyNames(result), ["segment", "index", "input"]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -36,6 +36,9 @@ const index_to_one = [
|
|||||||
"14.9E-1",
|
"14.9E-1",
|
||||||
"14.9e-1",
|
"14.9e-1",
|
||||||
true,
|
true,
|
||||||
|
{ toString(){ return "1"; } },
|
||||||
|
{ valueOf(){ return 1; } },
|
||||||
|
{ [Symbol.toPrimitive](){ return 1; } },
|
||||||
];
|
];
|
||||||
|
|
||||||
// Except granularity: "sentence", check the result.segment is " ".
|
// Except granularity: "sentence", check the result.segment is " ".
|
||||||
|
@ -37,6 +37,9 @@ const index_to_out_of_bound = [
|
|||||||
-Infinity,
|
-Infinity,
|
||||||
"Infinity",
|
"Infinity",
|
||||||
"-Infinity",
|
"-Infinity",
|
||||||
|
{ toString(){ return "-1"; } },
|
||||||
|
{ valueOf(){ return input.length; } },
|
||||||
|
{ [Symbol.toPrimitive](){ return -1; } },
|
||||||
];
|
];
|
||||||
|
|
||||||
granularities.forEach(
|
granularities.forEach(
|
||||||
|
@ -13,6 +13,7 @@ info: |
|
|||||||
a. Let isWordLike be a Boolean value indicating whether the segment in string is "word-like" according to locale segmenter.[[Locale]].
|
a. Let isWordLike be a Boolean value indicating whether the segment in string is "word-like" according to locale segmenter.[[Locale]].
|
||||||
b. Perform ! CreateDataPropertyOrThrow(result, "isWordLike", isWordLike).
|
b. Perform ! CreateDataPropertyOrThrow(result, "isWordLike", isWordLike).
|
||||||
|
|
||||||
|
includes: [compareArray.js]
|
||||||
features: [Intl.Segmenter]
|
features: [Intl.Segmenter]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
@ -48,5 +49,7 @@ inputs.forEach(function(input) {
|
|||||||
assert.sameValue("string", typeof result.input, msg + "input");
|
assert.sameValue("string", typeof result.input, msg + "input");
|
||||||
assert.sameValue("boolean", typeof result.isWordLike,
|
assert.sameValue("boolean", typeof result.isWordLike,
|
||||||
msg + "isWordLike should be boolean");
|
msg + "isWordLike should be boolean");
|
||||||
|
assert.compareArray(Object.getOwnPropertyNames(result),
|
||||||
|
["segment", "index", "input", "isWordLike"]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -52,6 +52,9 @@ const index_to_zeros = [
|
|||||||
"-4.9e-1",
|
"-4.9e-1",
|
||||||
"4.9E-1",
|
"4.9E-1",
|
||||||
"-4.9E-1",
|
"-4.9E-1",
|
||||||
|
{ toString(){ return "-0.1"; } },
|
||||||
|
{ valueOf(){ return 0.1; } },
|
||||||
|
{ [Symbol.toPrimitive](){ return -0.1; } },
|
||||||
];
|
];
|
||||||
|
|
||||||
granularities.forEach(
|
granularities.forEach(
|
||||||
|
@ -7,6 +7,7 @@ esid: sec-Intl.Segmenter.prototype.segment
|
|||||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||||
info: |
|
info: |
|
||||||
Intl.Segmenter.prototype.segment( string )
|
Intl.Segmenter.prototype.segment( string )
|
||||||
|
includes: [compareArray.js]
|
||||||
features: [Intl.Segmenter]
|
features: [Intl.Segmenter]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
@ -31,12 +32,22 @@ for (const text of [
|
|||||||
]) {
|
]) {
|
||||||
let segments = [];
|
let segments = [];
|
||||||
for (const v of seg.segment(text)) {
|
for (const v of seg.segment(text)) {
|
||||||
assert.sameValue(undefined, v.isWordLike);
|
|
||||||
assert.sameValue(false, v.hasOwnProperty("isWordLike"));
|
|
||||||
assert.sameValue("string", typeof v.segment);
|
assert.sameValue("string", typeof v.segment);
|
||||||
assert(v.segment.length > 0);
|
assert.sameValue(true, v.segment.length > 0, "length > 0");
|
||||||
|
|
||||||
|
assert.sameValue("number", typeof v.index);
|
||||||
|
assert.sameValue(true, v.index >= 0, "index >= 0");
|
||||||
|
assert.sameValue(true, v.index < text.length, "index < input.length");
|
||||||
|
|
||||||
assert.sameValue("string", typeof v.input);
|
assert.sameValue("string", typeof v.input);
|
||||||
assert.sameValue(text, v.input);
|
assert.sameValue(text, v.input);
|
||||||
|
|
||||||
|
assert.sameValue(undefined, v.isWordLike);
|
||||||
|
assert.sameValue(false, v.hasOwnProperty("isWordLike"));
|
||||||
|
|
||||||
|
assert.sameValue(text.slice(v.index, v.index + v.segment.length), v.segment);
|
||||||
|
assert.compareArray(Object.getOwnPropertyNames(v), ["segment", "index", "input"]);
|
||||||
|
|
||||||
segments.push(v.segment);
|
segments.push(v.segment);
|
||||||
}
|
}
|
||||||
assert.sameValue(text, segments.join(''));
|
assert.sameValue(text, segments.join(''));
|
||||||
|
@ -7,6 +7,7 @@ esid: sec-Intl.Segmenter.prototype.segment
|
|||||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||||
info: |
|
info: |
|
||||||
Intl.Segmenter.prototype.segment( string )
|
Intl.Segmenter.prototype.segment( string )
|
||||||
|
includes: [compareArray.js]
|
||||||
features: [Intl.Segmenter]
|
features: [Intl.Segmenter]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
@ -31,12 +32,22 @@ for (const text of [
|
|||||||
]) {
|
]) {
|
||||||
let segments = [];
|
let segments = [];
|
||||||
for (const v of seg.segment(text)) {
|
for (const v of seg.segment(text)) {
|
||||||
assert.sameValue(undefined, v.isWordLike);
|
|
||||||
assert.sameValue(false, v.hasOwnProperty("isWordLike"));
|
|
||||||
assert.sameValue("string", typeof v.segment);
|
assert.sameValue("string", typeof v.segment);
|
||||||
assert(v.segment.length > 0);
|
assert.sameValue(true, v.segment.length > 0, "length > 0");
|
||||||
|
|
||||||
|
assert.sameValue("number", typeof v.index);
|
||||||
|
assert.sameValue(true, v.index >= 0, "index >= 0");
|
||||||
|
assert.sameValue(true, v.index < text.length, "index < input.length");
|
||||||
|
|
||||||
assert.sameValue("string", typeof v.input);
|
assert.sameValue("string", typeof v.input);
|
||||||
assert.sameValue(text, v.input);
|
assert.sameValue(text, v.input);
|
||||||
|
|
||||||
|
assert.sameValue(undefined, v.isWordLike);
|
||||||
|
assert.sameValue(false, v.hasOwnProperty("isWordLike"));
|
||||||
|
|
||||||
|
assert.sameValue(text.slice(v.index, v.index + v.segment.length), v.segment);
|
||||||
|
assert.compareArray(Object.getOwnPropertyNames(v), ["segment", "index", "input"]);
|
||||||
|
|
||||||
segments.push(v.segment);
|
segments.push(v.segment);
|
||||||
}
|
}
|
||||||
assert.sameValue(text, segments.join(''));
|
assert.sameValue(text, segments.join(''));
|
||||||
|
@ -7,6 +7,7 @@ esid: sec-Intl.Segmenter.prototype.segment
|
|||||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||||
info: |
|
info: |
|
||||||
Intl.Segmenter.prototype.segment( string )
|
Intl.Segmenter.prototype.segment( string )
|
||||||
|
includes: [compareArray.js]
|
||||||
features: [Intl.Segmenter]
|
features: [Intl.Segmenter]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
@ -31,12 +32,22 @@ for (const text of [
|
|||||||
]) {
|
]) {
|
||||||
let segments = [];
|
let segments = [];
|
||||||
for (const v of seg.segment(text)) {
|
for (const v of seg.segment(text)) {
|
||||||
assert.sameValue("boolean", typeof v.isWordLike);
|
|
||||||
assert.sameValue(true, v.hasOwnProperty("isWordLike"));
|
|
||||||
assert.sameValue("string", typeof v.segment);
|
assert.sameValue("string", typeof v.segment);
|
||||||
assert(v.segment.length > 0);
|
assert.sameValue(true, v.segment.length > 0, "length > 0");
|
||||||
|
|
||||||
|
assert.sameValue("number", typeof v.index);
|
||||||
|
assert.sameValue(true, v.index >= 0, "index >= 0");
|
||||||
|
assert.sameValue(true, v.index < text.length, "index < input.length");
|
||||||
|
|
||||||
assert.sameValue("string", typeof v.input);
|
assert.sameValue("string", typeof v.input);
|
||||||
assert.sameValue(text, v.input);
|
assert.sameValue(text, v.input);
|
||||||
|
|
||||||
|
assert.sameValue("boolean", typeof v.isWordLike);
|
||||||
|
assert.sameValue(true, v.hasOwnProperty("isWordLike"));
|
||||||
|
|
||||||
|
assert.sameValue(text.slice(v.index, v.index + v.segment.length), v.segment);
|
||||||
|
assert.compareArray(Object.getOwnPropertyNames(v), ["segment", "index", "input", "isWordLike"]);
|
||||||
|
|
||||||
segments.push(v.segment);
|
segments.push(v.segment);
|
||||||
}
|
}
|
||||||
assert.sameValue(text, segments.join(''));
|
assert.sameValue(text, segments.join(''));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user