node/deps/v8/test/intl/relative-time-format/constructor.js
Ujjwal Sharma f579e11940 deps: update V8 to 7.4.288.13
PR-URL: https://github.com/nodejs/node/pull/26685
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2019-03-28 16:36:18 -04: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);