mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 761480: add Number.isFinite. r=jorendorff.
This commit is contained in:
parent
95ee5094b8
commit
154c5ff8a3
15
js/src/jit-test/tests/basic/number-isfinite.js
Normal file
15
js/src/jit-test/tests/basic/number-isfinite.js
Normal file
@ -0,0 +1,15 @@
|
||||
assertEq(Number.isFinite(Infinity), false);
|
||||
assertEq(Number.isFinite(-Infinity), false);
|
||||
assertEq(Number.isFinite(NaN), false);
|
||||
assertEq(Number.isFinite(4), true);
|
||||
assertEq(Number.isFinite(4.5), true);
|
||||
assertEq(Number.isFinite("hi"), false);
|
||||
assertEq(Number.isFinite("1.3"), false);
|
||||
assertEq(Number.isFinite("51"), false);
|
||||
assertEq(Number.isFinite(0), true);
|
||||
assertEq(Number.isFinite(-0), true);
|
||||
assertEq(Number.isFinite({valueOf: function () { return 3; }}), false);
|
||||
assertEq(Number.isFinite({valueOf: function () { return 0/0; }}), false);
|
||||
assertEq(Number.isFinite({ valueOf: function() { throw 17; } }), false);
|
||||
assertEq(Number.isFinite({ toString: function() { throw 17; } }), false);
|
||||
assertEq(Number.isFinite({ valueOf: function() { throw 17; }, toString: function() { throw 42; } }), false);
|
@ -850,8 +850,23 @@ Number_isNaN(JSContext *cx, unsigned argc, Value *vp)
|
||||
return true;
|
||||
}
|
||||
|
||||
// ES6 draft ES6 15.7.3.11
|
||||
static JSBool
|
||||
Number_isFinite(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
if (args.length() < 1 || !args[0].isNumber()) {
|
||||
args.rval().setBoolean(false);
|
||||
return true;
|
||||
}
|
||||
args.rval().setBoolean(args[0].isInt32() ||
|
||||
MOZ_DOUBLE_IS_FINITE(args[0].toDouble()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static JSFunctionSpec number_static_methods[] = {
|
||||
JS_FN("isFinite", Number_isFinite, 1, 0),
|
||||
JS_FN("isNaN", Number_isNaN, 1, 0),
|
||||
JS_FS_END
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user