-
Notifications
You must be signed in to change notification settings - Fork 851
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
some fixes/enhancements for the typed array support (#436)
* fix broken in operator for typed arrays (zero is a valid index too) * typed arrays are doing the buffer encoding based on little/big endian from the architecture they run on. So far Rhino always uses big endian. With this patch we are able to simulate little endian also by setting a context feature. * regarding the spec the default is always big endian and not architecture dependent * fix toString() for typed arrays
- Loading branch information
Showing
15 changed files
with
145 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
load("testsrc/assert.js"); | ||
|
||
var types = [Int8Array, Uint8Array, Int16Array, Uint16Array, | ||
Int32Array, Uint32Array, Uint8ClampedArray, Float32Array, | ||
Float64Array]; | ||
|
||
for (var t = 0; t < types.length; t++) { | ||
var type = types[t]; | ||
|
||
var empty = new type(0); | ||
assertFalse(0 in empty); | ||
assertFalse(1 in empty); | ||
|
||
var one = new type(1); | ||
one[0] = 1; | ||
assertTrue(0 in one); | ||
assertFalse(1 in one); | ||
|
||
var two = new type(2); | ||
assertTrue(0 in two); | ||
assertTrue(1 in two); | ||
assertFalse(2 in two); | ||
|
||
two[1] = 2; | ||
assertFalse(2 in two); | ||
} | ||
|
||
"success"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
load("testsrc/assert.js"); | ||
|
||
var types = [Int8Array, Uint8Array, Int16Array, Uint16Array, | ||
Int32Array, Uint32Array, Uint8ClampedArray, Float32Array, | ||
Float64Array]; | ||
|
||
for (var t = 0; t < types.length; t++) { | ||
var type = types[t]; | ||
|
||
var empty = new type(0); | ||
assertEquals("", empty.toString()); | ||
|
||
var one = new type([7]); | ||
assertEquals("7", one.toString()); | ||
|
||
var two = new type([7,13]); | ||
assertEquals("7,13", two.toString()); | ||
|
||
var many = new type([7,13,21,17,0,1,11]); | ||
assertEquals("7,13,21,17,0,1,11", many.toString()); | ||
} | ||
|
||
"success"; |
13 changes: 13 additions & 0 deletions
13
testsrc/org/mozilla/javascript/tests/harmony/TypedArrayInTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.mozilla.javascript.tests.harmony; | ||
|
||
import org.mozilla.javascript.drivers.RhinoTest; | ||
import org.mozilla.javascript.drivers.ScriptTestsBase; | ||
|
||
@RhinoTest("testsrc/jstests/harmony/typed-array-in.js") | ||
public class TypedArrayInTest extends ScriptTestsBase | ||
{ | ||
} |
13 changes: 13 additions & 0 deletions
13
testsrc/org/mozilla/javascript/tests/harmony/TypedArrayToStringTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.mozilla.javascript.tests.harmony; | ||
|
||
import org.mozilla.javascript.drivers.RhinoTest; | ||
import org.mozilla.javascript.drivers.ScriptTestsBase; | ||
|
||
@RhinoTest("testsrc/jstests/harmony/typed-array-to-string.js") | ||
public class TypedArrayToStringTest extends ScriptTestsBase | ||
{ | ||
} |