diff --git a/implementation-contributed/v8/intl/segmenter/segment-iterator-breakType.js b/implementation-contributed/v8/intl/segmenter/segment-iterator-breakType.js deleted file mode 100644 index ea5f523519..0000000000 --- a/implementation-contributed/v8/intl/segmenter/segment-iterator-breakType.js +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2018 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --harmony-intl-segmenter - -const segmenter = new Intl.Segmenter(); -const text = "Hello World, Test 123! Foo Bar. How are you?"; -const iter = segmenter.segment(text); - -assertEquals(undefined, iter.breakType); diff --git a/implementation-contributed/v8/intl/segmenter/segment-iterator-following.js b/implementation-contributed/v8/intl/segmenter/segment-iterator-following.js deleted file mode 100644 index c92cbaac35..0000000000 --- a/implementation-contributed/v8/intl/segmenter/segment-iterator-following.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2018 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --harmony-intl-segmenter - -const segmenter = new Intl.Segmenter(); -const text = "Hello World, Test 123! Foo Bar. How are you?"; -const iter = segmenter.segment(text); - -assertEquals("function", typeof iter.following); - -assertThrows(() => iter.following("ABC"), RangeError); -assertThrows(() => iter.following(null), RangeError); -assertThrows(() => iter.following(1.4), RangeError); -assertThrows(() => iter.following(-3), RangeError); - -// 1.5.3.2 %SegmentIteratorPrototype%.following( [ from ] ) -// 3.b If from >= iterator.[[SegmentIteratorString]], throw a RangeError exception. -assertDoesNotThrow(() => iter.following(text.length - 1)); -assertThrows(() => iter.following(text.length), RangeError); -assertThrows(() => iter.following(text.length + 1), RangeError); diff --git a/implementation-contributed/v8/intl/segmenter/segment-iterator-next.js b/implementation-contributed/v8/intl/segmenter/segment-iterator-next.js deleted file mode 100644 index 9aa40494ca..0000000000 --- a/implementation-contributed/v8/intl/segmenter/segment-iterator-next.js +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2018 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --harmony-intl-segmenter - -const segmenter = new Intl.Segmenter(); -const text = "Hello World, Test 123! Foo Bar. How are you?"; -const iter = segmenter.segment(text); - -assertEquals("function", typeof iter.next); diff --git a/implementation-contributed/v8/intl/segmenter/segment-iterator-ownPropertyDescriptor.js b/implementation-contributed/v8/intl/segmenter/segment-iterator-ownPropertyDescriptor.js deleted file mode 100644 index e706a0afb7..0000000000 --- a/implementation-contributed/v8/intl/segmenter/segment-iterator-ownPropertyDescriptor.js +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2018 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --harmony-intl-segmenter - -let seg = new Intl.Segmenter(); -let descriptor = Object.getOwnPropertyDescriptor( - Intl.Segmenter, "supportedLocalesOf"); -assertTrue(descriptor.writable); -assertFalse(descriptor.enumerable); -assertTrue(descriptor.configurable); - -// ecma402 #sec-Intl.Segmenter.prototype -// Intl.Segmenter.prototype -// The value of Intl.Segmenter.prototype is %SegmenterPrototype%. -// This property has the attributes -// { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. -descriptor = Object.getOwnPropertyDescriptor(Intl.Segmenter, "prototype"); -assertFalse(descriptor.writable); -assertFalse(descriptor.enumerable); -assertFalse(descriptor.configurable); - -for (let func of ["segment", "resolvedOptions"]) { - let descriptor = Object.getOwnPropertyDescriptor( - Intl.Segmenter.prototype, func); - assertTrue(descriptor.writable); - assertFalse(descriptor.enumerable); - assertTrue(descriptor.configurable); -} - -let segmentIterator = seg.segment('text'); -let prototype = Object.getPrototypeOf(segmentIterator); -for (let func of ["next", "following", "preceding"]) { - let descriptor = Object.getOwnPropertyDescriptor(prototype, func); - assertTrue(descriptor.writable); - assertFalse(descriptor.enumerable); - assertTrue(descriptor.configurable); -} - -function checkGetterProperty(prototype, property) { - let desc = Object.getOwnPropertyDescriptor(prototype, property); - assertEquals(`get ${property}`, desc.get.name); - assertEquals('function', typeof desc.get) - assertEquals(undefined, desc.set); - assertFalse(desc.enumerable); - assertTrue(desc.configurable); -} - -// Test the descriptor is correct for properties. -checkGetterProperty(prototype, 'position'); -checkGetterProperty(prototype, 'breakType'); - -// Test the SegmentIteratorPrototype methods are called with same -// receiver and won't throw. -assertDoesNotThrow(() => prototype.next.call(segmentIterator)); -assertDoesNotThrow(() => prototype.following.call(segmentIterator)); -assertDoesNotThrow(() => prototype.preceding.call(segmentIterator)); - -// Test the SegmentIteratorPrototype methods are called with a different -// receiver and correctly throw. -var otherReceivers = [ - 1, 123.45, undefined, null, "string", true, false, - Intl, Intl.Segmenter, Intl.Segmenter.prototype, - prototype, - new Intl.Segmenter(), - new Intl.Collator(), - new Intl.DateTimeFormat(), - new Intl.NumberFormat(), -]; -for (let rec of otherReceivers) { - assertThrows(() => prototype.next.call(rec), TypeError); - assertThrows(() => prototype.following.call(rec), TypeError); - assertThrows(() => prototype.preceding.call(rec), TypeError); -} - -// Check the property of the return object of next() -let nextReturn = segmentIterator.next(); - -function checkProperty(obj, property) { - let desc = Object.getOwnPropertyDescriptor(obj, property); - assertTrue(desc.writable); - assertTrue(desc.enumerable); - assertTrue(desc.configurable); -} - -checkProperty(nextReturn, 'done'); -checkProperty(nextReturn, 'value'); -checkProperty(nextReturn.value, 'segment'); -checkProperty(nextReturn.value, 'breakType'); -checkProperty(nextReturn.value, 'position'); diff --git a/implementation-contributed/v8/intl/segmenter/segment-iterator-position.js b/implementation-contributed/v8/intl/segmenter/segment-iterator-position.js deleted file mode 100644 index 93c529a53e..0000000000 --- a/implementation-contributed/v8/intl/segmenter/segment-iterator-position.js +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2018 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --harmony-intl-segmenter - -const segmenter = new Intl.Segmenter(); -const text = "Hello World, Test 123! Foo Bar. How are you?"; -const iter = segmenter.segment(text); - -assertEquals(0, iter.position); diff --git a/implementation-contributed/v8/intl/segmenter/segment-iterator-preceding.js b/implementation-contributed/v8/intl/segmenter/segment-iterator-preceding.js deleted file mode 100644 index 0130a4d229..0000000000 --- a/implementation-contributed/v8/intl/segmenter/segment-iterator-preceding.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2018 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --harmony-intl-segmenter - -const segmenter = new Intl.Segmenter(); -const text = "Hello World, Test 123! Foo Bar. How are you?"; -const iter = segmenter.segment(text); - -assertEquals("function", typeof iter.preceding); - -assertThrows(() => iter.preceding("ABC"), RangeError); -assertThrows(() => iter.preceding(null), RangeError); -assertThrows(() => iter.preceding(1.4), RangeError); -assertThrows(() => iter.preceding(-3), RangeError); - -// 1.5.3.3 %SegmentIteratorPrototype%.preceding( [ from ] ) -// 3.b If ... from = 0, throw a RangeError exception. -assertThrows(() => iter.preceding(0), RangeError); - -// 1.5.3.3 %SegmentIteratorPrototype%.preceding( [ from ] ) -// 3.b If from > iterator.[[SegmentIteratorString]] ... , throw a RangeError exception. -assertDoesNotThrow(() => iter.preceding(text.length - 1)); -assertDoesNotThrow(() => iter.preceding(text.length)); -assertThrows(() => iter.preceding(text.length + 1), RangeError); diff --git a/implementation-contributed/v8/intl/segmenter/segment-iterator.js b/implementation-contributed/v8/intl/segmenter/segment-iterator.js deleted file mode 100644 index 2821c8faaa..0000000000 --- a/implementation-contributed/v8/intl/segmenter/segment-iterator.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2018 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --harmony-intl-segmenter - -const text = "Hello World, Test 123! Foo Bar. How are you?"; -for (const granularity of ["grapheme", "word", "sentence", "line"]) { - const segmenter = new Intl.Segmenter("en", { granularity }); - const iter = segmenter.segment(text); - - assertEquals("number", typeof iter.position); - assertEquals(0, iter.position); - if (granularity === "grapheme") { - assertEquals(undefined, iter.breakType); - } else { - assertEquals("string", typeof iter.breakType); - } -} diff --git a/test/intl402/Segmenter/iterator/branding.js b/test/intl402/Segmenter/iterator/branding.js new file mode 100644 index 0000000000..f3fb02d80d --- /dev/null +++ b/test/intl402/Segmenter/iterator/branding.js @@ -0,0 +1,23 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-segment-iterator-prototype +description: Verifies the behavior for the iterators. +features: [Intl.Segmenter] +---*/ + +const otherReceivers = [ + 1, 123.45, undefined, null, "string", true, false, + Intl, Intl.Segmenter, Intl.Segmenter.prototype, + prototype, + new Intl.Segmenter(), + new Intl.Collator(), + new Intl.DateTimeFormat(), + new Intl.NumberFormat(), +]; +for (const rec of otherReceivers) { + assert.throws(TypeError, () => prototype.next.call(rec)); + assert.throws(TypeError, () => prototype.following.call(rec)); + assert.throws(TypeError, () => prototype.preceding.call(rec)); +} diff --git a/test/intl402/Segmenter/iterator/breakType.js b/test/intl402/Segmenter/iterator/breakType.js new file mode 100644 index 0000000000..bf6bd70091 --- /dev/null +++ b/test/intl402/Segmenter/iterator/breakType.js @@ -0,0 +1,14 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-segment-iterator-prototype +description: Verifies the behavior for the iterators. +features: [Intl.Segmenter] +---*/ + +const segmenter = new Intl.Segmenter(); +const text = "Hello World, Test 123! Foo Bar. How are you?"; +const iter = segmenter.segment(text); + +assert.sameValue(iter.breakType, undefined); diff --git a/test/intl402/Segmenter/iterator/following.js b/test/intl402/Segmenter/iterator/following.js new file mode 100644 index 0000000000..7ae6316507 --- /dev/null +++ b/test/intl402/Segmenter/iterator/following.js @@ -0,0 +1,36 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-segment-iterator-prototype +description: Verifies the behavior for the iterators. +features: [Intl.Segmenter] +---*/ + +const segmenter = new Intl.Segmenter(); +const text = "Hello World, Test 123! Foo Bar. How are you?"; +const iter = segmenter.segment(text); + +assert.sameValue("function", typeof iter.following); + +const tests = [ + ["3", 4], + ["ABC", 1], + [null, 1], + [true, 2], + [1.4, 2], + [{ valueOf() { return 5; } }, 6], + [0, 1], + [text.length - 1, text.length], +]; + +for (const [input, position] of tests) { + assert.sameValue(iter.following(0 | input), false); + assert.sameValue(iter.position, position, String(input)); +} + +assert.throws(RangeError, () => iter.following(-3)); +// 1.5.3.2 %SegmentIteratorPrototype%.following( [ from ] ) +// 3.b If from >= iterator.[[SegmentIteratorString]], throw a RangeError exception. +assert.throws(RangeError, () => iter.following(text.length)); +assert.throws(RangeError, () => iter.following(text.length + 1)); diff --git a/test/intl402/Segmenter/iterator/granularity.js b/test/intl402/Segmenter/iterator/granularity.js new file mode 100644 index 0000000000..d889f91a7d --- /dev/null +++ b/test/intl402/Segmenter/iterator/granularity.js @@ -0,0 +1,22 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-segment-iterator-prototype +description: Verifies the behavior for the iterators. +features: [Intl.Segmenter] +---*/ + +const text = "Hello World, Test 123! Foo Bar. How are you?"; +for (const granularity of ["grapheme", "word", "sentence", "line"]) { + const segmenter = new Intl.Segmenter("en", { granularity }); + const iter = segmenter.segment(text); + + assert.sameValue(typeof iter.position, "number"); + assert.sameValue(iter.position, 0); + if (granularity === "grapheme") { + assert.sameValue(iter.breakType, undefined); + } else { + assert.sameValue(typeof iter.breakType, "string"); + } +} diff --git a/test/intl402/Segmenter/iterator/next.js b/test/intl402/Segmenter/iterator/next.js new file mode 100644 index 0000000000..df9401036c --- /dev/null +++ b/test/intl402/Segmenter/iterator/next.js @@ -0,0 +1,14 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-segment-iterator-prototype +description: Verifies the behavior for the iterators. +features: [Intl.Segmenter] +---*/ + +const segmenter = new Intl.Segmenter(); +const text = "Hello World, Test 123! Foo Bar. How are you?"; +const iter = segmenter.segment(text); + +assert.sameValue(typeof iter.next, "function"); diff --git a/test/intl402/Segmenter/iterator/position.js b/test/intl402/Segmenter/iterator/position.js new file mode 100644 index 0000000000..21a1d08220 --- /dev/null +++ b/test/intl402/Segmenter/iterator/position.js @@ -0,0 +1,14 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-segment-iterator-prototype +description: Verifies the behavior for the iterators. +features: [Intl.Segmenter] +---*/ + +const segmenter = new Intl.Segmenter(); +const text = "Hello World, Test 123! Foo Bar. How are you?"; +const iter = segmenter.segment(text); + +assert.sameValue(iter.position, 0); diff --git a/test/intl402/Segmenter/iterator/preceding.js b/test/intl402/Segmenter/iterator/preceding.js new file mode 100644 index 0000000000..55eae7f96c --- /dev/null +++ b/test/intl402/Segmenter/iterator/preceding.js @@ -0,0 +1,41 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-segment-iterator-prototype +description: Verifies the behavior for the iterators. +features: [Intl.Segmenter] +---*/ + +const segmenter = new Intl.Segmenter(); +const text = "Hello World, Test 123! Foo Bar. How are you?"; +const iter = segmenter.segment(text); + +assert.sameValue("function", typeof iter.following); + +const tests = [ + ["3", 2], + [true, 0], + [1.4, 0], + [{ valueOf() { return 5; } }, 4], + [text.length - 1, text.length - 2], + [text.length, text.length - 1], +]; + +for (const [input, position] of tests) { + assert.sameValue(iter.preceding(0 | input), false); + assert.sameValue(iter.position, position, String(input)); +} + +assert.throws(RangeError, () => iter.preceding("ABC")); +assert.throws(RangeError, () => iter.preceding(null)); +assert.throws(RangeError, () => iter.preceding(1.4)); +assert.throws(RangeError, () => iter.preceding(-3)); + +// 1.5.3.3 %SegmentIteratorPrototype%.preceding( [ from ] ) +// 3.b If ... from = 0, throw a RangeError exception. +assert.throws(RangeError, () => iter.preceding(0)); + +// 1.5.3.3 %SegmentIteratorPrototype%.preceding( [ from ] ) +// 3.b If from > iterator.[[SegmentIteratorString]] ... , throw a RangeError exception. +assert.throws(RangeError, () => iter.preceding(text.length + 1)); diff --git a/test/intl402/Segmenter/iterator/prototype.js b/test/intl402/Segmenter/iterator/prototype.js new file mode 100644 index 0000000000..86c0f21d07 --- /dev/null +++ b/test/intl402/Segmenter/iterator/prototype.js @@ -0,0 +1,27 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-segment-iterator-prototype +description: Verifies the behavior for the iterators. +includes: [propertyHelper.js] +features: [Intl.Segmenter] +---*/ + +const prototype = Object.getPrototypeOf((new Intl.Segmenter()).segment('text')); +for (const func of ["next", "following", "preceding"]) { + verifyProperty(prototype, func, { + writable: true, + enumerable: false, + configurable: true, + }); +} + +for (const property of ["position", "breakType"]) { + let desc = Object.getOwnPropertyDescriptor(prototype, property); + assert.sameValue(desc.get.name, `get ${property}`); + assert.sameValue(typeof desc.get, "function") + assert.sameValue(desc.set, undefined); + assert.sameValue(desc.enumerable, false); + assert.sameValue(desc.configurable, true); +}