| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 25 matching lines...) Expand all Loading... |
| 36 var a = new Int32Array(2); | 36 var a = new Int32Array(2); |
| 37 for (var i = 0; i < 5; i++) { | 37 for (var i = 0; i < 5; i++) { |
| 38 f(a); | 38 f(a); |
| 39 } | 39 } |
| 40 %OptimizeFunctionOnNextCall(f); | 40 %OptimizeFunctionOnNextCall(f); |
| 41 f(a); | 41 f(a); |
| 42 | 42 |
| 43 assertEquals(0, a[0]); | 43 assertEquals(0, a[0]); |
| 44 assertEquals(0, a[1]); | 44 assertEquals(0, a[1]); |
| 45 | 45 |
| 46 // No-parameter constructor should fail right now. | 46 // No-parameter constructor shouldn't fail |
| 47 function abfunc1() { | 47 function abfunc1() { |
| 48 return new ArrayBuffer(); | 48 return new ArrayBuffer(); |
| 49 } | 49 } |
| 50 assertThrows(abfunc1); | 50 assertDoesNotThrow(abfunc1); |
| 51 | 51 |
| 52 // Test derivation from an ArrayBuffer | 52 // Test derivation from an ArrayBuffer |
| 53 var ab = new ArrayBuffer(12); | 53 var ab = new ArrayBuffer(12); |
| 54 var derived_uint8 = new Uint8Array(ab); | 54 var derived_uint8 = new Uint8Array(ab); |
| 55 assertEquals(12, derived_uint8.length); | 55 assertEquals(12, derived_uint8.length); |
| 56 var derived_uint32 = new Uint32Array(ab); | 56 var derived_uint32 = new Uint32Array(ab); |
| 57 assertEquals(3, derived_uint32.length); | 57 assertEquals(3, derived_uint32.length); |
| 58 var derived_uint32_2 = new Uint32Array(ab,4); | 58 var derived_uint32_2 = new Uint32Array(ab,4); |
| 59 assertEquals(2, derived_uint32_2.length); | 59 assertEquals(2, derived_uint32_2.length); |
| 60 var derived_uint32_3 = new Uint32Array(ab,4,1); | 60 var derived_uint32_3 = new Uint32Array(ab,4,1); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 // Make sure runtime does it right | 344 // Make sure runtime does it right |
| 345 store_float64_undefined(float64_array); | 345 store_float64_undefined(float64_array); |
| 346 assertTrue(isNaN(float64_array[0])); | 346 assertTrue(isNaN(float64_array[0])); |
| 347 // Make sure the ICs do it right | 347 // Make sure the ICs do it right |
| 348 store_float64_undefined(float64_array); | 348 store_float64_undefined(float64_array); |
| 349 assertTrue(isNaN(float64_array[0])); | 349 assertTrue(isNaN(float64_array[0])); |
| 350 // Make sure that Cranskshft does it right. | 350 // Make sure that Cranskshft does it right. |
| 351 %OptimizeFunctionOnNextCall(store_float64_undefined); | 351 %OptimizeFunctionOnNextCall(store_float64_undefined); |
| 352 store_float64_undefined(float64_array); | 352 store_float64_undefined(float64_array); |
| 353 assertTrue(isNaN(float64_array[0])); | 353 assertTrue(isNaN(float64_array[0])); |
| 354 |
| 355 // test external arrays call() and apply() methods with no arguments |
| 356 function testNoArgCallApply(type) { |
| 357 assertDoesNotThrow(type.call({})); |
| 358 assertDoesNotThrow(type.apply({})); |
| 359 } |
| 360 |
| 361 // compare type.call() and new type() own property names |
| 362 function testNoArgCallAndNewOwnPropertyNames(type) { |
| 363 var o1 = type.call({}); |
| 364 var o2 = new type(); |
| 365 |
| 366 assertPropertiesEqual( |
| 367 Object.getOwnPropertyNames(o1), |
| 368 Object.getOwnPropertyNames(o2) |
| 369 ); |
| 370 } |
| 371 |
| 372 // compare type.apply() and new type() own property names |
| 373 function testNoArgApplyAndNewOwnPropertyNames(type) { |
| 374 var o1 = type.apply({}); |
| 375 var o2 = new type(); |
| 376 |
| 377 assertPropertiesEqual( |
| 378 Object.getOwnPropertyNames(o1), |
| 379 Object.getOwnPropertyNames(o2) |
| 380 ); |
| 381 } |
| 382 |
| 383 for (var t = 0; t < types.length; t++) { |
| 384 testNoArgCallApply(types[t]); |
| 385 testNoArgCallAndNewOwnPropertyNames(types[t]); |
| 386 testNoArgApplyAndNewOwnPropertyNames(types[t]); |
| 387 } |
| OLD | NEW |