]>
Commit | Line | Data |
---|---|---|
ed1e77d3 A |
1 | // Test that a object accepts DFG PutByValueDirect operation with edge numbers. |
2 | ||
3 | function lookupWithKey(key) { | |
4 | var object = { | |
5 | [key]: 42 | |
6 | }; | |
7 | return object[key]; | |
8 | } | |
9 | noInline(lookupWithKey); | |
10 | ||
11 | for (var i = 0; i < 10000; ++i) { | |
12 | [ | |
13 | // integers | |
14 | -0x80000001, // out of int32_t | |
15 | -0x80000000, // int32_t min | |
16 | -1, // negative | |
17 | 0, // zero | |
18 | 1, // positive | |
19 | 0x7fffffff, // int32_t max | |
20 | 0x80000000, // out of int32_t | |
21 | 0xfffffffd, // less than array max in JSObject | |
22 | 0xfffffffe, // array max in JSObject | |
23 | 0xffffffff, // uint32_t max, not array index | |
24 | 0x100000000, // out of uint32_t | |
25 | ||
26 | // stringified integers | |
27 | (-0x80000001).toString(), // out of int32_t | |
28 | (-0x80000000).toString(), // int32_t min | |
29 | (-1).toString(), // negative | |
30 | (0).toString(), // zero | |
31 | (1).toString(), // positive | |
32 | (0x7fffffff).toString(), // int32_t max | |
33 | (0x80000000).toString(), // out of int32_t | |
34 | (0xfffffffd).toString(), // less than array max in JSObject | |
35 | (0xfffffffe).toString(), // array max in JSObject | |
36 | (0xffffffff).toString(), // (uint32_t max).toString() | |
37 | (0x100000000).toString(), // out of uint32_t | |
38 | ||
39 | // doubles | |
40 | Number.MIN_VALUE, | |
41 | Number.MAX_VALUE, | |
42 | Number.MIN_SAFE_INTEGER, | |
43 | Number.MAX_SAFE_INTEGER, | |
44 | Number.POSITIVE_INFINITY, | |
45 | Number.NEGATIVE_INFINITY, | |
46 | Number.NaN, | |
47 | Number.EPSILON, | |
48 | +0.0, | |
49 | -0.0, | |
50 | 0.1, | |
51 | -0.1, | |
52 | 4.2, | |
53 | -4.2, | |
54 | 0x80000000 + 0.5, // out of int32_t, double | |
55 | ||
56 | // stringified doules | |
57 | (Number.MIN_VALUE).toString(), | |
58 | (Number.MAX_VALUE).toString(), | |
59 | (Number.MIN_SAFE_INTEGER).toString(), | |
60 | (Number.MAX_SAFE_INTEGER).toString(), | |
61 | (Number.POSITIVE_INFINITY).toString(), | |
62 | (Number.NEGATIVE_INFINITY).toString(), | |
63 | "NaN", | |
64 | (Number.EPSILON).toString(), | |
65 | "+0.0", | |
66 | "-0.0", | |
67 | "0.1", | |
68 | "-0.1", | |
69 | "4.2", | |
70 | "-4.2", | |
71 | (0x80000000 + 0.5).toString() | |
72 | ].forEach(function (key) { | |
73 | var value = lookupWithKey(key); | |
74 | if (value !== 42) | |
75 | throw new Error('bad value: ' + value); | |
76 | }); | |
77 | } | |
78 | ||
79 | function lookupWithKey2(key) { | |
80 | var object = { | |
81 | [key]: 42 | |
82 | }; | |
83 | return object[key]; | |
84 | } | |
85 | noInline(lookupWithKey2); | |
86 | ||
87 | var toStringThrowsError = { | |
88 | toString: function () { | |
89 | throw new Error('ng'); | |
90 | } | |
91 | }; | |
92 | ||
93 | for (var i = 0; i < 10000; ++i) { | |
94 | var error = null; | |
95 | try { | |
96 | lookupWithKey2(toStringThrowsError); | |
97 | } catch (e) { | |
98 | error = e; | |
99 | } | |
100 | if (!error) | |
101 | throw new Error('not thrown'); | |
102 | if (String(error) !== 'Error: ng') | |
103 | throw new Error('bad error: ' + String(error)); | |
104 | } |