62915f403e
Also split out some order check tests. Bug: v8:5751 Change-Id: I1765d1809b456c43e21d9a379f720a0ea12e794e Reviewed-on: https://chromium-review.googlesource.com/c/1352283 Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Commit-Queue: Frank Tang <ftang@chromium.org> Cr-Commit-Position: refs/heads/master@{#57988}
193 lines
4.1 KiB
JavaScript
193 lines
4.1 KiB
JavaScript
// Copyright 2018 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Flags: --harmony-intl-segmenter
|
|
|
|
// Segmenter constructor can't be called as function.
|
|
assertThrows(() => Intl.Segmenter(["sr"]), TypeError);
|
|
|
|
// Invalid locale string.
|
|
assertThrows(() => new Intl.Segmenter(["abcdefghi"]), RangeError);
|
|
|
|
assertDoesNotThrow(() => new Intl.Segmenter(["sr"], {}), TypeError);
|
|
|
|
assertDoesNotThrow(() => new Intl.Segmenter([], {}));
|
|
|
|
assertDoesNotThrow(() => new Intl.Segmenter(["fr", "ar"], {}));
|
|
|
|
assertDoesNotThrow(() => new Intl.Segmenter({ 0: "ja", 1: "fr" }, {}));
|
|
|
|
assertDoesNotThrow(() => new Intl.Segmenter({ 1: "ja", 2: "fr" }, {}));
|
|
|
|
assertDoesNotThrow(() => new Intl.Segmenter(["sr"]));
|
|
|
|
assertDoesNotThrow(() => new Intl.Segmenter());
|
|
|
|
assertDoesNotThrow(
|
|
() =>
|
|
new Intl.Segmenter(["sr"], {
|
|
lineBreakStyle: "strict",
|
|
granularity: "grapheme"
|
|
})
|
|
);
|
|
|
|
assertDoesNotThrow(
|
|
() => new Intl.Segmenter(["sr"], { granularity: "sentence" })
|
|
);
|
|
|
|
assertDoesNotThrow(() => new Intl.Segmenter(["sr"], { granularity: "word" }));
|
|
|
|
assertDoesNotThrow(
|
|
() => new Intl.Segmenter(["sr"], { granularity: "grapheme" })
|
|
);
|
|
|
|
assertDoesNotThrow(() => new Intl.Segmenter(["sr"], { granularity: "line" }));
|
|
|
|
assertThrows(
|
|
() => new Intl.Segmenter(["sr"], { granularity: "standard" }),
|
|
RangeError
|
|
);
|
|
|
|
assertDoesNotThrow(
|
|
() => new Intl.Segmenter(["sr"], { lineBreakStyle: "normal" })
|
|
);
|
|
|
|
assertDoesNotThrow(
|
|
() => new Intl.Segmenter(["sr"], { lineBreakStyle: "strict" })
|
|
);
|
|
|
|
assertDoesNotThrow(
|
|
() => new Intl.Segmenter(["sr"], { lineBreakStyle: "loose" })
|
|
);
|
|
|
|
assertThrows(
|
|
() => new Intl.Segmenter(["sr"], { lineBreakStyle: "giant" }),
|
|
RangeError
|
|
);
|
|
|
|
assertDoesNotThrow(
|
|
() =>
|
|
new Intl.Segmenter(["sr"], {
|
|
granularity: "sentence",
|
|
lineBreakStyle: "normal"
|
|
})
|
|
);
|
|
|
|
assertDoesNotThrow(
|
|
() =>
|
|
new Intl.Segmenter(["sr"], {
|
|
granularity: "sentence",
|
|
lineBreakStyle: "strict"
|
|
})
|
|
);
|
|
|
|
assertDoesNotThrow(
|
|
() =>
|
|
new Intl.Segmenter(["sr"], {
|
|
granularity: "sentence",
|
|
lineBreakStyle: "loose"
|
|
})
|
|
);
|
|
|
|
assertDoesNotThrow(
|
|
() =>
|
|
new Intl.Segmenter(["sr"], {
|
|
granularity: "word",
|
|
lineBreakStyle: "normal"
|
|
})
|
|
);
|
|
|
|
assertDoesNotThrow(
|
|
() =>
|
|
new Intl.Segmenter(["sr"], {
|
|
granularity: "word",
|
|
lineBreakStyle: "strict"
|
|
})
|
|
);
|
|
|
|
assertDoesNotThrow(
|
|
() =>
|
|
new Intl.Segmenter(["sr"], {
|
|
granularity: "word",
|
|
lineBreakStyle: "loose"
|
|
})
|
|
);
|
|
|
|
assertDoesNotThrow(
|
|
() =>
|
|
new Intl.Segmenter(["sr"], {
|
|
granularity: "grapheme",
|
|
lineBreakStyle: "normal"
|
|
})
|
|
);
|
|
|
|
assertDoesNotThrow(
|
|
() =>
|
|
new Intl.Segmenter(["sr"], {
|
|
granularity: "grapheme",
|
|
lineBreakStyle: "strict"
|
|
})
|
|
);
|
|
|
|
assertDoesNotThrow(
|
|
() =>
|
|
new Intl.Segmenter(["sr"], {
|
|
granularity: "grapheme",
|
|
lineBreakStyle: "loose"
|
|
})
|
|
);
|
|
|
|
assertDoesNotThrow(
|
|
() =>
|
|
new Intl.Segmenter(["sr"], {
|
|
granularity: "line",
|
|
lineBreakStyle: "loose"
|
|
})
|
|
);
|
|
|
|
assertDoesNotThrow(
|
|
() =>
|
|
new Intl.Segmenter(["sr"], {
|
|
granularity: "line",
|
|
lineBreakStyle: "normal"
|
|
})
|
|
);
|
|
|
|
assertDoesNotThrow(
|
|
() =>
|
|
new Intl.Segmenter(["sr"], {
|
|
granularity: "line",
|
|
lineBreakStyle: "strict"
|
|
})
|
|
);
|
|
|
|
// propagate exception from getter
|
|
assertThrows(
|
|
() =>
|
|
new Intl.Segmenter(undefined, {
|
|
get localeMatcher() {
|
|
throw new TypeError("");
|
|
}
|
|
}),
|
|
TypeError
|
|
);
|
|
assertThrows(
|
|
() =>
|
|
new Intl.Segmenter(undefined, {
|
|
get lineBreakStyle() {
|
|
throw new TypeError("");
|
|
}
|
|
}),
|
|
TypeError
|
|
);
|
|
assertThrows(
|
|
() =>
|
|
new Intl.Segmenter(undefined, {
|
|
get granularity() {
|
|
throw new TypeError("");
|
|
}
|
|
}),
|
|
TypeError
|
|
);
|