aboutsummaryrefslogtreecommitdiffstats
path: root/test/suite/intl402/ch13/13.1/13.1.1_1.js
blob: 37be9711b34fad3ed3bf87e1d2e92e1bf7ab1a4f (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
// Copyright 2012 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/**
 * @description Tests that localeCompare rejects values that can't be coerced to an object.
 * @author Norbert Lindenberg
 */

var invalidValues = [undefined, null];
 
invalidValues.forEach(function (value) {
    var error;
    try {
        var result = String.prototype.localeCompare.call(value, "");
    } catch (e) {
        error = e;
    }
    if (error === undefined) {
        $ERROR("String.prototype.localeCompare did not reject this = " + value + ".");
    } else if (error.name !== "TypeError") {
        $ERROR("String.prototype.localeCompare rejected this = " + value + " with wrong error " + error.name + ".");
    }
});