Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
52 lines (45 loc) · 3.41 KB

File metadata and controls

52 lines (45 loc) · 3.41 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js");
const tests = [
{
name: "Test invalid options",
body: function () {
function verifyNFException(locale, options, expectingInvalidOption, validValuesStr) {
try {
//Since minute and second aren't supported alone; doing this to prevent that exception.
new Intl.NumberFormat(locale, options);
assert.fail("Exception was expected. Option: " + expectingInvalidOption + "; options passed in: " + JSON.stringify(options));
}
catch (e) {
if (!(e instanceof RangeError || e instanceof TypeError)) {
assert.fail("Incorrect exception was thrown.");
}
assert.isTrue(e.message.indexOf(validValuesStr) !== -1,
"Exception didn't have the correct valid values when testing option:" + expectingInvalidOption +
".\nMessage: " + e.message +
"\nSearched For:" + validValuesStr);
}
}
verifyNFException("en-US", { minimumSignificantDigits: -1 }, "minimumSignificantDigits", "[1 - 21]");
verifyNFException("en-US", { maximumSignificantDigits: -1 }, "maximumSignificantDigits", "[1 - 21]");
verifyNFException("en-US", { minimumFractionDigits: -1 }, "minimumFractionDigits", "[0 - 20]");
verifyNFException("en-US", { maximumFractionDigits: -1 }, "maximumFractionDigits", "[0 - 20]");
verifyNFException("en-US", { minimumIntegerDigits: -1 }, "minimumIntegerDigits", "[1 - 21]");
verifyNFException("en-US", { minimumSignificantDigits: 22 }, "minimumSignificantDigits", "[1 - 21]");
verifyNFException("en-US", { maximumSignificantDigits: 22 }, "maximumSignificantDigits", "[1 - 21]");
verifyNFException("en-US", { minimumFractionDigits: 21 }, "minimumFractionDigits", "[0 - 20]");
verifyNFException("en-US", { maximumFractionDigits: 21 }, "maximumFractionDigits", "[0 - 20]");
verifyNFException("en-US", { minimumIntegerDigits: 22 }, "minimumIntegerDigits", "[1 - 21]");
verifyNFException("en-US", { minimumSignificantDigits: 5, maximumSignificantDigits: 1 }, "maximumSignificantDigits", "[5 - 21]");
verifyNFException("en-US", { minimumFractionDigits: 5, maximumFractionDigits: 1 }, "maximumFractionDigits", "[5 - 20]");
verifyNFException("en-US", { style: "invalid" }, "style", "['decimal', 'percent', 'currency']");
verifyNFException("en-US", { style: "currency" }, "style", "Currency code was not specified");
verifyNFException("en-US", { style: "currency", currency: 5 }, "currency", "Currency code '5' is invalid");
verifyNFException("en-US", { style: "currency", currency: "USD", currencyDisplay: "invalid" }, "currencyDisplay", "['code', 'symbol', 'name']");
}
}
];
testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" });
Morty Proxy This is a proxified and sanitized view of the page, visit original site.