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}
40 lines
1.8 KiB
JavaScript
40 lines
1.8 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.
|
|
|
|
assertEquals("function", typeof Intl.Segmenter.prototype.segment);
|
|
assertEquals(1, Intl.Segmenter.prototype.segment.length);
|
|
|
|
let seg = new Intl.Segmenter("en", {granularity: "word"})
|
|
let segments;
|
|
|
|
// test with 0 args
|
|
assertDoesNotThrow(() => segments = seg.segment())
|
|
// test with 1 arg
|
|
assertDoesNotThrow(() => segments = seg.segment("hello"))
|
|
assertEquals("hello", segments.containing(0).input);
|
|
// test with 2 args
|
|
assertDoesNotThrow(() => segments = seg.segment("hello world"))
|
|
assertEquals("hello world", segments.containing(0).input);
|
|
|
|
// test with other types
|
|
assertDoesNotThrow(() => segments = seg.segment(undefined))
|
|
assertEquals("undefined", segments.containing(0).input);
|
|
assertDoesNotThrow(() => segments = seg.segment(null))
|
|
assertEquals("null", segments.containing(0).input);
|
|
assertDoesNotThrow(() => segments = seg.segment(true))
|
|
assertEquals("true", segments.containing(0).input);
|
|
assertDoesNotThrow(() => segments = seg.segment(false))
|
|
assertEquals("false", segments.containing(0).input);
|
|
assertDoesNotThrow(() => segments = seg.segment(1234))
|
|
assertEquals("1234", segments.containing(0).input);
|
|
assertDoesNotThrow(() => segments = seg.segment(3.1415926))
|
|
assertEquals("3.1415926", segments.containing(0).input);
|
|
assertDoesNotThrow(() => segments = seg.segment(98765432109876543210987654321n))
|
|
assertEquals("98765432109876543210987654321", segments.containing(0).input);
|
|
assertDoesNotThrow(() => segments = seg.segment(["hello","world"]))
|
|
assertEquals("hello,world", segments.containing(0).input);
|
|
assertDoesNotThrow(() => segments = seg.segment({k: 'v'}))
|
|
assertEquals("[object Object]", segments.containing(0).input);
|
|
assertThrows(() => segments = seg.segment(Symbol()), TypeError)
|