OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 assertEquals(2, !symbols[i] ? 1 : 2) | 107 assertEquals(2, !symbols[i] ? 1 : 2) |
108 if (!symbols[i]) assertUnreachable(); | 108 if (!symbols[i]) assertUnreachable(); |
109 if (symbols[i]) {} else assertUnreachable(); | 109 if (symbols[i]) {} else assertUnreachable(); |
110 } | 110 } |
111 } | 111 } |
112 TestToBoolean() | 112 TestToBoolean() |
113 | 113 |
114 | 114 |
115 function TestToNumber() { | 115 function TestToNumber() { |
116 for (var i in symbols) { | 116 for (var i in symbols) { |
117 assertSame(NaN, Number(symbols[i]).valueOf()) | 117 assertThrows(function() { Number(symbols[i]); }, TypeError); |
118 assertSame(NaN, symbols[i] + 0) | 118 assertThrows(function() { symbols[i] + 0; }, TypeError); |
119 } | 119 } |
120 } | 120 } |
121 TestToNumber() | 121 TestToNumber() |
122 | 122 |
123 | 123 |
124 function TestEquality() { | 124 function TestEquality() { |
125 // Every symbol should equal itself, and non-strictly equal its wrapper. | 125 // Every symbol should equal itself, and non-strictly equal its wrapper. |
126 for (var i in symbols) { | 126 for (var i in symbols) { |
127 assertSame(symbols[i], symbols[i]) | 127 assertSame(symbols[i], symbols[i]) |
128 assertEquals(symbols[i], symbols[i]) | 128 assertEquals(symbols[i], symbols[i]) |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 obj[sym] = 1 | 349 obj[sym] = 1 |
350 freeze(obj) | 350 freeze(obj) |
351 obj[sym] = 2 | 351 obj[sym] = 2 |
352 assertEquals(2, obj[sym]) | 352 assertEquals(2, obj[sym]) |
353 assertTrue(delete obj[sym]) | 353 assertTrue(delete obj[sym]) |
354 assertEquals(undefined, obj[sym]) | 354 assertEquals(undefined, obj[sym]) |
355 } | 355 } |
356 TestSealAndFreeze(Object.seal) | 356 TestSealAndFreeze(Object.seal) |
357 TestSealAndFreeze(Object.freeze) | 357 TestSealAndFreeze(Object.freeze) |
358 TestSealAndFreeze(Object.preventExtensions) | 358 TestSealAndFreeze(Object.preventExtensions) |
OLD | NEW |