Intl.RelativeTimeFormat: Add some tests for non-object options arguments to the constructor.

This commit is contained in:
Ms2ger 2018-08-14 17:39:18 +02:00
parent 60b9467630
commit 3161b18f71
3 changed files with 99 additions and 0 deletions

View File

@ -0,0 +1,35 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.RelativeTimeFormat
description: Checks handling of non-object option arguments to the RelativeTimeFormat constructor.
info: |
InitializeRelativeTimeFormat (relativeTimeFormat, locales, options)
features: [Intl.RelativeTimeFormat]
---*/
Object.defineProperties(Object.prototype, {
"style": {
value: "short",
},
"numeric": {
value: "auto",
},
})
const optionsArguments = [
true,
"test",
7,
Symbol(),
];
for (const options of optionsArguments) {
const rtf = new Intl.RelativeTimeFormat([], options);
const resolvedOptions = rtf.resolvedOptions();
assert.sameValue(resolvedOptions.style, "short",
`options argument ${String(options)} should yield the correct value for "style"`);
assert.sameValue(resolvedOptions.numeric, "auto",
`options argument ${String(options)} should yield the correct value for "numeric"`);
}

View File

@ -0,0 +1,26 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.RelativeTimeFormat
description: Checks handling of non-object option arguments to the RelativeTimeFormat constructor.
info: |
InitializeRelativeTimeFormat (relativeTimeFormat, locales, options)
features: [Intl.RelativeTimeFormat]
---*/
const optionsArguments = [
true,
"test",
7,
Symbol(),
];
for (const options of optionsArguments) {
const rtf = new Intl.RelativeTimeFormat([], options);
const resolvedOptions = rtf.resolvedOptions();
assert.sameValue(resolvedOptions.style, "long",
`options argument ${String(options)} should yield the correct value for "style"`);
assert.sameValue(resolvedOptions.numeric, "always",
`options argument ${String(options)} should yield the correct value for "numeric"`);
}

View File

@ -0,0 +1,38 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.RelativeTimeFormat
description: Checks handling of non-object option arguments to the RelativeTimeFormat constructor.
info: |
InitializeRelativeTimeFormat (relativeTimeFormat, locales, options)
features: [Intl.RelativeTimeFormat]
---*/
Object.defineProperties(Object.prototype, {
"style": {
get() {
throw new Error("Should not call style getter");
}
},
"numeric": {
get() {
throw new Error("Should not call numeric getter");
}
},
})
const optionsArguments = [
[],
[[]],
[[], undefined],
];
for (const args of optionsArguments) {
const rtf = new Intl.RelativeTimeFormat(...args);
const resolvedOptions = rtf.resolvedOptions();
assert.sameValue(resolvedOptions.style, "long",
`Calling with ${args.length} empty arguments should yield the correct value for "style"`);
assert.sameValue(resolvedOptions.numeric, "always",
`Calling with ${args.length} empty arguments should yield the correct value for "numeric"`);
}