[Intl] Add unit tests for Intl.Segmenter
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}
This commit is contained in:
parent
fdfdce1d1e
commit
994b23945c
@ -31,6 +31,13 @@
|
||||
'overrides/caching': [PASS, FAIL],
|
||||
|
||||
'date-format/constructor-order': [FAIL],
|
||||
|
||||
# https://bugs.chromium.org/p/v8/issues/detail?id=6891
|
||||
'segmenter/segment': [FAIL],
|
||||
'segmenter/segment-iterator': [FAIL],
|
||||
'segmenter/segment-iterator-following': [FAIL],
|
||||
'segmenter/segment-iterator-next': [FAIL],
|
||||
'segmenter/segment-iterator-preceding': [FAIL],
|
||||
}], # ALWAYS
|
||||
|
||||
['variant == no_wasm_traps', {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-lineBreakStyle license that can be
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-lineBreakStyle license that can be
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
|
17
test/intl/segmenter/segment-iterator-following.js
Normal file
17
test/intl/segmenter/segment-iterator-following.js
Normal file
@ -0,0 +1,17 @@
|
||||
// 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
|
||||
|
||||
const segmenter = new Intl.Segmenter();
|
||||
const text = "Hello World, Test 123! Foo Bar. How are you?";
|
||||
const iter = segmenter.segment(text);
|
||||
|
||||
assertEquals("function", typeof iter.following);
|
||||
|
||||
// 1.5.3.2 %SegmentIteratorPrototype%.following( [ from ] )
|
||||
// 3.b If from >= iterator.[[SegmentIteratorString]], throw a RangeError exception.
|
||||
assertDoesNotThrow(() => iter.following(text.length - 1));
|
||||
assertThrows(() => iter.following(text.length), RangeError);
|
||||
assertThrows(() => iter.following(text.length + 1), RangeError);
|
11
test/intl/segmenter/segment-iterator-next.js
Normal file
11
test/intl/segmenter/segment-iterator-next.js
Normal file
@ -0,0 +1,11 @@
|
||||
// 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
|
||||
|
||||
const segmenter = new Intl.Segmenter();
|
||||
const text = "Hello World, Test 123! Foo Bar. How are you?";
|
||||
const iter = segmenter.segment(text);
|
||||
|
||||
assertEquals("function", typeof iter.next);
|
21
test/intl/segmenter/segment-iterator-preceding.js
Normal file
21
test/intl/segmenter/segment-iterator-preceding.js
Normal file
@ -0,0 +1,21 @@
|
||||
// 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
|
||||
|
||||
const segmenter = new Intl.Segmenter();
|
||||
const text = "Hello World, Test 123! Foo Bar. How are you?";
|
||||
const iter = segmenter.segment(text);
|
||||
|
||||
assertEquals("function", typeof iter.preceding);
|
||||
|
||||
// 1.5.3.3 %SegmentIteratorPrototype%.preceding( [ from ] )
|
||||
// 3.b If ... from = 0, throw a RangeError exception.
|
||||
assertThrows(() => iter.preceding(0), RangeError);
|
||||
|
||||
// 1.5.3.3 %SegmentIteratorPrototype%.preceding( [ from ] )
|
||||
// 3.b If from > iterator.[[SegmentIteratorString]] ... , throw a RangeError exception.
|
||||
assertDoesNotThrow(() => iter.preceding(text.length - 1));
|
||||
assertDoesNotThrow(() => iter.preceding(text.length));
|
||||
assertThrows(() => iter.preceding(text.length + 1), RangeError);
|
13
test/intl/segmenter/segment-iterator.js
Normal file
13
test/intl/segmenter/segment-iterator.js
Normal file
@ -0,0 +1,13 @@
|
||||
// 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
|
||||
|
||||
const segmenter = new Intl.Segmenter();
|
||||
const text = "Hello World, Test 123! Foo Bar. How are you?";
|
||||
const iter = segmenter.segment(text);
|
||||
|
||||
assertEquals("number", typeof iter.position);
|
||||
assertEquals(0, iter.position);
|
||||
assertEquals("strig", typeof iter.breakType);
|
7
test/intl/segmenter/segment.js
Normal file
7
test/intl/segmenter/segment.js
Normal file
@ -0,0 +1,7 @@
|
||||
// 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);
|
Loading…
Reference in New Issue
Block a user