| OLD | NEW | 
|---|
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 // Flags: --allow-natives-syntax | 5 // Flags: --allow-natives-syntax --expose-gc | 
| 6 | 6 | 
| 7 // Ensure `Array.prototype.indexOf` functions correctly for numerous elements | 7 // Ensure `Array.prototype.indexOf` functions correctly for numerous elements | 
| 8 // kinds, and various exotic receiver types, | 8 // kinds, and various exotic receiver types, | 
| 9 | 9 | 
| 10 var kIterCount = 1; | 10 var kIterCount = 1; | 
| 11 var kTests = { | 11 var kTests = { | 
| 12   Array: { | 12   Array: { | 
| 13     FAST_ELEMENTS() { | 13     FAST_ELEMENTS() { | 
| 14       var r = /foo/; | 14       var r = /foo/; | 
| 15       var s = new String("bar"); | 15       var s = new String("bar"); | 
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 100         assertEquals(array.indexOf(NaN, -2), -1); | 100         assertEquals(array.indexOf(NaN, -2), -1); | 
| 101         assertEquals(array.indexOf(-13000.89412), 1); | 101         assertEquals(array.indexOf(-13000.89412), 1); | 
| 102         assertEquals(array.indexOf(-13000.89412, -2), -1); | 102         assertEquals(array.indexOf(-13000.89412, -2), -1); | 
| 103         assertEquals(array.indexOf(undefined, -2), -1); | 103         assertEquals(array.indexOf(undefined, -2), -1); | 
| 104         assertEquals(array.indexOf(undefined, -1), -1); | 104         assertEquals(array.indexOf(undefined, -1), -1); | 
| 105       } | 105       } | 
| 106     }, | 106     }, | 
| 107 | 107 | 
| 108     DICTIONARY_ELEMENTS() { | 108     DICTIONARY_ELEMENTS() { | 
| 109       var array = []; | 109       var array = []; | 
| 110       Object.defineProperty(array, 4, { get() { return NaN; } }); | 110       Object.defineProperty(array, 4, { get() { gc(); return NaN; } }); | 
| 111       Object.defineProperty(array, 7, { value: Function }); | 111       Object.defineProperty(array, 7, { value: Function }); | 
| 112 | 112 | 
| 113       assertTrue(%HasDictionaryElements(array)); | 113       assertTrue(%HasDictionaryElements(array)); | 
| 114 | 114 | 
| 115       for (var i = 0; i < kIterCount; ++i) { | 115       for (var i = 0; i < kIterCount; ++i) { | 
| 116         assertEquals(array.indexOf(NaN), -1); | 116         assertEquals(array.indexOf(NaN), -1); | 
| 117         assertEquals(array.indexOf(NaN, -3), -1); | 117         assertEquals(array.indexOf(NaN, -3), -1); | 
| 118         assertEquals(array.indexOf(Function), 7); | 118         assertEquals(array.indexOf(Function), 7); | 
| 119         assertEquals(array.indexOf(undefined), -1); | 119         assertEquals(array.indexOf(undefined), -1); | 
| 120         assertEquals(array.indexOf(undefined, 7), -1); | 120         assertEquals(array.indexOf(undefined, 7), -1); | 
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 219         assertEquals(Array.prototype.indexOf.call(object, NaN, -2), -1); | 219         assertEquals(Array.prototype.indexOf.call(object, NaN, -2), -1); | 
| 220         assertEquals(Array.prototype.indexOf.call(object, -13000.89412), 1); | 220         assertEquals(Array.prototype.indexOf.call(object, -13000.89412), 1); | 
| 221         assertEquals(Array.prototype.indexOf.call(object, -13000.89412, -2), -1)
     ; | 221         assertEquals(Array.prototype.indexOf.call(object, -13000.89412, -2), -1)
     ; | 
| 222         assertEquals(Array.prototype.indexOf.call(object, undefined, -2), -1); | 222         assertEquals(Array.prototype.indexOf.call(object, undefined, -2), -1); | 
| 223         assertEquals(Array.prototype.indexOf.call(object, undefined, -1), -1); | 223         assertEquals(Array.prototype.indexOf.call(object, undefined, -1), -1); | 
| 224       } | 224       } | 
| 225     }, | 225     }, | 
| 226 | 226 | 
| 227     DICTIONARY_ELEMENTS() { | 227     DICTIONARY_ELEMENTS() { | 
| 228       var object = { length: 8 }; | 228       var object = { length: 8 }; | 
| 229       Object.defineProperty(object, 4, { get() { return NaN; } }); | 229       Object.defineProperty(object, 4, { get() { gc(); return NaN; } }); | 
| 230       Object.defineProperty(object, 7, { value: Function }); | 230       Object.defineProperty(object, 7, { value: Function }); | 
| 231 | 231 | 
| 232       assertTrue(%HasDictionaryElements(object)); | 232       assertTrue(%HasDictionaryElements(object)); | 
| 233 | 233 | 
| 234       for (var i = 0; i < kIterCount; ++i) { | 234       for (var i = 0; i < kIterCount; ++i) { | 
| 235         assertEquals(Array.prototype.indexOf.call(object, NaN), -1); | 235         assertEquals(Array.prototype.indexOf.call(object, NaN), -1); | 
| 236         assertEquals(Array.prototype.indexOf.call(object, NaN, -3), -1); | 236         assertEquals(Array.prototype.indexOf.call(object, NaN, -3), -1); | 
| 237         assertEquals(Array.prototype.indexOf.call(object, Function), 7); | 237         assertEquals(Array.prototype.indexOf.call(object, Function), 7); | 
| 238         assertEquals(Array.prototype.indexOf.call(object, undefined), -1); | 238         assertEquals(Array.prototype.indexOf.call(object, undefined), -1); | 
| 239         assertEquals(Array.prototype.indexOf.call(object, undefined, 7), -1); | 239         assertEquals(Array.prototype.indexOf.call(object, undefined, 7), -1); | 
| 240       } | 240       } | 
| 241 | 241 | 
| 242       (function prototypeModifiedDuringAccessor() { | 242       (function prototypeModifiedDuringAccessor() { | 
| 243         function O() { | 243         function O() { | 
| 244           return { | 244           return { | 
| 245             __proto__: {}, | 245             __proto__: {}, | 
| 246             get 0() { | 246             get 0() { | 
|  | 247               gc(); | 
| 247               this.__proto__.__proto__ = { | 248               this.__proto__.__proto__ = { | 
| 248                 get 1() { | 249                 get 1() { | 
|  | 250                   gc(); | 
| 249                   this[2] = "c"; | 251                   this[2] = "c"; | 
| 250                   return "b"; | 252                   return "b"; | 
| 251                 } | 253                 } | 
| 252               }; | 254               }; | 
| 253               return "a"; | 255               return "a"; | 
| 254             }, | 256             }, | 
| 255             length: 3 | 257             length: 3 | 
| 256           }; | 258           }; | 
| 257         } | 259         } | 
| 258 | 260 | 
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 306       for (var i = 0; i < kIterCount; ++i) { | 308       for (var i = 0; i < kIterCount; ++i) { | 
| 307         assertEquals(Array.prototype.indexOf.call(args, undefined), -1); | 309         assertEquals(Array.prototype.indexOf.call(args, undefined), -1); | 
| 308         assertEquals(Array.prototype.indexOf.call(args, NaN), -1); | 310         assertEquals(Array.prototype.indexOf.call(args, NaN), -1); | 
| 309         assertEquals(Array.prototype.indexOf.call(args, NaN, -1), -1); | 311         assertEquals(Array.prototype.indexOf.call(args, NaN, -1), -1); | 
| 310         assertEquals(Array.prototype.indexOf.call(args, "bar", -1), 2); | 312         assertEquals(Array.prototype.indexOf.call(args, "bar", -1), 2); | 
| 311       } | 313       } | 
| 312     }, | 314     }, | 
| 313 | 315 | 
| 314     SLOW_SLOPPY_ARGUMENTS_ELEMENTS() { | 316     SLOW_SLOPPY_ARGUMENTS_ELEMENTS() { | 
| 315       var args = (function(a, a) { return arguments; })("foo", NaN, "bar"); | 317       var args = (function(a, a) { return arguments; })("foo", NaN, "bar"); | 
| 316       Object.defineProperty(args, 3, { get() { return "silver"; } }); | 318       Object.defineProperty(args, 3, { get() { gc(); return "silver"; } }); | 
| 317       Object.defineProperty(args, "length", { value: 4 }); | 319       Object.defineProperty(args, "length", { value: 4 }); | 
| 318       assertTrue(%HasSloppyArgumentsElements(args)); | 320       assertTrue(%HasSloppyArgumentsElements(args)); | 
| 319 | 321 | 
| 320       for (var i = 0; i < kIterCount; ++i) { | 322       for (var i = 0; i < kIterCount; ++i) { | 
| 321         assertEquals(Array.prototype.indexOf.call(args, undefined), -1); | 323         assertEquals(Array.prototype.indexOf.call(args, undefined), -1); | 
| 322         assertEquals(Array.prototype.indexOf.call(args, NaN), -1); | 324         assertEquals(Array.prototype.indexOf.call(args, NaN), -1); | 
| 323         assertEquals(Array.prototype.indexOf.call(args, NaN, -2), -1); | 325         assertEquals(Array.prototype.indexOf.call(args, NaN, -2), -1); | 
| 324         assertEquals(Array.prototype.indexOf.call(args, "bar", -2), 2); | 326         assertEquals(Array.prototype.indexOf.call(args, "bar", -2), 2); | 
| 325         assertEquals(Array.prototype.indexOf.call(args, "silver", -1), 3); | 327         assertEquals(Array.prototype.indexOf.call(args, "silver", -1), 3); | 
| 326       } | 328       } | 
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 623 | 625 | 
| 624 function runSuites(suites) { | 626 function runSuites(suites) { | 
| 625   Object.keys(suites).forEach(suite => runSuite(suites[suite])); | 627   Object.keys(suites).forEach(suite => runSuite(suites[suite])); | 
| 626 | 628 | 
| 627   function runSuite(suite) { | 629   function runSuite(suite) { | 
| 628     Object.keys(suite).forEach(test => suite[test]()); | 630     Object.keys(suite).forEach(test => suite[test]()); | 
| 629   } | 631   } | 
| 630 } | 632 } | 
| 631 | 633 | 
| 632 runSuites(kTests); | 634 runSuites(kTests); | 
| OLD | NEW | 
|---|