Commit 8c311273 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

[Intl] Rename position to index in Intl.Segmenter

Sync with
https://github.com/tc39/proposal-intl-segmenter/pull/55
and
https://github.com/tc39/test262/pull/1994

Bug: v8:8588
Change-Id: Ifc46779f156ea986e3dbe6a632a781bb7134112b
Reviewed-on: https://chromium-review.googlesource.com/c/1374997Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58301}
parent 60657604
...@@ -4846,8 +4846,8 @@ void Genesis::InitializeGlobal_harmony_intl_segmenter() { ...@@ -4846,8 +4846,8 @@ void Genesis::InitializeGlobal_harmony_intl_segmenter() {
false); false);
SimpleInstallGetter(isolate(), prototype, SimpleInstallGetter(isolate(), prototype,
factory()->InternalizeUtf8String("position"), factory()->InternalizeUtf8String("index"),
Builtins::kSegmentIteratorPrototypePosition, false); Builtins::kSegmentIteratorPrototypeIndex, false);
SimpleInstallGetter(isolate(), prototype, SimpleInstallGetter(isolate(), prototype,
factory()->InternalizeUtf8String("breakType"), factory()->InternalizeUtf8String("breakType"),
......
...@@ -1474,8 +1474,8 @@ namespace internal { ...@@ -1474,8 +1474,8 @@ namespace internal {
CPP(SegmentIteratorPrototypeFollowing) \ CPP(SegmentIteratorPrototypeFollowing) \
/* ecma402 #sec-segment-iterator-prototype-preceding */ \ /* ecma402 #sec-segment-iterator-prototype-preceding */ \
CPP(SegmentIteratorPrototypePreceding) \ CPP(SegmentIteratorPrototypePreceding) \
/* ecma402 #sec-segment-iterator-prototype-position */ \ /* ecma402 #sec-segment-iterator-prototype-index */ \
CPP(SegmentIteratorPrototypePosition) \ CPP(SegmentIteratorPrototypeIndex) \
/* ecma402 #sec-segment-iterator-prototype-next */ \ /* ecma402 #sec-segment-iterator-prototype-next */ \
CPP(SegmentIteratorPrototypeNext) \ CPP(SegmentIteratorPrototypeNext) \
/* ES #sec-string.prototype.normalize */ \ /* ES #sec-string.prototype.normalize */ \
......
...@@ -962,13 +962,13 @@ BUILTIN(SegmentIteratorPrototypePreceding) { ...@@ -962,13 +962,13 @@ BUILTIN(SegmentIteratorPrototypePreceding) {
return *isolate->factory()->ToBoolean(success.FromJust()); return *isolate->factory()->ToBoolean(success.FromJust());
} }
// ecma402 #sec-segment-iterator-prototype-position // ecma402 #sec-segment-iterator-prototype-index
BUILTIN(SegmentIteratorPrototypePosition) { BUILTIN(SegmentIteratorPrototypeIndex) {
const char* const method = "get %SegmentIteratorPrototype%.position"; const char* const method = "get %SegmentIteratorPrototype%.index";
HandleScope scope(isolate); HandleScope scope(isolate);
CHECK_RECEIVER(JSSegmentIterator, segment_iterator, method); CHECK_RECEIVER(JSSegmentIterator, segment_iterator, method);
return *JSSegmentIterator::Position(isolate, segment_iterator); return *JSSegmentIterator::Index(isolate, segment_iterator);
} }
BUILTIN(SegmenterConstructor) { BUILTIN(SegmenterConstructor) {
......
...@@ -68,7 +68,7 @@ MaybeHandle<JSSegmentIterator> JSSegmentIterator::Create( ...@@ -68,7 +68,7 @@ MaybeHandle<JSSegmentIterator> JSSegmentIterator::Create(
Intl::SetTextToBreakIterator(isolate, text, break_iterator); Intl::SetTextToBreakIterator(isolate, text, break_iterator);
segment_iterator->set_unicode_string(unicode_string); segment_iterator->set_unicode_string(unicode_string);
// 4. Let iterator.[[SegmentIteratorPosition]] be 0. // 4. Let iterator.[[SegmentIteratorIndex]] be 0.
// step 4 is stored inside break_iterator. // step 4 is stored inside break_iterator.
// 5. Let iterator.[[SegmentIteratorBreakType]] be undefined. // 5. Let iterator.[[SegmentIteratorBreakType]] be undefined.
...@@ -108,7 +108,7 @@ Handle<Object> JSSegmentIterator::BreakType() const { ...@@ -108,7 +108,7 @@ Handle<Object> JSSegmentIterator::BreakType() const {
return GetReadOnlyRoots().undefined_value_handle(); return GetReadOnlyRoots().undefined_value_handle();
case JSSegmenter::Granularity::LINE: case JSSegmenter::Granularity::LINE:
if (rule_status >= UBRK_LINE_SOFT && rule_status < UBRK_LINE_SOFT_LIMIT) { if (rule_status >= UBRK_LINE_SOFT && rule_status < UBRK_LINE_SOFT_LIMIT) {
// soft line breaks, positions at which a line break is acceptable but // soft line breaks, index at which a line break is acceptable but
// not required // not required
return GetReadOnlyRoots().soft_string_handle(); return GetReadOnlyRoots().soft_string_handle();
} }
...@@ -138,8 +138,8 @@ Handle<Object> JSSegmentIterator::BreakType() const { ...@@ -138,8 +138,8 @@ Handle<Object> JSSegmentIterator::BreakType() const {
} }
} }
// ecma402 #sec-segment-iterator-prototype-position // ecma402 #sec-segment-iterator-prototype-index
Handle<Object> JSSegmentIterator::Position( Handle<Object> JSSegmentIterator::Index(
Isolate* isolate, Handle<JSSegmentIterator> segment_iterator) { Isolate* isolate, Handle<JSSegmentIterator> segment_iterator) {
icu::BreakIterator* icu_break_iterator = icu::BreakIterator* icu_break_iterator =
segment_iterator->icu_break_iterator()->raw(); segment_iterator->icu_break_iterator()->raw();
...@@ -153,25 +153,25 @@ MaybeHandle<JSReceiver> JSSegmentIterator::Next( ...@@ -153,25 +153,25 @@ MaybeHandle<JSReceiver> JSSegmentIterator::Next(
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
icu::BreakIterator* icu_break_iterator = icu::BreakIterator* icu_break_iterator =
segment_iterator->icu_break_iterator()->raw(); segment_iterator->icu_break_iterator()->raw();
// 3. Let _previousPosition be iterator.[[SegmentIteratorPosition]]. // 3. Let _previousIndex be iterator.[[SegmentIteratorIndex]].
int32_t prev = icu_break_iterator->current(); int32_t prev = icu_break_iterator->current();
// 4. Let done be AdvanceSegmentIterator(iterator, forwards). // 4. Let done be AdvanceSegmentIterator(iterator, forwards).
int32_t position = icu_break_iterator->next(); int32_t index = icu_break_iterator->next();
segment_iterator->set_is_break_type_set(true); segment_iterator->set_is_break_type_set(true);
if (position == icu::BreakIterator::DONE) { if (index == icu::BreakIterator::DONE) {
// 5. If done is true, return CreateIterResultObject(undefined, true). // 5. If done is true, return CreateIterResultObject(undefined, true).
return factory->NewJSIteratorResult(isolate->factory()->undefined_value(), return factory->NewJSIteratorResult(isolate->factory()->undefined_value(),
true); true);
} }
// 6. Let newPosition be iterator.[[SegmentIteratorPosition]]. // 6. Let newIndex be iterator.[[SegmentIteratorIndex]].
Handle<Object> new_position = factory->NewNumberFromInt(position); Handle<Object> new_index = factory->NewNumberFromInt(index);
// 8. Let segment be the substring of string from previousPosition to // 8. Let segment be the substring of string from previousIndex to
// newPosition, inclusive of previousPosition and exclusive of newPosition. // newIndex, inclusive of previousIndex and exclusive of newIndex.
Handle<String> segment; Handle<String> segment;
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(isolate, segment,
isolate, segment, segment_iterator->GetSegment(isolate, prev, position), segment_iterator->GetSegment(isolate, prev, index),
JSReceiver); JSReceiver);
// 9. Let breakType be iterator.[[SegmentIteratorBreakType]]. // 9. Let breakType be iterator.[[SegmentIteratorBreakType]].
Handle<Object> break_type = segment_iterator->BreakType(); Handle<Object> break_type = segment_iterator->BreakType();
...@@ -190,10 +190,9 @@ MaybeHandle<JSReceiver> JSSegmentIterator::Next( ...@@ -190,10 +190,9 @@ MaybeHandle<JSReceiver> JSSegmentIterator::Next(
kDontThrow) kDontThrow)
.FromJust()); .FromJust());
// 13. Perform ! CreateDataProperty(result, "position", newPosition). // 13. Perform ! CreateDataProperty(result, "index", newIndex).
CHECK(JSReceiver::CreateDataProperty(isolate, result, CHECK(JSReceiver::CreateDataProperty(isolate, result, factory->index_string(),
factory->position_string(), new_position, new_index, kDontThrow)
kDontThrow)
.FromJust()); .FromJust());
// 14. Return CreateIterResultObject(result, false). // 14. Return CreateIterResultObject(result, false).
......
...@@ -48,8 +48,8 @@ class JSSegmentIterator : public JSObject { ...@@ -48,8 +48,8 @@ class JSSegmentIterator : public JSObject {
Isolate* isolate, Handle<JSSegmentIterator> segment_iterator_holder, Isolate* isolate, Handle<JSSegmentIterator> segment_iterator_holder,
Handle<Object> from); Handle<Object> from);
// ecma402 #sec-segment-iterator-prototype-position // ecma402 #sec-segment-iterator-prototype-index
static Handle<Object> Position( static Handle<Object> Index(
Isolate* isolate, Handle<JSSegmentIterator> segment_iterator_holder); Isolate* isolate, Handle<JSSegmentIterator> segment_iterator_holder);
Handle<String> GranularityAsString() const; Handle<String> GranularityAsString() const;
......
...@@ -28,11 +28,11 @@ for (const text of [ ...@@ -28,11 +28,11 @@ for (const text of [
let segments = []; let segments = [];
while (!iter.following()) { while (!iter.following()) {
assertEquals(undefined, iter.breakType); assertEquals(undefined, iter.breakType);
assertTrue(iter.position >= 0); assertTrue(iter.index >= 0);
assertTrue(iter.position <= text.length); assertTrue(iter.index <= text.length);
assertTrue(iter.position > prev); assertTrue(iter.index > prev);
segments.push(text.substring(prev, iter.position)); segments.push(text.substring(prev, iter.index));
prev = iter.position; prev = iter.index;
} }
assertEquals(text, segments.join("")); assertEquals(text, segments.join(""));
} }
...@@ -37,8 +37,8 @@ for (const text of [ ...@@ -37,8 +37,8 @@ for (const text of [
// manually advance the iter. // manually advance the iter.
assertFalse(iter.following()); assertFalse(iter.following());
assertEquals(iter.breakType, v.breakType); assertEquals(iter.breakType, v.breakType);
assertEquals(text.substring(prev, iter.position), v.segment); assertEquals(text.substring(prev, iter.index), v.segment);
prev = iter.position; prev = iter.index;
} }
assertTrue(iter.following()); assertTrue(iter.following());
assertEquals(text, segments.join('')); assertEquals(text, segments.join(''));
......
...@@ -32,9 +32,9 @@ for (const text of [ ...@@ -32,9 +32,9 @@ for (const text of [
assertEquals("string", typeof v.segment); assertEquals("string", typeof v.segment);
assertTrue(v.segment.length > 0); assertTrue(v.segment.length > 0);
segments.push(v.segment); segments.push(v.segment);
assertEquals("number", typeof v.position); assertEquals("number", typeof v.index);
assertTrue(oldPos < v.position); assertTrue(oldPos < v.index);
oldPos = v.position; oldPos = v.index;
} }
assertEquals(text, segments.join('')); assertEquals(text, segments.join(''));
} }
...@@ -28,17 +28,17 @@ for (const text of [ ...@@ -28,17 +28,17 @@ for (const text of [
let segments = []; let segments = [];
iter.preceding(prev) iter.preceding(prev)
assertEquals(undefined, iter.breakType) assertEquals(undefined, iter.breakType)
assertTrue(iter.position >= 0); assertTrue(iter.index >= 0);
assertTrue(iter.position < prev); assertTrue(iter.index < prev);
segments.push(text.substring(iter.position, prev)); segments.push(text.substring(iter.index, prev));
prev = iter.position; prev = iter.index;
while (!iter.preceding()) { while (!iter.preceding()) {
assertEquals(undefined, iter.breakType); assertEquals(undefined, iter.breakType);
assertTrue(iter.position >= 0); assertTrue(iter.index >= 0);
assertTrue(iter.position <= text.length); assertTrue(iter.index <= text.length);
assertTrue(iter.position < prev); assertTrue(iter.index < prev);
segments.push(text.substring(iter.position, prev)); segments.push(text.substring(iter.index, prev));
prev = iter.position; prev = iter.index;
} }
assertEquals(text, segments.reverse().join("")); assertEquals(text, segments.reverse().join(""));
} }
...@@ -25,5 +25,5 @@ for (const text of [ ...@@ -25,5 +25,5 @@ for (const text of [
]) { ]) {
const iter = seg.segment(text); const iter = seg.segment(text);
assertEquals(undefined, iter.breakType); assertEquals(undefined, iter.breakType);
assertEquals(0, iter.position); assertEquals(0, iter.index);
} }
...@@ -48,7 +48,7 @@ function checkGetterProperty(prototype, property) { ...@@ -48,7 +48,7 @@ function checkGetterProperty(prototype, property) {
} }
// Test the descriptor is correct for properties. // Test the descriptor is correct for properties.
checkGetterProperty(prototype, 'position'); checkGetterProperty(prototype, 'index');
checkGetterProperty(prototype, 'breakType'); checkGetterProperty(prototype, 'breakType');
// Test the SegmentIteratorPrototype methods are called with same // Test the SegmentIteratorPrototype methods are called with same
...@@ -88,4 +88,4 @@ checkProperty(nextReturn, 'done'); ...@@ -88,4 +88,4 @@ checkProperty(nextReturn, 'done');
checkProperty(nextReturn, 'value'); checkProperty(nextReturn, 'value');
checkProperty(nextReturn.value, 'segment'); checkProperty(nextReturn.value, 'segment');
checkProperty(nextReturn.value, 'breakType'); checkProperty(nextReturn.value, 'breakType');
checkProperty(nextReturn.value, 'position'); checkProperty(nextReturn.value, 'index');
...@@ -8,4 +8,4 @@ const segmenter = new Intl.Segmenter(); ...@@ -8,4 +8,4 @@ const segmenter = new Intl.Segmenter();
const text = "Hello World, Test 123! Foo Bar. How are you?"; const text = "Hello World, Test 123! Foo Bar. How are you?";
const iter = segmenter.segment(text); const iter = segmenter.segment(text);
assertEquals(0, iter.position); assertEquals(0, iter.index);
...@@ -9,7 +9,7 @@ for (const granularity of ["grapheme", "word", "sentence", "line"]) { ...@@ -9,7 +9,7 @@ for (const granularity of ["grapheme", "word", "sentence", "line"]) {
const segmenter = new Intl.Segmenter("en", { granularity }); const segmenter = new Intl.Segmenter("en", { granularity });
const iter = segmenter.segment(text); const iter = segmenter.segment(text);
assertEquals("number", typeof iter.position); assertEquals("number", typeof iter.index);
assertEquals(0, iter.position); assertEquals(0, iter.index);
assertEquals(undefined, iter.breakType); assertEquals(undefined, iter.breakType);
} }
...@@ -28,11 +28,11 @@ for (const text of [ ...@@ -28,11 +28,11 @@ for (const text of [
let segments = []; let segments = [];
while (!iter.following()) { while (!iter.following()) {
assertTrue(["soft", "hard"].includes(iter.breakType), iter.breakType); assertTrue(["soft", "hard"].includes(iter.breakType), iter.breakType);
assertTrue(iter.position >= 0); assertTrue(iter.index >= 0);
assertTrue(iter.position <= text.length); assertTrue(iter.index <= text.length);
assertTrue(iter.position > prev); assertTrue(iter.index > prev);
segments.push(text.substring(prev, iter.position)); segments.push(text.substring(prev, iter.index));
prev = iter.position; prev = iter.index;
} }
assertEquals(text, segments.join("")); assertEquals(text, segments.join(""));
} }
...@@ -37,8 +37,8 @@ for (const text of [ ...@@ -37,8 +37,8 @@ for (const text of [
// manually advance the iter. // manually advance the iter.
assertFalse(iter.following()); assertFalse(iter.following());
assertEquals(iter.breakType, v.breakType); assertEquals(iter.breakType, v.breakType);
assertEquals(text.substring(prev, iter.position), v.segment); assertEquals(text.substring(prev, iter.index), v.segment);
prev = iter.position; prev = iter.index;
} }
assertTrue(iter.following()); assertTrue(iter.following());
assertEquals(text, segments.join('')); assertEquals(text, segments.join(''));
......
...@@ -32,9 +32,9 @@ for (const text of [ ...@@ -32,9 +32,9 @@ for (const text of [
assertEquals("string", typeof v.segment); assertEquals("string", typeof v.segment);
assertTrue(v.segment.length > 0); assertTrue(v.segment.length > 0);
segments.push(v.segment); segments.push(v.segment);
assertEquals("number", typeof v.position); assertEquals("number", typeof v.index);
assertTrue(oldPos < v.position); assertTrue(oldPos < v.index);
oldPos = v.position; oldPos = v.index;
} }
assertEquals(text, segments.join('')); assertEquals(text, segments.join(''));
} }
...@@ -28,17 +28,17 @@ for (const text of [ ...@@ -28,17 +28,17 @@ for (const text of [
let segments = []; let segments = [];
iter.preceding(prev) iter.preceding(prev)
assertTrue(["soft", "hard"].includes(iter.breakType), iter.breakType); assertTrue(["soft", "hard"].includes(iter.breakType), iter.breakType);
assertTrue(iter.position >= 0); assertTrue(iter.index >= 0);
assertTrue(iter.position < prev); assertTrue(iter.index < prev);
segments.push(text.substring(iter.position, prev)); segments.push(text.substring(iter.index, prev));
prev = iter.position; prev = iter.index;
while (!iter.preceding()) { while (!iter.preceding()) {
assertTrue(["soft", "hard"].includes(iter.breakType), iter.breakType); assertTrue(["soft", "hard"].includes(iter.breakType), iter.breakType);
assertTrue(iter.position >= 0); assertTrue(iter.index >= 0);
assertTrue(iter.position <= text.length); assertTrue(iter.index <= text.length);
assertTrue(iter.position < prev); assertTrue(iter.index < prev);
segments.push(text.substring(iter.position, prev)); segments.push(text.substring(iter.index, prev));
prev = iter.position; prev = iter.index;
} }
assertEquals(text, segments.reverse().join("")); assertEquals(text, segments.reverse().join(""));
} }
...@@ -25,5 +25,5 @@ for (const text of [ ...@@ -25,5 +25,5 @@ for (const text of [
]) { ]) {
const iter = seg.segment(text); const iter = seg.segment(text);
assertEquals(undefined, iter.breakType); assertEquals(undefined, iter.breakType);
assertEquals(0, iter.position); assertEquals(0, iter.index);
} }
...@@ -28,11 +28,11 @@ for (const text of [ ...@@ -28,11 +28,11 @@ for (const text of [
let segments = []; let segments = [];
while (!iter.following()) { while (!iter.following()) {
assertTrue(["sep", "term"].includes(iter.breakType), iter.breakType); assertTrue(["sep", "term"].includes(iter.breakType), iter.breakType);
assertTrue(iter.position >= 0); assertTrue(iter.index >= 0);
assertTrue(iter.position <= text.length); assertTrue(iter.index <= text.length);
assertTrue(iter.position > prev); assertTrue(iter.index > prev);
segments.push(text.substring(prev, iter.position)); segments.push(text.substring(prev, iter.index));
prev = iter.position; prev = iter.index;
} }
assertEquals(text, segments.join("")); assertEquals(text, segments.join(""));
} }
...@@ -37,8 +37,8 @@ for (const text of [ ...@@ -37,8 +37,8 @@ for (const text of [
// manually advance the iter. // manually advance the iter.
assertFalse(iter.following()); assertFalse(iter.following());
assertEquals(iter.breakType, v.breakType); assertEquals(iter.breakType, v.breakType);
assertEquals(text.substring(prev, iter.position), v.segment); assertEquals(text.substring(prev, iter.index), v.segment);
prev = iter.position; prev = iter.index;
} }
assertTrue(iter.following()); assertTrue(iter.following());
assertEquals(text, segments.join('')); assertEquals(text, segments.join(''));
......
...@@ -32,9 +32,9 @@ for (const text of [ ...@@ -32,9 +32,9 @@ for (const text of [
assertEquals("string", typeof v.segment); assertEquals("string", typeof v.segment);
assertTrue(v.segment.length > 0); assertTrue(v.segment.length > 0);
segments.push(v.segment); segments.push(v.segment);
assertEquals("number", typeof v.position); assertEquals("number", typeof v.index);
assertTrue(oldPos < v.position); assertTrue(oldPos < v.index);
oldPos = v.position; oldPos = v.index;
} }
assertEquals(text, segments.join('')); assertEquals(text, segments.join(''));
} }
...@@ -28,17 +28,17 @@ for (const text of [ ...@@ -28,17 +28,17 @@ for (const text of [
let segments = []; let segments = [];
iter.preceding(prev); iter.preceding(prev);
assertTrue(["sep", "term"].includes(iter.breakType), iter.breakType); assertTrue(["sep", "term"].includes(iter.breakType), iter.breakType);
assertTrue(iter.position >= 0); assertTrue(iter.index >= 0);
assertTrue(iter.position < prev); assertTrue(iter.index < prev);
segments.push(text.substring(iter.position, prev)); segments.push(text.substring(iter.index, prev));
prev = iter.position; prev = iter.index;
while (!iter.preceding()) { while (!iter.preceding()) {
assertTrue(["sep", "term"].includes(iter.breakType), iter.breakType); assertTrue(["sep", "term"].includes(iter.breakType), iter.breakType);
assertTrue(iter.position >= 0); assertTrue(iter.index >= 0);
assertTrue(iter.position <= text.length); assertTrue(iter.index <= text.length);
assertTrue(iter.position < prev); assertTrue(iter.index < prev);
segments.push(text.substring(iter.position, prev)); segments.push(text.substring(iter.index, prev));
prev = iter.position; prev = iter.index;
} }
assertEquals(text, segments.reverse().join("")); assertEquals(text, segments.reverse().join(""));
} }
...@@ -25,5 +25,5 @@ for (const text of [ ...@@ -25,5 +25,5 @@ for (const text of [
]) { ]) {
const iter = seg.segment(text); const iter = seg.segment(text);
assertEquals(undefined, iter.breakType); assertEquals(undefined, iter.breakType);
assertEquals(0, iter.position); assertEquals(0, iter.index);
} }
...@@ -28,11 +28,11 @@ for (const text of [ ...@@ -28,11 +28,11 @@ for (const text of [
let segments = []; let segments = [];
while (!iter.following()) { while (!iter.following()) {
assertTrue(["word", "none"].includes(iter.breakType), iter.breakType); assertTrue(["word", "none"].includes(iter.breakType), iter.breakType);
assertTrue(iter.position >= 0); assertTrue(iter.index >= 0);
assertTrue(iter.position <= text.length); assertTrue(iter.index <= text.length);
assertTrue(iter.position > prev); assertTrue(iter.index > prev);
segments.push(text.substring(prev, iter.position)); segments.push(text.substring(prev, iter.index));
prev = iter.position; prev = iter.index;
} }
assertEquals(text, segments.join("")); assertEquals(text, segments.join(""));
} }
...@@ -37,8 +37,8 @@ for (const text of [ ...@@ -37,8 +37,8 @@ for (const text of [
// manually advance the iter. // manually advance the iter.
assertFalse(iter.following()); assertFalse(iter.following());
assertEquals(iter.breakType, v.breakType); assertEquals(iter.breakType, v.breakType);
assertEquals(text.substring(prev, iter.position), v.segment); assertEquals(text.substring(prev, iter.index), v.segment);
prev = iter.position; prev = iter.index;
} }
assertTrue(iter.following()); assertTrue(iter.following());
assertEquals(text, segments.join('')); assertEquals(text, segments.join(''));
......
...@@ -32,9 +32,9 @@ for (const text of [ ...@@ -32,9 +32,9 @@ for (const text of [
assertEquals("string", typeof v.segment); assertEquals("string", typeof v.segment);
assertTrue(v.segment.length > 0); assertTrue(v.segment.length > 0);
segments.push(v.segment); segments.push(v.segment);
assertEquals("number", typeof v.position); assertEquals("number", typeof v.index);
assertTrue(oldPos < v.position); assertTrue(oldPos < v.index);
oldPos = v.position; oldPos = v.index;
} }
assertEquals(text, segments.join('')); assertEquals(text, segments.join(''));
} }
...@@ -28,17 +28,17 @@ for (const text of [ ...@@ -28,17 +28,17 @@ for (const text of [
let segments = []; let segments = [];
iter.preceding(prev); iter.preceding(prev);
assertTrue(["word", "none"].includes(iter.breakType), iter.breakType); assertTrue(["word", "none"].includes(iter.breakType), iter.breakType);
assertTrue(iter.position >= 0); assertTrue(iter.index >= 0);
assertTrue(iter.position < prev); assertTrue(iter.index < prev);
segments.push(text.substring(iter.position, prev)); segments.push(text.substring(iter.index, prev));
prev = iter.position; prev = iter.index;
while (!iter.preceding()) { while (!iter.preceding()) {
assertTrue(["word", "none"].includes(iter.breakType), iter.breakType); assertTrue(["word", "none"].includes(iter.breakType), iter.breakType);
assertTrue(iter.position >= 0); assertTrue(iter.index >= 0);
assertTrue(iter.position <= text.length); assertTrue(iter.index <= text.length);
assertTrue(iter.position < prev); assertTrue(iter.index < prev);
segments.push(text.substring(iter.position, prev)); segments.push(text.substring(iter.index, prev));
prev = iter.position; prev = iter.index;
} }
assertEquals(text, segments.reverse().join("")); assertEquals(text, segments.reverse().join(""));
} }
...@@ -25,5 +25,5 @@ for (const text of [ ...@@ -25,5 +25,5 @@ for (const text of [
]) { ]) {
const iter = seg.segment(text); const iter = seg.segment(text);
assertEquals(undefined, iter.breakType); assertEquals(undefined, iter.breakType);
assertEquals(0, iter.position); assertEquals(0, iter.index);
} }
...@@ -661,34 +661,6 @@ ...@@ -661,34 +661,6 @@
'language/expressions/await/for-await-of-interleaved': ['--harmony-await-optimization'], 'language/expressions/await/for-await-of-interleaved': ['--harmony-await-optimization'],
'language/expressions/await/async-await-interleaved': ['--harmony-await-optimization'], 'language/expressions/await/async-await-interleaved': ['--harmony-await-optimization'],
# https://bugs.chromium.org/p/v8/issues/detail?id=8588
'intl402/Segmenter/iterator/following': [FAIL],
'intl402/Segmenter/iterator/granularity': [FAIL],
'intl402/Segmenter/iterator/position': [FAIL],
'intl402/Segmenter/iterator/preceding': [FAIL],
'intl402/Segmenter/iterator/prototype': [FAIL],
'intl402/Segmenter/prototype/segment/segment-grapheme': [FAIL],
'intl402/Segmenter/prototype/segment/segment-grapheme-following': [FAIL],
'intl402/Segmenter/prototype/segment/segment-grapheme-iterable': [FAIL],
'intl402/Segmenter/prototype/segment/segment-grapheme-next': [FAIL],
'intl402/Segmenter/prototype/segment/segment-grapheme-preceding': [FAIL],
'intl402/Segmenter/prototype/segment/segment-line': [FAIL],
'intl402/Segmenter/prototype/segment/segment-line-following': [FAIL],
'intl402/Segmenter/prototype/segment/segment-line-iterable': [FAIL],
'intl402/Segmenter/prototype/segment/segment-line-next': [FAIL],
'intl402/Segmenter/prototype/segment/segment-line-preceding': [FAIL],
'intl402/Segmenter/prototype/segment/segment-sentence': [FAIL],
'intl402/Segmenter/prototype/segment/segment-sentence-following': [FAIL],
'intl402/Segmenter/prototype/segment/segment-sentence-iterable': [FAIL],
'intl402/Segmenter/prototype/segment/segment-sentence-next': [FAIL],
'intl402/Segmenter/prototype/segment/segment-sentence-preceding': [FAIL],
'intl402/Segmenter/prototype/segment/segment-tostring': [FAIL],
'intl402/Segmenter/prototype/segment/segment-word': [FAIL],
'intl402/Segmenter/prototype/segment/segment-word-following': [FAIL],
'intl402/Segmenter/prototype/segment/segment-word-iterable': [FAIL],
'intl402/Segmenter/prototype/segment/segment-word-next': [FAIL],
'intl402/Segmenter/prototype/segment/segment-word-preceding': [FAIL],
######################## NEEDS INVESTIGATION ########################### ######################## NEEDS INVESTIGATION ###########################
# These test failures are specific to the intl402 suite and need investigation # These test failures are specific to the intl402 suite and need investigation
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment