| 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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  474   assertArrayPrefix(expected, a); |  474   assertArrayPrefix(expected, a); | 
|  475   assertThrows(function() { a.set.call({}) }, TypeError); |  475   assertThrows(function() { a.set.call({}) }, TypeError); | 
|  476   assertThrows(function() { a.set.call([]) }, TypeError); |  476   assertThrows(function() { a.set.call([]) }, TypeError); | 
|  477  |  477  | 
|  478   assertThrows(function() { a.set(0); }, TypeError); |  478   assertThrows(function() { a.set(0); }, TypeError); | 
|  479   assertThrows(function() { a.set(0, 1); }, TypeError); |  479   assertThrows(function() { a.set(0, 1); }, TypeError); | 
|  480 } |  480 } | 
|  481  |  481  | 
|  482 TestTypedArraySet(); |  482 TestTypedArraySet(); | 
|  483  |  483  | 
 |  484 function TestTypedArraysWithIllegalIndices() { | 
 |  485   var a = new Int32Array(100); | 
 |  486  | 
 |  487   a[-10] = 10; | 
 |  488   assertEquals(undefined, a[-10]); | 
 |  489   a["-10"] = 10; | 
 |  490   assertEquals(undefined, a["-10"]); | 
 |  491  | 
 |  492   var s = "    -10"; | 
 |  493   a[s] = 10; | 
 |  494   assertEquals(10, a[s]); | 
 |  495   var s1 = "    -10   "; | 
 |  496   a[s] = 10; | 
 |  497   assertEquals(10, a[s]); | 
 |  498  | 
 |  499   a["-1e2"] = 10; | 
 |  500   assertEquals(10, a["-1e2"]); | 
 |  501   assertEquals(undefined, a[-1e2]); | 
 |  502  | 
 |  503   /* Chromium bug: 424619 | 
 |  504    * a[-Infinity] = 50; | 
 |  505    * assertEquals(undefined, a[-Infinity]); | 
 |  506    */ | 
 |  507   a[1.5] = 10; | 
 |  508   assertEquals(undefined, a[1.5]); | 
 |  509   var nan = Math.sqrt(-1); | 
 |  510   a[nan] = 5; | 
 |  511   assertEquals(5, a[nan]); | 
 |  512  | 
 |  513   var x = 0; | 
 |  514   var y = -0; | 
 |  515   assertEquals(Infinity, 1/x); | 
 |  516   assertEquals(-Infinity, 1/y); | 
 |  517   a[x] = 5; | 
 |  518   a[y] = 27; | 
 |  519   assertEquals(27, a[x]); | 
 |  520   assertEquals(27, a[y]); | 
 |  521 } | 
 |  522  | 
 |  523 TestTypedArraysWithIllegalIndices(); | 
 |  524  | 
 |  525 function TestTypedArraysWithIllegalIndicesStrict() { | 
 |  526   'use strict'; | 
 |  527   var a = new Int32Array(100); | 
 |  528  | 
 |  529   a[-10] = 10; | 
 |  530   assertEquals(undefined, a[-10]); | 
 |  531   a["-10"] = 10; | 
 |  532   assertEquals(undefined, a["-10"]); | 
 |  533  | 
 |  534   var s = "    -10"; | 
 |  535   a[s] = 10; | 
 |  536   assertEquals(10, a[s]); | 
 |  537   var s1 = "    -10   "; | 
 |  538   a[s] = 10; | 
 |  539   assertEquals(10, a[s]); | 
 |  540  | 
 |  541   a["-1e2"] = 10; | 
 |  542   assertEquals(10, a["-1e2"]); | 
 |  543   assertEquals(undefined, a[-1e2]); | 
 |  544  | 
 |  545   /* Chromium bug: 424619 | 
 |  546    * a[-Infinity] = 50; | 
 |  547    * assertEquals(undefined, a[-Infinity]); | 
 |  548    */ | 
 |  549   a[1.5] = 10; | 
 |  550   assertEquals(undefined, a[1.5]); | 
 |  551   var nan = Math.sqrt(-1); | 
 |  552   a[nan] = 5; | 
 |  553   assertEquals(5, a[nan]); | 
 |  554  | 
 |  555   var x = 0; | 
 |  556   var y = -0; | 
 |  557   assertEquals(Infinity, 1/x); | 
 |  558   assertEquals(-Infinity, 1/y); | 
 |  559   a[x] = 5; | 
 |  560   a[y] = 27; | 
 |  561   assertEquals(27, a[x]); | 
 |  562   assertEquals(27, a[y]); | 
 |  563 } | 
 |  564  | 
 |  565 TestTypedArraysWithIllegalIndicesStrict(); | 
 |  566  | 
|  484 // DataView |  567 // DataView | 
|  485 function TestDataViewConstructor() { |  568 function TestDataViewConstructor() { | 
|  486   var ab = new ArrayBuffer(256); |  569   var ab = new ArrayBuffer(256); | 
|  487  |  570  | 
|  488   var d1 = new DataView(ab, 1, 255); |  571   var d1 = new DataView(ab, 1, 255); | 
|  489   assertTrue(ArrayBuffer.isView(d1)); |  572   assertTrue(ArrayBuffer.isView(d1)); | 
|  490   assertSame(ab, d1.buffer); |  573   assertSame(ab, d1.buffer); | 
|  491   assertSame(1, d1.byteOffset); |  574   assertSame(1, d1.byteOffset); | 
|  492   assertSame(255, d1.byteLength); |  575   assertSame(255, d1.byteLength); | 
|  493  |  576  | 
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  584 TestArbitrary(new ArrayBuffer(256)); |  667 TestArbitrary(new ArrayBuffer(256)); | 
|  585 for(i = 0; i < typedArrayConstructors.length; i++) { |  668 for(i = 0; i < typedArrayConstructors.length; i++) { | 
|  586   TestArbitrary(new typedArrayConstructors[i](10)); |  669   TestArbitrary(new typedArrayConstructors[i](10)); | 
|  587 } |  670 } | 
|  588 TestArbitrary(new DataView(new ArrayBuffer(256))); |  671 TestArbitrary(new DataView(new ArrayBuffer(256))); | 
|  589  |  672  | 
|  590  |  673  | 
|  591 // Test direct constructor call |  674 // Test direct constructor call | 
|  592 assertThrows(function() { ArrayBuffer(); }, TypeError); |  675 assertThrows(function() { ArrayBuffer(); }, TypeError); | 
|  593 assertThrows(function() { DataView(new ArrayBuffer()); }, TypeError); |  676 assertThrows(function() { DataView(new ArrayBuffer()); }, TypeError); | 
| OLD | NEW |