mirror of
https://github.com/tc39/test262.git
synced 2025-07-31 01:44:54 +02:00
intl: Tests for default options tweak proposal (#1220)
Tests for ECMA 402 PR https://github.com/tc39/ecma402/pull/170 The tests on Date/DateTimeFormat are valid without the PR.
This commit is contained in:
parent
d809fd0a4f
commit
765f273ac4
20
test/intl402/Collator/default-options-object-prototype.js
Normal file
20
test/intl402/Collator/default-options-object-prototype.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright (C) 2017 Daniel Ehrenberg. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-initializecollator
|
||||||
|
description: >
|
||||||
|
Monkey-patching Object.prototype does not change the default
|
||||||
|
options for Collator as a null prototype is used.
|
||||||
|
info: >
|
||||||
|
InitializeCollator ( collator, locales, options )
|
||||||
|
|
||||||
|
1. If _options_ is *undefined*, then
|
||||||
|
1. Let _options_ be ObjectCreate(*null*).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
let defaultSensitivity = new Intl.Collator("en").resolvedOptions().sensitivity;
|
||||||
|
|
||||||
|
Object.prototype.sensitivity = "base";
|
||||||
|
let collator = new Intl.Collator("en");
|
||||||
|
assert.sameValue(collator.resolvedOptions().sensitivity, defaultSensitivity);
|
19
test/intl402/Date/prototype/toLocaleString/default-options-object-prototype.js
vendored
Normal file
19
test/intl402/Date/prototype/toLocaleString/default-options-object-prototype.js
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (C) 2017 Daniel Ehrenberg. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-todatetimeoptions
|
||||||
|
description: >
|
||||||
|
Monkey-patching Object.prototype does not change the default
|
||||||
|
options for DateTimeFormat as a null prototype is used.
|
||||||
|
info: >
|
||||||
|
ToDateTimeOptions ( options, required, defaults )
|
||||||
|
|
||||||
|
1. If options is undefined, let options be null; otherwise let options be ? ToObject(options).
|
||||||
|
1. Let options be ObjectCreate(options).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
if (new Intl.DateTimeFormat("en").resolvedOptions().locale === "en") {
|
||||||
|
Object.prototype.year = "2-digit";
|
||||||
|
assert.notSameValue(new Date().toLocaleString("en").length, 2);
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright (C) 2017 Daniel Ehrenberg. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-todatetimeoptions
|
||||||
|
description: >
|
||||||
|
Monkey-patching Object.prototype does not change the default
|
||||||
|
options for DateTimeFormat as a null prototype is used.
|
||||||
|
info: >
|
||||||
|
ToDateTimeOptions ( options, required, defaults )
|
||||||
|
|
||||||
|
1. If options is undefined, let options be null; otherwise let options be ? ToObject(options).
|
||||||
|
1. Let options be ObjectCreate(options).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
let defaultYear = new Intl.DateTimeFormat("en").resolvedOptions().year;
|
||||||
|
|
||||||
|
Object.prototype.year = "2-digit";
|
||||||
|
let formatter = new Intl.DateTimeFormat("en");
|
||||||
|
assert.sameValue(formatter.resolvedOptions().year, defaultYear);
|
19
test/intl402/Number/prototype/toLocaleString/default-options-object-prototype.js
vendored
Normal file
19
test/intl402/Number/prototype/toLocaleString/default-options-object-prototype.js
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (C) 2017 Daniel Ehrenberg. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-initializenumberformat
|
||||||
|
description: >
|
||||||
|
Monkey-patching Object.prototype does not change the default
|
||||||
|
options for NumberFormat as a null prototype is used.
|
||||||
|
info: >
|
||||||
|
InitializeNumberFormat ( numberFormat, locales, options )
|
||||||
|
|
||||||
|
1. If _options_ is *undefined*, then
|
||||||
|
1. Let _options_ be ObjectCreate(*null*).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
if (new Intl.NumberFormat("en").resolvedOptions().locale === "en") {
|
||||||
|
Object.prototype.maximumFractionDigits = 1;
|
||||||
|
assert.sameValue(1.23.toLocaleString("en"), "1.23");
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (C) 2017 Daniel Ehrenberg. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-initializenumberformat
|
||||||
|
description: >
|
||||||
|
Monkey-patching Object.prototype does not change the default
|
||||||
|
options for NumberFormat as a null prototype is used.
|
||||||
|
info: >
|
||||||
|
InitializeNumberFormat ( numberFormat, locales, options )
|
||||||
|
|
||||||
|
1. If _options_ is *undefined*, then
|
||||||
|
1. Let _options_ be ObjectCreate(*null*).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
let defaultMaximumFractionDigits =
|
||||||
|
new Intl.NumberFormat("en").resolvedOptions().maximumFractionDigits;
|
||||||
|
|
||||||
|
Object.prototype.maximumFractionDigits = 1;
|
||||||
|
let formatter = new Intl.NumberFormat("en");
|
||||||
|
assert.sameValue(formatter.resolvedOptions().maximumFractionDigits,
|
||||||
|
defaultMaximumFractionDigits);
|
19
test/intl402/String/prototype/localeCompare/default-options-object-prototype.js
vendored
Normal file
19
test/intl402/String/prototype/localeCompare/default-options-object-prototype.js
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (C) 2017 Daniel Ehrenberg. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-initializecollator
|
||||||
|
description: >
|
||||||
|
Monkey-patching Object.prototype does not change the default
|
||||||
|
options for Collator as a null prototype is used.
|
||||||
|
info: >
|
||||||
|
InitializeCollator ( collator, locales, options )
|
||||||
|
|
||||||
|
1. If _options_ is *undefined*, then
|
||||||
|
1. Let _options_ be ObjectCreate(*null*).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
if (new Intl.Collator("en").resolvedOptions().locale === "en") {
|
||||||
|
Object.prototype.sensitivity = "base";
|
||||||
|
assert.sameValue("a".localeCompare("A"), -1);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user