| 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 function TestKeyHas() { | 225 function TestKeyHas() { |
| 226 for (var i in symbols) { | 226 for (var i in symbols) { |
| 227 assertTrue(symbols[i] in obj) | 227 assertTrue(symbols[i] in obj) |
| 228 assertTrue(Object.hasOwnProperty.call(obj, symbols[i])) | 228 assertTrue(Object.hasOwnProperty.call(obj, symbols[i])) |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 | 231 |
| 232 | 232 |
| 233 function TestKeyEnum(obj) { | 233 function TestKeyEnum(obj) { |
| 234 for (var name in obj) { | 234 for (var name in obj) { |
| 235 assertTrue(typeof name !== "symbol") | 235 assertEquals("string", typeof name) |
| 236 } | 236 } |
| 237 } | 237 } |
| 238 | 238 |
| 239 | 239 |
| 240 function TestKeyNames(obj) { | 240 function TestKeyNames(obj) { |
| 241 assertEquals(0, Object.keys(obj).length) | 241 assertEquals(0, Object.keys(obj).length) |
| 242 | 242 |
| 243 var names = Object.getOwnPropertyNames(obj) | 243 var names = Object.getOwnPropertyNames(obj) |
| 244 assertTrue(symbols.length <= names.length) | 244 for (var i in names) { |
| 245 // TODO(rossberg): once we have iterators, the following would be: | 245 assertEquals("string", typeof names[i]) |
| 246 // var expected = new Set(symbols) | |
| 247 var expected = new Set | |
| 248 for (var i = 0; i < symbols.length; ++i) expected.add(symbols[i]) | |
| 249 for (var i = 0; i < names.length; ++i) { | |
| 250 var name = names[i] | |
| 251 if (typeof name === 'symbol') { | |
| 252 assertTrue(expected.has(name)) | |
| 253 expected.delete(name) | |
| 254 } | |
| 255 } | 246 } |
| 256 assertEquals(0, expected.size) | |
| 257 } | 247 } |
| 258 | 248 |
| 259 | 249 |
| 260 function TestKeyDescriptor(obj) { | 250 function TestKeyDescriptor(obj) { |
| 261 for (var i in symbols) { | 251 for (var i in symbols) { |
| 262 var desc = Object.getOwnPropertyDescriptor(obj, symbols[i]); | 252 var desc = Object.getOwnPropertyDescriptor(obj, symbols[i]); |
| 263 assertEquals(i|0, desc.value) | 253 assertEquals(i|0, desc.value) |
| 264 assertTrue(desc.configurable) | 254 assertTrue(desc.configurable) |
| 265 assertEquals(i % 2 == 0, desc.writable) | 255 assertEquals(i % 2 == 0, desc.writable) |
| 266 assertEquals(i % 2 == 0, desc.enumerable) | 256 assertEquals(i % 2 == 0, desc.enumerable) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 286 var obj = objs[i] | 276 var obj = objs[i] |
| 287 TestKeySet(obj) | 277 TestKeySet(obj) |
| 288 TestKeyDefine(obj) | 278 TestKeyDefine(obj) |
| 289 TestKeyGet(obj) | 279 TestKeyGet(obj) |
| 290 TestKeyHas(obj) | 280 TestKeyHas(obj) |
| 291 TestKeyEnum(obj) | 281 TestKeyEnum(obj) |
| 292 TestKeyNames(obj) | 282 TestKeyNames(obj) |
| 293 TestKeyDescriptor(obj) | 283 TestKeyDescriptor(obj) |
| 294 TestKeyDelete(obj) | 284 TestKeyDelete(obj) |
| 295 } | 285 } |
| OLD | NEW |