Browse Source

Testcase: Math.trunc()

pull/1093/head
Bruce Pascoe 8 years ago
parent
commit
59ce1b2351
  1. 7
      tests/ecmascript/test-bi-math-cbrt.js
  2. 4
      tests/ecmascript/test-bi-math-log10.js
  3. 62
      tests/ecmascript/test-bi-math-log2.js
  4. 48
      tests/ecmascript/test-bi-math-trunc.js

7
tests/ecmascript/test-bi-math-cbrt.js

@ -28,9 +28,10 @@ function test() {
printExact(Math.cbrt(0)); printExact(Math.cbrt(0));
printExact(Math.cbrt(-0)); printExact(Math.cbrt(-0));
printExact(Math.cbrt(Infinity)); printExact(Math.cbrt(1 / 0));
printExact(Math.cbrt(-Infinity)); printExact(Math.cbrt(-1 / 0));
printExact(Math.cbrt(NaN)); printExact(Math.cbrt(0 / 0));
printExact(Math.cbrt(8)); printExact(Math.cbrt(8));
printExact(Math.cbrt(64)); printExact(Math.cbrt(64));
printExact(Math.cbrt(1000)); printExact(Math.cbrt(1000));

4
tests/ecmascript/test-bi-math-log10.js

@ -24,12 +24,12 @@ function test() {
print(typeof pd.value, pd.writable, pd.enumerable, pd.configurable); print(typeof pd.value, pd.writable, pd.enumerable, pd.configurable);
print(Math.log10.length); print(Math.log10.length);
printExact(Math.log10(NaN)); printExact(Math.log10(0 / 0));
printExact(Math.log10(-1)); printExact(Math.log10(-1));
printExact(Math.log10(0)); printExact(Math.log10(0));
printExact(Math.log10(-0)); printExact(Math.log10(-0));
printExact(Math.log10(1)); printExact(Math.log10(1));
printExact(Math.log10(Infinity)); printExact(Math.log10(1 / 0));
printExact(Math.log10(10)); printExact(Math.log10(10));
printExact(Math.log10(1000)); printExact(Math.log10(1000));

62
tests/ecmascript/test-bi-math-log2.js

@ -17,6 +17,60 @@ Infinity
10 10
812 812
9965784 9965784
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
===*/ ===*/
function test() { function test() {
@ -24,17 +78,21 @@ function test() {
print(typeof pd.value, pd.writable, pd.enumerable, pd.configurable); print(typeof pd.value, pd.writable, pd.enumerable, pd.configurable);
print(Math.log2.length); print(Math.log2.length);
printExact(Math.log2(NaN)); printExact(Math.log2(0 / 0));
printExact(Math.log2(-1)); printExact(Math.log2(-1));
printExact(Math.log2(0)); printExact(Math.log2(0));
printExact(Math.log2(-0)); printExact(Math.log2(-0));
printExact(Math.log2(1)); printExact(Math.log2(1));
printExact(Math.log2(Infinity)); printExact(Math.log2(1 / 0));
printExact(Math.log2(2)); printExact(Math.log2(2));
printExact(Math.log2(1024)); printExact(Math.log2(1024));
printExact(Math.log2(2.73121871170759e+244)); printExact(Math.log2(2.73121871170759e+244));
printRounded6(Math.log2(1000)); printRounded6(Math.log2(1000));
for (var n = 0; n <= 53; ++n) {
printExact(Math.log2(2 ** n));
}
} }
try { try {

48
tests/ecmascript/test-bi-math-trunc.js

@ -0,0 +1,48 @@
/*
* Math.trunc()
*/
/*@include util-number.js@*/
/*===
function true false true
1
NaN
-0
0
Infinity
-Infinity
0
-0
10
9000
-1
-812
812
===*/
function test() {
var pd = Object.getOwnPropertyDescriptor(Math, 'trunc');
print(typeof pd.value, pd.writable, pd.enumerable, pd.configurable);
print(Math.trunc.length);
printExact(Math.trunc(0 / 0));
printExact(Math.trunc(-0));
printExact(Math.trunc(0));
printExact(Math.trunc(1 / 0));
printExact(Math.trunc(-1 / 0));
printExact(Math.trunc(0.5));
printExact(Math.trunc(-0.5));
printExact(Math.trunc(10.5));
printExact(Math.trunc(9000.5));
printExact(Math.trunc(-1.5));
printExact(Math.trunc(-812.88));
printExact(Math.trunc(812.88));
}
try {
test();
} catch (e) {
print(e.stack || e);
}
Loading…
Cancel
Save