mirror of https://github.com/tc39/test262.git
Merge pull request #1678 from Ms2ger/rtf-options-non-object
Intl.RelativeTimeFormat: Add some tests for non-object options arguments to the constructor.
This commit is contained in:
commit
fcefbc7945
|
@ -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"`);
|
||||
}
|
|
@ -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"`);
|
||||
}
|
|
@ -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"`);
|
||||
}
|
Loading…
Reference in New Issue