v8/test/mjsunit/intl-pluralrules-select.js
Jungshik Shin ea9e2c6400 Remove flags for plural rules and number formatToParts
Intl.PluralRules and Intl.NumberFormat.prototype.formatToParts
were shipped in 6.3 and 6.4, respectively.

Remove harmony_plural_rules and harmony_number_format_to_parts.

Bug: v8:5601, v8:5244
Test: mjsunit/intl-pluralrules-select
Test: mjsunit/intl-numberformat-formattoparts
Test: test262/intl402/PluralRules/unit/harmony/intl-numberformat-formattoparts
Test: test262/intl402/NumberFormat/prototype/formatToParts/*
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: I1752622484bf9a0a8b9d810db54fc238f4caf3f3
Reviewed-on: https://chromium-review.googlesource.com/1032260
Commit-Queue: Jungshik Shin <jshin@chromium.org>
Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52866}
2018-04-27 20:02:48 +00:00

51 lines
1.5 KiB
JavaScript

// Copyright 2017 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.
if (this.Intl) {
var pr;
var suffixes;
function format(n) {
return "" + n + suffixes[pr.select(n)];
}
// These English examples illustrate the purpose of the PluralRules class.
pr = new Intl.PluralRules("en-US");
suffixes = {
one: " day",
other: " days",
};
assertEquals("0 days", format(0));
assertEquals("0.5 days", format(0.5));
assertEquals("1 day", format(1));
assertEquals("1.5 days", format(1.5));
assertEquals("2 days", format(2));
pr = new Intl.PluralRules("en-US", {type: "ordinal"});
suffixes = {
one: "st",
two: "nd",
few: "rd",
other: "th",
};
assertEquals("0th", format(0));
assertEquals("1st", format(1));
assertEquals("2nd", format(2));
assertEquals("3rd", format(3));
assertEquals("4th", format(4));
assertEquals("11th", format(11));
assertEquals("21st", format(21));
assertEquals("103rd", format(103));
// Arabic can cause every possible return value from select()
pr = new Intl.PluralRules("ar");
suffixes = null;
assertEquals("zero", pr.select(0));
assertEquals("one", pr.select(1));
assertEquals("two", pr.select(2));
assertEquals("few", pr.select(3));
assertEquals("many", pr.select(11));
assertEquals("other", pr.select(100));
assertEquals("other", pr.select(1.5));
}