mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 20:33:10 +00:00
LibJS: Add Number.parseFloat()
This commit is contained in:
parent
6f6b089aa0
commit
73eef31f49
|
@ -45,7 +45,7 @@ NumberConstructor::NumberConstructor()
|
|||
put_native_function("isInteger", is_integer, 1, attr);
|
||||
put_native_function("isNaN", is_nan, 1, attr);
|
||||
put_native_function("isSafeInteger", is_safe_integer, 1, attr);
|
||||
|
||||
put("parseFloat", interpreter().global_object().get("parseFloat"));
|
||||
put("prototype", interpreter().global_object().number_prototype(), 0);
|
||||
put("length", Value(1), Attribute::Configurable);
|
||||
put("EPSILON", Value(EPSILON), 0);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
load("test-common.js");
|
||||
|
||||
try {
|
||||
assert(Number.isFinite !== isFinite);
|
||||
assert(Number.isFinite.length === 1);
|
||||
|
||||
assert(Number.isFinite(0) === true);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
load("test-common.js");
|
||||
|
||||
try {
|
||||
assert(Number.isNaN !== isNaN);
|
||||
assert(Number.isNaN.length === 1);
|
||||
|
||||
assert(Number.isNaN(0) === false);
|
||||
|
|
11
Libraries/LibJS/Tests/Number.parseFloat.js
Normal file
11
Libraries/LibJS/Tests/Number.parseFloat.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
load("test-common.js");
|
||||
|
||||
try {
|
||||
// Ensuring it's the same function as the global
|
||||
// parseFloat() is enough as that already has tests :^)
|
||||
assert(Number.parseFloat === parseFloat);
|
||||
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
}
|
Loading…
Reference in a new issue