summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Math/clz32.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/tests/non262/Math/clz32.js
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/non262/Math/clz32.js')
-rw-r--r--js/src/tests/non262/Math/clz32.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/js/src/tests/non262/Math/clz32.js b/js/src/tests/non262/Math/clz32.js
new file mode 100644
index 0000000000..0062676365
--- /dev/null
+++ b/js/src/tests/non262/Math/clz32.js
@@ -0,0 +1,40 @@
+// Undefined and NaN end up as zero after ToUint32
+assertEq(Math.clz32(), 32);
+assertEq(Math.clz32(NaN), 32);
+assertEq(Math.clz32.call(), 32);
+// 0
+assertEq(Math.clz32(null), 32);
+assertEq(Math.clz32(false), 32);
+// 1
+assertEq(Math.clz32(true), 31);
+// 3
+assertEq(Math.clz32(3.5), 30);
+// NaN -> 0
+assertEq(Math.clz32({}), 32);
+// 2
+assertEq(Math.clz32({valueOf: function() { return 2; }}), 30);
+// 0 -> 0
+assertEq(Math.clz32([]), 32);
+assertEq(Math.clz32(""), 32);
+// NaN -> 0
+assertEq(Math.clz32([1, 2, 3]), 32);
+assertEq(Math.clz32("bar"), 32);
+// 15
+assertEq(Math.clz32("15"), 28);
+
+
+assertEq(Math.clz32(0x80000000), 0);
+assertEq(Math.clz32(0xF0FF1000), 0);
+assertEq(Math.clz32(0x7F8F0001), 1);
+assertEq(Math.clz32(0x3FFF0100), 2);
+assertEq(Math.clz32(0x1FF50010), 3);
+assertEq(Math.clz32(0x00800000), 8);
+assertEq(Math.clz32(0x00400000), 9);
+assertEq(Math.clz32(0x00008000), 16);
+assertEq(Math.clz32(0x00004000), 17);
+assertEq(Math.clz32(0x00000080), 24);
+assertEq(Math.clz32(0x00000040), 25);
+assertEq(Math.clz32(0x00000001), 31);
+assertEq(Math.clz32(0), 32);
+
+reportCompare(0, 0, 'ok');