Skip to content
Snippets Groups Projects
Commit 0460c520 authored by Frank Tang's avatar Frank Tang Committed by Rick Waldron
Browse files

Remove "line" tests and ensure error under "line"

parent cc9c773c
No related branches found
No related tags found
No related merge requests found
Showing
with 10 additions and 432 deletions
...@@ -7,7 +7,7 @@ description: Checks handling of valid values for the granularity option to the S ...@@ -7,7 +7,7 @@ description: Checks handling of valid values for the granularity option to the S
info: | info: |
Intl.Segmenter ([ locales [ , options ]]) Intl.Segmenter ([ locales [ , options ]])
13. Let granularity be ? GetOption(options, "granularity", "string", « "grapheme", "word", "sentence", "line" », "grapheme"). 13. Let granularity be ? GetOption(options, "granularity", "string", « "grapheme", "word", "sentence" », "grapheme").
14. Set segmenter.[[SegmenterGranularity]] to granularity. 14. Set segmenter.[[SegmenterGranularity]] to granularity.
features: [Intl.Segmenter] features: [Intl.Segmenter]
---*/ ---*/
...@@ -17,8 +17,7 @@ const validOptions = [ ...@@ -17,8 +17,7 @@ const validOptions = [
["grapheme", "grapheme"], ["grapheme", "grapheme"],
["word", "word"], ["word", "word"],
["sentence", "sentence"], ["sentence", "sentence"],
["line", "line"], [{ toString() { return "word"; } }, "word"],
[{ toString() { return "line"; } }, "line"],
]; ];
for (const [granularity, expected] of validOptions) { for (const [granularity, expected] of validOptions) {
......
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.Segmenter
description: Checks handling of invalid value for the style option to the Segmenter constructor.
info: |
Intl.Segmenter ([ locales [ , options ]])
9. Let lineBreakStyle be ? GetOption(options, "lineBreakStyle", "string", « "strict", "normal", "loose" », "normal").
15. If granularity is "line",
a. Set segmenter.[[SegmenterLineBreakStyle]] to r.[[lb]].
features: [Intl.Segmenter]
---*/
const invalidOptions = [
null,
1,
"",
"giant",
"Strict",
"STRICT",
"strict\0",
"Normal",
"NORMAL",
"normal\0",
"Loose",
"LOOSE",
"loose\0",
];
for (const lineBreakStyle of invalidOptions) {
assert.throws(RangeError, function() {
new Intl.Segmenter([], { lineBreakStyle });
}, `${lineBreakStyle} is an invalid style option value`);
}
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.Segmenter
description: Checks handling of valid values for the lineBreakStyle option to the Segmenter constructor.
info: |
Intl.Segmenter ([ locales [ , options ]])
9. Let lineBreakStyle be ? GetOption(options, "lineBreakStyle", "string", « "strict", "normal", "loose" », "normal").
15. If granularity is "line",
a. Set segmenter.[[SegmenterLineBreakStyle]] to r.[[lb]].
features: [Intl.Segmenter]
---*/
const validOptions = [
[undefined, "normal"],
["strict", "strict"],
["normal", "normal"],
["loose", "loose"],
[{ toString() { return "loose"; } }, "loose"],
];
for (const [lineBreakStyle, expected] of validOptions) {
const segmenter = new Intl.Segmenter([], { granularity: "line", lineBreakStyle });
const resolvedOptions = segmenter.resolvedOptions();
assert.sameValue(resolvedOptions.lineBreakStyle, expected);
}
...@@ -8,8 +8,7 @@ info: | ...@@ -8,8 +8,7 @@ info: |
Intl.Segmenter ([ locales [ , options ]]) Intl.Segmenter ([ locales [ , options ]])
7. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit"). 7. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
9. Let lineBreakStyle be ? GetOption(options, "lineBreakStyle", "string", « "strict", "normal", "loose" », "normal"). 13. Let granularity be ? GetOption(options, "granularity", "string", « "grapheme", "word", "sentence" », "grapheme").
13. Let granularity be ? GetOption(options, "granularity", "string", « "grapheme", "word", "sentence", "line" », "grapheme").
includes: [compareArray.js] includes: [compareArray.js]
features: [Intl.Segmenter] features: [Intl.Segmenter]
---*/ ---*/
...@@ -49,8 +48,6 @@ new Intl.Segmenter([], { ...@@ -49,8 +48,6 @@ new Intl.Segmenter([], {
assert.compareArray(callOrder, [ assert.compareArray(callOrder, [
"localeMatcher", "localeMatcher",
"localeMatcher toString", "localeMatcher toString",
"lineBreakStyle",
"lineBreakStyle toString",
"granularity", "granularity",
"granularity toString", "granularity toString",
]); ]);
...@@ -11,7 +11,6 @@ function CustomError() {} ...@@ -11,7 +11,6 @@ function CustomError() {}
const options = [ const options = [
"localeMatcher", "localeMatcher",
"lineBreakStyle",
"granularity", "granularity",
]; ];
......
...@@ -13,11 +13,8 @@ features: [Intl.Segmenter] ...@@ -13,11 +13,8 @@ features: [Intl.Segmenter]
---*/ ---*/
Object.defineProperties(Object.prototype, { Object.defineProperties(Object.prototype, {
"lineBreakStyle": {
value: "loose",
},
"granularity": { "granularity": {
value: "line", value: "word",
}, },
}) })
...@@ -32,8 +29,6 @@ const optionsArguments = [ ...@@ -32,8 +29,6 @@ const optionsArguments = [
for (const options of optionsArguments) { for (const options of optionsArguments) {
const segmenter = new Intl.Segmenter([], options); const segmenter = new Intl.Segmenter([], options);
const resolvedOptions = segmenter.resolvedOptions(); const resolvedOptions = segmenter.resolvedOptions();
assert.sameValue(resolvedOptions.lineBreakStyle, "loose", assert.sameValue(resolvedOptions.granularity, "word",
`options argument ${String(options)} should yield the correct value for "lineBreakStyle"`);
assert.sameValue(resolvedOptions.granularity, "line",
`options argument ${String(options)} should yield the correct value for "granularity"`); `options argument ${String(options)} should yield the correct value for "granularity"`);
} }
...@@ -7,16 +7,12 @@ description: Checks handling of valid values for the granularity option to the S ...@@ -7,16 +7,12 @@ description: Checks handling of valid values for the granularity option to the S
info: | info: |
Intl.Segmenter ([ locales [ , options ]]) Intl.Segmenter ([ locales [ , options ]])
9. Let lineBreakStyle be ? GetOption(options, "lineBreakStyle", "string", « "strict", "normal", "loose" », "normal"). 13. Let granularity be ? GetOption(options, "granularity", "string", « "grapheme", "word", "sentence" », "grapheme").
13. Let granularity be ? GetOption(options, "granularity", "string", « "grapheme", "word", "sentence", "line" », "grapheme").
14. Set segmenter.[[SegmenterGranularity]] to granularity. 14. Set segmenter.[[SegmenterGranularity]] to granularity.
15. If granularity is "line",
a. Set segmenter.[[SegmenterLineBreakStyle]] to r.[[lb]].
features: [Intl.Segmenter] features: [Intl.Segmenter]
---*/ ---*/
const lineBreakStyleOptions = ["strict", "normal", "loose"]; const granularityOptions = ["grapheme", "word", "sentence"];
const granularityOptions = ["grapheme", "word", "sentence", "line"];
const combinations = []; const combinations = [];
combinations.push([ combinations.push([
...@@ -25,35 +21,16 @@ combinations.push([ ...@@ -25,35 +21,16 @@ combinations.push([
undefined, undefined,
]); ]);
for (const lineBreakStyle of lineBreakStyleOptions) {
combinations.push([
{ lineBreakStyle },
"grapheme",
undefined,
]);
}
for (const granularity of granularityOptions) { for (const granularity of granularityOptions) {
combinations.push([ combinations.push([
{ granularity }, { granularity },
granularity, granularity,
granularity === "line" ? "normal" : undefined, undefined,
]); ]);
} }
for (const lineBreakStyle of lineBreakStyleOptions) {
for (const granularity of granularityOptions) {
combinations.push([
{ granularity, lineBreakStyle },
granularity,
granularity === "line" ? lineBreakStyle : undefined,
]);
}
}
for (const [input, granularity, lineBreakStyle] of combinations) { for (const [input, granularity, lineBreakStyle] of combinations) {
const segmenter = new Intl.Segmenter([], input); const segmenter = new Intl.Segmenter([], input);
const resolvedOptions = segmenter.resolvedOptions(); const resolvedOptions = segmenter.resolvedOptions();
assert.sameValue(resolvedOptions.granularity, granularity); assert.sameValue(resolvedOptions.granularity, granularity);
assert.sameValue(resolvedOptions.lineBreakStyle, lineBreakStyle);
} }
...@@ -8,7 +8,7 @@ features: [Intl.Segmenter] ...@@ -8,7 +8,7 @@ features: [Intl.Segmenter]
---*/ ---*/
const text = "Hello World, Test 123! Foo Bar. How are you?"; const text = "Hello World, Test 123! Foo Bar. How are you?";
for (const granularity of ["grapheme", "word", "sentence", "line"]) { for (const granularity of ["grapheme", "word", "sentence"]) {
const segmenter = new Intl.Segmenter("en", { granularity }); const segmenter = new Intl.Segmenter("en", { granularity });
const iter = segmenter.segment(text); const iter = segmenter.segment(text);
......
...@@ -9,13 +9,12 @@ features: [Intl.Segmenter] ...@@ -9,13 +9,12 @@ features: [Intl.Segmenter]
---*/ ---*/
const options = new Intl.Segmenter([], { const options = new Intl.Segmenter([], {
"granularity": "line", "granularity": "word",
}).resolvedOptions(); }).resolvedOptions();
const expected = [ const expected = [
"locale", "locale",
"granularity", "granularity",
"lineBreakStyle",
]; ];
assert.compareArray(Object.getOwnPropertyNames(options), expected); assert.compareArray(Object.getOwnPropertyNames(options), expected);
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.Segmenter.prototype.resolvedOptions
description: Checks the properties of the result of Intl.Segmenter.prototype.resolvedOptions().
info: |
Intl.Segmenter.prototype.resolvedOptions ()
3. Let options be ! ObjectCreate(%ObjectPrototype%).
4. For each row of Table 1, except the header row, do
c. If v is not undefined, then
i. Perform ! CreateDataPropertyOrThrow(options, p, v).
includes: [propertyHelper.js]
features: [Intl.Segmenter]
---*/
const rtf = new Intl.Segmenter("en-us", { "lineBreakStyle": "loose", "granularity": "line" });
const options = rtf.resolvedOptions();
assert.sameValue(Object.getPrototypeOf(options), Object.prototype, "Prototype");
verifyProperty(options, "locale", {
value: "en-US",
writable: true,
enumerable: true,
configurable: true,
});
verifyProperty(options, "granularity", {
value: "line",
writable: true,
enumerable: true,
configurable: true,
});
verifyProperty(options, "lineBreakStyle", {
value: "loose",
writable: true,
enumerable: true,
configurable: true,
});
// Copyright 2018 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.Segmenter.prototype.segment
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
info: |
Intl.Segmenter.prototype.segment( string )
features: [Intl.Segmenter]
---*/
let breakCounts = {};
for (const locale of ["en", "fr", "ja", "zh", "ko"]) {
for (const lineBreakStyle of ["strict", "normal", "loose"]) {
const seg = new Intl.Segmenter(
[locale], {granularity: "line", lineBreakStyle: lineBreakStyle});
let opportunity = 0;
for (const text of [
// We know the following data caused different line break results between
// different modes.
// https://www.w3.org/TR/css-text-3/#propdef-line-break
// Japanese small kana or the Katakana-Hiragana prolonged sound mark
"あぁーぃーあーいーぁーぃー",
// hyphens:
// ‐ U+2010, – U+2013, 〜 U+301C, ゠ U+30A0
"ABC‐DEF–GHI〜JKL゠MNO",
// iteration marks:
// 々 U+3005, 〻 U+303B, ゝ U+309D, ゞ U+309E, ヽ U+30FD, ヾ U+30FE
"あ々あ〻あゝあゞあヽあヾあ",
// centered punctuation marks:
// ・ U+30FB, : U+FF1A, ; U+FF1B, ・ U+FF65, ‼ U+203C
"ABC・DEF:GHI;JKL・MNO‼PQR",
// centered punctuation marks:
// ⁇ U+2047, ⁈ U+2048, ⁉ U+2049, ! U+FF01, ? U+FF1F
"ABC⁇DEF⁈GHI⁉JKL!MNO?PQR",
]) {
const iter = seg.segment(text);
while (!iter.following()) {
opportunity++;
}
}
breakCounts[locale + "-" + lineBreakStyle] = opportunity;
}
}
// In Japanese
// Just test the break count in loose mode is greater than normal mode.
assert(breakCounts["ja-loose"] > breakCounts["ja-normal"]);
// and test the break count in normal mode is greater than strict mode.
assert(breakCounts["ja-normal"] > breakCounts["ja-strict"]);
// In Chinese
// Just test the break count in loose mode is greater than normal mode.
assert(breakCounts["zh-loose"] > breakCounts["zh-normal"]);
// and test the break count in normal mode is greater than strict mode.
assert(breakCounts["zh-normal"] > breakCounts["zh-strict"]);
// In English, French and Korean
assert(breakCounts["en-loose"] >= breakCounts["en-normal"]);
assert(breakCounts["fr-loose"] >= breakCounts["fr-normal"]);
assert(breakCounts["ko-loose"] >= breakCounts["ko-normal"]);
// and test the break count in normal mode is greater than strict mode.
assert(breakCounts["en-normal"] > breakCounts["en-strict"]);
assert(breakCounts["fr-normal"] > breakCounts["fr-strict"]);
assert(breakCounts["ko-normal"] > breakCounts["ko-strict"]);
// Copyright 2018 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.Segmenter.prototype.segment
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
info: |
Intl.Segmenter.prototype.segment( string )
features: [Intl.Segmenter]
---*/
const seg = new Intl.Segmenter([], {granularity: "line"})
for (const text of [
"Hello world!", // English
" Hello world! ", // English with space before/after
" Hello world? Foo bar!", // English
"Jedovatou mambu objevila žena v zahrádkářské kolonii.", // Czech
"Việt Nam: Nhất thể hóa sẽ khác Trung Quốc?", // Vietnamese
"Σοβαρές ενστάσεις Κομισιόν για τον προϋπολογισμό της Ιταλίας", // Greek
"Решение Индии о покупке российских С-400 расценили как вызов США", // Russian
"הרופא שהציל נשים והנערה ששועבדה ע", // Hebrew,
"ترامب للملك سلمان: أنا جاد للغاية.. عليك دفع المزيد", // Arabic
"भारत की एस 400 मिसाइल के मुकाबले पाक की थाड, जानें कौन कितना ताकतवर", // Hindi
"ரெட் அலர்ட் எச்சரிக்கை; புதுச்சேரியில் நாளை அரசு விடுமுறை!", // Tamil
"'ఉత్తర్వులు అందే వరకు ఓటర్ల తుది జాబితాను వెబ్‌సైట్లో పెట్టవద్దు'", // Telugu
"台北》抹黑柯P失敗?朱學恒酸:姚文智氣pupu嗆大老闆", // Chinese
"วัดไทรตีระฆังเบาลงช่วงเข้าพรรษา เจ้าอาวาสเผยคนร้องเรียนรับผลกรรมแล้ว", // Thai
"九州北部の一部が暴風域に入りました(日直予報士 2018年10月06日) - 日本気象協会 tenki.jp", // Japanese
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
]) {
const iter = seg.segment(text);
let prev = 0;
let segments = [];
while (!iter.following()) {
assert(["soft", "hard"].includes(iter.breakType), iter.breakType);
assert(iter.index >= 0);
assert(iter.index <= text.length);
assert(iter.index > prev);
segments.push(text.substring(prev, iter.index));
prev = iter.index;
}
assert.sameValue(text, segments.join(""));
}
// Copyright 2018 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.Segmenter.prototype.segment
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
info: |
Intl.Segmenter.prototype.segment( string )
features: [Intl.Segmenter]
---*/
const seg = new Intl.Segmenter([], {granularity: "line"})
for (const text of [
"Hello world!", // English
" Hello world! ", // English with space before/after
" Hello world? Foo bar!", // English
"Jedovatou mambu objevila žena v zahrádkářské kolonii.", // Czech
"Việt Nam: Nhất thể hóa sẽ khác Trung Quốc?", // Vietnamese
"Σοβαρές ενστάσεις Κομισιόν για τον προϋπολογισμό της Ιταλίας", // Greek
"Решение Индии о покупке российских С-400 расценили как вызов США", // Russian
"הרופא שהציל נשים והנערה ששועבדה ע", // Hebrew,
"ترامب للملك سلمان: أنا جاد للغاية.. عليك دفع المزيد", // Arabic
"भारत की एस 400 मिसाइल के मुकाबले पाक की थाड, जानें कौन कितना ताकतवर", // Hindi
"ரெட் அலர்ட் எச்சரிக்கை; புதுச்சேரியில் நாளை அரசு விடுமுறை!", // Tamil
"'ఉత్తర్వులు అందే వరకు ఓటర్ల తుది జాబితాను వెబ్‌సైట్లో పెట్టవద్దు'", // Telugu
"台北》抹黑柯P失敗?朱學恒酸:姚文智氣pupu嗆大老闆", // Chinese
"วัดไทรตีระฆังเบาลงช่วงเข้าพรรษา เจ้าอาวาสเผยคนร้องเรียนรับผลกรรมแล้ว", // Thai
"九州北部の一部が暴風域に入りました(日直予報士 2018年10月06日) - 日本気象協会 tenki.jp", // Japanese
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
]) {
let segments = [];
// Create another %SegmentIterator% to compare with result from the one that
// created in the for of loop.
let iter = seg.segment(text);
let prev = 0;
for (const v of seg.segment(text)) {
assert(["soft", "hard"].includes(v.breakType), v.breakType);
assert.sameValue("string", typeof v.segment);
assert(v.segment.length > 0);
segments.push(v.segment);
// manually advance the iter.
assert.sameValue(iter.following(), false);
assert.sameValue(iter.breakType, v.breakType);
assert.sameValue(text.substring(prev, iter.index), v.segment);
prev = iter.index;
}
assert(iter.following());
assert.sameValue(text, segments.join(''));
}
// Copyright 2018 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.Segmenter.prototype.segment
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
info: |
Intl.Segmenter.prototype.segment( string )
features: [Intl.Segmenter]
---*/
const seg = new Intl.Segmenter([], {granularity: "line"})
for (const text of [
"Hello world!", // English
" Hello world! ", // English with space before/after
" Hello world? Foo bar!", // English
"Jedovatou mambu objevila žena v zahrádkářské kolonii.", // Czech
"Việt Nam: Nhất thể hóa sẽ khác Trung Quốc?", // Vietnamese
"Σοβαρές ενστάσεις Κομισιόν για τον προϋπολογισμό της Ιταλίας", // Greek
"Решение Индии о покупке российских С-400 расценили как вызов США", // Russian
"הרופא שהציל נשים והנערה ששועבדה ע", // Hebrew,
"ترامب للملك سلمان: أنا جاد للغاية.. عليك دفع المزيد", // Arabic
"भारत की एस 400 मिसाइल के मुकाबले पाक की थाड, जानें कौन कितना ताकतवर", // Hindi
"ரெட் அலர்ட் எச்சரிக்கை; புதுச்சேரியில் நாளை அரசு விடுமுறை!", // Tamil
"'ఉత్తర్వులు అందే వరకు ఓటర్ల తుది జాబితాను వెబ్‌సైట్లో పెట్టవద్దు'", // Telugu
"台北》抹黑柯P失敗?朱學恒酸:姚文智氣pupu嗆大老闆", // Chinese
"วัดไทรตีระฆังเบาลงช่วงเข้าพรรษา เจ้าอาวาสเผยคนร้องเรียนรับผลกรรมแล้ว", // Thai
"九州北部の一部が暴風域に入りました(日直予報士 2018年10月06日) - 日本気象協会 tenki.jp", // Japanese
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
]) {
const iter = seg.segment(text);
let segments = [];
let oldPos = -1;
for (let result = iter.next(); !result.done; result = iter.next()) {
const v = result.value;
assert(["soft", "hard"].includes(iter.breakType), iter.breakType);
assert.sameValue("string", typeof v.segment);
assert(v.segment.length > 0);
segments.push(v.segment);
assert.sameValue(typeof v.index, "number");
assert(oldPos < v.index);
oldPos = v.index;
}
assert.sameValue(text, segments.join(''));
}
// Copyright 2018 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.Segmenter.prototype.segment
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
info: |
Intl.Segmenter.prototype.segment( string )
features: [Intl.Segmenter]
---*/
const seg = new Intl.Segmenter([], {granularity: "line"})
for (const text of [
"Hello world!", // English
" Hello world! ", // English with space before/after
" Hello world? Foo bar!", // English
"Jedovatou mambu objevila žena v zahrádkářské kolonii.", // Czech
"Việt Nam: Nhất thể hóa sẽ khác Trung Quốc?", // Vietnamese
"Σοβαρές ενστάσεις Κομισιόν για τον προϋπολογισμό της Ιταλίας", // Greek
"Решение Индии о покупке российских С-400 расценили как вызов США", // Russian
"הרופא שהציל נשים והנערה ששועבדה ע", // Hebrew,
"ترامب للملك سلمان: أنا جاد للغاية.. عليك دفع المزيد", // Arabic
"भारत की एस 400 मिसाइल के मुकाबले पाक की थाड, जानें कौन कितना ताकतवर", // Hindi
"ரெட் அலர்ட் எச்சரிக்கை; புதுச்சேரியில் நாளை அரசு விடுமுறை!", // Tamil
"'ఉత్తర్వులు అందే వరకు ఓటర్ల తుది జాబితాను వెబ్‌సైట్లో పెట్టవద్దు'", // Telugu
"台北》抹黑柯P失敗?朱學恒酸:姚文智氣pupu嗆大老闆", // Chinese
"วัดไทรตีระฆังเบาลงช่วงเข้าพรรษา เจ้าอาวาสเผยคนร้องเรียนรับผลกรรมแล้ว", // Thai
"九州北部の一部が暴風域に入りました(日直予報士 2018年10月06日) - 日本気象協会 tenki.jp", // Japanese
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
]) {
const iter = seg.segment(text);
let prev = text.length;
let segments = [];
iter.preceding(prev)
assert(["soft", "hard"].includes(iter.breakType), iter.breakType);
assert(iter.index >= 0);
assert(iter.index < prev);
segments.push(text.substring(iter.index, prev));
prev = iter.index;
while (!iter.preceding()) {
assert(["soft", "hard"].includes(iter.breakType), iter.breakType);
assert(iter.index >= 0);
assert(iter.index <= text.length);
assert(iter.index < prev);
segments.push(text.substring(iter.index, prev));
prev = iter.index;
}
assert.sameValue(text, segments.reverse().join(""));
}
// Copyright 2018 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.Segmenter.prototype.segment
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
info: |
Intl.Segmenter.prototype.segment( string )
features: [Intl.Segmenter]
---*/
const seg = new Intl.Segmenter([], {granularity: "line"})
for (const text of [
"Hello world!", // English
" Hello world! ", // English with space before/after
" Hello world? Foo bar!", // English
"Jedovatou mambu objevila žena v zahrádkářské kolonii.", // Czech
"Việt Nam: Nhất thể hóa sẽ khác Trung Quốc?", // Vietnamese
"Σοβαρές ενστάσεις Κομισιόν για τον προϋπολογισμό της Ιταλίας", // Greek
"Решение Индии о покупке российских С-400 расценили как вызов США", // Russian
"הרופא שהציל נשים והנערה ששועבדה ע", // Hebrew,
"ترامب للملك سلمان: أنا جاد للغاية.. عليك دفع المزيد", // Arabic
"भारत की एस 400 मिसाइल के मुकाबले पाक की थाड, जानें कौन कितना ताकतवर", // Hindi
"ரெட் அலர்ட் எச்சரிக்கை; புதுச்சேரியில் நாளை அரசு விடுமுறை!", // Tamil
"'ఉత్తర్వులు అందే వరకు ఓటర్ల తుది జాబితాను వెబ్‌సైట్లో పెట్టవద్దు'", // Telugu
"台北》抹黑柯P失敗?朱學恒酸:姚文智氣pupu嗆大老闆", // Chinese
"วัดไทรตีระฆังเบาลงช่วงเข้าพรรษา เจ้าอาวาสเผยคนร้องเรียนรับผลกรรมแล้ว", // Thai
"九州北部の一部が暴風域に入りました(日直予報士 2018年10月06日) - 日本気象協会 tenki.jp", // Japanese
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
]) {
const iter = seg.segment(text);
assert.sameValue(undefined, iter.breakType);
assert.sameValue(0, iter.index);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment