mirror of
https://github.com/tc39/test262.git
synced 2025-07-25 15:04:43 +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.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "grapheme"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -27,12 +32,12 @@ for (const text of [
|
|||||||
let prev = 0;
|
let prev = 0;
|
||||||
let segments = [];
|
let segments = [];
|
||||||
while (!iter.following()) {
|
while (!iter.following()) {
|
||||||
assertEquals(undefined, iter.breakType);
|
assert.sameValue(undefined, iter.breakType);
|
||||||
assertTrue(iter.position >= 0);
|
assert(iter.position >= 0);
|
||||||
assertTrue(iter.position <= text.length);
|
assert(iter.position <= text.length);
|
||||||
assertTrue(iter.position > prev);
|
assert(iter.position > prev);
|
||||||
segments.push(text.substring(prev, iter.position));
|
segments.push(text.substring(prev, iter.position));
|
||||||
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.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "grapheme"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -29,17 +34,17 @@ for (const text of [
|
|||||||
let iter = seg.segment(text);
|
let iter = seg.segment(text);
|
||||||
let prev = 0;
|
let prev = 0;
|
||||||
for (const v of seg.segment(text)) {
|
for (const v of seg.segment(text)) {
|
||||||
assertEquals(undefined, v.breakType);
|
assert.sameValue(undefined, v.breakType);
|
||||||
assertEquals("string", typeof v.segment);
|
assert.sameValue("string", typeof v.segment);
|
||||||
assertTrue(v.segment.length > 0);
|
assert(v.segment.length > 0);
|
||||||
segments.push(v.segment);
|
segments.push(v.segment);
|
||||||
|
|
||||||
// manually advance the iter.
|
// manually advance the iter.
|
||||||
assertFalse(iter.following());
|
assertFalse(iter.following());
|
||||||
assertEquals(iter.breakType, v.breakType);
|
assert.sameValue(iter.breakType, v.breakType);
|
||||||
assertEquals(text.substring(prev, iter.position), v.segment);
|
assert.sameValue(text.substring(prev, iter.position), v.segment);
|
||||||
prev = iter.position;
|
prev = iter.position;
|
||||||
}
|
}
|
||||||
assertTrue(iter.following());
|
assert(iter.following());
|
||||||
assertEquals(text, segments.join(''));
|
assert.sameValue(text, segments.join(''));
|
||||||
}
|
}
|
@ -1,8 +1,13 @@
|
|||||||
// Copyright 2018 the V8 project authors. All rights reserved.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "grapheme"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -27,10 +32,10 @@ for (const text of [
|
|||||||
let segments = [];
|
let segments = [];
|
||||||
for (let result = iter.next(); !result.done; result = iter.next()) {
|
for (let result = iter.next(); !result.done; result = iter.next()) {
|
||||||
const v = result.value;
|
const v = result.value;
|
||||||
assertEquals(undefined, v.breakType);
|
assert.sameValue(undefined, v.breakType);
|
||||||
assertEquals("string", typeof v.segment);
|
assert.sameValue("string", typeof v.segment);
|
||||||
assertTrue(v.segment.length > 0);
|
assert(v.segment.length > 0);
|
||||||
segments.push(v.segment);
|
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.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "grapheme"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -27,18 +32,18 @@ for (const text of [
|
|||||||
let prev = text.length;
|
let prev = text.length;
|
||||||
let segments = [];
|
let segments = [];
|
||||||
iter.preceding(prev)
|
iter.preceding(prev)
|
||||||
assertEquals(undefined, iter.breakType)
|
assert.sameValue(undefined, iter.breakType)
|
||||||
assertTrue(iter.position >= 0);
|
assert(iter.position >= 0);
|
||||||
assertTrue(iter.position < prev);
|
assert(iter.position < prev);
|
||||||
segments.push(text.substring(iter.position, prev));
|
segments.push(text.substring(iter.position, prev));
|
||||||
prev = iter.position;
|
prev = iter.position;
|
||||||
while (!iter.preceding()) {
|
while (!iter.preceding()) {
|
||||||
assertEquals(undefined, iter.breakType);
|
assert.sameValue(undefined, iter.breakType);
|
||||||
assertTrue(iter.position >= 0);
|
assert(iter.position >= 0);
|
||||||
assertTrue(iter.position <= text.length);
|
assert(iter.position <= text.length);
|
||||||
assertTrue(iter.position < prev);
|
assert(iter.position < prev);
|
||||||
segments.push(text.substring(iter.position, prev));
|
segments.push(text.substring(iter.position, prev));
|
||||||
prev = iter.position;
|
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.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "grapheme"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -24,6 +29,6 @@ for (const text of [
|
|||||||
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
|
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
|
||||||
]) {
|
]) {
|
||||||
const iter = seg.segment(text);
|
const iter = seg.segment(text);
|
||||||
assertEquals(undefined, iter.breakType);
|
assert.sameValue(undefined, iter.breakType);
|
||||||
assertEquals(0, iter.position);
|
assert.sameValue(0, iter.position);
|
||||||
}
|
}
|
@ -1,8 +1,13 @@
|
|||||||
// Copyright 2018 the V8 project authors. All rights reserved.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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 = {};
|
let breakCounts = {};
|
||||||
for (const locale of ["en", "fr", "ja", "zh", "ko"]) {
|
for (const locale of ["en", "fr", "ja", "zh", "ko"]) {
|
||||||
@ -39,19 +44,19 @@ for (const locale of ["en", "fr", "ja", "zh", "ko"]) {
|
|||||||
}
|
}
|
||||||
// In Japanese
|
// In Japanese
|
||||||
// Just test the break count in loose mode is greater than normal mode.
|
// 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.
|
// 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
|
// In Chinese
|
||||||
// Just test the break count in loose mode is greater than normal mode.
|
// 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.
|
// 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
|
// In English, French and Korean
|
||||||
assertEquals(breakCounts["en-loose"], breakCounts["en-normal"]);
|
assert.sameValue(breakCounts["en-loose"], breakCounts["en-normal"]);
|
||||||
assertEquals(breakCounts["fr-loose"], breakCounts["fr-normal"]);
|
assert.sameValue(breakCounts["fr-loose"], breakCounts["fr-normal"]);
|
||||||
assertEquals(breakCounts["ko-loose"], breakCounts["ko-normal"]);
|
assert.sameValue(breakCounts["ko-loose"], breakCounts["ko-normal"]);
|
||||||
// and test the break count in normal mode is greater than strict mode.
|
// and test the break count in normal mode is greater than strict mode.
|
||||||
assertTrue(breakCounts["en-normal"] > breakCounts["en-strict"]);
|
assert(breakCounts["en-normal"] > breakCounts["en-strict"]);
|
||||||
assertTrue(breakCounts["fr-normal"] > breakCounts["fr-strict"]);
|
assert(breakCounts["fr-normal"] > breakCounts["fr-strict"]);
|
||||||
assertTrue(breakCounts["ko-normal"] > breakCounts["ko-strict"]);
|
assert(breakCounts["ko-normal"] > breakCounts["ko-strict"]);
|
@ -1,8 +1,13 @@
|
|||||||
// Copyright 2018 the V8 project authors. All rights reserved.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "line"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -27,12 +32,12 @@ for (const text of [
|
|||||||
let prev = 0;
|
let prev = 0;
|
||||||
let segments = [];
|
let segments = [];
|
||||||
while (!iter.following()) {
|
while (!iter.following()) {
|
||||||
assertTrue(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
assert(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
||||||
assertTrue(iter.position >= 0);
|
assert(iter.position >= 0);
|
||||||
assertTrue(iter.position <= text.length);
|
assert(iter.position <= text.length);
|
||||||
assertTrue(iter.position > prev);
|
assert(iter.position > prev);
|
||||||
segments.push(text.substring(prev, iter.position));
|
segments.push(text.substring(prev, iter.position));
|
||||||
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.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "line"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -29,17 +34,17 @@ for (const text of [
|
|||||||
let iter = seg.segment(text);
|
let iter = seg.segment(text);
|
||||||
let prev = 0;
|
let prev = 0;
|
||||||
for (const v of seg.segment(text)) {
|
for (const v of seg.segment(text)) {
|
||||||
assertTrue(["soft", "hard"].includes(v.breakType), v.breakType);
|
assert(["soft", "hard"].includes(v.breakType), v.breakType);
|
||||||
assertEquals("string", typeof v.segment);
|
assert.sameValue("string", typeof v.segment);
|
||||||
assertTrue(v.segment.length > 0);
|
assert(v.segment.length > 0);
|
||||||
segments.push(v.segment);
|
segments.push(v.segment);
|
||||||
|
|
||||||
// manually advance the iter.
|
// manually advance the iter.
|
||||||
assertFalse(iter.following());
|
assertFalse(iter.following());
|
||||||
assertEquals(iter.breakType, v.breakType);
|
assert.sameValue(iter.breakType, v.breakType);
|
||||||
assertEquals(text.substring(prev, iter.position), v.segment);
|
assert.sameValue(text.substring(prev, iter.position), v.segment);
|
||||||
prev = iter.position;
|
prev = iter.position;
|
||||||
}
|
}
|
||||||
assertTrue(iter.following());
|
assert(iter.following());
|
||||||
assertEquals(text, segments.join(''));
|
assert.sameValue(text, segments.join(''));
|
||||||
}
|
}
|
@ -1,8 +1,13 @@
|
|||||||
// Copyright 2018 the V8 project authors. All rights reserved.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "line"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -27,10 +32,10 @@ for (const text of [
|
|||||||
let segments = [];
|
let segments = [];
|
||||||
for (let result = iter.next(); !result.done; result = iter.next()) {
|
for (let result = iter.next(); !result.done; result = iter.next()) {
|
||||||
const v = result.value;
|
const v = result.value;
|
||||||
assertTrue(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
assert(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
||||||
assertEquals("string", typeof v.segment);
|
assert.sameValue("string", typeof v.segment);
|
||||||
assertTrue(v.segment.length > 0);
|
assert(v.segment.length > 0);
|
||||||
segments.push(v.segment);
|
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.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "line"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -27,18 +32,18 @@ for (const text of [
|
|||||||
let prev = text.length;
|
let prev = text.length;
|
||||||
let segments = [];
|
let segments = [];
|
||||||
iter.preceding(prev)
|
iter.preceding(prev)
|
||||||
assertTrue(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
assert(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
||||||
assertTrue(iter.position >= 0);
|
assert(iter.position >= 0);
|
||||||
assertTrue(iter.position < prev);
|
assert(iter.position < prev);
|
||||||
segments.push(text.substring(iter.position, prev));
|
segments.push(text.substring(iter.position, prev));
|
||||||
prev = iter.position;
|
prev = iter.position;
|
||||||
while (!iter.preceding()) {
|
while (!iter.preceding()) {
|
||||||
assertTrue(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
assert(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
||||||
assertTrue(iter.position >= 0);
|
assert(iter.position >= 0);
|
||||||
assertTrue(iter.position <= text.length);
|
assert(iter.position <= text.length);
|
||||||
assertTrue(iter.position < prev);
|
assert(iter.position < prev);
|
||||||
segments.push(text.substring(iter.position, prev));
|
segments.push(text.substring(iter.position, prev));
|
||||||
prev = iter.position;
|
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.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "line"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -24,6 +29,6 @@ for (const text of [
|
|||||||
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
|
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
|
||||||
]) {
|
]) {
|
||||||
const iter = seg.segment(text);
|
const iter = seg.segment(text);
|
||||||
assertTrue(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
assert(["soft", "hard"].includes(iter.breakType), iter.breakType);
|
||||||
assertEquals(0, iter.position);
|
assert.sameValue(0, iter.position);
|
||||||
}
|
}
|
@ -1,8 +1,13 @@
|
|||||||
// Copyright 2018 the V8 project authors. All rights reserved.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "sentence"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -27,12 +32,12 @@ for (const text of [
|
|||||||
let prev = 0;
|
let prev = 0;
|
||||||
let segments = [];
|
let segments = [];
|
||||||
while (!iter.following()) {
|
while (!iter.following()) {
|
||||||
assertTrue(["sep", "term"].includes(iter.breakType), iter.breakType);
|
assert(["sep", "term"].includes(iter.breakType), iter.breakType);
|
||||||
assertTrue(iter.position >= 0);
|
assert(iter.position >= 0);
|
||||||
assertTrue(iter.position <= text.length);
|
assert(iter.position <= text.length);
|
||||||
assertTrue(iter.position > prev);
|
assert(iter.position > prev);
|
||||||
segments.push(text.substring(prev, iter.position));
|
segments.push(text.substring(prev, iter.position));
|
||||||
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.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "sentence"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -29,17 +34,17 @@ for (const text of [
|
|||||||
let iter = seg.segment(text);
|
let iter = seg.segment(text);
|
||||||
let prev = 0;
|
let prev = 0;
|
||||||
for (const v of seg.segment(text)) {
|
for (const v of seg.segment(text)) {
|
||||||
assertTrue(["sep", "term"].includes(v.breakType), v.breakType);
|
assert(["sep", "term"].includes(v.breakType), v.breakType);
|
||||||
assertEquals("string", typeof v.segment);
|
assert.sameValue("string", typeof v.segment);
|
||||||
assertTrue(v.segment.length > 0);
|
assert(v.segment.length > 0);
|
||||||
segments.push(v.segment);
|
segments.push(v.segment);
|
||||||
|
|
||||||
// manually advance the iter.
|
// manually advance the iter.
|
||||||
assertFalse(iter.following());
|
assertFalse(iter.following());
|
||||||
assertEquals(iter.breakType, v.breakType);
|
assert.sameValue(iter.breakType, v.breakType);
|
||||||
assertEquals(text.substring(prev, iter.position), v.segment);
|
assert.sameValue(text.substring(prev, iter.position), v.segment);
|
||||||
prev = iter.position;
|
prev = iter.position;
|
||||||
}
|
}
|
||||||
assertTrue(iter.following());
|
assert(iter.following());
|
||||||
assertEquals(text, segments.join(''));
|
assert.sameValue(text, segments.join(''));
|
||||||
}
|
}
|
@ -1,8 +1,13 @@
|
|||||||
// Copyright 2018 the V8 project authors. All rights reserved.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "sentence"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -27,10 +32,10 @@ for (const text of [
|
|||||||
let segments = [];
|
let segments = [];
|
||||||
for (let result = iter.next(); !result.done; result = iter.next()) {
|
for (let result = iter.next(); !result.done; result = iter.next()) {
|
||||||
const v = result.value;
|
const v = result.value;
|
||||||
assertTrue(["sep", "term"].includes(iter.breakType), iter.breakType);
|
assert(["sep", "term"].includes(iter.breakType), iter.breakType);
|
||||||
assertEquals("string", typeof v.segment);
|
assert.sameValue("string", typeof v.segment);
|
||||||
assertTrue(v.segment.length > 0);
|
assert(v.segment.length > 0);
|
||||||
segments.push(v.segment);
|
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.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "sentence"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -27,18 +32,18 @@ for (const text of [
|
|||||||
let prev = text.length;
|
let prev = text.length;
|
||||||
let segments = [];
|
let segments = [];
|
||||||
iter.preceding(prev);
|
iter.preceding(prev);
|
||||||
assertTrue(["sep", "term"].includes(iter.breakType), iter.breakType);
|
assert(["sep", "term"].includes(iter.breakType), iter.breakType);
|
||||||
assertTrue(iter.position >= 0);
|
assert(iter.position >= 0);
|
||||||
assertTrue(iter.position < prev);
|
assert(iter.position < prev);
|
||||||
segments.push(text.substring(iter.position, prev));
|
segments.push(text.substring(iter.position, prev));
|
||||||
prev = iter.position;
|
prev = iter.position;
|
||||||
while (!iter.preceding()) {
|
while (!iter.preceding()) {
|
||||||
assertTrue(["sep", "term"].includes(iter.breakType), iter.breakType);
|
assert(["sep", "term"].includes(iter.breakType), iter.breakType);
|
||||||
assertTrue(iter.position >= 0);
|
assert(iter.position >= 0);
|
||||||
assertTrue(iter.position <= text.length);
|
assert(iter.position <= text.length);
|
||||||
assertTrue(iter.position < prev);
|
assert(iter.position < prev);
|
||||||
segments.push(text.substring(iter.position, prev));
|
segments.push(text.substring(iter.position, prev));
|
||||||
prev = iter.position;
|
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.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "sentence"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -24,6 +29,6 @@ for (const text of [
|
|||||||
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
|
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
|
||||||
]) {
|
]) {
|
||||||
const iter = seg.segment(text);
|
const iter = seg.segment(text);
|
||||||
assertTrue(["sep", "term"].includes(iter.breakType), iter.breakType);
|
assert(["sep", "term"].includes(iter.breakType), iter.breakType);
|
||||||
assertEquals(0, iter.position);
|
assert.sameValue(0, iter.position);
|
||||||
}
|
}
|
@ -1,8 +1,13 @@
|
|||||||
// Copyright 2018 the V8 project authors. All rights reserved.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "word"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -27,12 +32,12 @@ for (const text of [
|
|||||||
let prev = 0;
|
let prev = 0;
|
||||||
let segments = [];
|
let segments = [];
|
||||||
while (!iter.following()) {
|
while (!iter.following()) {
|
||||||
assertTrue(["word", "none"].includes(iter.breakType), iter.breakType);
|
assert(["word", "none"].includes(iter.breakType), iter.breakType);
|
||||||
assertTrue(iter.position >= 0);
|
assert(iter.position >= 0);
|
||||||
assertTrue(iter.position <= text.length);
|
assert(iter.position <= text.length);
|
||||||
assertTrue(iter.position > prev);
|
assert(iter.position > prev);
|
||||||
segments.push(text.substring(prev, iter.position));
|
segments.push(text.substring(prev, iter.position));
|
||||||
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.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "word"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -29,17 +34,17 @@ for (const text of [
|
|||||||
let iter = seg.segment(text);
|
let iter = seg.segment(text);
|
||||||
let prev = 0;
|
let prev = 0;
|
||||||
for (const v of seg.segment(text)) {
|
for (const v of seg.segment(text)) {
|
||||||
assertTrue(["word", "none"].includes(v.breakType), v.breakType);
|
assert(["word", "none"].includes(v.breakType), v.breakType);
|
||||||
assertEquals("string", typeof v.segment);
|
assert.sameValue("string", typeof v.segment);
|
||||||
assertTrue(v.segment.length > 0);
|
assert(v.segment.length > 0);
|
||||||
segments.push(v.segment);
|
segments.push(v.segment);
|
||||||
|
|
||||||
// manually advance the iter.
|
// manually advance the iter.
|
||||||
assertFalse(iter.following());
|
assertFalse(iter.following());
|
||||||
assertEquals(iter.breakType, v.breakType);
|
assert.sameValue(iter.breakType, v.breakType);
|
||||||
assertEquals(text.substring(prev, iter.position), v.segment);
|
assert.sameValue(text.substring(prev, iter.position), v.segment);
|
||||||
prev = iter.position;
|
prev = iter.position;
|
||||||
}
|
}
|
||||||
assertTrue(iter.following());
|
assert(iter.following());
|
||||||
assertEquals(text, segments.join(''));
|
assert.sameValue(text, segments.join(''));
|
||||||
}
|
}
|
@ -1,8 +1,13 @@
|
|||||||
// Copyright 2018 the V8 project authors. All rights reserved.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "word"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -27,10 +32,10 @@ for (const text of [
|
|||||||
let segments = [];
|
let segments = [];
|
||||||
for (let result = iter.next(); !result.done; result = iter.next()) {
|
for (let result = iter.next(); !result.done; result = iter.next()) {
|
||||||
const v = result.value;
|
const v = result.value;
|
||||||
assertTrue(["word", "none"].includes(iter.breakType), iter.breakType);
|
assert(["word", "none"].includes(iter.breakType), iter.breakType);
|
||||||
assertEquals("string", typeof v.segment);
|
assert.sameValue("string", typeof v.segment);
|
||||||
assertTrue(v.segment.length > 0);
|
assert(v.segment.length > 0);
|
||||||
segments.push(v.segment);
|
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.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "word"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -27,18 +32,18 @@ for (const text of [
|
|||||||
let prev = text.length;
|
let prev = text.length;
|
||||||
let segments = [];
|
let segments = [];
|
||||||
iter.preceding(prev);
|
iter.preceding(prev);
|
||||||
assertTrue(["word", "none"].includes(iter.breakType), iter.breakType);
|
assert(["word", "none"].includes(iter.breakType), iter.breakType);
|
||||||
assertTrue(iter.position >= 0);
|
assert(iter.position >= 0);
|
||||||
assertTrue(iter.position < prev);
|
assert(iter.position < prev);
|
||||||
segments.push(text.substring(iter.position, prev));
|
segments.push(text.substring(iter.position, prev));
|
||||||
prev = iter.position;
|
prev = iter.position;
|
||||||
while (!iter.preceding()) {
|
while (!iter.preceding()) {
|
||||||
assertTrue(["word", "none"].includes(iter.breakType), iter.breakType);
|
assert(["word", "none"].includes(iter.breakType), iter.breakType);
|
||||||
assertTrue(iter.position >= 0);
|
assert(iter.position >= 0);
|
||||||
assertTrue(iter.position <= text.length);
|
assert(iter.position <= text.length);
|
||||||
assertTrue(iter.position < prev);
|
assert(iter.position < prev);
|
||||||
segments.push(text.substring(iter.position, prev));
|
segments.push(text.substring(iter.position, prev));
|
||||||
prev = iter.position;
|
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.
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
// 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"})
|
const seg = new Intl.Segmenter([], {granularity: "word"})
|
||||||
for (const text of [
|
for (const text of [
|
||||||
@ -24,6 +29,6 @@ for (const text of [
|
|||||||
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
|
"법원 “다스 지분 처분권·수익권 모두 MB가 보유”", // Korean
|
||||||
]) {
|
]) {
|
||||||
const iter = seg.segment(text);
|
const iter = seg.segment(text);
|
||||||
assertTrue(["word", "none"].includes(iter.breakType), iter.breakType);
|
assert(["word", "none"].includes(iter.breakType), iter.breakType);
|
||||||
assertEquals(0, iter.position);
|
assert.sameValue(0, iter.position);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user