64da43ef36
This is a reland of c9c3ec4c14
Original change's description:
> [intl] Clean up intl_segmenter flag
>
> Intl.Segmenter shipped in m87 and launched.
>
> Bug: v8:11225
> Change-Id: I4213e261e1aea717c1281f19785a8c29ff1bbd8b
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2570461
> Commit-Queue: Frank Tang <ftang@chromium.org>
> Reviewed-by: Shu-yu Guo <syg@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#71653}
Bug: v8:11225, v8:11240
Change-Id: Ibded9038671862d90206d328f8a12db51c40e63c
Cq-Include-Trybots: luci.v8.try:v8_linux64_gc_stress_custom_snapshot_dbg_ng,v8_linux_arm64_gc_stress_dbg_ng,v8_linux_gc_stress_dbg_ng,v8_mac64_gc_stress_dbg_ng
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2579043
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71691}
29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
// Copyright 2020 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.
|
|
|
|
// Test to ensure the calling of containing() won't impact the calling of
|
|
// the next() method.
|
|
const segmenter = new Intl.Segmenter();
|
|
const man_light_skin_tone_red_hair =
|
|
"\uD83D\uDC68\uD83C\uDFFB\u200D\uD83E\uDDB0";
|
|
const input = "ABCD" + man_light_skin_tone_red_hair;
|
|
const segments = segmenter.segment(input);
|
|
for (let i = 0; i < input.length; i++) {
|
|
let idx = i < 4 ? i : 4;
|
|
let expectation = i < 4 ? input[i] : man_light_skin_tone_red_hair;
|
|
assertEquals({segment: expectation, index: idx, input},
|
|
segments.containing(i));
|
|
let result = [];
|
|
for (let v of segments) {
|
|
result.push(v.segment);
|
|
result.push(":");
|
|
// Ensure the value n passing into segments.containing(n) will not impact
|
|
// the result of next().
|
|
assertEquals({segment: expectation, index: idx, input},
|
|
segments.containing(i));
|
|
}
|
|
assertEquals("A:B:C:D:" + man_light_skin_tone_red_hair + ":",
|
|
result.join(""));
|
|
}
|