summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Locale/constructor-getter-order.js
blob: 4948f22480ed9291594275d4e13c2154b42e88af (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.locale
description: >
    Checks the order of evaluations of arguments and options for the Locale
    constructor.
features: [Intl.Locale]
includes: [compareArray.js]
---*/

const order = [];
new Intl.Locale(
  { toString() { order.push("tag toString"); return "en"; } },
  {
    get language() {
      order.push("get language");
      return {
        toString() {
          order.push("toString language");
          return "de";
        }
      }
    },

    get script() {
      order.push("get script");
      return {
        toString() {
          order.push("toString script");
          return "Latn";
        }
      }
    },

    get region() {
      order.push("get region");
      return {
        toString() {
          order.push("toString region");
          return "DE";
        }
      }
    },

    get calendar() {
      order.push("get calendar");
      return {
        toString() {
          order.push("toString calendar");
          return "gregory";
        }
      }
    },

    get collation() {
      order.push("get collation");
      return {
        toString() {
          order.push("toString collation");
          return "zhuyin";
        }
      }
    },

    get hourCycle() {
      order.push("get hourCycle");
      return {
        toString() {
          order.push("toString hourCycle");
          return "h24";
        }
      }
    },

    get caseFirst() {
      order.push("get caseFirst");
      return {
        toString() {
          order.push("toString caseFirst");
          return "upper";
        }
      }
    },

    get numeric() {
      order.push("get numeric");
      return false;
    },

    get numberingSystem() {
      order.push("get numberingSystem");
      return {
        toString() {
          order.push("toString numberingSystem");
          return "latn";
        }
      }
    },
  }
);

const expected_order = [
  "tag toString",
  "get language",
  "toString language",
  "get script",
  "toString script",
  "get region",
  "toString region",
  "get calendar",
  "toString calendar",
  "get collation",
  "toString collation",
  "get hourCycle",
  "toString hourCycle",
  "get caseFirst",
  "toString caseFirst",
  "get numeric",
  "get numberingSystem",
  "toString numberingSystem"
];

assert.compareArray(order, expected_order);

reportCompare(0, 0);