bf95c6fa67
Design doc https://goo.gl/fgc2Cp Bug: v8:6891 Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng Change-Id: I8bc5ea3137fd1b66213403ae9ea3461f40efc977 Reviewed-on: https://chromium-review.googlesource.com/c/1257923 Commit-Queue: Frank Tang <ftang@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Cr-Commit-Position: refs/heads/master@{#56757}
40 lines
1.6 KiB
JavaScript
40 lines
1.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
|
|
|
|
assertEquals("function", typeof Intl.Segmenter.prototype.segment);
|
|
assertEquals(1, Intl.Segmenter.prototype.segment.length);
|
|
|
|
let seg = new Intl.Segmenter("en", {granularity: "word"})
|
|
let res;
|
|
|
|
// test with 0 args
|
|
assertDoesNotThrow(() => res = seg.segment())
|
|
// test with 1 arg
|
|
assertDoesNotThrow(() => res = seg.segment("hello"))
|
|
assertEquals("hello", res.next().value.segment);
|
|
// test with 2 args
|
|
assertDoesNotThrow(() => res = seg.segment("hello world"))
|
|
assertEquals("hello", res.next().value.segment);
|
|
|
|
// test with other types
|
|
assertDoesNotThrow(() => res = seg.segment(undefined))
|
|
assertEquals("undefined", res.next().value.segment);
|
|
assertDoesNotThrow(() => res = seg.segment(null))
|
|
assertEquals("null", res.next().value.segment);
|
|
assertDoesNotThrow(() => res = seg.segment(true))
|
|
assertEquals("true", res.next().value.segment);
|
|
assertDoesNotThrow(() => res = seg.segment(false))
|
|
assertEquals("false", res.next().value.segment);
|
|
assertDoesNotThrow(() => res = seg.segment(1234))
|
|
assertEquals("1234", res.next().value.segment);
|
|
assertDoesNotThrow(() => res = seg.segment(3.1415926))
|
|
assertEquals("3.1415926", res.next().value.segment);
|
|
assertDoesNotThrow(() => res = seg.segment(["hello","world"]))
|
|
assertEquals("hello", res.next().value.segment);
|
|
assertDoesNotThrow(() => res = seg.segment({k: 'v'}))
|
|
assertEquals("[", res.next().value.segment);
|
|
assertThrows(() => res = seg.segment(Symbol()), TypeError)
|