mirror of
https://github.com/tc39/test262.git
synced 2025-07-24 06:25:30 +02:00
Intl.Segmenter: Submit batch of V8 tests for segment().
This commit is contained in:
parent
9b170e77e2
commit
0d07ed06c0
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "grapheme"})
|
||||
for (const text of [
|
||||
@ -27,12 +32,12 @@ for (const text of [
|
||||
let prev = 0;
|
||||
let segments = [];
|
||||
while (!iter.following()) {
|
||||
assertEquals(undefined, iter.breakType);
|
||||
assertTrue(iter.position >= 0);
|
||||
assertTrue(iter.position <= text.length);
|
||||
assertTrue(iter.position > prev);
|
||||
assert.sameValue(undefined, iter.breakType);
|
||||
assert(iter.position >= 0);
|
||||
assert(iter.position <= text.length);
|
||||
assert(iter.position > prev);
|
||||
segments.push(text.substring(prev, iter.position));
|
||||
prev = iter.position;
|
||||
}
|
||||
assertEquals(text, segments.join(""));
|
||||
assert.sameValue(text, segments.join(""));
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "grapheme"})
|
||||
for (const text of [
|
||||
@ -29,17 +34,17 @@ for (const text of [
|
||||
let iter = seg.segment(text);
|
||||
let prev = 0;
|
||||
for (const v of seg.segment(text)) {
|
||||
assertEquals(undefined, v.breakType);
|
||||
assertEquals("string", typeof v.segment);
|
||||
assertTrue(v.segment.length > 0);
|
||||
assert.sameValue(undefined, v.breakType);
|
||||
assert.sameValue("string", typeof v.segment);
|
||||
assert(v.segment.length > 0);
|
||||
segments.push(v.segment);
|
||||
|
||||
// manually advance the iter.
|
||||
assertFalse(iter.following());
|
||||
assertEquals(iter.breakType, v.breakType);
|
||||
assertEquals(text.substring(prev, iter.position), v.segment);
|
||||
assert.sameValue(iter.breakType, v.breakType);
|
||||
assert.sameValue(text.substring(prev, iter.position), v.segment);
|
||||
prev = iter.position;
|
||||
}
|
||||
assertTrue(iter.following());
|
||||
assertEquals(text, segments.join(''));
|
||||
assert(iter.following());
|
||||
assert.sameValue(text, segments.join(''));
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "grapheme"})
|
||||
for (const text of [
|
||||
@ -27,10 +32,10 @@ for (const text of [
|
||||
let segments = [];
|
||||
for (let result = iter.next(); !result.done; result = iter.next()) {
|
||||
const v = result.value;
|
||||
assertEquals(undefined, v.breakType);
|
||||
assertEquals("string", typeof v.segment);
|
||||
assertTrue(v.segment.length > 0);
|
||||
assert.sameValue(undefined, v.breakType);
|
||||
assert.sameValue("string", typeof v.segment);
|
||||
assert(v.segment.length > 0);
|
||||
segments.push(v.segment);
|
||||
}
|
||||
assertEquals(text, segments.join(''));
|
||||
assert.sameValue(text, segments.join(''));
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "grapheme"})
|
||||
for (const text of [
|
||||
@ -27,18 +32,18 @@ for (const text of [
|
||||
let prev = text.length;
|
||||
let segments = [];
|
||||
iter.preceding(prev)
|
||||
assertEquals(undefined, iter.breakType)
|
||||
assertTrue(iter.position >= 0);
|
||||
assertTrue(iter.position < prev);
|
||||
assert.sameValue(undefined, iter.breakType)
|
||||
assert(iter.position >= 0);
|
||||
assert(iter.position < prev);
|
||||
segments.push(text.substring(iter.position, prev));
|
||||
prev = iter.position;
|
||||
while (!iter.preceding()) {
|
||||
assertEquals(undefined, iter.breakType);
|
||||
assertTrue(iter.position >= 0);
|
||||
assertTrue(iter.position <= text.length);
|
||||
assertTrue(iter.position < prev);
|
||||
assert.sameValue(undefined, iter.breakType);
|
||||
assert(iter.position >= 0);
|
||||
assert(iter.position <= text.length);
|
||||
assert(iter.position < prev);
|
||||
segments.push(text.substring(iter.position, prev));
|
||||
prev = iter.position;
|
||||
}
|
||||
assertEquals(text, segments.reverse().join(""));
|
||||
assert.sameValue(text, segments.reverse().join(""));
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "grapheme"})
|
||||
for (const text of [
|
||||
@ -24,6 +29,6 @@ for (const text of [
|
||||
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
|
||||
]) {
|
||||
const iter = seg.segment(text);
|
||||
assertEquals(undefined, iter.breakType);
|
||||
assertEquals(0, iter.position);
|
||||
assert.sameValue(undefined, iter.breakType);
|
||||
assert.sameValue(0, iter.position);
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
let breakCounts = {};
|
||||
for (const locale of ["en", "fr", "ja", "zh", "ko"]) {
|
||||
@ -39,19 +44,19 @@ for (const locale of ["en", "fr", "ja", "zh", "ko"]) {
|
||||
}
|
||||
// In Japanese
|
||||
// Just test the break count in loose mode is greater than normal mode.
|
||||
assertTrue(breakCounts["ja-loose"] > breakCounts["ja-normal"]);
|
||||
assert(breakCounts["ja-loose"] > breakCounts["ja-normal"]);
|
||||
// and test the break count in normal mode is greater than strict mode.
|
||||
assertTrue(breakCounts["ja-normal"] > breakCounts["ja-strict"]);
|
||||
assert(breakCounts["ja-normal"] > breakCounts["ja-strict"]);
|
||||
// In Chinese
|
||||
// Just test the break count in loose mode is greater than normal mode.
|
||||
assertTrue(breakCounts["zh-loose"] > breakCounts["zh-normal"]);
|
||||
assert(breakCounts["zh-loose"] > breakCounts["zh-normal"]);
|
||||
// and test the break count in normal mode is greater than strict mode.
|
||||
assertTrue(breakCounts["zh-normal"] > breakCounts["zh-strict"]);
|
||||
assert(breakCounts["zh-normal"] > breakCounts["zh-strict"]);
|
||||
// In English, French and Korean
|
||||
assertEquals(breakCounts["en-loose"], breakCounts["en-normal"]);
|
||||
assertEquals(breakCounts["fr-loose"], breakCounts["fr-normal"]);
|
||||
assertEquals(breakCounts["ko-loose"], breakCounts["ko-normal"]);
|
||||
assert.sameValue(breakCounts["en-loose"], breakCounts["en-normal"]);
|
||||
assert.sameValue(breakCounts["fr-loose"], breakCounts["fr-normal"]);
|
||||
assert.sameValue(breakCounts["ko-loose"], breakCounts["ko-normal"]);
|
||||
// and test the break count in normal mode is greater than strict mode.
|
||||
assertTrue(breakCounts["en-normal"] > breakCounts["en-strict"]);
|
||||
assertTrue(breakCounts["fr-normal"] > breakCounts["fr-strict"]);
|
||||
assertTrue(breakCounts["ko-normal"] > breakCounts["ko-strict"]);
|
||||
assert(breakCounts["en-normal"] > breakCounts["en-strict"]);
|
||||
assert(breakCounts["fr-normal"] > breakCounts["fr-strict"]);
|
||||
assert(breakCounts["ko-normal"] > breakCounts["ko-strict"]);
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "line"})
|
||||
for (const text of [
|
||||
@ -27,12 +32,12 @@ for (const text of [
|
||||
let prev = 0;
|
||||
let segments = [];
|
||||
while (!iter.following()) {
|
||||
assertTrue(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
||||
assertTrue(iter.position >= 0);
|
||||
assertTrue(iter.position <= text.length);
|
||||
assertTrue(iter.position > prev);
|
||||
assert(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
||||
assert(iter.position >= 0);
|
||||
assert(iter.position <= text.length);
|
||||
assert(iter.position > prev);
|
||||
segments.push(text.substring(prev, iter.position));
|
||||
prev = iter.position;
|
||||
}
|
||||
assertEquals(text, segments.join(""));
|
||||
assert.sameValue(text, segments.join(""));
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "line"})
|
||||
for (const text of [
|
||||
@ -29,17 +34,17 @@ for (const text of [
|
||||
let iter = seg.segment(text);
|
||||
let prev = 0;
|
||||
for (const v of seg.segment(text)) {
|
||||
assertTrue(["soft", "hard"].includes(v.breakType), v.breakType);
|
||||
assertEquals("string", typeof v.segment);
|
||||
assertTrue(v.segment.length > 0);
|
||||
assert(["soft", "hard"].includes(v.breakType), v.breakType);
|
||||
assert.sameValue("string", typeof v.segment);
|
||||
assert(v.segment.length > 0);
|
||||
segments.push(v.segment);
|
||||
|
||||
// manually advance the iter.
|
||||
assertFalse(iter.following());
|
||||
assertEquals(iter.breakType, v.breakType);
|
||||
assertEquals(text.substring(prev, iter.position), v.segment);
|
||||
assert.sameValue(iter.breakType, v.breakType);
|
||||
assert.sameValue(text.substring(prev, iter.position), v.segment);
|
||||
prev = iter.position;
|
||||
}
|
||||
assertTrue(iter.following());
|
||||
assertEquals(text, segments.join(''));
|
||||
assert(iter.following());
|
||||
assert.sameValue(text, segments.join(''));
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "line"})
|
||||
for (const text of [
|
||||
@ -27,10 +32,10 @@ for (const text of [
|
||||
let segments = [];
|
||||
for (let result = iter.next(); !result.done; result = iter.next()) {
|
||||
const v = result.value;
|
||||
assertTrue(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
||||
assertEquals("string", typeof v.segment);
|
||||
assertTrue(v.segment.length > 0);
|
||||
assert(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
||||
assert.sameValue("string", typeof v.segment);
|
||||
assert(v.segment.length > 0);
|
||||
segments.push(v.segment);
|
||||
}
|
||||
assertEquals(text, segments.join(''));
|
||||
assert.sameValue(text, segments.join(''));
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "line"})
|
||||
for (const text of [
|
||||
@ -27,18 +32,18 @@ for (const text of [
|
||||
let prev = text.length;
|
||||
let segments = [];
|
||||
iter.preceding(prev)
|
||||
assertTrue(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
||||
assertTrue(iter.position >= 0);
|
||||
assertTrue(iter.position < prev);
|
||||
assert(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
||||
assert(iter.position >= 0);
|
||||
assert(iter.position < prev);
|
||||
segments.push(text.substring(iter.position, prev));
|
||||
prev = iter.position;
|
||||
while (!iter.preceding()) {
|
||||
assertTrue(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
||||
assertTrue(iter.position >= 0);
|
||||
assertTrue(iter.position <= text.length);
|
||||
assertTrue(iter.position < prev);
|
||||
assert(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
||||
assert(iter.position >= 0);
|
||||
assert(iter.position <= text.length);
|
||||
assert(iter.position < prev);
|
||||
segments.push(text.substring(iter.position, prev));
|
||||
prev = iter.position;
|
||||
}
|
||||
assertEquals(text, segments.reverse().join(""));
|
||||
assert.sameValue(text, segments.reverse().join(""));
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "line"})
|
||||
for (const text of [
|
||||
@ -24,6 +29,6 @@ for (const text of [
|
||||
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
|
||||
]) {
|
||||
const iter = seg.segment(text);
|
||||
assertTrue(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
||||
assertEquals(0, iter.position);
|
||||
assert(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
||||
assert.sameValue(0, iter.position);
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "sentence"})
|
||||
for (const text of [
|
||||
@ -27,12 +32,12 @@ for (const text of [
|
||||
let prev = 0;
|
||||
let segments = [];
|
||||
while (!iter.following()) {
|
||||
assertTrue(["sep", "term"].includes(iter.breakType), iter.breakType);
|
||||
assertTrue(iter.position >= 0);
|
||||
assertTrue(iter.position <= text.length);
|
||||
assertTrue(iter.position > prev);
|
||||
assert(["sep", "term"].includes(iter.breakType), iter.breakType);
|
||||
assert(iter.position >= 0);
|
||||
assert(iter.position <= text.length);
|
||||
assert(iter.position > prev);
|
||||
segments.push(text.substring(prev, iter.position));
|
||||
prev = iter.position;
|
||||
}
|
||||
assertEquals(text, segments.join(""));
|
||||
assert.sameValue(text, segments.join(""));
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "sentence"})
|
||||
for (const text of [
|
||||
@ -29,17 +34,17 @@ for (const text of [
|
||||
let iter = seg.segment(text);
|
||||
let prev = 0;
|
||||
for (const v of seg.segment(text)) {
|
||||
assertTrue(["sep", "term"].includes(v.breakType), v.breakType);
|
||||
assertEquals("string", typeof v.segment);
|
||||
assertTrue(v.segment.length > 0);
|
||||
assert(["sep", "term"].includes(v.breakType), v.breakType);
|
||||
assert.sameValue("string", typeof v.segment);
|
||||
assert(v.segment.length > 0);
|
||||
segments.push(v.segment);
|
||||
|
||||
// manually advance the iter.
|
||||
assertFalse(iter.following());
|
||||
assertEquals(iter.breakType, v.breakType);
|
||||
assertEquals(text.substring(prev, iter.position), v.segment);
|
||||
assert.sameValue(iter.breakType, v.breakType);
|
||||
assert.sameValue(text.substring(prev, iter.position), v.segment);
|
||||
prev = iter.position;
|
||||
}
|
||||
assertTrue(iter.following());
|
||||
assertEquals(text, segments.join(''));
|
||||
assert(iter.following());
|
||||
assert.sameValue(text, segments.join(''));
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "sentence"})
|
||||
for (const text of [
|
||||
@ -27,10 +32,10 @@ for (const text of [
|
||||
let segments = [];
|
||||
for (let result = iter.next(); !result.done; result = iter.next()) {
|
||||
const v = result.value;
|
||||
assertTrue(["sep", "term"].includes(iter.breakType), iter.breakType);
|
||||
assertEquals("string", typeof v.segment);
|
||||
assertTrue(v.segment.length > 0);
|
||||
assert(["sep", "term"].includes(iter.breakType), iter.breakType);
|
||||
assert.sameValue("string", typeof v.segment);
|
||||
assert(v.segment.length > 0);
|
||||
segments.push(v.segment);
|
||||
}
|
||||
assertEquals(text, segments.join(''));
|
||||
assert.sameValue(text, segments.join(''));
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "sentence"})
|
||||
for (const text of [
|
||||
@ -27,18 +32,18 @@ for (const text of [
|
||||
let prev = text.length;
|
||||
let segments = [];
|
||||
iter.preceding(prev);
|
||||
assertTrue(["sep", "term"].includes(iter.breakType), iter.breakType);
|
||||
assertTrue(iter.position >= 0);
|
||||
assertTrue(iter.position < prev);
|
||||
assert(["sep", "term"].includes(iter.breakType), iter.breakType);
|
||||
assert(iter.position >= 0);
|
||||
assert(iter.position < prev);
|
||||
segments.push(text.substring(iter.position, prev));
|
||||
prev = iter.position;
|
||||
while (!iter.preceding()) {
|
||||
assertTrue(["sep", "term"].includes(iter.breakType), iter.breakType);
|
||||
assertTrue(iter.position >= 0);
|
||||
assertTrue(iter.position <= text.length);
|
||||
assertTrue(iter.position < prev);
|
||||
assert(["sep", "term"].includes(iter.breakType), iter.breakType);
|
||||
assert(iter.position >= 0);
|
||||
assert(iter.position <= text.length);
|
||||
assert(iter.position < prev);
|
||||
segments.push(text.substring(iter.position, prev));
|
||||
prev = iter.position;
|
||||
}
|
||||
assertEquals(text, segments.reverse().join(""));
|
||||
assert.sameValue(text, segments.reverse().join(""));
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "sentence"})
|
||||
for (const text of [
|
||||
@ -24,6 +29,6 @@ for (const text of [
|
||||
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
|
||||
]) {
|
||||
const iter = seg.segment(text);
|
||||
assertTrue(["sep", "term"].includes(iter.breakType), iter.breakType);
|
||||
assertEquals(0, iter.position);
|
||||
assert(["sep", "term"].includes(iter.breakType), iter.breakType);
|
||||
assert.sameValue(0, iter.position);
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "word"})
|
||||
for (const text of [
|
||||
@ -27,12 +32,12 @@ for (const text of [
|
||||
let prev = 0;
|
||||
let segments = [];
|
||||
while (!iter.following()) {
|
||||
assertTrue(["word", "none"].includes(iter.breakType), iter.breakType);
|
||||
assertTrue(iter.position >= 0);
|
||||
assertTrue(iter.position <= text.length);
|
||||
assertTrue(iter.position > prev);
|
||||
assert(["word", "none"].includes(iter.breakType), iter.breakType);
|
||||
assert(iter.position >= 0);
|
||||
assert(iter.position <= text.length);
|
||||
assert(iter.position > prev);
|
||||
segments.push(text.substring(prev, iter.position));
|
||||
prev = iter.position;
|
||||
}
|
||||
assertEquals(text, segments.join(""));
|
||||
assert.sameValue(text, segments.join(""));
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "word"})
|
||||
for (const text of [
|
||||
@ -29,17 +34,17 @@ for (const text of [
|
||||
let iter = seg.segment(text);
|
||||
let prev = 0;
|
||||
for (const v of seg.segment(text)) {
|
||||
assertTrue(["word", "none"].includes(v.breakType), v.breakType);
|
||||
assertEquals("string", typeof v.segment);
|
||||
assertTrue(v.segment.length > 0);
|
||||
assert(["word", "none"].includes(v.breakType), v.breakType);
|
||||
assert.sameValue("string", typeof v.segment);
|
||||
assert(v.segment.length > 0);
|
||||
segments.push(v.segment);
|
||||
|
||||
// manually advance the iter.
|
||||
assertFalse(iter.following());
|
||||
assertEquals(iter.breakType, v.breakType);
|
||||
assertEquals(text.substring(prev, iter.position), v.segment);
|
||||
assert.sameValue(iter.breakType, v.breakType);
|
||||
assert.sameValue(text.substring(prev, iter.position), v.segment);
|
||||
prev = iter.position;
|
||||
}
|
||||
assertTrue(iter.following());
|
||||
assertEquals(text, segments.join(''));
|
||||
assert(iter.following());
|
||||
assert.sameValue(text, segments.join(''));
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "word"})
|
||||
for (const text of [
|
||||
@ -27,10 +32,10 @@ for (const text of [
|
||||
let segments = [];
|
||||
for (let result = iter.next(); !result.done; result = iter.next()) {
|
||||
const v = result.value;
|
||||
assertTrue(["word", "none"].includes(iter.breakType), iter.breakType);
|
||||
assertEquals("string", typeof v.segment);
|
||||
assertTrue(v.segment.length > 0);
|
||||
assert(["word", "none"].includes(iter.breakType), iter.breakType);
|
||||
assert.sameValue("string", typeof v.segment);
|
||||
assert(v.segment.length > 0);
|
||||
segments.push(v.segment);
|
||||
}
|
||||
assertEquals(text, segments.join(''));
|
||||
assert.sameValue(text, segments.join(''));
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "word"})
|
||||
for (const text of [
|
||||
@ -27,18 +32,18 @@ for (const text of [
|
||||
let prev = text.length;
|
||||
let segments = [];
|
||||
iter.preceding(prev);
|
||||
assertTrue(["word", "none"].includes(iter.breakType), iter.breakType);
|
||||
assertTrue(iter.position >= 0);
|
||||
assertTrue(iter.position < prev);
|
||||
assert(["word", "none"].includes(iter.breakType), iter.breakType);
|
||||
assert(iter.position >= 0);
|
||||
assert(iter.position < prev);
|
||||
segments.push(text.substring(iter.position, prev));
|
||||
prev = iter.position;
|
||||
while (!iter.preceding()) {
|
||||
assertTrue(["word", "none"].includes(iter.breakType), iter.breakType);
|
||||
assertTrue(iter.position >= 0);
|
||||
assertTrue(iter.position <= text.length);
|
||||
assertTrue(iter.position < prev);
|
||||
assert(["word", "none"].includes(iter.breakType), iter.breakType);
|
||||
assert(iter.position >= 0);
|
||||
assert(iter.position <= text.length);
|
||||
assert(iter.position < prev);
|
||||
segments.push(text.substring(iter.position, prev));
|
||||
prev = iter.position;
|
||||
}
|
||||
assertEquals(text, segments.reverse().join(""));
|
||||
assert.sameValue(text, segments.reverse().join(""));
|
||||
}
|
@ -1,8 +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.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
/*---
|
||||
esid: sec-Intl.Segmenter.prototype.segment
|
||||
description: Verifies the behavior for the "segment" function of the Segmenter prototype object.
|
||||
info: |
|
||||
Intl.Segmenter.prototype.segment( string )
|
||||
features: [Intl.Segmenter]
|
||||
---*/
|
||||
|
||||
const seg = new Intl.Segmenter([], {granularity: "word"})
|
||||
for (const text of [
|
||||
@ -24,6 +29,6 @@ for (const text of [
|
||||
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
|
||||
]) {
|
||||
const iter = seg.segment(text);
|
||||
assertTrue(["word", "none"].includes(iter.breakType), iter.breakType);
|
||||
assertEquals(0, iter.position);
|
||||
assert(["word", "none"].includes(iter.breakType), iter.breakType);
|
||||
assert.sameValue(0, iter.position);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user