Skip to content

Commit

Permalink
Fix up TypedArray tests broken by previous commit
Browse files Browse the repository at this point in the history
Bring these TypedArray tests inline with the changes in the previous
commit to match the latest ES spec behavior.

util.js and int8array.js had a few bugs as well, fixed those too.

These tests have cumbersome to work with and contain a lot of
redundancy. It would be great to consolidate them into a single test
file using UTF.js and looping through the different TypedArray
constructors instead of repeating tests for each explicity.
  • Loading branch information
Ian Halliday committed Nov 17, 2016
1 parent 3c2f1fc commit 0b03604
Show file tree
Hide file tree
Showing 17 changed files with 702 additions and 505 deletions.
85 changes: 36 additions & 49 deletions test/typedarray/float32array.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@ WScript.LoadScriptFile("util.js");

function oneTest(a)
{
a[1] = 0.54;
a[5] = 10;
WScript.Echo(a[5]);
if (Object.getOwnPropertyDescriptor(a, 100000) != undefined) {
WScript.Echo('FAIL');
}

try {
var pro = Float32Array.prototype;
WScript.Echo(pro.toString());

WScript.Echo("prototype is");
printObj(pro);
} catch(e) {
WScript.Echo("constructor is");
printObj(Float32Array);
}

WScript.Echo("object is");
printObj(a);

a[20] =20;
a.foo ='bar';
WScript.Echo("object after expando is");
printObj(a);
WScript.Echo("");
a[1] = 0.54;
a[5] = 10;
WScript.Echo(a[5]);
if (Object.getOwnPropertyDescriptor(a, 100000) != undefined) {
WScript.Echo('FAIL');
}

try {
var pro = Float32Array.prototype;
WScript.Echo(pro.toString());

WScript.Echo("prototype is");
printObj(pro);
} catch(e) {
WScript.Echo("constructor is");
printObj(Float32Array);
}

WScript.Echo("object is");
printObj(a);

a[20] =20;
a.foo ='bar';
WScript.Echo("object after expando is");
printObj(a);
WScript.Echo("");
}

WScript.Echo("test1");
Expand Down Expand Up @@ -86,25 +86,12 @@ test9.set(test5);
oneTest(test9);

WScript.Echo("test10");
try {
var test10 = new Float32Array({});
oneTest(test10);
}
catch(e)
{
WScript.Echo("succeed with catching" + e);
}

WScript.Echo("test11");
try
{
var test11 = new Float32Array('abcdefg');
oneTest(test11);
}
catch(e)
{
WScript.Echo("succeed with catching" + e);
}

WScript.Echo("test11.1");
var test111 = new Float32Array(new String('abcdefg'));
Expand All @@ -124,35 +111,35 @@ oneTest(test13);
WScript.Echo("test14");
try
{
var test14 = new Float32Array(arrayBuffer, 0, 0);
oneTest(test14);
var test14 = new Float32Array(arrayBuffer, 0, 0);
oneTest(test14);
}
catch(e)
{
WScript.Echo("succeed with catching" + e);
WScript.Echo("succeed with catching" + e);
}


WScript.Echo("test15");
try
{
var test15 = new Float32Array(arrayBuffer, 0, 40);
oneTest(test15);
var test15 = new Float32Array(arrayBuffer, 0, 40);
oneTest(test15);
}
catch(e)
{
WScript.Echo("succeed with catching" + e);
WScript.Echo("succeed with catching" + e);
}

WScript.Echo("test16");
try
{
var test16 = new Float32Array(arrayBuffer, 40, 4);
oneTest(test16);
var test16 = new Float32Array(arrayBuffer, 40, 4);
oneTest(test16);
}
catch(e)
{
WScript.Echo("succeed with catching" + e);
WScript.Echo("succeed with catching" + e);
}
printObj(test5);
WScript.Echo("test17");
Expand Down Expand Up @@ -187,4 +174,4 @@ testSetWithObj(-1, 2, new Float32Array(3), new Float32Array(3), new Float32Array
WScript.Echo("test22");
testIndexValueForSet(new Float32Array(5));
WScript.Echo("test22 JIT");
testIndexValueForSet(new Float32Array(5));
testIndexValueForSet(new Float32Array(5));
26 changes: 24 additions & 2 deletions test/typedarray/float32array_es6.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,31 @@ foo == bar
byteLength = 48

test10
succeed with catchingTypeError: Typed array constructor argument is invalid
undefined
constructor is
function Float32Array() { [native code] }
byteLength = undefined
object is

byteLength = 0
object after expando is

foo == bar
byteLength = 0

test11
succeed with catchingTypeError: Typed array constructor argument is invalid
undefined
constructor is
function Float32Array() { [native code] }
byteLength = undefined
object is

byteLength = 0
object after expando is

foo == bar
byteLength = 0

test11.1
10
constructor is
Expand Down
85 changes: 36 additions & 49 deletions test/typedarray/float64array.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@ WScript.LoadScriptFile("util.js");

function oneTest(a)
{
a[1] = -0.65;
a[5] = 10;
WScript.Echo(a[5]);
if (Object.getOwnPropertyDescriptor(a, 100000) != undefined) {
WScript.Echo('FAIL');
}

try {
var pro = Float64Array.prototype;
WScript.Echo(pro.toString());

WScript.Echo("prototype is");
printObj(pro);
} catch(e) {
WScript.Echo("constructor is");
printObj(Float64Array);
}

WScript.Echo("object is");
printObj(a);

a[20] =20;
a.foo ='bar';
WScript.Echo("object after expando is");
printObj(a);
WScript.Echo("");
a[1] = -0.65;
a[5] = 10;
WScript.Echo(a[5]);
if (Object.getOwnPropertyDescriptor(a, 100000) != undefined) {
WScript.Echo('FAIL');
}

try {
var pro = Float64Array.prototype;
WScript.Echo(pro.toString());

WScript.Echo("prototype is");
printObj(pro);
} catch(e) {
WScript.Echo("constructor is");
printObj(Float64Array);
}

WScript.Echo("object is");
printObj(a);

a[20] =20;
a.foo ='bar';
WScript.Echo("object after expando is");
printObj(a);
WScript.Echo("");
}

WScript.Echo("test1");
Expand Down Expand Up @@ -86,25 +86,12 @@ test9.set(test5);
oneTest(test9);

WScript.Echo("test10");
try {
var test10 = new Float64Array({});
oneTest(test10);
}
catch(e)
{
WScript.Echo("succeed with catching" + e);
}

WScript.Echo("test11");
try
{
var test11 = new Float64Array('abcdefg');
oneTest(test11);
}
catch(e)
{
WScript.Echo("succeed with catching" + e);
}

WScript.Echo("test11.1");
var test111 = new Float64Array(new String('abcdefg'));
Expand All @@ -123,35 +110,35 @@ oneTest(test13);
WScript.Echo("test14");
try
{
var test14 = new Float64Array(arrayBuffer, 0, 0);
oneTest(test14);
var test14 = new Float64Array(arrayBuffer, 0, 0);
oneTest(test14);
}
catch(e)
{
WScript.Echo("succeed with catching" + e);
WScript.Echo("succeed with catching" + e);
}


WScript.Echo("test15");
try
{
var test15 = new Float64Array(arrayBuffer, 0, 40);
oneTest(test15);
var test15 = new Float64Array(arrayBuffer, 0, 40);
oneTest(test15);
}
catch(e)
{
WScript.Echo("succeed with catching" + e);
WScript.Echo("succeed with catching" + e);
}

WScript.Echo("test16");
try
{
var test16 = new Float64Array(arrayBuffer, 40, 4);
oneTest(test16);
var test16 = new Float64Array(arrayBuffer, 40, 4);
oneTest(test16);
}
catch(e)
{
WScript.Echo("succeed with catching" + e);
WScript.Echo("succeed with catching" + e);
}
printObj(test5);
WScript.Echo("test17");
Expand Down Expand Up @@ -203,4 +190,4 @@ testSetWithObj(-1, 2, new Float64Array(3), new Float64Array(3), new Float64Array
WScript.Echo("test24");
testIndexValueForSet(new Float64Array(5));
WScript.Echo("test24 JIT");
testIndexValueForSet(new Float64Array(5));
testIndexValueForSet(new Float64Array(5));
26 changes: 24 additions & 2 deletions test/typedarray/float64array_es6.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,31 @@ foo == bar
byteLength = 96

test10
succeed with catchingTypeError: Typed array constructor argument is invalid
undefined
constructor is
function Float64Array() { [native code] }
byteLength = undefined
object is

byteLength = 0
object after expando is

foo == bar
byteLength = 0

test11
succeed with catchingTypeError: Typed array constructor argument is invalid
undefined
constructor is
function Float64Array() { [native code] }
byteLength = undefined
object is

byteLength = 0
object after expando is

foo == bar
byteLength = 0

test11.1
10
constructor is
Expand Down
Loading

0 comments on commit 0b03604

Please sign in to comment.