mirror of
https://github.com/tc39/test262.git
synced 2025-12-17 02:34:03 +01:00
23 lines
748 B
JavaScript
23 lines
748 B
JavaScript
// 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");
|
|
}
|
|
}
|