Added typed array unit test

This commit is contained in:
Atlante45 2014-07-09 10:28:50 -07:00
parent 28438d66b1
commit a76ebae771

View file

@ -11,12 +11,31 @@
Script.include("Test.js");
test("ArrayBuffer", function(finished) {
this.assertEquals(new ArrayBuffer().byteLength, 0, 'no length');
test('ArrayBuffer', function(finished) {
this.assertEquals(new ArrayBuffer(0).byteLength, 0, 'no length');
this.assertEquals(typeof(new ArrayBuffer(0)), 'object', 'creation');
this.assertEquals(typeof(new ArrayBuffer(1)), 'object', 'creation');
this.assertEquals(typeof(new ArrayBuffer(123)), 'object', 'creation');
this.assertEquals(new ArrayBuffer(123).byteLength, 123, 'length');
});
});
test('DataView constructors', function (finished) {
var d = new DataView(new ArrayBuffer(8));
d.setUint32(0, 0x12345678);
this.assertEquals(d.getUint32(0), 0x12345678, 'big endian/big endian');
d.setUint32(0, 0x12345678, true);
this.assertEquals(d.getUint32(0, true), 0x12345678, 'little endian/little endian');
d.setUint32(0, 0x12345678, true);
this.assertEquals(d.getUint32(0), 0x78563412, 'little endian/big endian');
d.setUint32(0, 0x12345678);
this.assertEquals(d.getUint32(0, true), 0x78563412, 'big endian/little endian');
// raises(function () { return new DataView({}); }, 'non-ArrayBuffer argument');
// raises(function () { return new DataView("bogus"); }, TypeError, 'non-ArrayBuffer argument');
});