summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Intl/Locale/surface.js
blob: ba9018243603d9580c736bc1850f97621e1a51dd (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// |reftest| skip-if(!this.hasOwnProperty('Intl'))

function assertProperty(object, name, desc) {
    assertEq(desc === undefined || (typeof desc === "object" && desc !== null), true,
             "desc is a property descriptor");

    var actual = Object.getOwnPropertyDescriptor(object, name);
    if (desc === undefined) {
        assertEq(actual, desc, `property ${String(name)} is absent`);
        return;
    }
    assertEq(actual !== undefined, true, `property ${String(name)} is present`);

    var fields = ["value", "writable", "enumerable", "configurable", "get", "set"];
    for (var field of fields) {
        if (Object.prototype.hasOwnProperty.call(desc, field)) {
            assertEq(actual[field], desc[field], `unexpected value for ${field}`);
        }
    }
}

function assertBuiltinFunction(fn, length, name) {
    assertProperty(fn, "length", {
       value: length, writable: false, enumerable: false, configurable: true,
    });
}

function assertBuiltinMethod(object, propName, length, name) {
    var desc = Object.getOwnPropertyDescriptor(object, propName);
    assertProperty(object, propName, {
        value: desc.value, writable: true, enumerable: false, configurable: true
    });
    assertBuiltinFunction(desc.value, length, name);
}

function assertBuiltinGetter(object, propName, length, name) {
    var desc = Object.getOwnPropertyDescriptor(object, propName);

    assertBuiltinFunction(desc.get, length, name);
}

// Intl.Locale( tag[, options] )
assertBuiltinFunction(Intl.Locale, 1, "Locale");

// Properties of the Intl.Locale Constructor

// Intl.Locale.prototype
assertProperty(Intl.Locale, "prototype", {
    value: Intl.Locale.prototype, writable: false, enumerable: false, configurable: false,
});

// Properties of the Intl.Locale Prototype Object

// Intl.Locale.prototype.constructor
assertProperty(Intl.Locale.prototype, "constructor", {
    value: Intl.Locale, writable: true, enumerable: false, configurable: true,
});

// Intl.Locale.prototype[ @@toStringTag ]
assertProperty(Intl.Locale.prototype, Symbol.toStringTag, {
    value: "Intl.Locale", writable: false, enumerable: false, configurable: true,
});

// Intl.Locale.prototype.toString ()
assertBuiltinMethod(Intl.Locale.prototype, "toString", 0, "toString");

// get Intl.Locale.prototype.baseName
assertBuiltinGetter(Intl.Locale.prototype, "baseName", 0, "get baseName");

// get Intl.Locale.prototype.calendar
assertBuiltinGetter(Intl.Locale.prototype, "calendar", 0, "get calendar");

// get Intl.Locale.prototype.collation
assertBuiltinGetter(Intl.Locale.prototype, "collation", 0, "get collation");

// get Intl.Locale.prototype.hourCycle
assertBuiltinGetter(Intl.Locale.prototype, "hourCycle", 0, "get hourCycle");

// get Intl.Locale.prototype.caseFirst
assertBuiltinGetter(Intl.Locale.prototype, "caseFirst", 0, "get caseFirst");

// get Intl.Locale.prototype.numeric
assertBuiltinGetter(Intl.Locale.prototype, "numeric", 0, "get numeric");

// get Intl.Locale.prototype.numberingSystem
assertBuiltinGetter(Intl.Locale.prototype, "numberingSystem", 0, "get numberingSystem");

// get Intl.Locale.prototype.language
assertBuiltinGetter(Intl.Locale.prototype, "language", 0, "get language");

// get Intl.Locale.prototype.script
assertBuiltinGetter(Intl.Locale.prototype, "script", 0, "get script");

// get Intl.Locale.prototype.region
assertBuiltinGetter(Intl.Locale.prototype, "region", 0, "get region");

if (typeof reportCompare === "function")
    reportCompare(0, 0);