Skip to content

Commit

Permalink
Update tests which are generic across all TypedArrays for Float16Array
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot authored Apr 8, 2024
1 parent b72282f commit 5aa50dd
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 2 deletions.
3 changes: 2 additions & 1 deletion FileAPI/blob/Blob-constructor.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,11 @@ test_blob(function() {
new Int16Array([0x4150, 0x5353]),
new Uint32Array([0x53534150]),
new Int32Array([0x53534150]),
new Float16Array([2.65625, 58.59375]),
new Float32Array([0xD341500000])
]);
}, {
expected: "PASSPASSPASSPASSPASSPASSPASS",
expected: "PASSPASSPASSPASSPASSPASSPASSPASS",
type: "",
desc: "Passing typed arrays as elements of the blobParts array should work."
});
Expand Down
1 change: 1 addition & 0 deletions IndexedDB/idb-binary-key-roundtrip.htm
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
'Int16Array',
'Uint32Array',
'Int32Array',
'Float16Array',
'Float32Array',
'Float64Array'
].forEach((type) => { view_type_test(type); });
Expand Down
1 change: 1 addition & 0 deletions IndexedDB/structured-clone.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ cloneObjectTest(new Uint8Array([0, 1, 254, 255]).buffer, (orig, clone) => {
new Int16Array([0x0000, 0x0001, 0xFFFE, 0xFFFF]),
new Int32Array([0x00000000, 0x00000001, 0xFFFFFFFE, 0xFFFFFFFF]),
new Uint8ClampedArray([0, 1, 254, 255]),
new Float16Array([-Infinity, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, Infinity, NaN]),
new Float32Array([-Infinity, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, Infinity, NaN]),
new Float64Array([-Infinity, -Number.MAX_VALUE, -Number.MIN_VALUE, 0,
Number.MIN_VALUE, Number.MAX_VALUE, Infinity, NaN])
Expand Down
7 changes: 7 additions & 0 deletions WebCryptoAPI/getRandomValues.any.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
// Step 1.
test(function() {
assert_throws_dom("TypeMismatchError", function() {
self.crypto.getRandomValues(new Float16Array(6))
}, "Float16Array")
assert_throws_dom("TypeMismatchError", function() {
self.crypto.getRandomValues(new Float32Array(6))
}, "Float32Array")
assert_throws_dom("TypeMismatchError", function() {
self.crypto.getRandomValues(new Float64Array(6))
}, "Float64Array")

assert_throws_dom("TypeMismatchError", function() {
const len = 65536 / Float16Array.BYTES_PER_ELEMENT + 1;
self.crypto.getRandomValues(new Float16Array(len));
}, "Float16Array (too long)")
assert_throws_dom("TypeMismatchError", function() {
const len = 65536 / Float32Array.BYTES_PER_ELEMENT + 1;
self.crypto.getRandomValues(new Float32Array(len));
Expand Down
12 changes: 12 additions & 0 deletions compression/decompression-buffersource.tentative.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ const bufferSourceChunksForDeflate = [
name: 'Uint32Array',
value: new Uint32Array(new Uint8Array(compressedBytesWithDeflate).buffer)
},
{
name: 'Float16Array',
value: new Float16Array(new Uint8Array(compressedBytesWithDeflate).buffer)
},
{
name: 'Float32Array',
value: new Float32Array(new Uint8Array(compressedBytesWithDeflate).buffer)
Expand Down Expand Up @@ -94,6 +98,10 @@ const bufferSourceChunksForGzip = [
name: 'Uint32Array',
value: new Uint32Array(new Uint8Array(compressedBytesWithGzip).buffer)
},
{
name: 'Float16Array',
value: new Float16Array(new Uint8Array(compressedBytesWithGzip).buffer)
},
{
name: 'Float32Array',
value: new Float32Array(new Uint8Array(compressedBytesWithGzip).buffer)
Expand Down Expand Up @@ -141,6 +149,10 @@ const bufferSourceChunksForDeflateRaw = [
name: 'Uint32Array',
value: new Uint32Array(new Uint8Array(compressedBytesWithDeflateRaw).buffer)
},
{
name: 'Float16Array',
value: new Float16Array(new Uint8Array(compressedBytesWithDeflateRaw).buffer)
},
{
name: 'Float32Array',
value: new Float32Array(new Uint8Array(compressedBytesWithDeflateRaw).buffer)
Expand Down
1 change: 1 addition & 0 deletions encoding/encodeInto.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
"Uint8ClampedArray",
"BigInt64Array",
"BigUint64Array",
"Float16Array",
"Float32Array",
"Float64Array"].forEach(type => {
["ArrayBuffer", "SharedArrayBuffer"].forEach((arrayBufferOrSharedArrayBuffer) => {
Expand Down
1 change: 1 addition & 0 deletions fetch/api/basic/request-headers.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ requestHeaders("Fetch with POST with Blob body", url, "POST", new Blob(["Test"])
requestHeaders("Fetch with POST with ArrayBuffer body", url, "POST", new ArrayBuffer(4), location.origin, "4");
requestHeaders("Fetch with POST with Uint8Array body", url, "POST", new Uint8Array(4), location.origin, "4");
requestHeaders("Fetch with POST with Int8Array body", url, "POST", new Int8Array(4), location.origin, "4");
requestHeaders("Fetch with POST with Float16Array body", url, "POST", new Float16Array(1), location.origin, "2");
requestHeaders("Fetch with POST with Float32Array body", url, "POST", new Float32Array(1), location.origin, "4");
requestHeaders("Fetch with POST with Float64Array body", url, "POST", new Float64Array(1), location.origin, "8");
requestHeaders("Fetch with POST with DataView body", url, "POST", new DataView(new ArrayBuffer(8), 0, 4), location.origin, "4");
Expand Down
4 changes: 4 additions & 0 deletions fetch/api/basic/request-upload.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ testUpload("Fetch with POST with Int8Array body", url,
"POST",
() => new Int8Array(4),
"\0\0\0\0");
testUpload("Fetch with POST with Float16Array body", url,
"POST",
() => new Float16Array(2),
"\0\0\0\0");
testUpload("Fetch with POST with Float32Array body", url,
"POST",
() => new Float32Array(1),
Expand Down
1 change: 1 addition & 0 deletions fetch/api/response/response-clone.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ testReadableStreamClone(new Uint16Array(arrayBuffer, 2), "Uint16Array");
testReadableStreamClone(new Uint32Array(arrayBuffer), "Uint32Array");
testReadableStreamClone(typeof BigInt64Array === "function" ? new BigInt64Array(arrayBuffer) : undefined, "BigInt64Array");
testReadableStreamClone(typeof BigUint64Array === "function" ? new BigUint64Array(arrayBuffer) : undefined, "BigUint64Array");
testReadableStreamClone(typeof Float16Array === "function" ? new Float16Array(arrayBuffer) : undefined, "Float16Array");
testReadableStreamClone(new Float32Array(arrayBuffer), "Float32Array");
testReadableStreamClone(new Float64Array(arrayBuffer), "Float64Array");
testReadableStreamClone(new DataView(arrayBuffer, 2, 8), "DataView");
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"Uint32Array",
"BigInt64Array",
"BigUint64Array",
"Float16Array",
"Float32Array",
"Float64Array"
].forEach(type => {
Expand Down
1 change: 1 addition & 0 deletions resources/idlharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ IdlArray.prototype.is_json_type = function(type)
case "Uint8ClampedArray":
case "BigInt64Array":
case "BigUint64Array":
case "Float16Array":
case "Float32Array":
case "Float64Array":
case "ArrayBuffer":
Expand Down
1 change: 1 addition & 0 deletions resources/test/tests/unit/IdlArray/is_json_type.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
assert_false(idl.is_json_type(typeFrom("Uint8ClampedArray")));
assert_false(idl.is_json_type(typeFrom("BigInt64Array")));
assert_false(idl.is_json_type(typeFrom("BigUint64Array")));
assert_false(idl.is_json_type(typeFrom("Float16Array")));
assert_false(idl.is_json_type(typeFrom("Float32Array")));
assert_false(idl.is_json_type(typeFrom("Float64Array")));
assert_false(idl.is_json_type(typeFrom("ArrayBuffer")));
Expand Down
40 changes: 40 additions & 0 deletions websockets/Send-binary-arraybufferview-float16.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// META: script=constants.sub.js
// META: variant=?default
// META: variant=?wpt_flags=h2
// META: variant=?wss

var test = async_test("Send binary data on a WebSocket - ArrayBufferView - Float16Array - Connection should be closed");

var data = "";
var datasize = 4;
var view;
var wsocket = CreateWebSocket(false, false);
var isOpenCalled = false;
var isMessageCalled = false;

wsocket.addEventListener('open', test.step_func(function(evt) {
wsocket.binaryType = "arraybuffer";
data = new ArrayBuffer(datasize);
view = new Float16Array(data);
for (var i = 0; i < 2; i++) {
view[i] = i;
}
wsocket.send(view);
isOpenCalled = true;
}), true);

wsocket.addEventListener('message', test.step_func(function(evt) {
isMessageCalled = true;
var resultView = new Float16Array(evt.data);
for (var i = 0; i < resultView.length; i++) {
assert_equals(resultView[i], view[i], "ArrayBufferView returned is the same");
}
wsocket.close();
}), true);

wsocket.addEventListener('close', test.step_func(function(evt) {
assert_true(isOpenCalled, "WebSocket connection should be open");
assert_true(isMessageCalled, "message should be received")
assert_equals(evt.wasClean, true, "wasClean should be true");
test.done();
}), true);
1 change: 1 addition & 0 deletions workers/semantics/interface-objects/001.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var expected = [
"Uint16Array",
"Int32Array",
"Uint32Array",
"Float16Array",
"Float32Array",
"Float64Array",
"DataView",
Expand Down
1 change: 1 addition & 0 deletions workers/semantics/interface-objects/003.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var expected = [
"Uint16Array",
"Int32Array",
"Uint32Array",
"Float16Array",
"Float32Array",
"Float64Array",
"DataView",
Expand Down
2 changes: 1 addition & 1 deletion xhr/send-data-sharedarraybuffer.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test(() => {

["Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array",
"Int32Array", "Uint32Array", "BigInt64Array", "BigUint64Array",
"Float32Array", "Float64Array", "DataView"].forEach((type) => {
"Float16Array", "Float32Array", "Float64Array", "DataView"].forEach((type) => {
test(() => {
const xhr = new XMLHttpRequest();
// See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
Expand Down

0 comments on commit 5aa50dd

Please sign in to comment.