summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Segmenter
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/intl402/Segmenter
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/intl402/Segmenter')
-rw-r--r--js/src/tests/test262/intl402/Segmenter/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/locales-invalid.js20
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/locales-valid.js53
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/newtarget-undefined.js29
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-getoptionsobject.js28
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-granularity-abrupt-throws.js28
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-granularity-invalid.js42
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-granularity-toString-abrupt-throws.js59
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-granularity-valid.js32
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-invalid.js20
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-localeMatcher-abrupt-throws.js34
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-localeMatcher-invalid.js33
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-localeMatcher-toString-abrupt-throws.js68
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-localeMatcher-valid.js41
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-null.js26
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-order.js56
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-throwing-getters.js28
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-undefined.js52
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-valid-combinations.js39
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/proto-from-ctor-realm.js61
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/shell.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/constructor/subclassing.js56
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/length.js25
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/name.js23
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/prop-desc.js35
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/prototype.js20
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/shell.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/basic.js22
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/branding.js35
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/length.js25
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-empty.js22
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-invalid.js23
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-specific.js25
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/name.js24
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-localeMatcher-invalid.js37
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-null.js23
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-toobject.js44
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-undefined.js29
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/prop-desc.js32
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/result-type.js36
-rw-r--r--js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/shell.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/ctor-custom-get-prototype-poison-throws.js37
-rw-r--r--js/src/tests/test262/intl402/Segmenter/ctor-custom-prototype.js34
-rw-r--r--js/src/tests/test262/intl402/Segmenter/ctor-default-prototype.js20
-rw-r--r--js/src/tests/test262/intl402/Segmenter/instance/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/instance/extensibility.js22
-rw-r--r--js/src/tests/test262/intl402/Segmenter/instance/prototype.js22
-rw-r--r--js/src/tests/test262/intl402/Segmenter/instance/shell.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/proto-from-ctor-realm.js56
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/Symbol.toStringTag.js23
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/constructor/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/constructor/prop-desc.js27
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/constructor/shell.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/prop-desc.js24
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/branding.js29
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/caching.js20
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/length.js24
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/name.js23
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/order.js30
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/prop-desc.js30
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/shell.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/type-without-lbs.js39
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/branding.js29
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/browser.js0
-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
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/length.js24
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/name.js23
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/nested-next.js39
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/next-inside-next.js50
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/next-mix-with-containing.js55
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/prop-desc.js31
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/segment-grapheme-iterable.js57
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/segment-sentence-iterable.js57
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/segment-tostring.js37
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/segment-word-iterable.js57
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/segment/shell.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/shell.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/toStringTag/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/toStringTag/shell.js0
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/toStringTag/toString.js19
-rw-r--r--js/src/tests/test262/intl402/Segmenter/prototype/toStringTag/toStringTag.js26
-rw-r--r--js/src/tests/test262/intl402/Segmenter/shell.js0
100 files changed, 2829 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Segmenter/browser.js b/js/src/tests/test262/intl402/Segmenter/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/browser.js
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/browser.js b/js/src/tests/test262/intl402/Segmenter/constructor/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/browser.js
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/browser.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/browser.js
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/locales-invalid.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/locales-invalid.js
new file mode 100644
index 0000000000..cb4b709c05
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/locales-invalid.js
@@ -0,0 +1,20 @@
+// |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-Intl.Segmenter
+description: Checks error cases for the locales argument to the Segmenter constructor.
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+
+ 3. Let _requestedLocales_ be ? CanonicalizeLocaleList(_locales_).
+includes: [testIntl.js]
+features: [Intl.Segmenter]
+---*/
+
+for (const [locales, expectedError] of getInvalidLocaleArguments()) {
+ assert.throws(expectedError, function() { new Intl.Segmenter(locales) })
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/locales-valid.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/locales-valid.js
new file mode 100644
index 0000000000..3aa9976448
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/locales-valid.js
@@ -0,0 +1,53 @@
+// |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-Intl.Segmenter
+description: Checks various cases for the locales argument to the Segmenter constructor.
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+
+ 3. Let _requestedLocales_ be ? CanonicalizeLocaleList(_locales_).
+features: [Intl.Segmenter, Array.prototype.includes]
+---*/
+
+const defaultLocale = new Intl.Segmenter().resolvedOptions().locale;
+
+const tests = [
+ [undefined, [defaultLocale], "undefined"],
+ ["EN", ["en"], "Single value"],
+ [[], [defaultLocale], "Empty array"],
+ [["sr"], ["sr"], "Single-element array"],
+ [["fr", "ar"], ["fr", "ar"], "Two-element array"],
+ [["xyz", "ar"], ["ar"], "Two-element array with unknown code"],
+ [["en", "EN"], ["en"], "Duplicate value (canonical first)"],
+ [["EN", "en"], ["en"], "Duplicate value (canonical last)"],
+ [{ 0: "DE", length: 0 }, [defaultLocale], "Object with zero length"],
+ [{ 0: "DE", length: 1 }, ["de"], "Object with length"],
+ [{ 0: "ja", 1: "fr" }, [defaultLocale], "Object without length, indexed from 0"],
+ [{ 1: "ja", 2: "fr" }, [defaultLocale], "Object without length, indexed from 1"],
+];
+
+const errorTests = [
+ [["en-GB-oed"], "Grandfathered"],
+ [["x-private"], "Private", ["lookup"]],
+];
+
+for (const [locales, expected, name, matchers = ["best fit", "lookup"]] of tests) {
+ for (const localeMatcher of matchers) {
+ const segmenter = new Intl.Segmenter(locales, { localeMatcher });
+ const actual = segmenter.resolvedOptions().locale;
+ assert(expected.includes(actual), `${name}: expected one of ${expected}, found ${actual}`);
+ }
+}
+
+for (const [locales, name, matchers = ["best fit", "lookup"]] of errorTests) {
+ for (const localeMatcher of matchers) {
+ assert.throws(RangeError, function() {
+ new Intl.Segmenter(locales, { localeMatcher });
+ }, name);
+ }
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/newtarget-undefined.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/newtarget-undefined.js
new file mode 100644
index 0000000000..37d4d35d2b
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/newtarget-undefined.js
@@ -0,0 +1,29 @@
+// |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-Intl.Segmenter
+description: Verifies the NewTarget check for Intl.Segmenter.
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+
+ 1. If NewTarget is undefined, throw a TypeError exception.
+features: [Intl.Segmenter]
+---*/
+
+assert.sameValue(typeof Intl.Segmenter, "function");
+
+assert.throws(TypeError, function() {
+ Intl.Segmenter();
+});
+
+assert.throws(TypeError, function() {
+ Intl.Segmenter("en");
+});
+
+assert.throws(TypeError, function() {
+ Intl.Segmenter("not-valid-tag");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-getoptionsobject.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-getoptionsobject.js
new file mode 100644
index 0000000000..c8a1851ae3
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-getoptionsobject.js
@@ -0,0 +1,28 @@
+// |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-Intl.Segmenter
+description: Checks handling of non-object option arguments to the Segmenter constructor.
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+
+features: [Intl.Segmenter,BigInt]
+---*/
+
+const optionsArguments = [
+ null,
+ true,
+ false,
+ "test",
+ 7,
+ Symbol(),
+ 123456789n,
+];
+
+for (const options of optionsArguments) {
+ assert.throws(TypeError, function() { new Intl.Segment([], options) })
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-granularity-abrupt-throws.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-granularity-abrupt-throws.js
new file mode 100644
index 0000000000..ed64988cfd
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-granularity-abrupt-throws.js
@@ -0,0 +1,28 @@
+// |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-intl.segmenter
+description: Return abrupt completion from GetOption granularity
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+
+ 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).
+features: [Intl.Segmenter]
+---*/
+
+
+var options = {};
+Object.defineProperty(options, 'granularity', {
+ get() { throw new Test262Error(); },
+});
+
+assert.throws(Test262Error, () => {
+ new Intl.Segmenter(undefined, options);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-granularity-invalid.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-granularity-invalid.js
new file mode 100644
index 0000000000..37f0fa262d
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-granularity-invalid.js
@@ -0,0 +1,42 @@
+// |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-Intl.Segmenter
+description: Checks handling of invalid value for the style option to the Segmenter constructor.
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+
+ 13. Let granularity be ? GetOption(options, "granularity", "string", « "grapheme", "word", "sentence" », "grapheme").
+ 14. Set segmenter.[[SegmenterGranularity]] to granularity.
+features: [Intl.Segmenter]
+---*/
+
+const invalidOptions = [
+ null,
+ 1,
+ "",
+ "standard",
+ "Grapheme",
+ "GRAPHEME",
+ "grapheme\0",
+ "Word",
+ "WORD",
+ "word\0",
+ "Sentence",
+ "SENTENCE",
+ "sentence\0",
+ "line",
+ "Line",
+ "LINE",
+ "line\0",
+];
+
+for (const granularity of invalidOptions) {
+ assert.throws(RangeError, function() {
+ new Intl.Segmenter([], { granularity });
+ }, `${granularity} is an invalid style option value`);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-granularity-toString-abrupt-throws.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-granularity-toString-abrupt-throws.js
new file mode 100644
index 0000000000..547dd69381
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-granularity-toString-abrupt-throws.js
@@ -0,0 +1,59 @@
+// |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-intl.segmenter
+description: Return abrupt completion from GetOption granularity
+
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+
+ 13. Let granularity be ? GetOption(options, "granularity", "string", « "grapheme", "word", "sentence" », "grapheme").
+
+ GetOption ( options, property, type, values, fallback )
+ 6. If type is "string", then
+ a. Let value be ? ToString(value).
+features: [Intl.Segmenter, Symbol]
+---*/
+
+const options = {
+ granularity: {
+ toString() {
+ throw new Test262Error();
+ }
+ }
+};
+
+assert.throws(Test262Error, () => {
+ new Intl.Segmenter(undefined, options);
+}, 'from toString');
+
+options.granularity = {
+ toString: undefined,
+ valueOf() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, () => {
+ new Intl.Segmenter(undefined, options);
+}, 'from valueOf');
+
+options.granularity = {
+ [Symbol.toPrimitive]() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, () => {
+ new Intl.Segmenter(undefined, options);
+}, 'from ToPrimitive');
+
+options.granularity = Symbol();
+
+assert.throws(TypeError, () => {
+ new Intl.Segmenter(undefined, options);
+}, 'symbol value');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-granularity-valid.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-granularity-valid.js
new file mode 100644
index 0000000000..f96b1cf45a
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-granularity-valid.js
@@ -0,0 +1,32 @@
+// |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-Intl.Segmenter
+description: Checks handling of valid values for the granularity option to the Segmenter constructor.
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+
+ 11. Let granularity be ? GetOption(options, "granularity", "string", « "grapheme", "word", "sentence" », "grapheme").
+ 12. Set segmenter.[[SegmenterGranularity]] to granularity.
+features: [Intl.Segmenter]
+---*/
+
+const validOptions = [
+ [undefined, "grapheme"],
+ ["grapheme", "grapheme"],
+ ["word", "word"],
+ ["sentence", "sentence"],
+ [{ toString() { return "word"; } }, "word"],
+];
+
+for (const [granularity, expected] of validOptions) {
+ const segmenter = new Intl.Segmenter([], { granularity });
+ const resolvedOptions = segmenter.resolvedOptions();
+ assert.sameValue(resolvedOptions.granularity, expected);
+}
+
+assert.throws(RangeError, () => new Intl.Segmenter([], {granularity: "line"}));
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-invalid.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-invalid.js
new file mode 100644
index 0000000000..107efa8c9b
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-invalid.js
@@ -0,0 +1,20 @@
+// |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-Intl.Segmenter
+description: Checks handling of a null options argument to the Segmenter constructor.
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+
+ 5. Else
+ a. Let options be ? ToObject(options).
+features: [Intl.Segmenter]
+---*/
+
+assert.sameValue(typeof Intl.Segmenter, "function");
+
+assert.throws(TypeError, function() { new Intl.Segmenter([], null) })
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-localeMatcher-abrupt-throws.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-localeMatcher-abrupt-throws.js
new file mode 100644
index 0000000000..16548dcc13
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-localeMatcher-abrupt-throws.js
@@ -0,0 +1,34 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-intl.segmenter
+description: >
+ Return abrupt completion from GetOption localeMatcher
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+ 1. If NewTarget is undefined, throw a TypeError exception.
+ ...
+ 4. If options is undefined, then
+ a. Let options be ObjectCreate(null).
+ 5. Else
+ a. Let options be ? ToObject(options).
+ ...
+ 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).
+ ...
+features: [Intl.Segmenter]
+---*/
+
+var options = {};
+Object.defineProperty(options, 'localeMatcher', {
+ get() { throw new Test262Error(); },
+});
+
+assert.throws(Test262Error, () => {
+ new Intl.Segmenter(undefined, options);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-localeMatcher-invalid.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-localeMatcher-invalid.js
new file mode 100644
index 0000000000..53fe25e8a5
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-localeMatcher-invalid.js
@@ -0,0 +1,33 @@
+// |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-Intl.Segmenter
+description: Checks handling of invalid value for the localeMatcher option to the Segmenter constructor.
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+
+ 7. Let matcher be ? GetOption(options, "localeMatcher", "string", «"lookup", "best fit"», "best fit").
+features: [Intl.Segmenter]
+---*/
+
+const invalidOptions = [
+ null,
+ 1,
+ "",
+ "Lookup",
+ "LOOKUP",
+ "lookup\0",
+ "Best fit",
+ "BEST FIT",
+ "best\u00a0fit",
+];
+
+for (const localeMatcher of invalidOptions) {
+ assert.throws(RangeError, function() {
+ new Intl.Segmenter([], { localeMatcher });
+ }, `${localeMatcher} is an invalid localeMatcher option value`);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-localeMatcher-toString-abrupt-throws.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-localeMatcher-toString-abrupt-throws.js
new file mode 100644
index 0000000000..991af934db
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-localeMatcher-toString-abrupt-throws.js
@@ -0,0 +1,68 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-intl.segmenter
+description: >
+ Return abrupt completion from GetOption localeMatcher
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+
+ 1. If NewTarget is undefined, throw a TypeError exception.
+ 3. Let segmenter be ? OrdinaryCreateFromConstructor(NewTarget, "%Segmenter.prototype%", internalSlotsList).
+ ...
+ 4. If options is undefined, then
+ a. Let options be ObjectCreate(null).
+ 5. Else
+ a. Let options be ? ToObject(options).
+ ...
+ 8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
+
+ GetOption ( options, property, type, values, fallback )
+ 6. If type is "string", then
+ a. Let value be ? ToString(value).
+ ...
+features: [Intl.Segmenter, Symbol]
+---*/
+
+const options = {
+ localeMatcher: {
+ toString() {
+ throw new Test262Error();
+ }
+ }
+};
+
+assert.throws(Test262Error, () => {
+ new Intl.Segmenter(undefined, options);
+}, 'from toString');
+
+options.localeMatcher = {
+ toString: undefined,
+ valueOf() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, () => {
+ new Intl.Segmenter(undefined, options);
+}, 'from valueOf');
+
+options.localeMatcher = {
+ [Symbol.toPrimitive]() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, () => {
+ new Intl.Segmenter(undefined, options);
+}, 'from ToPrimitive');
+
+options.localeMatcher = Symbol();
+
+assert.throws(TypeError, () => {
+ new Intl.Segmenter(undefined, options);
+}, 'symbol value');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-localeMatcher-valid.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-localeMatcher-valid.js
new file mode 100644
index 0000000000..e572cf14b7
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-localeMatcher-valid.js
@@ -0,0 +1,41 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-intl.segmenter
+description: >
+ Valid options for localeMatcher
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+
+ 1. If NewTarget is undefined, throw a TypeError exception.
+ 3. Let segmenter be ? OrdinaryCreateFromConstructor(NewTarget, "%Segmenter.prototype%", internalSlotsList).
+ ...
+ 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).
+ ...
+features: [Intl.Segmenter]
+locale: [en]
+---*/
+
+// results for option values verified in the tests for resolvedOptions
+
+const localeMatchers = [
+ undefined,
+ 'lookup',
+ 'best fit'
+];
+
+localeMatchers.forEach(localeMatcher => {
+ 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}`);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-null.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-null.js
new file mode 100644
index 0000000000..f3f9d56c31
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-null.js
@@ -0,0 +1,26 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-intl.Segmenter
+description: >
+ Throws TypeError if options is null
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+ 1. If NewTarget is undefined, throw a TypeError exception.
+ 3. Let segmenter be ? OrdinaryCreateFromConstructor(NewTarget, "%Segmenter.prototype%", internalSlotsList).
+ ...
+ 4. If options is undefined, then
+ a. Let options be ObjectCreate(null).
+ 5. Else
+ a. Let options be ? ToObject(options).
+ ...
+features: [Intl.Segmenter]
+---*/
+
+assert.throws(TypeError, () => {
+ new Intl.Segmenter(undefined, null);
+}, 'null');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-order.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-order.js
new file mode 100644
index 0000000000..aaf1464569
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-order.js
@@ -0,0 +1,56 @@
+// |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-Intl.Segmenter
+description: Checks the order of operations on the options argument to the Segmenter constructor.
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+
+ 7. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
+ 11. Let granularity be ? GetOption(options, "granularity", "string", « "grapheme", "word", "sentence" », "grapheme").
+includes: [compareArray.js]
+features: [Intl.Segmenter]
+---*/
+
+const callOrder = [];
+
+new Intl.Segmenter([], {
+ get localeMatcher() {
+ callOrder.push("localeMatcher");
+ return {
+ toString() {
+ callOrder.push("localeMatcher toString");
+ return "best fit";
+ }
+ };
+ },
+ get lineBreakStyle() {
+ callOrder.push("lineBreakStyle");
+ return {
+ toString() {
+ callOrder.push("lineBreakStyle toString");
+ return "strict";
+ }
+ };
+ },
+ get granularity() {
+ callOrder.push("granularity");
+ return {
+ toString() {
+ callOrder.push("granularity toString");
+ return "word";
+ }
+ };
+ },
+});
+
+assert.compareArray(callOrder, [
+ "localeMatcher",
+ "localeMatcher toString",
+ "granularity",
+ "granularity toString",
+]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-throwing-getters.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-throwing-getters.js
new file mode 100644
index 0000000000..4329cfedcd
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-throwing-getters.js
@@ -0,0 +1,28 @@
+// |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-Intl.Segmenter
+description: Checks the propagation of exceptions from the options for the Segmenter constructor.
+features: [Intl.Segmenter]
+---*/
+
+function CustomError() {}
+
+const options = [
+ "localeMatcher",
+ "granularity",
+];
+
+for (const option of options) {
+ assert.throws(CustomError, () => {
+ new Intl.Segmenter("en", {
+ get [option]() {
+ throw new CustomError();
+ }
+ });
+ }, `Exception from ${option} getter should be propagated`);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-undefined.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-undefined.js
new file mode 100644
index 0000000000..76486524f9
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-undefined.js
@@ -0,0 +1,52 @@
+// |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-Intl.Segmenter
+description: Checks handling of non-object option arguments to the Segmenter constructor.
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+
+ 4. If options is undefined, then
+ a. Let options be ObjectCreate(null).
+features: [Intl.Segmenter]
+---*/
+
+Object.defineProperties(Object.prototype, {
+ "localeMatcher": {
+ "get": function() {
+ throw new Error("Should not call getter on Object.prototype: localeMatcher");
+ },
+ },
+
+ "lineBreakStyle": {
+ "get": function() {
+ throw new Error("Should not call getter on Object.prototype: lineBreakStyle");
+ },
+ },
+
+ "granularity": {
+ "get": function() {
+ throw new Error("Should not call getter on Object.prototype: granularity");
+ },
+ },
+});
+
+const optionsArguments = [
+ [],
+ [[]],
+ [[], undefined],
+];
+
+for (const args of optionsArguments) {
+ const segmenter = new Intl.Segmenter(...args);
+ const resolvedOptions = segmenter.resolvedOptions();
+ assert.sameValue(resolvedOptions.granularity, "grapheme",
+ `Calling with ${args.length} empty arguments should yield the correct value for "granularity"`);
+ assert(
+ !Object.prototype.hasOwnProperty.call(resolvedOptions, "lineBreakStyle"),
+ `Calling with ${args.length} empty arguments should yield the correct value for "lineBreakStyle"`);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-valid-combinations.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-valid-combinations.js
new file mode 100644
index 0000000000..dfddc80cee
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/options-valid-combinations.js
@@ -0,0 +1,39 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2018 the V8 project authors, 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 granularity option to the Segmenter constructor.
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+
+ 11. Let granularity be ? GetOption(options, "granularity", "string", « "grapheme", "word", "sentence" », "grapheme").
+ 12. Set segmenter.[[SegmenterGranularity]] to granularity.
+features: [Intl.Segmenter]
+---*/
+
+const granularityOptions = ["grapheme", "word", "sentence"];
+const combinations = [];
+
+combinations.push([
+ {},
+ "grapheme",
+ undefined,
+]);
+
+for (const granularity of granularityOptions) {
+ combinations.push([
+ { granularity },
+ granularity,
+ undefined,
+ ]);
+}
+
+for (const [input, granularity, lineBreakStyle] of combinations) {
+ const segmenter = new Intl.Segmenter([], input);
+ const resolvedOptions = segmenter.resolvedOptions();
+ assert.sameValue(resolvedOptions.granularity, granularity);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/proto-from-ctor-realm.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/proto-from-ctor-realm.js
new file mode 100644
index 0000000000..e3bc3b7be1
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/proto-from-ctor-realm.js
@@ -0,0 +1,61 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-Intl.Segmenter
+description: Default [[Prototype]] value derived from realm of the NewTarget.
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+
+ 1. If NewTarget is undefined, throw a TypeError exception.
+ 2. Let segmenter be ? OrdinaryCreateFromConstructor(NewTarget, "%SegmenterPrototype%", « [[InitializedSegmenter]] »).
+ ...
+ 14. Return segmenter.
+
+ OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
+
+ ...
+ 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
+ 3. Return ObjectCreate(proto, internalSlotsList).
+
+ 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, cross-realm, Reflect, Symbol]
+---*/
+
+var other = $262.createRealm().global;
+var newTarget = new other.Function();
+var seg;
+
+newTarget.prototype = undefined;
+seg = Reflect.construct(Intl.Segmenter, [], newTarget);
+assert.sameValue(Object.getPrototypeOf(seg), other.Intl.Segmenter.prototype, 'newTarget.prototype is undefined');
+
+newTarget.prototype = null;
+seg = Reflect.construct(Intl.Segmenter, [], newTarget);
+assert.sameValue(Object.getPrototypeOf(seg), other.Intl.Segmenter.prototype, 'newTarget.prototype is null');
+
+newTarget.prototype = false;
+seg = Reflect.construct(Intl.Segmenter, [], newTarget);
+assert.sameValue(Object.getPrototypeOf(seg), other.Intl.Segmenter.prototype, 'newTarget.prototype is a Boolean');
+
+newTarget.prototype = 'str';
+seg = Reflect.construct(Intl.Segmenter, [], newTarget);
+assert.sameValue(Object.getPrototypeOf(seg), other.Intl.Segmenter.prototype, 'newTarget.prototype is a String');
+
+newTarget.prototype = Symbol();
+seg = Reflect.construct(Intl.Segmenter, [], newTarget);
+assert.sameValue(Object.getPrototypeOf(seg), other.Intl.Segmenter.prototype, 'newTarget.prototype is a Symbol');
+
+newTarget.prototype = 1;
+seg = Reflect.construct(Intl.Segmenter, [], newTarget);
+assert.sameValue(Object.getPrototypeOf(seg), other.Intl.Segmenter.prototype, 'newTarget.prototype is a Number');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/shell.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/shell.js
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/constructor/subclassing.js b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/subclassing.js
new file mode 100644
index 0000000000..485ece668b
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/constructor/subclassing.js
@@ -0,0 +1,56 @@
+// |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-Intl.Segmenter
+description: Checks that Segmenter can be subclassed.
+info: |
+ Intl.Segmenter ( [ locales [ , options ] ] )
+
+ 2. Let segmenter be ? OrdinaryCreateFromConstructor(NewTarget, "%SegmenterPrototype%", « [[InitializedSegmenter]] »).
+includes: [compareArray.js]
+features: [Intl.Segmenter]
+---*/
+
+function segments(iterator) {
+ return [...iterator].map(result => result.segment);
+}
+
+class CustomSegmenter extends Intl.Segmenter {
+ constructor(locales, options) {
+ super(locales, options);
+ this.isCustom = true;
+ }
+}
+
+const locale = "de";
+const value = "Hello";
+
+const real_segmenter = new Intl.Segmenter(locale);
+assert.sameValue(real_segmenter.isCustom, undefined, "Custom property");
+
+const custom_segmenter = new CustomSegmenter(locale);
+assert.sameValue(custom_segmenter.isCustom, true, "Custom property");
+
+assert.compareArray(segments(custom_segmenter.segment(value)),
+ segments(real_segmenter.segment(value)),
+ "Direct call");
+
+assert.compareArray(segments(Intl.Segmenter.prototype.segment.call(custom_segmenter, value)),
+ segments(Intl.Segmenter.prototype.segment.call(real_segmenter, value)),
+ "Indirect call");
+
+assert.sameValue(Object.getPrototypeOf(custom_segmenter), CustomSegmenter.prototype, "Prototype");
+assert.sameValue(Object.getPrototypeOf(CustomSegmenter), Intl.Segmenter,
+ "Object.getPrototypeOf(CustomSegmenter) returns Intl.Segmenter");
+assert.sameValue(Object.getPrototypeOf(CustomSegmenter.prototype), Intl.Segmenter.prototype,
+ "Object.getPrototypeOf(CustomSegmenter.prototype) returns Intl.Segmenter.prototype");
+assert.sameValue(custom_segmenter instanceof Intl.Segmenter, true,
+ "The result of `custom_segmenter instanceof Intl.Segmenter` is true");
+
+assert.throws(TypeError, function() {
+ CustomSegmenter();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/length.js b/js/src/tests/test262/intl402/Segmenter/constructor/length.js
new file mode 100644
index 0000000000..97bcaf7a38
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/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-Intl.Segmenter
+description: >
+ Checks the "length" property of the Segmenter constructor.
+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]
+---*/
+
+verifyProperty(Intl.Segmenter, "length", {
+ value: 0,
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/name.js b/js/src/tests/test262/intl402/Segmenter/constructor/name.js
new file mode 100644
index 0000000000..f055578fe8
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/name.js
@@ -0,0 +1,23 @@
+// |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-Intl.Segmenter
+description: Checks the "name" property of the Segmenter constructor.
+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.
+ 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]
+---*/
+
+verifyProperty(Intl.Segmenter, "name", {
+ value: "Segmenter",
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/prop-desc.js b/js/src/tests/test262/intl402/Segmenter/constructor/prop-desc.js
new file mode 100644
index 0000000000..bab8f0d3a4
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/prop-desc.js
@@ -0,0 +1,35 @@
+// |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-Intl.Segmenter
+description: Verifies the "Segmenter" property of Intl.
+info: |
+ Requirements for Standard Built-in ECMAScript Objects
+
+ 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 2018 Language
+ Specification, 9th edition, clause 17, or successor.
+
+ ECMAScript Standard Built-in Objects:
+
+ Every other data property described in clauses 18 through 26 and in Annex B.2 has the
+ attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }
+ unless otherwise specified.
+
+includes: [propertyHelper.js]
+features: [Intl.Segmenter]
+---*/
+
+assert.sameValue(typeof Intl.Segmenter, "function");
+
+verifyProperty(Intl, "Segmenter", {
+ value: Intl.Segmenter,
+ writable: true,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/prototype.js b/js/src/tests/test262/intl402/Segmenter/constructor/prototype.js
new file mode 100644
index 0000000000..7725c52654
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/prototype.js
@@ -0,0 +1,20 @@
+// |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-Intl.Segmenter
+description: The prototype of the Intl.Segmenter constructor is %FunctionPrototype%.
+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.
+ Unless otherwise specified every built-in function object has the %FunctionPrototype% object as the initial value of its [[Prototype]] internal slot.
+features: [Intl.Segmenter]
+---*/
+
+assert.sameValue(
+ Object.getPrototypeOf(Intl.Segmenter),
+ Function.prototype,
+ "Object.getPrototypeOf(Intl.Segmenter) equals the value of Function.prototype"
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/shell.js b/js/src/tests/test262/intl402/Segmenter/constructor/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/shell.js
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/basic.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/basic.js
new file mode 100644
index 0000000000..d2f847e0e1
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/basic.js
@@ -0,0 +1,22 @@
+// |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-Intl.Segmenter.supportedLocalesOf
+description: Tests that Intl.Segmenter has a supportedLocalesOf property, and it works as expected.
+features: [Intl.Segmenter]
+---*/
+
+assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function",
+ "supportedLocalesOf should be supported.");
+
+const defaultLocale = new Intl.Segmenter().resolvedOptions().locale;
+const notSupported = "zxx"; // "no linguistic content"
+const requestedLocales = [defaultLocale, notSupported];
+
+const supportedLocales = Intl.Segmenter.supportedLocalesOf(requestedLocales);
+assert.sameValue(supportedLocales.length, 1, "The length of supported locales list is not 1.");
+assert.sameValue(supportedLocales[0], defaultLocale, "The default locale is not returned in the supported list.");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/branding.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/branding.js
new file mode 100644
index 0000000000..dee2601595
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/branding.js
@@ -0,0 +1,35 @@
+// |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-Intl.Segmenter.supportedLocalesOf
+description: >
+ Verifies there's no branding check for Intl.Segmenter.supportedLocalesOf().
+info: |
+ Intl.Segmenter.supportedLocalesOf ( locales [, options ])
+features: [Intl.Segmenter]
+---*/
+
+const supportedLocalesOf = Intl.Segmenter.supportedLocalesOf;
+
+assert.sameValue(typeof supportedLocalesOf, "function");
+
+const thisValues = [
+ undefined,
+ null,
+ true,
+ "",
+ Symbol(),
+ 1,
+ {},
+ Intl.Segmenter,
+ Intl.Segmenter.prototype,
+];
+
+for (const thisValue of thisValues) {
+ const result = supportedLocalesOf.call(thisValue);
+ assert.sameValue(Array.isArray(result), true);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/browser.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/browser.js
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/length.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/length.js
new file mode 100644
index 0000000000..e9bcaa18bc
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/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-Intl.Segmenter.supportedLocalesOf
+description: >
+ Checks the "length" property of Intl.Segmenter.supportedLocalesOf().
+info: |
+ The value of the length property of the supportedLocalesOf method is 1.
+ 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.
+ Every built-in function object, including constructors, has a length property whose value is an integer.
+ 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]
+---*/
+
+verifyProperty(Intl.Segmenter.supportedLocalesOf, "length", {
+ value: 1,
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-empty.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-empty.js
new file mode 100644
index 0000000000..642ab7f744
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-empty.js
@@ -0,0 +1,22 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2018 the V8 project authors, Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-Intl.Segmenter.supportedLocalesOf
+description: Checks handling of an empty locales argument to the supportedLocalesOf function.
+info: |
+ Intl.Segmenter.supportedLocalesOf ( locales [, options ])
+
+ 3. Return ? SupportedLocales(availableLocales, requestedLocales, options).
+includes: [compareArray.js]
+features: [Intl.Segmenter]
+---*/
+
+assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function",
+ "Should support Intl.Segmenter.supportedLocalesOf.");
+
+assert.compareArray(Intl.Segmenter.supportedLocalesOf(), []);
+assert.compareArray(Intl.Segmenter.supportedLocalesOf([]), []);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-invalid.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-invalid.js
new file mode 100644
index 0000000000..a8cc8ffbde
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-invalid.js
@@ -0,0 +1,23 @@
+// |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-Intl.Segmenter.supportedLocalesOf
+description: Checks error cases for the locales argument to the supportedLocalesOf function.
+info: |
+ Intl.Segmenter.supportedLocalesOf ( locales [, options ])
+
+ 2. Let requestedLocales be CanonicalizeLocaleList(locales).
+includes: [testIntl.js]
+features: [Intl.Segmenter]
+---*/
+
+assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function",
+ "Should support Intl.Segmenter.supportedLocalesOf.");
+
+for (const [locales, expectedError] of getInvalidLocaleArguments()) {
+ assert.throws(expectedError, () => Intl.Segmenter.supportedLocalesOf(locales));
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-specific.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-specific.js
new file mode 100644
index 0000000000..17970524f0
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-specific.js
@@ -0,0 +1,25 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2018 the V8 project authors, Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-Intl.Segmenter.supportedLocalesOf
+description: Checks handling of specific locales arguments to the supportedLocalesOf function.
+info: |
+ Intl.Segmenter.supportedLocalesOf ( locales [, options ])
+
+ 3. Return ? SupportedLocales(availableLocales, requestedLocales, options).
+includes: [compareArray.js]
+locale: [sr, sr-Thai-RS, de, zh-CN]
+features: [Intl.Segmenter]
+---*/
+
+assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function",
+ "Should support Intl.Segmenter.supportedLocalesOf.");
+
+assert.compareArray(Intl.Segmenter.supportedLocalesOf("sr"), ["sr"]);
+
+const multiLocale = ["sr-Thai-RS", "de", "zh-CN"];
+assert.compareArray(Intl.Segmenter.supportedLocalesOf(multiLocale, {localeMatcher: "lookup"}), multiLocale);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/name.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/name.js
new file mode 100644
index 0000000000..c4fdcfff14
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/name.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-Intl.Segmenter.supportedLocalesOf
+description: >
+ Checks the "name" property of Intl.Segmenter.supportedLocalesOf().
+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.
+ 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]
+---*/
+
+verifyProperty(Intl.Segmenter.supportedLocalesOf, "name", {
+ value: "supportedLocalesOf",
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-localeMatcher-invalid.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-localeMatcher-invalid.js
new file mode 100644
index 0000000000..02d1699849
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-localeMatcher-invalid.js
@@ -0,0 +1,37 @@
+// |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-Intl.Segmenter.supportedLocalesOf
+description: Checks handling of invalid values for the localeMatcher option to the supportedLocalesOf function.
+info: |
+ SupportedLocales ( availableLocales, requestedLocales, options )
+
+ 1. If options is not undefined, then
+ b. Let matcher be ? GetOption(options, "localeMatcher", "string", «"lookup", "best fit"», "best fit").
+features: [Intl.Segmenter]
+---*/
+
+assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function",
+ "Should support Intl.Segmenter.supportedLocalesOf.");
+
+const invalidOptions = [
+ null,
+ 1,
+ "",
+ "Lookup",
+ "LOOKUP",
+ "lookup\0",
+ "Best fit",
+ "BEST FIT",
+ "best\u00a0fit",
+];
+
+for (const invalidOption of invalidOptions) {
+ assert.throws(RangeError, function() {
+ Intl.Segmenter.supportedLocalesOf([], {"localeMatcher": invalidOption});
+ }, `${invalidOption} is an invalid localeMatcher option value`);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-null.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-null.js
new file mode 100644
index 0000000000..f97ad6627f
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-null.js
@@ -0,0 +1,23 @@
+// |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-Intl.Segmenter.supportedLocalesOf
+description: Checks handling of a null options argument to the supportedLocalesOf function.
+info: |
+ SupportedLocales ( availableLocales, requestedLocales, options )
+
+ 1. If options is not undefined, then
+ a. Let options be ? ToObject(options).
+features: [Intl.Segmenter]
+---*/
+
+assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function",
+ "Should support Intl.Segmenter.supportedLocalesOf.");
+
+assert.throws(TypeError, function() {
+ Intl.Segmenter.supportedLocalesOf([], null);
+}, "Should throw when passing null as the options argument");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-toobject.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-toobject.js
new file mode 100644
index 0000000000..db621a80c6
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-toobject.js
@@ -0,0 +1,44 @@
+// |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-Intl.Segmenter.supportedLocalesOf
+description: Checks handling of non-object options arguments to the supportedLocalesOf function.
+info: |
+ SupportedLocales ( availableLocales, requestedLocales, options )
+
+ 1. If options is not undefined, then
+ a. Let options be ? ToObject(options).
+features: [Intl.Segmenter]
+---*/
+
+assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function",
+ "Should support Intl.Segmenter.supportedLocalesOf.");
+
+let called;
+Object.defineProperties(Object.prototype, {
+ "localeMatcher": {
+ get() {
+ ++called;
+ return "best fit";
+ }
+ }
+});
+
+const optionsArguments = [
+ true,
+ "test",
+ 7,
+ Symbol(),
+];
+
+for (const options of optionsArguments) {
+ called = 0;
+ const result = Intl.Segmenter.supportedLocalesOf([], options);
+ assert.sameValue(Array.isArray(result), true, `Expected array from ${String(options)}`);
+ assert.sameValue(called, 1, `Expected one call from ${String(options)}`);
+}
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-undefined.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-undefined.js
new file mode 100644
index 0000000000..b81006fe81
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-undefined.js
@@ -0,0 +1,29 @@
+// |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-Intl.Segmenter.supportedLocalesOf
+description: Checks handling of an undefined options argument to the supportedLocalesOf function.
+info: |
+ SupportedLocales ( availableLocales, requestedLocales, options )
+
+ 1. If options is not undefined, then
+ b. Let matcher be ? GetOption(options, "localeMatcher", "string", «"lookup", "best fit"», "best fit").
+features: [Intl.Segmenter]
+---*/
+
+assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function",
+ "Should support Intl.Segmenter.supportedLocalesOf.");
+
+Object.defineProperties(Object.prototype, {
+ "localeMatcher": {
+ get() { throw new Error("Should not call localeMatcher getter"); }
+ }
+});
+
+assert.sameValue(Array.isArray(Intl.Segmenter.supportedLocalesOf()), true, "No arguments");
+assert.sameValue(Array.isArray(Intl.Segmenter.supportedLocalesOf([])), true, "One argument");
+assert.sameValue(Array.isArray(Intl.Segmenter.supportedLocalesOf([], undefined)), true, "Two arguments");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/prop-desc.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/prop-desc.js
new file mode 100644
index 0000000000..ac246193b2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/prop-desc.js
@@ -0,0 +1,32 @@
+// |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-Intl.Segmenter.supportedLocalesOf
+description: >
+ Checks the "supportedLocalesOf" property of the Segmenter prototype object.
+info: |
+ Intl.Segmenter.supportedLocalesOf ( locales [, options ])
+
+ 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.
+
+ Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js]
+features: [Intl.Segmenter]
+---*/
+
+assert.sameValue(
+ typeof Intl.Segmenter.supportedLocalesOf,
+ "function",
+ "typeof Intl.Segmenter.supportedLocalesOf is function"
+);
+
+verifyProperty(Intl.Segmenter, "supportedLocalesOf", {
+ writable: true,
+ enumerable: false,
+ configurable: true,
+});
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/result-type.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/result-type.js
new file mode 100644
index 0000000000..f476c36251
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/result-type.js
@@ -0,0 +1,36 @@
+// |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-Intl.Segmenter.supportedLocalesOf
+description: Verifies the type of the return value of Intl.Segmenter.supportedLocalesOf().
+info: |
+ Intl.Segmenter.supportedLocalesOf ( locales [, options ])
+includes: [propertyHelper.js]
+features: [Intl.Segmenter]
+---*/
+
+const result = Intl.Segmenter.supportedLocalesOf("en");
+assert.sameValue(Array.isArray(result), true,
+ "Array.isArray() should return true");
+assert.sameValue(Object.getPrototypeOf(result), Array.prototype,
+ "The prototype should be Array.prototype");
+assert.sameValue(Object.isExtensible(result), true,
+ "Object.isExtensible() should return true");
+
+assert.notSameValue(result.length, 0);
+for (let i = 0; i < result.length; ++i) {
+ verifyProperty(result, String(i), {
+ "writable": true,
+ "enumerable": true,
+ "configurable": true,
+ });
+}
+
+verifyProperty(result, "length", {
+ "enumerable": false,
+ "configurable": false,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/shell.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/shell.js
diff --git a/js/src/tests/test262/intl402/Segmenter/ctor-custom-get-prototype-poison-throws.js b/js/src/tests/test262/intl402/Segmenter/ctor-custom-get-prototype-poison-throws.js
new file mode 100644
index 0000000000..3ad69bb425
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/ctor-custom-get-prototype-poison-throws.js
@@ -0,0 +1,37 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-intl.segmenter
+description: >
+ Return abrupt from Get Prototype from a custom NewTarget
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+ 1. If NewTarget is undefined, throw a TypeError exception.
+ 3. Let segmenter be ? OrdinaryCreateFromConstructor(NewTarget, "%Segmenter.prototype%", internalSlotsList).
+ ...
+ OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
+ ...
+ 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
+ ...
+ GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
+ 3. Let proto be ? Get(constructor, "prototype").
+features: [Intl.Segmenter, Reflect, Proxy]
+---*/
+
+const custom = new Proxy(new Function(), {
+ get(target, key) {
+ if (key === 'prototype') {
+ throw new Test262Error();
+ }
+
+ return target[key];
+ }
+});
+
+assert.throws(Test262Error, () => {
+ Reflect.construct(Intl.Segmenter, [], custom);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/ctor-custom-prototype.js b/js/src/tests/test262/intl402/Segmenter/ctor-custom-prototype.js
new file mode 100644
index 0000000000..394a457fab
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/ctor-custom-prototype.js
@@ -0,0 +1,34 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-intl.segmenter
+description: >
+ Custom Prototype of the returned object based on the NewTarget
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+ 1. If NewTarget is undefined, throw a TypeError exception.
+ 3. Let segmenter be ? OrdinaryCreateFromConstructor(NewTarget, "%Segmenter.prototype%", internalSlotsList).
+ ...
+ OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
+ ...
+ 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
+ ...
+ 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]
+---*/
+
+var custom = new Function();
+custom.prototype = {};
+
+const obj = Reflect.construct(Intl.Segmenter, [], custom);
+
+assert.sameValue(Object.getPrototypeOf(obj), custom.prototype);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/ctor-default-prototype.js b/js/src/tests/test262/intl402/Segmenter/ctor-default-prototype.js
new file mode 100644
index 0000000000..053b890eac
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/ctor-default-prototype.js
@@ -0,0 +1,20 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-intl.segmenter
+description: >
+ Prototype of the returned object is Segmenter.prototype
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+ 1. If NewTarget is undefined, throw a TypeError exception.
+ 3. Let segmenter be ? OrdinaryCreateFromConstructor(NewTarget, "%Segmenter.prototype%", internalSlotsList).
+features: [Intl.Segmenter]
+---*/
+
+var obj = new Intl.Segmenter();
+
+assert.sameValue(Object.getPrototypeOf(obj), Intl.Segmenter.prototype);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/instance/browser.js b/js/src/tests/test262/intl402/Segmenter/instance/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/instance/browser.js
diff --git a/js/src/tests/test262/intl402/Segmenter/instance/extensibility.js b/js/src/tests/test262/intl402/Segmenter/instance/extensibility.js
new file mode 100644
index 0000000000..2254e7f996
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/instance/extensibility.js
@@ -0,0 +1,22 @@
+// |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-Intl.Segmenter
+description: Intl.Segmenter instance object extensibility
+info: |
+ 17 ECMAScript Standard Built-in Objects:
+
+ Unless specified otherwise, the [[Extensible]] internal slot
+ of a built-in object initially has the value true.
+features: [Intl.Segmenter]
+---*/
+
+assert.sameValue(
+ Object.isExtensible(new Intl.Segmenter()),
+ true,
+ "Object.isExtensible(new Intl.Segmenter()) returns true"
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/instance/prototype.js b/js/src/tests/test262/intl402/Segmenter/instance/prototype.js
new file mode 100644
index 0000000000..4a5af5c73e
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/instance/prototype.js
@@ -0,0 +1,22 @@
+// |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-Intl.Segmenter
+description: Intl.Segmenter instance object is created from %SegmenterPrototype%.
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+
+ 2. Let segmenter be ? OrdinaryCreateFromConstructor(NewTarget, "%SegmenterPrototype%", « [[InitializedSegmenter]] »).
+features: [Intl.Segmenter]
+---*/
+
+const value = new Intl.Segmenter();
+assert.sameValue(
+ Object.getPrototypeOf(value),
+ Intl.Segmenter.prototype,
+ "Object.getPrototypeOf(value) equals the value of Intl.Segmenter.prototype"
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/instance/shell.js b/js/src/tests/test262/intl402/Segmenter/instance/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/instance/shell.js
diff --git a/js/src/tests/test262/intl402/Segmenter/proto-from-ctor-realm.js b/js/src/tests/test262/intl402/Segmenter/proto-from-ctor-realm.js
new file mode 100644
index 0000000000..4466d2e9c2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/proto-from-ctor-realm.js
@@ -0,0 +1,56 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-intl.segmenter
+description: Default [[Prototype]] value derived from realm of the NewTarget.
+info: |
+ Intl.Segmenter ([ locales [ , options ]])
+ 1. If NewTarget is undefined, throw a TypeError exception.
+ 3. Let segmenter be ? OrdinaryCreateFromConstructor(NewTarget, "%Segmenter.prototype%", internalSlotsList).
+ ...
+ 15. Return segmenter.
+ OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
+ ...
+ 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
+ 3. Return ObjectCreate(proto, internalSlotsList).
+ 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: [cross-realm, Reflect, Symbol, Intl.Segmenter]
+---*/
+
+const other = $262.createRealm().global;
+const newTarget = new other.Function();
+let sgm;
+
+newTarget.prototype = undefined;
+sgm = Reflect.construct(Intl.Segmenter, [], newTarget);
+assert.sameValue(Object.getPrototypeOf(sgm), other.Intl.Segmenter.prototype, 'newTarget.prototype is undefined');
+
+newTarget.prototype = null;
+sgm = Reflect.construct(Intl.Segmenter, [], newTarget);
+assert.sameValue(Object.getPrototypeOf(sgm), other.Intl.Segmenter.prototype, 'newTarget.prototype is null');
+
+newTarget.prototype = false;
+sgm = Reflect.construct(Intl.Segmenter, [], newTarget);
+assert.sameValue(Object.getPrototypeOf(sgm), other.Intl.Segmenter.prototype, 'newTarget.prototype is a Boolean');
+
+newTarget.prototype = 'str';
+sgm = Reflect.construct(Intl.Segmenter, [], newTarget);
+assert.sameValue(Object.getPrototypeOf(sgm), other.Intl.Segmenter.prototype, 'newTarget.prototype is a String');
+
+newTarget.prototype = Symbol();
+sgm = Reflect.construct(Intl.Segmenter, [], newTarget);
+assert.sameValue(Object.getPrototypeOf(sgm), other.Intl.Segmenter.prototype, 'newTarget.prototype is a Symbol');
+
+newTarget.prototype = 1;
+sgm = Reflect.construct(Intl.Segmenter, [], newTarget);
+assert.sameValue(Object.getPrototypeOf(sgm), other.Intl.Segmenter.prototype, 'newTarget.prototype is a Number');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/Symbol.toStringTag.js b/js/src/tests/test262/intl402/Segmenter/prototype/Symbol.toStringTag.js
new file mode 100644
index 0000000000..2960428e22
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/Symbol.toStringTag.js
@@ -0,0 +1,23 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-intl.segmenter.prototype-@@tostringtag
+description: >
+ Property descriptor of Segmenter.prototype[@@toStringTag]
+info: |
+ The initial value of the @@toStringTag property is the string value "Intl.Segmenter".
+ This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+features: [Intl.Segmenter, Symbol.toStringTag]
+---*/
+
+verifyProperty(Intl.Segmenter.prototype, Symbol.toStringTag, {
+ value: "Intl.Segmenter",
+ writable: false,
+ enumerable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/browser.js b/js/src/tests/test262/intl402/Segmenter/prototype/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/browser.js
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/constructor/browser.js b/js/src/tests/test262/intl402/Segmenter/prototype/constructor/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/constructor/browser.js
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/constructor/prop-desc.js b/js/src/tests/test262/intl402/Segmenter/prototype/constructor/prop-desc.js
new file mode 100644
index 0000000000..566e36a669
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/constructor/prop-desc.js
@@ -0,0 +1,27 @@
+// |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-Intl.Segmenter.prototype.constructor
+description: Checks the "constructor" property of the Segmenter prototype object.
+info: |
+ Intl.Segmenter.prototype.constructor
+
+ The initial value of Intl.Segmenter.prototype.constructor is %Segmenter%.
+
+ 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.
+
+ Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js]
+features: [Intl.Segmenter]
+---*/
+
+verifyProperty(Intl.Segmenter.prototype, "constructor", {
+ value: Intl.Segmenter,
+ writable: true,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/constructor/shell.js b/js/src/tests/test262/intl402/Segmenter/prototype/constructor/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/constructor/shell.js
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/prop-desc.js b/js/src/tests/test262/intl402/Segmenter/prototype/prop-desc.js
new file mode 100644
index 0000000000..34839605ec
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/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-Intl.Segmenter.prototype
+description: Checks the "prototype" property of the Segmenter constructor.
+info: |
+ Intl.Segmenter.prototype
+
+ The value of Intl.Segmenter.prototype is %SegmenterPrototype%.
+
+ This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
+includes: [propertyHelper.js]
+features: [Intl.Segmenter]
+---*/
+
+verifyProperty(Intl.Segmenter, "prototype", {
+ writable: false,
+ enumerable: false,
+ configurable: false,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/branding.js b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/branding.js
new file mode 100644
index 0000000000..756a9132d2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/branding.js
@@ -0,0 +1,29 @@
+// |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-Intl.Segmenter.prototype.resolvedOptions
+description: Verifies the branding check for the "resolvedOptions" function of the Segmenter prototype object.
+info: |
+ Intl.Segmenter.prototype.resolvedOptions ()
+
+ 2. If Type(pr) is not Object or pr does not have an [[InitializedSegmenter]] internal slot, throw a TypeError exception.
+features: [Intl.Segmenter]
+---*/
+
+const resolvedOptions = Intl.Segmenter.prototype.resolvedOptions;
+
+assert.sameValue(typeof resolvedOptions, "function");
+
+assert.throws(TypeError, () => resolvedOptions.call(undefined), "undefined");
+assert.throws(TypeError, () => resolvedOptions.call(null), "null");
+assert.throws(TypeError, () => resolvedOptions.call(true), "true");
+assert.throws(TypeError, () => resolvedOptions.call(""), "empty string");
+assert.throws(TypeError, () => resolvedOptions.call(Symbol()), "symbol");
+assert.throws(TypeError, () => resolvedOptions.call(1), "1");
+assert.throws(TypeError, () => resolvedOptions.call({}), "plain object");
+assert.throws(TypeError, () => resolvedOptions.call(Intl.Segmenter), "Intl.Segmenter");
+assert.throws(TypeError, () => resolvedOptions.call(Intl.Segmenter.prototype), "Intl.Segmenter.prototype");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/browser.js b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/browser.js
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/caching.js b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/caching.js
new file mode 100644
index 0000000000..96c76ec704
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/caching.js
@@ -0,0 +1,20 @@
+// |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-Intl.Segmenter.prototype.resolvedOptions
+description: Verifies that the return value of Intl.Segmenter.prototype.resolvedOptions() is not cached.
+info: |
+ Intl.Segmenter.prototype.resolvedOptions ()
+
+ 3. Let options be ! ObjectCreate(%ObjectPrototype%).
+features: [Intl.Segmenter]
+---*/
+
+const s = new Intl.Segmenter("en-us");
+const options1 = s.resolvedOptions();
+const options2 = s.resolvedOptions();
+assert.notSameValue(options1, options2, "Should create a new object each time.");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/length.js b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/length.js
new file mode 100644
index 0000000000..e43dea0c6d
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/length.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-Intl.Segmenter.prototype.resolvedOptions
+description: Checks the "length" property of Intl.Segmenter.prototype.resolvedOptions().
+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]
+---*/
+
+verifyProperty(Intl.Segmenter.prototype.resolvedOptions, "length", {
+ value: 0,
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/name.js b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/name.js
new file mode 100644
index 0000000000..041afb9d92
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/name.js
@@ -0,0 +1,23 @@
+// |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-Intl.Segmenter.prototype.resolvedOptions
+description: Checks the "name" property of Intl.Segmenter.prototype.resolvedOptions().
+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.
+ 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]
+---*/
+
+verifyProperty(Intl.Segmenter.prototype.resolvedOptions, "name", {
+ value: "resolvedOptions",
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/order.js b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/order.js
new file mode 100644
index 0000000000..aa254958c3
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/order.js
@@ -0,0 +1,30 @@
+// |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-Intl.Segmenter.prototype.resolvedOptions
+description: Verifies the property order for the object returned by resolvedOptions().
+features: [Intl.Segmenter]
+---*/
+
+const options = new Intl.Segmenter([], {
+ "granularity": "word",
+}).resolvedOptions();
+
+const expected = [
+ "locale",
+ "granularity",
+];
+
+const actual = Object.getOwnPropertyNames(options);
+
+// Ensure all expected items are in actual and also allow other properties
+// implemented in new proposals.
+assert(actual.indexOf("locale") > -1, "\"locale\" is present");
+for (var i = 1; i < expected.length; i++) {
+ // Ensure the order as expected but allow additional new property in between
+ assert(actual.indexOf(expected[i-1]) < actual.indexOf(expected[i]), `"${expected[i-1]}" precedes "${expected[i]}"`);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/prop-desc.js b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/prop-desc.js
new file mode 100644
index 0000000000..d210777575
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/prop-desc.js
@@ -0,0 +1,30 @@
+// |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-Intl.Segmenter.prototype.resolvedOptions
+description: Checks the "resolvedOptions" property of the Segmenter prototype object.
+info: |
+ Intl.Segmenter.prototype.resolvedOptions ()
+
+ 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.
+
+ Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js]
+features: [Intl.Segmenter]
+---*/
+
+assert.sameValue(
+ typeof Intl.Segmenter.prototype.resolvedOptions,
+ "function",
+ "typeof Intl.Segmenter.prototype.resolvedOptions is function"
+);
+
+verifyProperty(Intl.Segmenter.prototype, "resolvedOptions", {
+ writable: true,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/shell.js b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/shell.js
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/type-without-lbs.js b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/type-without-lbs.js
new file mode 100644
index 0000000000..b12e734dba
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/type-without-lbs.js
@@ -0,0 +1,39 @@
+// |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-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": "word" });
+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: "word",
+ writable: true,
+ enumerable: true,
+ configurable: true,
+});
+
+verifyProperty(options, "lineBreakStyle", undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/branding.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/branding.js
new file mode 100644
index 0000000000..7bb5ab5ae5
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/branding.js
@@ -0,0 +1,29 @@
+// |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-Intl.Segmenter.prototype.segment
+description: Verifies the branding check for the "segment" function of the Segmenter prototype object.
+info: |
+ Intl.Segmenter.prototype.segment( string )
+
+ 2. If Type(segment) is not Object or segment does not have an [[InitializedSegmenter]] internal slot, throw a TypeError exception.
+features: [Intl.Segmenter]
+---*/
+
+const segment = Intl.Segmenter.prototype.segment;
+
+assert.sameValue(typeof segment, "function");
+
+assert.throws(TypeError, () => segment.call(undefined), "undefined");
+assert.throws(TypeError, () => segment.call(null), "null");
+assert.throws(TypeError, () => segment.call(true), "true");
+assert.throws(TypeError, () => segment.call(""), "empty string");
+assert.throws(TypeError, () => segment.call(Symbol()), "symbol");
+assert.throws(TypeError, () => segment.call(1), "1");
+assert.throws(TypeError, () => segment.call({}), "plain object");
+assert.throws(TypeError, () => segment.call(Intl.Segmenter), "Intl.Segmenter");
+assert.throws(TypeError, () => segment.call(Intl.Segmenter.prototype), "Intl.Segmenter.prototype");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/browser.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/browser.js
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);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/length.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/length.js
new file mode 100644
index 0000000000..21db9d950e
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/length.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-Intl.Segmenter.prototype.segment
+description: Checks the "length" property of Intl.Segmenter.prototype.segment().
+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]
+---*/
+
+verifyProperty(Intl.Segmenter.prototype.segment, "length", {
+ value: 1,
+ writable: false,
+ enumerable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/name.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/name.js
new file mode 100644
index 0000000000..823f44f579
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/name.js
@@ -0,0 +1,23 @@
+// |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-Intl.Segmenter.prototype.segment
+description: Checks the "name" property of Intl.Segmenter.prototype.segment().
+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.
+ 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]
+---*/
+
+verifyProperty(Intl.Segmenter.prototype.segment, "name", {
+ value: "segment",
+ writable: false,
+ enumerable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/nested-next.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/nested-next.js
new file mode 100644
index 0000000000..6d21985021
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/nested-next.js
@@ -0,0 +1,39 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2020 the V8 project authors, Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%segmentsprototype%-@@iterator
+description: Test to ensure the nested calling of the next method won't caused confusion to each other.
+info: |
+ %Segments.prototype% [ @@iterator ] ()
+ 5. Return ! CreateSegmentIterator(segmenter, string)
+
+ CreateSegmentIterator ( segmenter, string )
+ 1. Let internalSlotsList be « [[IteratingSegmenter]], [[IteratedString]], [[IteratedStringNextSegmentCodeUnitIndex]] ».
+ 2. Let iterator be ! ObjectCreate(%SegmentIterator.prototype%, internalSlotsList).
+ 3. Set iterator.[[IteratingSegmenter]] to segmenter.
+ 4. Set iterator.[[IteratedString]] to string.
+ 5. Set iterator.[[IteratedStringNextSegmentCodeUnitIndex]] to 0.
+ 6. Return iterator.
+
+ %SegmentIterator.prototype%.next ()
+ 5. Let startIndex be iterator.[[IteratedStringNextSegmentCodeUnitIndex]].
+
+features: [Intl.Segmenter]
+---*/
+
+const segmenter = new Intl.Segmenter();
+const input = "ABCD";
+const segments = segmenter.segment(input);
+let result = "";
+for (let v1 of segments) {
+ for (let v2 of segments) {
+ result += v1.segment;
+ result += v2.segment;
+ }
+ result += ":";
+}
+assert.sameValue("AAABACAD:BABBBCBD:CACBCCCD:DADBDCDD:", result);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/next-inside-next.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/next-inside-next.js
new file mode 100644
index 0000000000..2936d7621e
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/next-inside-next.js
@@ -0,0 +1,50 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2020 the V8 project authors, Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%segmentsprototype%-@@iterator
+description: Test to ensure the next on two segments of the segmenter won't interfer each other.
+info: |
+ %Segments.prototype% [ @@iterator ] ()
+ 5. Return ! CreateSegmentIterator(segmenter, string)
+
+ CreateSegmentIterator ( segmenter, string )
+ 1. Let internalSlotsList be « [[IteratingSegmenter]], [[IteratedString]], [[IteratedStringNextSegmentCodeUnitIndex]] ».
+ 2. Let iterator be ! ObjectCreate(%SegmentIterator.prototype%, internalSlotsList).
+ 3. Set iterator.[[IteratingSegmenter]] to segmenter.
+ 4. Set iterator.[[IteratedString]] to string.
+ 5. Set iterator.[[IteratedStringNextSegmentCodeUnitIndex]] to 0.
+ 6. Return iterator.
+
+ %SegmentIterator.prototype%.next ()
+ 5. Let startIndex be iterator.[[IteratedStringNextSegmentCodeUnitIndex]].
+
+features: [Intl.Segmenter]
+---*/
+
+const segmenter = new Intl.Segmenter();
+const input1 = "ABCD";
+const input2 = "123";
+const segments1 = segmenter.segment(input1);
+const segments2 = segmenter.segment(input2);
+let result = "";
+for (let v1 of segments1) {
+ for (let v2 of segments2) {
+ result += v1.segment;
+ result += v2.segment;
+ }
+ result += ":";
+}
+// Now loop segments2 .
+for (let v2 of segments2) {
+ for (let v1 of segments1) {
+ result += v2.segment;
+ result += v1.segment;
+ }
+ result += ":";
+}
+assert.sameValue(
+ "A1A2A3:B1B2B3:C1C2C3:D1D2D3:1A1B1C1D:2A2B2C2D:3A3B3C3D:", result);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/next-mix-with-containing.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/next-mix-with-containing.js
new file mode 100644
index 0000000000..dcc231c12b
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/next-mix-with-containing.js
@@ -0,0 +1,55 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2020 the V8 project authors, Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%segmentsprototype%-@@iterator
+description: Test to ensure the the calling of containing() won't impact the calling of the next().
+info: |
+ %Segments.prototype% [ @@iterator ] ()
+ 5. Return ! CreateSegmentIterator(segmenter, string)
+
+ CreateSegmentIterator ( segmenter, string )
+ 1. Let internalSlotsList be « [[IteratingSegmenter]], [[IteratedString]], [[IteratedStringNextSegmentCodeUnitIndex]] ».
+ 2. Let iterator be ! ObjectCreate(%SegmentIterator.prototype%, internalSlotsList).
+ 3. Set iterator.[[IteratingSegmenter]] to segmenter.
+ 4. Set iterator.[[IteratedString]] to string.
+ 5. Set iterator.[[IteratedStringNextSegmentCodeUnitIndex]] to 0.
+ 6. Return iterator.
+
+ %SegmentIterator.prototype%.next ()
+ 5. Let startIndex be iterator.[[IteratedStringNextSegmentCodeUnitIndex]].
+
+ %Segments.prototype%.containing ( index )
+ 3. Let segmenter be segments.[[SegmentsSegmenter]].
+ 4. Let string be segments.[[SegmentsString]].
+
+
+features: [Intl.Segmenter]
+---*/
+
+const segmenter = new Intl.Segmenter();
+const input = "ABC";
+const segments = segmenter.segment(input);
+let next_result = "";
+for (let i = 0; i < input.length; i++) {
+ let containing_result = segments.containing(i);
+ let msg = "containing(" + i + ") before the loop. ";
+ assert.sameValue(input[i], containing_result.segment, msg + "segment");
+ assert.sameValue(i, containing_result.index, msg + "index");
+ assert.sameValue(input, containing_result.input, msg + "input");
+ for (let v of segments) {
+ next_result += v.segment;
+ next_result += ":";
+ // Ensure the value n passing into segments.containing(n) will not impact
+ // the result of next().
+ msg = "containing(" + i + ") inside the loop. ";
+ containing_result = segments.containing(i);
+ assert.sameValue(input[i], containing_result.segment, msg + "segment");
+ assert.sameValue(i, containing_result.index, msg + "index");
+ assert.sameValue(input, containing_result.input, msg + "input");
+ }
+}
+assert.sameValue("A:B:C:A:B:C:A:B:C:", next_result);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/prop-desc.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/prop-desc.js
new file mode 100644
index 0000000000..d760eab7e5
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/prop-desc.js
@@ -0,0 +1,31 @@
+// |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-Intl.Segmenter.prototype.segment
+description: Checks the "segment" property of the Segmenter prototype object.
+info: |
+ Intl.Segmenter.prototype.segment( string )
+
+ 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.
+
+ Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js]
+features: [Intl.Segmenter]
+---*/
+
+assert.sameValue(
+ typeof Intl.Segmenter.prototype.segment,
+ "function",
+ "typeof Intl.Segmenter.prototype.segment is function"
+);
+
+verifyProperty(Intl.Segmenter.prototype, "segment", {
+ writable: true,
+ enumerable: false,
+ configurable: true,
+});
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/segment-grapheme-iterable.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/segment-grapheme-iterable.js
new file mode 100644
index 0000000000..5b3766ff3a
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/segment-grapheme-iterable.js
@@ -0,0 +1,57 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2018 the V8 project authors. All rights reserved.
+// Copyright 2020 Apple Inc. 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 )
+includes: [compareArray.js]
+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
+ ]) {
+ let segments = [];
+ for (const v of seg.segment(text)) {
+ assert.sameValue("string", typeof v.segment);
+ 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(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);
+ }
+ assert.sameValue(text, segments.join(''));
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/segment-sentence-iterable.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/segment-sentence-iterable.js
new file mode 100644
index 0000000000..706e49b4c5
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/segment-sentence-iterable.js
@@ -0,0 +1,57 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2018 the V8 project authors. All rights reserved.
+// Copyright 2020 Apple Inc. 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 )
+includes: [compareArray.js]
+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
+ ]) {
+ let segments = [];
+ for (const v of seg.segment(text)) {
+ assert.sameValue("string", typeof v.segment);
+ 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(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);
+ }
+ assert.sameValue(text, segments.join(''));
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/segment-tostring.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/segment-tostring.js
new file mode 100644
index 0000000000..433cd9ad44
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/segment-tostring.js
@@ -0,0 +1,37 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2018 the V8 project authors, Igalia, S.L. 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 string coercion in the "segment" function of the Segmenter prototype object.
+info: |
+ Intl.Segmenter.prototype.segment( string )
+
+ 3. Let string be ? ToString(string).
+features: [Intl.Segmenter]
+---*/
+
+const tests = [
+ [[], "undefined"],
+ [[undefined], "undefined"],
+ [[null], "null"],
+ [[true], "true"],
+ [[false], "false"],
+ [[12], "12"],
+ [[1.23], "1.23"],
+ [[["a", "b"]], "a"],
+ [[{}], "["], // "[object Object]"
+];
+
+const segmenter = new Intl.Segmenter("en", { "granularity": "word" });
+for (const [args, expected] of tests) {
+ const segments = segmenter.segment(...args);
+ const actual = [...segments][0].segment;
+ assert.sameValue(actual, expected, `Expected segment "${expected}", found "${actual}" for arguments ${args}`);
+}
+
+const symbol = Symbol();
+assert.throws(TypeError, () => segmenter.segment(symbol));
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/segment-word-iterable.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/segment-word-iterable.js
new file mode 100644
index 0000000000..af7b9598d5
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/segment-word-iterable.js
@@ -0,0 +1,57 @@
+// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
+// Copyright 2018 the V8 project authors. All rights reserved.
+// Copyright 2020 Apple Inc. 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 )
+includes: [compareArray.js]
+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
+ ]) {
+ let segments = [];
+ for (const v of seg.segment(text)) {
+ assert.sameValue("string", typeof v.segment);
+ 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(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);
+ }
+ assert.sameValue(text, segments.join(''));
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/segment/shell.js b/js/src/tests/test262/intl402/Segmenter/prototype/segment/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/segment/shell.js
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/shell.js b/js/src/tests/test262/intl402/Segmenter/prototype/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/shell.js
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/toStringTag/browser.js b/js/src/tests/test262/intl402/Segmenter/prototype/toStringTag/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/toStringTag/browser.js
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/toStringTag/shell.js b/js/src/tests/test262/intl402/Segmenter/prototype/toStringTag/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/toStringTag/shell.js
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/toStringTag/toString.js b/js/src/tests/test262/intl402/Segmenter/prototype/toStringTag/toString.js
new file mode 100644
index 0000000000..b2bb14f326
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/toStringTag/toString.js
@@ -0,0 +1,19 @@
+// |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-intl.Segmenter.prototype-@@tostringtag
+description: >
+ Checks Object.prototype.toString with Intl.Segmenter objects.
+info: |
+ Intl.Segmenter.prototype[ @@toStringTag ]
+
+ The initial value of the @@toStringTag property is the string value "Intl.Segmenter".
+features: [Intl.Segmenter]
+---*/
+
+assert.sameValue(Object.prototype.toString.call(Intl.Segmenter.prototype), "[object Intl.Segmenter]");
+assert.sameValue(Object.prototype.toString.call(new Intl.Segmenter()), "[object Intl.Segmenter]");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/toStringTag/toStringTag.js b/js/src/tests/test262/intl402/Segmenter/prototype/toStringTag/toStringTag.js
new file mode 100644
index 0000000000..a5ce6a1c39
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/prototype/toStringTag/toStringTag.js
@@ -0,0 +1,26 @@
+// |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-intl.Segmenter.prototype-@@tostringtag
+description: >
+ Checks the @@toStringTag property of the Segmenter prototype object.
+info: |
+ Intl.Segmenter.prototype[ @@toStringTag ]
+
+ The initial value of the @@toStringTag property is the string value "Intl.Segmenter".
+
+ This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+features: [Intl.Segmenter, Symbol.toStringTag]
+---*/
+
+verifyProperty(Intl.Segmenter.prototype, Symbol.toStringTag, {
+ value: "Intl.Segmenter",
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Segmenter/shell.js b/js/src/tests/test262/intl402/Segmenter/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Segmenter/shell.js