summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/intl402/Segmenter/prototype/segment/containing')
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/branding.js28
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/breakable-input.js56
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/index-throws.js48
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/iswordlike.js59
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/length.js25
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/name.js24
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/one-index.js70
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/out-of-bound-index.js56
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/prop-desc.js24
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/shell.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/unbreakable-input.js60
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/word-iswordlike.js58
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/zero-index.js72
14 files changed, 580 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/branding.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/branding.js
new file mode 100644
index 0000000000..d3b323ead2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/branding.js
@@ -0,0 +1,28 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2020 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%segmentsprototype%.containing
+description: Verifies the branding check for the "segment" function of the %Segments.prototype%.containing.
+info: |
+ %Segments.prototype%.containing ( index )
+ 1. Let segments be the this value.
+ 2. Perform ? RequireInternalSlot(segments, [[SegmentsSegmenter]]).
+
+features: [Intl.Segmenter]
+---*/
+const segment = (new Intl.Segmenter()).segment("123");
+const containing = segment.containing;
+assert.sameValue(typeof containing, "function");
+assert.throws(TypeError, () => containing.call(undefined), "undefined");
+assert.throws(TypeError, () => containing.call(null), "null");
+assert.throws(TypeError, () => containing.call(true), "true");
+assert.throws(TypeError, () => containing.call(""), "empty string");
+assert.throws(TypeError, () => containing.call(Symbol()), "symbol");
+assert.throws(TypeError, () => containing.call(1), "1");
+assert.throws(TypeError, () => containing.call({}), "plain object");
+assert.throws(TypeError, () => containing.call(Intl.Segmenter), "Intl.Segmenter");
+assert.throws(TypeError, () => containing.call(Intl.Segmenter.prototype), "Intl.Segmenter.prototype");
+assert.sameValue(undefined, containing.call(segment, -1));
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/breakable-input.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/breakable-input.js
new file mode 100644
index 0000000000..d1f50c5b9c
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/breakable-input.js
@@ -0,0 +1,56 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2020 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%segmentsprototype%.containing
+description: Verifies the cases which the input is breakable.
+info: |
+ %Segments.prototype%.containing ( index )
+
+ 8. Let startIndex be ! FindBoundary(segmenter, string, n, before).
+ 9. Let endIndex be ! FindBoundary(segmenter, string, n, after).
+
+features: [Intl.Segmenter]
+---*/
+
+// The inputs are breakable for "grapheme" and "word" but not for "sentence"
+const granularities = [undefined, "grapheme", "word"];
+// The following all contains more than one segments in either "grapheme" or "word"
+// granularity.
+const inputs = [
+ "123 ",
+ "a ",
+ " a",
+ " \ud800\udc00", // SPACE + surrogate
+ "\ud800\udc00 ", // surrogate + SPACE
+ "\udc00\ud800", // incorrect surrogate- tail + leading
+ "\ud800 ", // only leading surrogate + SPACE
+ "\udc00 ", // only trailing surrogate + SPACE
+ " \ud800", // SPACE + only leading surrogate
+ " \udc00", // SPACE + only trailing surrogate
+ " 台", // SPACE + a Han character
+ "台 ", // a Han character + SPACE
+ "\u0301 ", // a modifier + SPACE
+];
+
+granularities.forEach(
+ function(granularity) {
+ const segmenter = new Intl.Segmenter(undefined, {granularity});
+ inputs.forEach(function(input) {
+ const segment = segmenter.segment(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(false, first.segment == input,
+ `${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`);
+ });
+ });
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/browser.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/browser.js
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/index-throws.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/index-throws.js
new file mode 100644
index 0000000000..2948b6a242
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/index-throws.js
@@ -0,0 +1,48 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2020 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%segmentsprototype%.containing
+description: Verifies the cases which the value of index which throws.
+info: |
+ %Segments.prototype%.containing ( index )
+
+ 6. Let n be ? ToInteger(index).
+ 7. If n < 0 or n ≥ len, return undefined.
+ 8. Let startIndex be ! FindBoundary(segmenter, string, n, before).
+
+ ToInteger ( argument )
+ 1. Let number be ? ToNumber(argument).
+
+ ToNumber ( argument )
+ Symbol | Throw a TypeError exception.
+ BigInt | Throw a TypeError exception.
+
+features: [Intl.Segmenter]
+---*/
+
+const input = "a b c";
+const granularities = [undefined, "grapheme", "word", "sentence"];
+const index_throws = [
+ // Symbol
+ Symbol(),
+ // BigInt
+ 0n,
+ -1n,
+ 1n,
+ BigInt(0),
+ BigInt(1),
+ BigInt(-1),
+ BigInt(input.length),
+];
+
+granularities.forEach(
+ function(granularity) {
+ const segmenter = new Intl.Segmenter(undefined, {granularity});
+ const segment = segmenter.segment(input);
+ index_throws.forEach(function(index) {
+ assert.throws(TypeError, () => {segment.containing(index);})
+ });
+ });
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/iswordlike.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/iswordlike.js
new file mode 100644
index 0000000000..599e95aa27
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/iswordlike.js
@@ -0,0 +1,59 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2020 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%segmentsprototype%.containing
+description: Verifies the isWordLike in the result when granularity is not "word".
+info: |
+ %Segments.prototype%.containing ( index )
+
+ 10. Return ! CreateSegmentDataObject(segmenter, string, startIndex, endIndex).
+
+ CreateSegmentDataObject ( segmenter, string, startIndex, endIndex )
+ 11. If granularity is "word", then
+ 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).
+
+includes: [compareArray.js]
+features: [Intl.Segmenter]
+---*/
+
+const other_granularities = [undefined, "grapheme", "sentence"];
+// Some text
+const inputs = [
+ "Hello world!", // 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
+];
+
+other_granularities.forEach(
+ function(granularity) {
+ const segmenter = new Intl.Segmenter(undefined, {granularity});
+ inputs.forEach(function(input) {
+ 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`);
+ assert.sameValue("string", typeof result.input, `${msg} input`);
+ assert.sameValue(undefined, result.isWordLike,
+ `${msg} isWordLike should be undefined`);
+ assert.compareArray(Object.getOwnPropertyNames(result), ["segment", "index", "input"]);
+ }
+ });
+ });
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/length.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/length.js
new file mode 100644
index 0000000000..e42cf8f308
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/length.js
@@ -0,0 +1,25 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2018 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%segmentsprototype%.containing
+description: Checks the "length" property of %Segments.prototype%.containing()
+info: |
+ 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 2019 Language Specification, 10th edition, clause 17, or successor.
+ The Segmenter constructor is a standard built-in property of the Intl object.
+ Every built-in function object, including constructors, has a length property whose value is an integer. Unless otherwise specified, this value is equal to the largest number of named arguments shown in the subclause headings for the function description. Optional parameters (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form «...name») are not included in the default argument count.
+ Unless otherwise specified, the length property of a built-in function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+features: [Intl.Segmenter]
+---*/
+
+const segment = (new Intl.Segmenter()).segment("");
+verifyProperty(segment.containing, "length", {
+ value: 1,
+ writable: false,
+ enumerable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/name.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/name.js
new file mode 100644
index 0000000000..e5d4bb9403
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/name.js
@@ -0,0 +1,24 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2020 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%segmentsprototype%.containing
+description: Checks the "name" property of %Segments.prototype%.containing ( index )
+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 }.
+
+includes: [propertyHelper.js]
+features: [Intl.Segmenter]
+---*/
+const segment = (new Intl.Segmenter()).segment("");
+verifyProperty(segment.containing, "name", {
+ value: "containing",
+ writable: false,
+ enumerable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/one-index.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/one-index.js
new file mode 100644
index 0000000000..b23683ef99
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/one-index.js
@@ -0,0 +1,70 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2020 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%segmentsprototype%.containing
+description: Verifies the cases which the value of index turn into 1.
+info: |
+ %Segments.prototype%.containing ( index )
+
+ 6. Let n be ? ToInteger(index).
+ 7. If n < 0 or n ≥ len, return undefined.
+ 8. Let startIndex be ! FindBoundary(segmenter, string, n, before).
+
+ ToInteger ( argument )
+ 1. Let number be ? ToNumber(argument).
+ 2. If number is NaN, +0, or -0, return +0.
+ 4. Let integer be the Number value that is the same sign as number and whose magnitude is floor(abs(number)).
+ 5. If integer is -0, return +0.
+ 6. Return integer.
+
+ ToNumber ( argument )
+ Undefined | Return NaN.
+ Null | Return +0.
+ Boolean | If argument is true, return 1. If argument is false, return +0.
+
+features: [Intl.Segmenter]
+---*/
+
+const input = "a c";
+const granularities = [undefined, "grapheme", "word"];
+const index_to_one = [
+ 1,
+ 1.49,
+ 14.9E-1,
+ 14.9e-1,
+ "1.49",
+ "14.9E-1",
+ "14.9e-1",
+ true,
+ { toString(){ return "1"; } },
+ { valueOf(){ return 1; } },
+ { [Symbol.toPrimitive](){ return 1; } },
+];
+
+// Except granularity: "sentence", check the result.segment is " ".
+granularities.forEach(
+ function(granularity) {
+ const segmenter = new Intl.Segmenter(undefined, {granularity});
+ const segment = segmenter.segment(input);
+ index_to_one.forEach(function(index) {
+ const result = segment.containing(index);
+ const msg = "granularity: " + granularity + " index: " + index;
+ assert.sameValue(1, result.index, msg + " index");
+ assert.sameValue(" ", result.segment, msg + " segment");
+ assert.sameValue(input, result.input, msg + " input");
+ });
+ });
+
+// For granularity: "sentence", result.segment is input
+const segmenter = new Intl.Segmenter(undefined, {granularity: "sentence"});
+const segment = segmenter.segment(input);
+index_to_one.forEach(function(index) {
+ const result = segment.containing(index);
+ const msg = "granularity: sentence index: " + index;
+ assert.sameValue(0, result.index, msg + " index");
+ assert.sameValue(input, result.segment, msg + " segment");
+ assert.sameValue(input, result.input, msg + " input");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/out-of-bound-index.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/out-of-bound-index.js
new file mode 100644
index 0000000000..196de36d7f
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/out-of-bound-index.js
@@ -0,0 +1,56 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2020 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%segmentsprototype%.containing
+description: Verifies the cases which the value of index turn into out of bound.
+info: |
+ %Segments.prototype%.containing ( index )
+
+ 6. Let n be ? ToInteger(index).
+ 7. If n < 0 or n ≥ len, return undefined.
+ 8. Let startIndex be ! FindBoundary(segmenter, string, n, before).
+
+ ToInteger ( argument )
+ 1. Let number be ? ToNumber(argument).
+ 2. If number is NaN, +0, or -0, return +0.
+ 4. Let integer be the Number value that is the same sign as number and whose magnitude is floor(abs(number)).
+ 5. If integer is -0, return +0.
+ 6. Return integer.
+
+ ToNumber ( argument )
+ String | See grammar and conversion algorithm below.
+
+features: [Intl.Segmenter]
+---*/
+
+const input = "a b c";
+const granularities = [undefined, "grapheme", "word", "sentence"];
+const index_to_out_of_bound = [
+ input.length,
+ input.length + 0.1,
+ -1,
+ -2,
+ "-1",
+ "-2",
+ "-1.1",
+ Infinity,
+ -Infinity,
+ "Infinity",
+ "-Infinity",
+ { toString(){ return "-1"; } },
+ { valueOf(){ return input.length; } },
+ { [Symbol.toPrimitive](){ return -1; } },
+];
+
+granularities.forEach(
+ function(granularity) {
+ const segmenter = new Intl.Segmenter(undefined, {granularity});
+ const segment = segmenter.segment(input);
+ index_to_out_of_bound.forEach(function(index) {
+ const result = segment.containing(index);
+ assert.sameValue(undefined, result);
+ });
+ });
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/prop-desc.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/prop-desc.js
new file mode 100644
index 0000000000..dd39c1862b
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/prop-desc.js
@@ -0,0 +1,24 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2018 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%segmentsprototype%.containing
+description: Checks the "containing" property of the %Segments.prototype% object.
+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 2019 Language Specification, 10th edition, clause 17, or successor.
+
+features: [Intl.Segmenter]
+---*/
+
+const segment = (new Intl.Segmenter()).segment("");
+assert.sameValue(
+ typeof segment.containing,
+ "function",
+ "typeof %Segments.prototype%.containing is function"
+);
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/shell.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/shell.js
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/unbreakable-input.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/unbreakable-input.js
new file mode 100644
index 0000000000..bcc43b81f7
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/unbreakable-input.js
@@ -0,0 +1,60 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2020 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%segmentsprototype%.containing
+description: Verifies the cases which the input is unbreakable.
+info: |
+ %Segments.prototype%.containing ( index )
+
+ 8. Let startIndex be ! FindBoundary(segmenter, string, n, before).
+ 9. Let endIndex be ! FindBoundary(segmenter, string, n, after).
+
+features: [Intl.Segmenter]
+---*/
+
+const granularities = [undefined, "grapheme", "word", "sentence"];
+// The following all contains only one segment in any granularity.
+const inputs = [
+ "a",
+ " ",
+ "\ud800\udc00", // surrogate
+ "\ud800", // only leading surrogate
+ "\udc00", // only trailing surrogate
+ "台", // a Han character
+ "\u0301", // a modifier
+ "a\u0301", // ASCII + a modifier
+ "ซิ่", // a Thai cluster
+ "𐂰", // a Surrogate pair
+ "\uD83D\uDC4B\uD83C\uDFFB", // Emoji short sequence: waving_hand_light_skin_tone
+ "\uD83D\uDC68\uD83C\uDFFB\u200D\uD83E\uDDB0", // Emoji long sequence: man_light_skin_tone_red_hair
+ "\u1102", // Jamo L
+ "\u1162", // Jamo V
+ "\u11A9", // Jamo T
+ "\u1102\u1162", // Jamo LV
+ "\u1102\u1162\u11A9", // Jamo LVT
+ "\u1102\u1102", // Jamo L L
+ "\u1102\u1102\u1162", // Jamo L L V
+ "\u1102\u1102\u1162\u11A9", // Jamo L L V T
+ "\u1162\u1162", // Jamo V V
+ "\u1162\u11A9", // Jamo V T
+ "\u1102\u1162\u1162", // Jamo V V
+ "\u11A9\u11A9", // Jamo T T
+ "\u1102\u1162\u11A9\u11A9", // Jamo LVT T
+];
+
+granularities.forEach(
+ function(granularity) {
+ const segmenter = new Intl.Segmenter(undefined, {granularity});
+ inputs.forEach(function(input) {
+ const segment = segmenter.segment(input);
+ for (let index = 0; index < input.length; index++) {
+ const result = segment.containing(index);
+ assert.sameValue(0, result.index);
+ assert.sameValue(input, result.input);
+ assert.sameValue(input, result.segment);
+ }
+ });
+ });
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/word-iswordlike.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/word-iswordlike.js
new file mode 100644
index 0000000000..3124a65619
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/word-iswordlike.js
@@ -0,0 +1,58 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2020 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%segmentsprototype%.containing
+description: Verifies the isWordLike in the result when granularity is "word".
+info: |
+ %Segments.prototype%.containing ( index )
+
+ 10. Return ! CreateSegmentDataObject(segmenter, string, startIndex, endIndex).
+
+ CreateSegmentDataObject ( segmenter, string, startIndex, endIndex )
+ 11. If granularity is "word", then
+ 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).
+
+includes: [compareArray.js]
+features: [Intl.Segmenter]
+---*/
+
+// Some text
+const inputs = [
+ "Hello world!", // 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 granularity = "word";
+const segmenter = new Intl.Segmenter(undefined, {granularity});
+inputs.forEach(function(input) {
+ 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");
+ assert.sameValue("boolean", typeof result.isWordLike,
+ msg + "isWordLike should be boolean");
+ assert.compareArray(Object.getOwnPropertyNames(result),
+ ["segment", "index", "input", "isWordLike"]);
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/zero-index.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/zero-index.js
new file mode 100644
index 0000000000..0e768bd224
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/containing/zero-index.js
@@ -0,0 +1,72 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2020 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%segmentsprototype%.containing
+description: Verifies the cases which the value of index turn into 0.
+info: |
+ %Segments.prototype%.containing ( index )
+
+ 6. Let n be ? ToInteger(index).
+ 7. If n < 0 or n ≥ len, return undefined.
+ 8. Let startIndex be ! FindBoundary(segmenter, string, n, before).
+
+ ToInteger ( argument )
+ 1. Let number be ? ToNumber(argument).
+ 2. If number is NaN, +0, or -0, return +0.
+ 4. Let integer be the Number value that is the same sign as number and whose magnitude is floor(abs(number)).
+ 5. If integer is -0, return +0.
+ 6. Return integer.
+
+ ToNumber ( argument )
+ Undefined | Return NaN.
+ Null | Return +0.
+ Boolean | If argument is true, return 1. If argument is false, return +0.
+
+features: [Intl.Segmenter]
+---*/
+
+const input = "a b c";
+const granularities = [undefined, "grapheme", "word", "sentence"];
+const index_to_zeros = [
+ 0,
+ -0,
+ NaN,
+ 0.49,
+ -0.49,
+ null,
+ undefined,
+ false,
+ "\ud800\udc00", // surrogate
+ "\ud800", // only leading surrogate
+ "\udc00", // only trailing surrogate
+ "a",
+ "g",
+ "\u00DD",
+ "0",
+ "+0",
+ "-0",
+ "0.49",
+ "+0.49",
+ "-0.49",
+ "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(
+ function(granularity) {
+ const segmenter = new Intl.Segmenter(undefined, {granularity});
+ const segment = segmenter.segment(input);
+ index_to_zeros.forEach(function(index) {
+ const result = segment.containing(index);
+ assert.sameValue(0, result.index);
+ assert.sameValue(input, result.input);
+ });
+ });
+
+reportCompare(0, 0);