994b23945c
Bug: v8:6891 Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng Change-Id: I075c4f615a4366c34723104410e8445054a3cacd Reviewed-on: https://chromium-review.googlesource.com/c/1256867 Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Reviewed-by: Daniel Ehrenberg <littledan@chromium.org> Commit-Queue: Frank Tang <ftang@chromium.org> Cr-Commit-Position: refs/heads/master@{#56424}
300 lines
6.6 KiB
JavaScript
300 lines
6.6 KiB
JavaScript
// 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 segmenter = new Intl.Segmenter([], { granularity: "line" });
|
|
// The default lineBreakStyle is 'normal'
|
|
assertEquals("normal", segmenter.resolvedOptions().lineBreakStyle);
|
|
|
|
segmenter = new Intl.Segmenter();
|
|
assertEquals(undefined, segmenter.resolvedOptions().lineBreakStyle);
|
|
|
|
// The default granularity is 'grapheme'
|
|
assertEquals("grapheme", segmenter.resolvedOptions().granularity);
|
|
|
|
assertEquals(
|
|
undefined,
|
|
new Intl.Segmenter(["sr"], { lineBreakStyle: "strict" }).resolvedOptions()
|
|
.lineBreakStyle
|
|
);
|
|
|
|
assertEquals(
|
|
"grapheme",
|
|
new Intl.Segmenter(["sr"], { lineBreakStyle: "strict" }).resolvedOptions()
|
|
.granularity
|
|
);
|
|
|
|
assertEquals(
|
|
undefined,
|
|
new Intl.Segmenter(["sr"], { lineBreakStyle: "normal" }).resolvedOptions()
|
|
.lineBreakStyle
|
|
);
|
|
|
|
assertEquals(
|
|
"grapheme",
|
|
new Intl.Segmenter(["sr"], { lineBreakStyle: "normal" }).resolvedOptions()
|
|
.granularity
|
|
);
|
|
|
|
assertEquals(
|
|
undefined,
|
|
new Intl.Segmenter(["sr"], { lineBreakStyle: "loose" }).resolvedOptions()
|
|
.lineBreakStyle
|
|
);
|
|
|
|
assertEquals(
|
|
"grapheme",
|
|
new Intl.Segmenter(["sr"], { lineBreakStyle: "loose" }).resolvedOptions()
|
|
.granularity
|
|
);
|
|
|
|
assertEquals(
|
|
"word",
|
|
new Intl.Segmenter(["sr"], { granularity: "word" }).resolvedOptions()
|
|
.granularity
|
|
);
|
|
|
|
assertEquals(
|
|
undefined,
|
|
new Intl.Segmenter(["sr"], { granularity: "word" }).resolvedOptions()
|
|
.lineBreakStyle
|
|
);
|
|
|
|
assertEquals(
|
|
"grapheme",
|
|
new Intl.Segmenter(["sr"], { granularity: "grapheme" }).resolvedOptions()
|
|
.granularity
|
|
);
|
|
|
|
assertEquals(
|
|
undefined,
|
|
new Intl.Segmenter(["sr"], { granularity: "grapheme" }).resolvedOptions()
|
|
.lineBreakStyle
|
|
);
|
|
|
|
assertEquals(
|
|
"sentence",
|
|
new Intl.Segmenter(["sr"], { granularity: "sentence" }).resolvedOptions()
|
|
.granularity
|
|
);
|
|
|
|
assertEquals(
|
|
undefined,
|
|
new Intl.Segmenter(["sr"], { granularity: "sentence" }).resolvedOptions()
|
|
.lineBreakStyle
|
|
);
|
|
|
|
assertEquals(
|
|
"line",
|
|
new Intl.Segmenter(["sr"], { granularity: "line" }).resolvedOptions()
|
|
.granularity
|
|
);
|
|
|
|
assertEquals(
|
|
"normal",
|
|
new Intl.Segmenter(["sr"], { granularity: "line" }).resolvedOptions()
|
|
.lineBreakStyle
|
|
);
|
|
|
|
assertEquals(
|
|
"grapheme",
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "loose",
|
|
granularity: "grapheme"
|
|
}).resolvedOptions().granularity
|
|
);
|
|
|
|
assertEquals(
|
|
undefined,
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "loose",
|
|
granularity: "grapheme"
|
|
}).resolvedOptions().lineBreakStyle
|
|
);
|
|
|
|
assertEquals(
|
|
"grapheme",
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "strict",
|
|
granularity: "grapheme"
|
|
}).resolvedOptions().granularity
|
|
);
|
|
|
|
assertEquals(
|
|
undefined,
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "strict",
|
|
granularity: "grapheme"
|
|
}).resolvedOptions().lineBreakStyle
|
|
);
|
|
|
|
assertEquals(
|
|
"grapheme",
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "normal",
|
|
granularity: "grapheme"
|
|
}).resolvedOptions().granularity
|
|
);
|
|
|
|
assertEquals(
|
|
undefined,
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "normal",
|
|
granularity: "grapheme"
|
|
}).resolvedOptions().lineBreakStyle
|
|
);
|
|
|
|
assertEquals(
|
|
"word",
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "loose",
|
|
granularity: "word"
|
|
}).resolvedOptions().granularity
|
|
);
|
|
|
|
assertEquals(
|
|
undefined,
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "loose",
|
|
granularity: "word"
|
|
}).resolvedOptions().lineBreakStyle
|
|
);
|
|
|
|
assertEquals(
|
|
"word",
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "strict",
|
|
granularity: "word"
|
|
}).resolvedOptions().granularity
|
|
);
|
|
|
|
assertEquals(
|
|
undefined,
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "strict",
|
|
granularity: "word"
|
|
}).resolvedOptions().lineBreakStyle
|
|
);
|
|
|
|
assertEquals(
|
|
"word",
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "normal",
|
|
granularity: "word"
|
|
}).resolvedOptions().granularity
|
|
);
|
|
|
|
assertEquals(
|
|
undefined,
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "normal",
|
|
granularity: "word"
|
|
}).resolvedOptions().lineBreakStyle
|
|
);
|
|
|
|
assertEquals(
|
|
"sentence",
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "loose",
|
|
granularity: "sentence"
|
|
}).resolvedOptions().granularity
|
|
);
|
|
|
|
assertEquals(
|
|
undefined,
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "loose",
|
|
granularity: "sentence"
|
|
}).resolvedOptions().lineBreakStyle
|
|
);
|
|
|
|
assertEquals(
|
|
"sentence",
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "strict",
|
|
granularity: "sentence"
|
|
}).resolvedOptions().granularity
|
|
);
|
|
|
|
assertEquals(
|
|
undefined,
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "strict",
|
|
granularity: "sentence"
|
|
}).resolvedOptions().lineBreakStyle
|
|
);
|
|
|
|
assertEquals(
|
|
"sentence",
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "normal",
|
|
granularity: "sentence"
|
|
}).resolvedOptions().granularity
|
|
);
|
|
|
|
assertEquals(
|
|
"normal",
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "normal",
|
|
granularity: "line"
|
|
}).resolvedOptions().lineBreakStyle
|
|
);
|
|
|
|
assertEquals(
|
|
"line",
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "loose",
|
|
granularity: "line"
|
|
}).resolvedOptions().granularity
|
|
);
|
|
|
|
assertEquals(
|
|
"loose",
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "loose",
|
|
granularity: "line"
|
|
}).resolvedOptions().lineBreakStyle
|
|
);
|
|
|
|
assertEquals(
|
|
"line",
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "strict",
|
|
granularity: "line"
|
|
}).resolvedOptions().granularity
|
|
);
|
|
|
|
assertEquals(
|
|
"strict",
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "strict",
|
|
granularity: "line"
|
|
}).resolvedOptions().lineBreakStyle
|
|
);
|
|
|
|
assertEquals(
|
|
"line",
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "normal",
|
|
granularity: "line"
|
|
}).resolvedOptions().granularity
|
|
);
|
|
|
|
assertEquals(
|
|
"normal",
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "normal",
|
|
granularity: "line"
|
|
}).resolvedOptions().lineBreakStyle
|
|
);
|
|
|
|
assertEquals("ar", new Intl.Segmenter(["ar"]).resolvedOptions().locale);
|
|
|
|
assertEquals("ar", new Intl.Segmenter(["ar", "en"]).resolvedOptions().locale);
|
|
|
|
assertEquals("fr", new Intl.Segmenter(["fr", "en"]).resolvedOptions().locale);
|
|
|
|
assertEquals("ar", new Intl.Segmenter(["xyz", "ar"]).resolvedOptions().locale);
|