Implemented Number object routines (#2972)

Implemented Number.isNaN & Number.isFinite &
Number.isSafeInteger & Number.isInteger & Number.EPSILON.

JerryScript-DCO-1.0-Signed-off-by: Virag Orkenyi orkvi@inf.u-szeged.hu
This commit is contained in:
Virag Orkenyi
2019-08-27 10:18:51 +02:00
committed by Dániel Bátyai
parent 47f2f0ea8b
commit d0435e1db0
11 changed files with 249 additions and 2 deletions
+19
View File
@@ -0,0 +1,19 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
assert(Number['isFinite'] (Infinity) === false);
assert(Number['isFinite'] (-Infinity) === false);
assert(Number['isFinite'] (NaN) === false);
assert(Number['isFinite'] (0) === true);
assert(Number['isFinite'] (2e64) === true);
+21
View File
@@ -0,0 +1,21 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
assert(Number['isInteger'] ('valami') === false);
assert(Number['isInteger'] (NaN) === false);
assert(Number['isInteger'] (Infinity) === false);
assert(Number['isInteger'] (-Infinity) === false);
assert(Number['isInteger'] (3.5) === false);
assert(Number['isInteger'] (-100000) === true);
assert(Number['isInteger'] (5.0000000000000001) === true);
+19
View File
@@ -0,0 +1,19 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
assert(Number['isNaN'] ('valami') === false);
assert(Number['isNaN'] (NaN) === true);
assert(Number['isNaN'] (1) === false);
assert(Number['isNaN'] (Number.NaN) === true);
assert(Number['isNaN'] (0 / 0) === true);
@@ -0,0 +1,20 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
assert(Number['isSafeInteger'] (Math.pow(2, 53)) === false);
assert(Number['isSafeInteger'] (Math.pow(2, 53) - 1) === true);
assert(Number['isSafeInteger'] (NaN) === false);
assert(Number['isSafeInteger'] (-3.0) === true);
assert(Number['isSafeInteger'] (Infinity) === false);
assert(Number['isSafeInteger'] (3.5) === false);