v8/test/intl/relative-time-format/constructor.js
Frank Tang 9732200408 Reland test part of "[Intl] Cleans up intl-relative-time-format flag"
This is a partial reland of 048a3a3ecb

Original change's description:
> [Intl] Cleans up intl-relative-time-format flag
>
> Cleans up always=true intl-relative-time-format flag
> It shipped in m71 in Dec 2018.
>
> Bug: v8:8704
> Change-Id: I52d86aea9aedf201a216a1df0773a486fbee37b9
> Reviewed-on: https://chromium-review.googlesource.com/c/1417299
> Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> Commit-Queue: Frank Tang <ftang@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#58904}

Bug: v8:8704
Change-Id: Iac62a347eea7f85dd3fa4a3bbfb18091b80f9a5e
Reviewed-on: https://chromium-review.googlesource.com/c/1429224
Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59081}
2019-01-24 23:17:35 +00:00

78 lines
2.2 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.
// RelativeTimeFormat constructor can't be called as function.
assertThrows(() => Intl.RelativeTimeFormat('sr'), TypeError);
// Non-string locale.
//assertThrows(() => new Intl.RelativeTimeFormat(5), TypeError);
// Invalid locale string.
//assertThrows(() => new Intl.RelativeTimeFormat('abcdefghi'), RangeError);
assertDoesNotThrow(() => new Intl.RelativeTimeFormat('sr', {}));
assertDoesNotThrow(() => new Intl.RelativeTimeFormat([], {}));
assertDoesNotThrow(() => new Intl.RelativeTimeFormat(['fr', 'ar'], {}));
assertDoesNotThrow(() => new Intl.RelativeTimeFormat({0: 'ja', 1:'fr'}, {}));
assertDoesNotThrow(() => new Intl.RelativeTimeFormat({1: 'ja', 2:'fr'}, {}));
assertDoesNotThrow(() => new Intl.RelativeTimeFormat('sr'));
assertDoesNotThrow(() => new Intl.RelativeTimeFormat());
assertDoesNotThrow(
() => new Intl.RelativeTimeFormat(
'sr', {
localeMatcher: 'lookup',
style: 'short',
numeric: 'always'
}));
assertDoesNotThrow(
() => new Intl.RelativeTimeFormat('sr', {localeMatcher: 'lookup'}));
assertDoesNotThrow(
() => new Intl.RelativeTimeFormat('sr', {localeMatcher: 'best fit'}));
assertThrows(
() => new Intl.RelativeTimeFormat('sr', {localeMatcher: 'hello'}),
RangeError);
assertThrows(
() => new Intl.RelativeTimeFormat('sr', {localeMatcher: 'look up'}),
RangeError);
assertThrows(
() => new Intl.RelativeTimeFormat('sr', {localeMatcher: 'bestfit'}),
RangeError);
assertDoesNotThrow(
() => new Intl.RelativeTimeFormat('sr', {style: 'long'}));
assertDoesNotThrow(
() => new Intl.RelativeTimeFormat('sr', {style: 'short'}));
assertDoesNotThrow(
() => new Intl.RelativeTimeFormat('sr', {style: 'narrow'}));
assertThrows(
() => new Intl.RelativeTimeFormat('sr', {style: 'giant'}),
RangeError);
assertDoesNotThrow(
() => new Intl.RelativeTimeFormat('sr', {numeric: 'always'}));
assertDoesNotThrow(
() => new Intl.RelativeTimeFormat('sr', {numeric: 'auto'}));
assertThrows(
() => new Intl.RelativeTimeFormat('sr', {numeric: 'never'}),
RangeError);