diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/intl402/Segmenter/prototype/segment/next-inside-next.js | |
parent | Initial commit. (diff) | |
download | firefox-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/prototype/segment/next-inside-next.js')
-rw-r--r-- | js/src/tests/test262/intl402/Segmenter/prototype/segment/next-inside-next.js | 50 |
1 files changed, 50 insertions, 0 deletions
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); |