mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:28:11 +00:00
LibJS: Add support for arbitrary arguments to Math.max
Address the FIXME in MathObject::max to handle an arbitrary number of arguments. Also adding a test case to verify the behavior of Math.max() while I'm here.
This commit is contained in:
parent
79539378c6
commit
4e54d0ff21
2 changed files with 22 additions and 13 deletions
14
Libraries/LibJS/Tests/Math.max.js
Normal file
14
Libraries/LibJS/Tests/Math.max.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert(Math.max.length === 2);
|
||||
assert(Math.max(1) === 1);
|
||||
assert(Math.max(2, 1) === 2);
|
||||
assert(Math.max(1, 2, 3) === 3);
|
||||
assert(isNaN(Math.max(NaN)));
|
||||
assert(isNaN(Math.max("String", 1)));
|
||||
|
||||
console.log("PASS");
|
||||
} catch {
|
||||
console.log("FAIL");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue