From 0f5a274aad28e529ef4442681d50640e9090ea25 Mon Sep 17 00:00:00 2001 From: Frank Yung-Fong Tang <41213225+FrankYFTang@users.noreply.github.com> Date: Wed, 29 Jul 2020 12:00:35 -0700 Subject: [PATCH] Fix Segmenter tests: Check "input" in segment-*-iterable.js (#2714) * Check "input" in segment-*-iterable.js Remove dup test in segment-*.js * Fix segment-tostring.js --- .../segment/segment-grapheme-iterable.js | 2 ++ .../prototype/segment/segment-grapheme.js | 34 ------------------- .../segment/segment-sentence-iterable.js | 2 ++ .../prototype/segment/segment-sentence.js | 34 ------------------- .../prototype/segment/segment-tostring.js | 3 +- .../segment/segment-word-iterable.js | 2 ++ .../prototype/segment/segment-word.js | 34 ------------------- 7 files changed, 8 insertions(+), 103 deletions(-) delete mode 100644 test/intl402/Segmenter/prototype/segment/segment-grapheme.js delete mode 100644 test/intl402/Segmenter/prototype/segment/segment-sentence.js delete mode 100644 test/intl402/Segmenter/prototype/segment/segment-word.js diff --git a/test/intl402/Segmenter/prototype/segment/segment-grapheme-iterable.js b/test/intl402/Segmenter/prototype/segment/segment-grapheme-iterable.js index 694776ba0f..e40abaa377 100644 --- a/test/intl402/Segmenter/prototype/segment/segment-grapheme-iterable.js +++ b/test/intl402/Segmenter/prototype/segment/segment-grapheme-iterable.js @@ -35,6 +35,8 @@ for (const text of [ assert.sameValue(false, v.hasOwnProperty("isWordLike")); assert.sameValue("string", typeof v.segment); assert(v.segment.length > 0); + assert.sameValue("string", typeof v.input); + assert.sameValue(text, v.input); segments.push(v.segment); } assert.sameValue(text, segments.join('')); diff --git a/test/intl402/Segmenter/prototype/segment/segment-grapheme.js b/test/intl402/Segmenter/prototype/segment/segment-grapheme.js deleted file mode 100644 index fe19edc9c1..0000000000 --- a/test/intl402/Segmenter/prototype/segment/segment-grapheme.js +++ /dev/null @@ -1,34 +0,0 @@ -// 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: "grapheme"}) -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); -} diff --git a/test/intl402/Segmenter/prototype/segment/segment-sentence-iterable.js b/test/intl402/Segmenter/prototype/segment/segment-sentence-iterable.js index ff847f99d1..60b58ed105 100644 --- a/test/intl402/Segmenter/prototype/segment/segment-sentence-iterable.js +++ b/test/intl402/Segmenter/prototype/segment/segment-sentence-iterable.js @@ -35,6 +35,8 @@ for (const text of [ assert.sameValue(false, v.hasOwnProperty("isWordLike")); assert.sameValue("string", typeof v.segment); assert(v.segment.length > 0); + assert.sameValue("string", typeof v.input); + assert.sameValue(text, v.input); segments.push(v.segment); } assert.sameValue(text, segments.join('')); diff --git a/test/intl402/Segmenter/prototype/segment/segment-sentence.js b/test/intl402/Segmenter/prototype/segment/segment-sentence.js deleted file mode 100644 index 765e6a8192..0000000000 --- a/test/intl402/Segmenter/prototype/segment/segment-sentence.js +++ /dev/null @@ -1,34 +0,0 @@ -// 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: "sentence"}) -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); -} diff --git a/test/intl402/Segmenter/prototype/segment/segment-tostring.js b/test/intl402/Segmenter/prototype/segment/segment-tostring.js index 3d1ad27cdc..8ec2dfb9a7 100644 --- a/test/intl402/Segmenter/prototype/segment/segment-tostring.js +++ b/test/intl402/Segmenter/prototype/segment/segment-tostring.js @@ -26,7 +26,8 @@ const tests = [ const segmenter = new Intl.Segmenter("en", { "granularity": "word" }); for (const [args, expected] of tests) { const segments = segmenter.segment(...args); - assert.sameValue(segments.string, expected, `Expected segment "${expected}", found "${segments.segment}" for arguments ${args}`); + const actual = [...segments][0].segment; + assert.sameValue(actual, expected, `Expected segment "${expected}", found "${actual}" for arguments ${args}`); } const symbol = Symbol(); diff --git a/test/intl402/Segmenter/prototype/segment/segment-word-iterable.js b/test/intl402/Segmenter/prototype/segment/segment-word-iterable.js index 0c84ac4b55..dde3f61483 100644 --- a/test/intl402/Segmenter/prototype/segment/segment-word-iterable.js +++ b/test/intl402/Segmenter/prototype/segment/segment-word-iterable.js @@ -35,6 +35,8 @@ for (const text of [ assert.sameValue(true, v.hasOwnProperty("isWordLike")); assert.sameValue("string", typeof v.segment); assert(v.segment.length > 0); + assert.sameValue("string", typeof v.input); + assert.sameValue(text, v.input); segments.push(v.segment); } assert.sameValue(text, segments.join('')); diff --git a/test/intl402/Segmenter/prototype/segment/segment-word.js b/test/intl402/Segmenter/prototype/segment/segment-word.js deleted file mode 100644 index 29f546dcb4..0000000000 --- a/test/intl402/Segmenter/prototype/segment/segment-word.js +++ /dev/null @@ -1,34 +0,0 @@ -// 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: "word"}) -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); -}