Skip to content

Commit 693b8ae

Browse files
committed
Testing that Float[32|16]Array.p.copyWithin keep NaN payloads.
1 parent 0a9a0f3 commit 693b8ae

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
6+
*/
7+
8+
/**
9+
* @option ecmascript-version=staging
10+
*/
11+
12+
load("assert.js");
13+
14+
(function copyWithinPreservesFloat32NaNPayload() {
15+
const buffer = new ArrayBuffer(8);
16+
const dataView = new DataView(buffer);
17+
dataView.setUint32(0, 0x7f801234, true);
18+
19+
const float32Array = new Float32Array(buffer);
20+
float32Array.copyWithin(1, 0, 1);
21+
22+
assertSame(0x7f801234, dataView.getUint32(4, true));
23+
})();
24+
25+
(function copyWithinPreservesFloat16NaNPayload() {
26+
const buffer = new ArrayBuffer(4);
27+
const dataView = new DataView(buffer);
28+
dataView.setUint16(0, 0x7c01, true);
29+
30+
const float16Array = new Float16Array(buffer);
31+
float16Array.copyWithin(1, 0, 1);
32+
33+
assertSame(0x7c01, dataView.getUint16(2, true));
34+
})();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
6+
*/
7+
8+
/**
9+
* @option direct-byte-buffer
10+
* @option ecmascript-version=staging
11+
*/
12+
13+
load("GR-76553.js");

0 commit comments

Comments
 (0)