v8/test/intl/segmenter/segment-line-following-modes.js
Jungshik Shin a46bc03591 Prepare for ICU roll to 63.1
In Chromium tree, ICU is rolled to 63.1. And, auto-roller will soon
try to roll ICU in v8 to 63.1.  Due to a nodejs trybot issue,
autoroll needs a manual intervention. In the meantime, this CL
will get rid of other blocking issues for ICU update.

Prepare for the ICU roll by revising test/intl as following:

* Line breaking loose mode is now supported in the
Chromium's copy of ICU. Adjust the test expectation.

* ICU's uloc_* can handle overlong locale ids. Drop tests
that are not valid any more.

Once ICU is rolled, a couple of TSAN-suppressed tests can
be unsuppressed, but that has to be done in a separate CL.

Bug: chromium:893196,v8:8272, v8:8110
Test: intl/*, test262/test402/*
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: I17f11457b61376b1e8d41bbbc951fa6cd3355a54
Reviewed-on: https://chromium-review.googlesource.com/c/1289369
Commit-Queue: Jungshik Shin <jshin@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57105}
2018-10-30 05:01:18 +00:00

58 lines
2.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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 breakCounts = {};
for (const locale of ["en", "fr", "ja", "zh", "ko"]) {
for (const lineBreakStyle of ["strict", "normal", "loose"]) {
const seg = new Intl.Segmenter(
[locale], {granularity: "line", lineBreakStyle: lineBreakStyle});
let opportunity = 0;
for (const text of [
// We know the following data caused different line break results between
// different modes.
// https://www.w3.org/TR/css-text-3/#propdef-line-break
// Japanese small kana or the Katakana-Hiragana prolonged sound mark
"あぁーぃーあーいーぁーぃー",
// hyphens:
// U+2010, U+2013, 〜 U+301C, U+30A0
"ABCDEFGHI〜JKLMNO",
// iteration marks:
// 々 U+3005, 〻 U+303B, ゝ U+309D, ゞ U+309E, ヽ U+30FD, ヾ U+30FE
"あ々あ〻あゝあゞあヽあヾあ",
// centered punctuation marks:
// ・ U+30FB, U+FF1A, U+FF1B, ・ U+FF65, ‼ U+203C
"ABC・DEFGHIJKL・MNO‼PQR",
// centered punctuation marks:
// ⁇ U+2047, ⁈ U+2048, ⁉ U+2049, U+FF01, U+FF1F
"ABC⁇DEF⁈GHI⁉JKLMNOPQR",
]) {
const iter = seg.segment(text);
while (!iter.following()) {
opportunity++;
}
}
breakCounts[locale + "-" + lineBreakStyle] = opportunity;
}
}
// In Japanese
// Just test the break count in loose mode is greater than normal mode.
assertTrue(breakCounts["ja-loose"] > breakCounts["ja-normal"]);
// and test the break count in normal mode is greater than strict mode.
assertTrue(breakCounts["ja-normal"] > breakCounts["ja-strict"]);
// In Chinese
// Just test the break count in loose mode is greater than normal mode.
assertTrue(breakCounts["zh-loose"] > breakCounts["zh-normal"]);
// and test the break count in normal mode is greater than strict mode.
assertTrue(breakCounts["zh-normal"] > breakCounts["zh-strict"]);
// In English, French and Korean
assertTrue(breakCounts["en-loose"] >= breakCounts["en-normal"]);
assertTrue(breakCounts["fr-loose"] >= breakCounts["fr-normal"]);
assertTrue(breakCounts["ko-loose"] >= breakCounts["ko-normal"]);
// and test the break count in normal mode is greater than strict mode.
assertTrue(breakCounts["en-normal"] > breakCounts["en-strict"]);
assertTrue(breakCounts["fr-normal"] > breakCounts["fr-strict"]);
assertTrue(breakCounts["ko-normal"] > breakCounts["ko-strict"]);