summaryrefslogtreecommitdiff
path: root/test/suite/intl402/ch11/11.1/11.1.1_19.js
blob: e41ca5bec9bf854f86fed376147927dfd745c570 (plain)
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
// Copyright 2012 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/**
 * @description Tests that the currency style can not be used without a specified currency.
 * @author Norbert Lindenberg
 */

var defaultLocale = new Intl.NumberFormat().resolvedOptions().locale;

function expectError(f) {
    var error;
    try {
        f();
    } catch (e) {
        error = e;
    }
    if (error === undefined) {
        $ERROR("Invalid currency value " + value + " was not rejected.");
    } else if (error.name !== "TypeError") {
        $ERROR("Invalid currency value " + value + " was rejected with wrong error " + error.name + ".");
    }
}

expectError(function () {
        return new Intl.NumberFormat([defaultLocale], {style: "currency"});
});
expectError(function () {
        return new Intl.NumberFormat([defaultLocale + "-u-cu-krw"], {style: "currency"});
});