| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 | 30 |
| 31 function TestArrayPrototype() { | 31 function TestArrayPrototype() { |
| 32 assertTrue(Array.prototype.hasOwnProperty('entries')); | 32 assertTrue(Array.prototype.hasOwnProperty('entries')); |
| 33 assertTrue(Array.prototype.hasOwnProperty('values')); | 33 assertTrue(Array.prototype.hasOwnProperty('values')); |
| 34 assertTrue(Array.prototype.hasOwnProperty('keys')); | 34 assertTrue(Array.prototype.hasOwnProperty('keys')); |
| 35 | 35 |
| 36 assertFalse(Array.prototype.propertyIsEnumerable('entries')); | 36 assertFalse(Array.prototype.propertyIsEnumerable('entries')); |
| 37 assertFalse(Array.prototype.propertyIsEnumerable('values')); | 37 assertFalse(Array.prototype.propertyIsEnumerable('values')); |
| 38 assertFalse(Array.prototype.propertyIsEnumerable('keys')); | 38 assertFalse(Array.prototype.propertyIsEnumerable('keys')); |
| 39 |
| 40 assertEquals(Array.prototype.values, Array.prototype[Symbol.iterator]); |
| 39 } | 41 } |
| 40 TestArrayPrototype(); | 42 TestArrayPrototype(); |
| 41 | 43 |
| 42 | 44 |
| 43 function assertIteratorResult(value, done, result) { | 45 function assertIteratorResult(value, done, result) { |
| 44 assertEquals({value: value, done: done}, result); | 46 assertEquals({value: value, done: done}, result); |
| 45 } | 47 } |
| 46 | 48 |
| 47 | 49 |
| 48 function TestValues() { | 50 function TestValues() { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 } | 211 } |
| 210 assertTrue(isNaN(buffer[buffer.length - 1][1])); | 212 assertTrue(isNaN(buffer[buffer.length - 1][1])); |
| 211 | 213 |
| 212 for (var i = 0; i < buffer.length; i++) { | 214 for (var i = 0; i < buffer.length; i++) { |
| 213 assertEquals(i, buffer[i][0]); | 215 assertEquals(i, buffer[i][0]); |
| 214 } | 216 } |
| 215 } | 217 } |
| 216 TestForArrayEntries(); | 218 TestForArrayEntries(); |
| 217 | 219 |
| 218 | 220 |
| 221 function TestForArray() { |
| 222 var buffer = []; |
| 223 var array = [0, 'a', true, false, null, /* hole */, undefined, NaN]; |
| 224 var i = 0; |
| 225 for (var value of array) { |
| 226 buffer[i++] = value; |
| 227 } |
| 228 |
| 229 assertEquals(8, buffer.length); |
| 230 |
| 231 for (var i = 0; i < buffer.length - 1; i++) { |
| 232 assertEquals(array[i], buffer[i]); |
| 233 } |
| 234 assertTrue(isNaN(buffer[buffer.length - 1])); |
| 235 } |
| 236 TestForArrayValues(); |
| 237 |
| 238 |
| 219 function TestNonOwnSlots() { | 239 function TestNonOwnSlots() { |
| 220 var array = [0]; | 240 var array = [0]; |
| 221 var iterator = array.values(); | 241 var iterator = array.values(); |
| 222 var object = {__proto__: iterator}; | 242 var object = {__proto__: iterator}; |
| 223 | 243 |
| 224 assertThrows(function() { | 244 assertThrows(function() { |
| 225 object.next(); | 245 object.next(); |
| 226 }, TypeError); | 246 }, TypeError); |
| 227 } | 247 } |
| 228 TestNonOwnSlots(); | 248 TestNonOwnSlots(); |
| OLD | NEW |