Skip to content
Snippets Groups Projects
Commit 3161b18f authored by Ms2ger's avatar Ms2ger
Browse files

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

parent 60b94676
No related branches found
No related tags found
No related merge requests found
// 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"`);
}
// 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"`);
}
// 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"`);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment