Skip to content

Commit b56af07

Browse files
committed
Merge pull request #269 from suwc/Math_builtins
Add new tests for Math built-ins
2 parents 68e6a66 + b6e870d commit b56af07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+687
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Math.Log2 with sample values.
6+
includes: [assert.js]
7+
es6id: 20.2.2.23
8+
---*/
9+
10+
assert.sameValue(Math.log2(-0), Number.NEGATIVE_INFINITY,
11+
"Math.log2 produces incorrect output for -0");
12+
assert.sameValue(Math.log2(+0), Number.NEGATIVE_INFINITY,
13+
"Math.log2 produces incorrect output for +0");
14+
assert.sameValue(Math.log2(-0.9), NaN,
15+
"Math.log2 produces incorrect output for -0.9");
16+
assert.sameValue(Math.log2(NaN), NaN,
17+
"Math.log2 produces incorrect output for NaN");
18+
assert.sameValue(Math.log2(-10), NaN,
19+
"Math.log2 produces incorrect output for -10");
20+
assert.sameValue(Math.log2(-Infinity), NaN,
21+
"Math.log2 produces incorrect output for -Infinity");
22+
assert.sameValue(Math.log2(null), Number.NEGATIVE_INFINITY,
23+
"Math.log2 produces incorrect output for null");
24+
assert.sameValue(Math.log2(undefined), NaN,
25+
"Math.log2 produces incorrect output for undefined");
26+
assert.sameValue(Math.log2(Number.POSITIVE_INFINITY), Number.POSITIVE_INFINITY,
27+
"Math.log2 produces incorrect output for Number.POSITIVE_INFINITY");
28+
assert.sameValue(Math.log2(1), 0,
29+
"Math.log2 produces incorrect output for 1");
30+
assert.sameValue(Math.log2(2.00), 1,
31+
"Math.log2 produces incorrect output for 2.00");
32+
assert.sameValue(Math.log2(4.00), 2,
33+
"Math.log2 produces incorrect output for 4.00");
34+
assert.sameValue(Math.log2(8.00), 3,
35+
"Math.log2 produces incorrect output for 8.00");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Testing descriptor property of Math.log2
6+
includes:
7+
- propertyHelper.js
8+
es6id: 20.2.2.23
9+
---*/
10+
11+
verifyWritable(Math, "log2");
12+
verifyNotEnumerable(Math, "log2");
13+
verifyConfigurable(Math, "log2");
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Testing length property of Math.log2
6+
includes:
7+
- assert.js
8+
es6id: 20.2.2.23
9+
---*/
10+
11+
assert.sameValue(Math.log2.length, 1);
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Testing descriptor property of Math.acosh
6+
includes:
7+
- propertyHelper.js
8+
es6id: 20.2.2.3
9+
---*/
10+
11+
verifyWritable(Math, "acosh");
12+
verifyNotEnumerable(Math, "acosh");
13+
verifyConfigurable(Math, "acosh");
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Testing length property of Math.acosh
6+
includes:
7+
- assert.js
8+
es6id: 20.2.2.3
9+
---*/
10+
11+
assert.sameValue(Math.acosh.length, 1);
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Math.acosh with special values
6+
includes:
7+
- assert.js
8+
es6id: 20.2.2.3
9+
---*/
10+
11+
assert.sameValue(Math.acosh(NaN), Number.NaN,
12+
"Math.acosh produces incorrect output for NaN");
13+
assert.sameValue(Math.acosh(0), Number.NaN,
14+
"Math.acosh should produce NaN for values < 1");
15+
assert.sameValue(Math.acosh(Number.NEGATIVE_INFINITY), Number.NaN,
16+
"Math.acosh should produce NaN for inputs <1");
17+
assert.notSameValue(Math.acosh(Number.NEGATIVE_INFINITY),
18+
Number.POSITIVE_INFINITY,
19+
"Math.acosh should produce POSITIVE_INFINITY for input Number.POSITIVE_INFINITY");
20+
assert.sameValue(Math.acosh(+1), 0, "Math.acosh should produce 0 for +1");
21+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Testing descriptor property of Math.asinh
6+
includes:
7+
- propertyHelper.js
8+
es6id: 20.2.2.5
9+
---*/
10+
11+
verifyWritable(Math, "asinh");
12+
verifyNotEnumerable(Math, "asinh");
13+
verifyConfigurable(Math, "asinh");
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Testing length property of Math.asinh
6+
includes:
7+
- assert.js
8+
es6id: 20.2.2.5
9+
---*/
10+
11+
assert.sameValue(Math.asinh.length, 1);
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Math.asinh with special values
6+
includes:
7+
- assert.js
8+
es6id: 20.2.2.5
9+
---*/
10+
11+
assert.sameValue(Math.asinh(NaN), Number.NaN,
12+
"Math.asinh produces incorrect output for NaN");
13+
assert.sameValue(Math.asinh(Number.NEGATIVE_INFINITY), Number.NEGATIVE_INFINITY,
14+
"Math.asinh should produce negative infinity for Number.NEGATIVE_INFINITY");
15+
assert.sameValue(Math.asinh(Number.POSITIVE_INFINITY), Number.POSITIVE_INFINITY,
16+
"Math.asinh should produce positive infinity for Number.POSITIVE_INFINITY");
17+
assert.sameValue(1 / Math.asinh(-0), Number.NEGATIVE_INFINITY,
18+
"Math.asinh should produce -0 for -0");
19+
assert.sameValue(1 / Math.asinh(0), Number.POSITIVE_INFINITY,
20+
"Math.asinh should produce +0 for +0");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Testing descriptor property of Math.atanh
6+
includes:
7+
- propertyHelper.js
8+
es6id: 20.2.2.7
9+
---*/
10+
11+
verifyWritable(Math, "atanh");
12+
verifyNotEnumerable(Math, "atanh");
13+
verifyConfigurable(Math, "atanh");
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Testing length property of Math.atanh
6+
includes:
7+
- assert.js
8+
es6id: 20.2.2.7
9+
---*/
10+
11+
assert.sameValue(Math.atanh.length, 1);
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Math.atanh with special values
6+
includes:
7+
- assert.js
8+
es6id: 20.2.2.7
9+
---*/
10+
11+
assert.sameValue(Math.atanh(-1.9), Number.NaN,
12+
"Math.atanh produces incorrect output for -1.9");
13+
assert.sameValue(Math.atanh(NaN), Number.NaN,
14+
"Math.atanh produces incorrect output for NaN");
15+
assert.sameValue(Math.atanh(-10), Number.NaN,
16+
"Math.atanh produces incorrect output for -10");
17+
assert.sameValue(Math.atanh(-Infinity), Number.NaN,
18+
"Math.atanh produces incorrect output for -Infinity");
19+
assert.sameValue(Math.atanh(1.9), Number.NaN,
20+
"Math.atanh produces incorrect output for 1.9");
21+
assert.sameValue(Math.atanh(10), Number.NaN,
22+
"Math.atanh produces incorrect output for 10");
23+
assert.sameValue(Math.atanh(Number.POSITIVE_INFINITY), Number.NaN,
24+
"Math.atanh produces incorrect output for Number.POSITIVE_INFINITY");
25+
26+
assert.sameValue(Math.atanh(-1), Number.NEGATIVE_INFINITY,
27+
"Math.atanh should produce negative infinity for -1");
28+
assert.sameValue(Math.atanh(+1), Number.POSITIVE_INFINITY,
29+
"Math.atanh should produce positive infinity for +1");
30+
assert.sameValue(1/Math.atanh(-0), Number.NEGATIVE_INFINITY,
31+
"Math.atanh should produce -0 for -0");
32+
assert.sameValue(1/Math.atanh(0), Number.POSITIVE_INFINITY,
33+
"Math.atanh should produce +0 for +0");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Testing descriptor property of Math.cbrt
6+
includes:
7+
- propertyHelper.js
8+
es6id: 20.2.2.9
9+
---*/
10+
11+
verifyWritable(Math, "cbrt");
12+
verifyNotEnumerable(Math, "cbrt");
13+
verifyConfigurable(Math, "cbrt");
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Testing length property of Math.cbrt
6+
includes:
7+
- assert.js
8+
es6id: 20.2.2.9
9+
---*/
10+
11+
assert.sameValue(Math.cbrt.length, 1);
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Math.cbrt with special values
6+
includes:
7+
- assert.js
8+
es6id: 20.2.2.9
9+
---*/
10+
11+
assert.sameValue(Math.cbrt(NaN), Number.NaN,
12+
"Math.cbrt produces incorrect output for NaN");
13+
assert.sameValue(Math.cbrt(Number.NEGATIVE_INFINITY), Number.NEGATIVE_INFINITY,
14+
"Math.cbrt should produce negative infinity for Number.NEGATIVE_INFINITY");
15+
assert.sameValue(Math.cbrt(Number.POSITIVE_INFINITY), Number.POSITIVE_INFINITY,
16+
"Math.cbrt should produce positive infinity for Number.POSITIVE_INFINITY");
17+
assert.sameValue(1/Math.cbrt(-0), Number.NEGATIVE_INFINITY,
18+
"Math.cbrt should produce -0 for -0");
19+
assert.sameValue(1/Math.cbrt(0), Number.POSITIVE_INFINITY,
20+
"Math.cbrt should produce +0 for +0");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Testing descriptor property of Math.cosh
6+
includes:
7+
- propertyHelper.js
8+
es6id: 20.2.2.13
9+
---*/
10+
11+
verifyWritable(Math, "cosh");
12+
verifyNotEnumerable(Math, "cosh");
13+
verifyConfigurable(Math, "cosh");
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Testing length property of Math.cosh
6+
includes:
7+
- assert.js
8+
es6id: 20.2.2.13
9+
---*/
10+
11+
assert.sameValue(Math.cosh.length, 1);
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Math.cosh with special values
6+
includes:
7+
- assert.js
8+
es6id: 20.2.2.13
9+
---*/
10+
11+
assert.sameValue(Math.cosh(NaN), Number.NaN,
12+
"Math.cosh produces incorrect output for NaN");
13+
assert.sameValue(Math.cosh(0), 1, "Math.cosh should produce 1 for input = 0");
14+
assert.sameValue(Math.cosh(-0), 1, "Math.cosh should produce 1 for input = -0");
15+
assert.sameValue(Math.cosh(Number.NEGATIVE_INFINITY), Number.POSITIVE_INFINITY,
16+
"Math.cosh should produce Number.POSITIVE_INFINITY for Number.NEGATIVE_INFINITY");
17+
assert.sameValue(Math.cosh(Number.POSITIVE_INFINITY), Number.POSITIVE_INFINITY,
18+
"Math.cosh should produce Number.POSITIVE_INFINITY for Number.POSITIVE_INFINITY");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Testing descriptor property of Math.expm1
6+
includes:
7+
- propertyHelper.js
8+
es6id: 20.2.2.15
9+
---*/
10+
11+
verifyWritable(Math, "expm1");
12+
verifyNotEnumerable(Math, "expm1");
13+
verifyConfigurable(Math, "expm1");
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Testing length property of Math.expm1
6+
includes:
7+
- assert.js
8+
es6id: 20.2.2.15
9+
---*/
10+
11+
assert.sameValue(Math.expm1.length, 1);
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Math.expm1 with sample values.
6+
includes:
7+
- assert.js
8+
es6id: 20.2.2.15
9+
---*/
10+
11+
assert.sameValue(Math.expm1(NaN), Number.NaN,
12+
"Math.expm1 produces incorrect output for NaN");
13+
assert.sameValue(Math.expm1(Number.NEGATIVE_INFINITY), -1,
14+
"Math.expm1 should produce -1 for Number.NEGATIVE_INFINITY");
15+
assert.sameValue(Math.expm1(Number.POSITIVE_INFINITY), Number.POSITIVE_INFINITY,
16+
"Math.expm1 should produce POSITIVE infinity for Number.POSITIVE_INFINITY");
17+
assert.sameValue(1/Math.expm1(-0), Number.NEGATIVE_INFINITY,
18+
"Math.expm1 should produce -0 for -0");
19+
assert.sameValue(1/Math.expm1(0), Number.POSITIVE_INFINITY,
20+
"Math.expm1 should produce +0 for +0");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Testing descriptor property of Math.hypot
6+
includes:
7+
- propertyHelper.js
8+
es6id: 20.2.2.18
9+
---*/
10+
11+
verifyWritable(Math, "hypot");
12+
verifyNotEnumerable(Math, "hypot");
13+
verifyConfigurable(Math, "hypot");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 Microsoft Corporation. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
description: Testing descriptor property of Math.imul
6+
includes:
7+
- propertyHelper.js
8+
es6id: 20.2.2.19
9+
---*/
10+
11+
verifyWritable(Math, "imul");
12+
verifyNotEnumerable(Math, "imul");
13+
verifyConfigurable(Math, "imul");

0 commit comments

Comments
 (0)