blob: 8f04d12a15e3bc5b327a2237fc178a69a716e7f9 [file] [log] [blame]
This test checks the behavior of the Math object as described in 15.8 of the language specification.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Math.abs(NaN) is NaN
PASS Math.abs(0) is 0
PASS Math.abs(-0) is 0
PASS Math.abs(1) is 1
PASS Math.abs(-1) is 1
PASS Math.abs(Number.MIN_VALUE) is Number.MIN_VALUE
PASS Math.abs(-Number.MIN_VALUE) is Number.MIN_VALUE
PASS Math.abs(Number.MAX_VALUE) is Number.MAX_VALUE
PASS Math.abs(-Number.MAX_VALUE) is Number.MAX_VALUE
PASS Math.abs(Infinity) is Infinity
PASS Math.abs(-Infinity) is Infinity
PASS Math.acos(NaN) is NaN
PASS Math.acos(-0) is Math.acos(0)
PASS Math.acos(1) is 0
PASS Math.acos(1.1) is NaN
PASS Math.acos(-1.1) is NaN
PASS Math.acos(Infinity) is NaN
PASS Math.acos(-Infinity) is NaN
PASS Math.asin(NaN) is NaN
PASS Math.asin(0) is 0
PASS Math.asin(-0) is -0
PASS Math.asin(1) is -Math.asin(-1)
PASS Math.asin(1.1) is NaN
PASS Math.asin(-1.1) is NaN
PASS Math.asin(Infinity) is NaN
PASS Math.asin(-Infinity) is NaN
PASS Math.atan(NaN) is NaN
PASS Math.atan(0) is 0
PASS Math.atan(-0) is -0
PASS Math.atan(Infinity) is -Math.atan(-Infinity)
PASS Math.atan2(NaN, NaN) is NaN
PASS Math.atan2(NaN, 0) is NaN
PASS Math.atan2(NaN, -0) is NaN
PASS Math.atan2(NaN, 1) is NaN
PASS Math.atan2(NaN, Infinity) is NaN
PASS Math.atan2(NaN, -Infinity) is NaN
PASS Math.atan2(0, NaN) is NaN
PASS Math.atan2(-0, NaN) is NaN
PASS Math.atan2(1, NaN) is NaN
PASS Math.atan2(Infinity, NaN) is NaN
PASS Math.atan2(-Infinity, NaN) is NaN
PASS testStr is "onetwo"
PASS Math.ceil(NaN) is NaN
PASS Math.ceil(0) is 0
PASS Math.ceil(-0) is -0
PASS Math.ceil(-0.5) is -0
PASS Math.ceil(1) is 1
PASS Math.ceil(-1) is -1
PASS Math.ceil(1.1) is 2
PASS Math.ceil(-1.1) is -1
PASS Math.ceil(Number.MAX_VALUE) is Number.MAX_VALUE
PASS Math.ceil(-Number.MAX_VALUE) is -Number.MAX_VALUE
PASS Math.ceil(Infinity) is Infinity
PASS Math.ceil(-Infinity) is -Infinity
PASS Math.cos(NaN) is NaN
PASS Math.cos(0) is 1
PASS Math.cos(-0) is 1
PASS Math.cos(Infinity) is NaN
PASS Math.cos(-Infinity) is NaN
PASS Math.exp(NaN) is NaN
PASS Math.exp(0) is 1
PASS Math.exp(-0) is 1
PASS Math.exp(Infinity) is Infinity
PASS Math.exp(-Infinity) is 0
PASS Math.floor(NaN) is NaN
PASS Math.floor(0) is 0
PASS Math.floor(-0) is -0
PASS Math.floor(0.5) is 0
PASS Math.floor(1) is 1
PASS Math.floor(-1) is -1
PASS Math.floor(1.1) is 1
PASS Math.floor(-1.1) is -2
PASS Math.floor(Number.MAX_VALUE) is Number.MAX_VALUE
PASS Math.floor(-Number.MAX_VALUE) is -Number.MAX_VALUE
PASS Math.floor(Infinity) is Infinity
PASS Math.floor(-Infinity) is -Infinity
PASS Math.hypot.length is 2
PASS Math.hypot(NaN) is NaN
PASS Math.hypot() is 0
PASS Math.hypot(-0) is 0
PASS Math.hypot(0) is 0
PASS Math.hypot(-Infinity) is Infinity
PASS Math.hypot(Infinity) is Infinity
PASS Math.hypot(-3) is 3
PASS Math.hypot(3, 4) is 5
PASS Math.hypot(1, NaN, Infinity) is Infinity
PASS Math.hypot(3, 4, 5) is 7.0710678118654755
PASS Math.hypot(3, 4, '5') is 7.0710678118654755
PASS Math.hypot(-3, -4) is 5
PASS Math.hypot(3, -Infinity) is Infinity
PASS Math.hypot(3, NaN) is NaN
PASS Math.hypot(NaN, 3) is NaN
PASS Math.hypot(0, NaN) is NaN
PASS Math.hypot(NaN, 0) is NaN
PASS Math.hypot(NaN, {valueOf:function(){throw "err"}}) threw exception err.
PASS Math.hypot(NaN, NaN, {valueOf:function(){throw "err"}}) threw exception err.
PASS Math.hypot({valueOf:function(){throw "error1"}}, {valueOf:function(){sideEffect = 1}}) threw exception error1.
PASS sideEffect is 0
PASS Math.hypot(3, 4, 'foo') is NaN
PASS Math.imul.length is 2
PASS Math.log(NaN) is NaN
PASS Math.log(0) is -Infinity
PASS Math.log(-0) is -Infinity
PASS Math.log(1) is 0
PASS Math.log(-1) is NaN
PASS Math.log(-1.1) is NaN
PASS Math.log(Infinity) is Infinity
PASS Math.log(-Infinity) is NaN
PASS Math.max() is -Infinity
PASS Math.max(NaN) is NaN
PASS Math.max(NaN,1) is NaN
PASS Math.max(0) is 0
PASS Math.max(-0) is -0
PASS Math.max(-0, 0) is 0
PASS Math.max(NaN, {valueOf:function(){throw "err"}}) threw exception err.
PASS Math.max(NaN, NaN, {valueOf:function(){throw "err"}}) threw exception err.
PASS Math.max(-0, NaN, 0) is NaN
PASS Math.max(-0, NaN, 0, NaN) is NaN
PASS Math.max({valueOf:function(){throw "error1"}}, {valueOf:function(){sideEffect = 1}}) threw exception error1.
PASS sideEffect is 0
PASS Math.min() is Infinity
PASS Math.min(NaN) is NaN
PASS Math.min(NaN,1) is NaN
PASS Math.min(0) is 0
PASS Math.min(-0) is -0
PASS Math.min(-0, 0) is -0
PASS Math.min(NaN, {valueOf:function(){throw "err"}}) threw exception err.
PASS Math.min(NaN, NaN, {valueOf:function(){throw "err"}}) threw exception err.
PASS Math.min(-0, NaN, 0) is NaN
PASS Math.min(-0, NaN, 0, NaN) is NaN
PASS Math.min({valueOf:function(){throw "error1"}}, {valueOf:function(){sideEffect = 1}}) threw exception error1.
PASS sideEffect is 0
PASS Math.pow(NaN, NaN) is NaN
PASS Math.pow(NaN, 0) is 1
PASS Math.pow(NaN, -0) is 1
PASS Math.pow(NaN, 1) is NaN
PASS Math.pow(NaN, Infinity) is NaN
PASS Math.pow(NaN, -Infinity) is NaN
PASS Math.pow(0, NaN) is NaN
PASS Math.pow(-0, NaN) is NaN
PASS Math.pow(1, NaN) is NaN
PASS Math.pow(Infinity, NaN) is NaN
PASS Math.pow(-Infinity, NaN) is NaN
PASS Math.round(NaN) is NaN
PASS Math.round(0) is 0
PASS Math.round(-0) is -0
PASS Math.round(0.4) is 0
PASS Math.round(-0.4) is -0
PASS Math.round(0.5) is 1
PASS Math.round(-0.5) is -0
PASS Math.round(0.6) is 1
PASS Math.round(-0.6) is -1
PASS Math.round(1) is 1
PASS Math.round(-1) is -1
PASS Math.round(1.1) is 1
PASS Math.round(-1.1) is -1
PASS Math.round(1.5) is 2
PASS Math.round(-1.5) is -1
PASS Math.round(1.6) is 2
PASS Math.round(-1.6) is -2
PASS Math.round(8640000000000000) is 8640000000000000
PASS Math.round(8640000000000000.5) is 8640000000000000
PASS Math.round(8640000000000001) is 8640000000000001
PASS Math.round(8640000000000002) is 8640000000000002
PASS Math.round(9007199254740990) is 9007199254740990
PASS Math.round(9007199254740991) is 9007199254740991
PASS Math.round(1.7976931348623157e+308) is 1.7976931348623157e+308
PASS Math.round(-8640000000000000) is -8640000000000000
PASS Math.round(-8640000000000001) is -8640000000000001
PASS Math.round(-8640000000000002) is -8640000000000002
PASS Math.round(-9007199254740990) is -9007199254740990
PASS Math.round(-9007199254740991) is -9007199254740991
PASS Math.round(-1.7976931348623157e+308) is -1.7976931348623157e+308
PASS Math.round(Infinity) is Infinity
PASS Math.round(-Infinity) is -Infinity
PASS Math.sign(NaN) is NaN
PASS Math.sign('string') is NaN
PASS Math.sign([1, 2, 3]) is NaN
PASS Math.sign({}) is NaN
PASS Math.sign(0) is 0
PASS Math.sign(-0) is -0
PASS Math.sign(-1) is -1
PASS Math.sign(1) is 1
PASS Math.sign(0.1) is 1
PASS Math.sign(-0.1) is -1
PASS Math.sign(10000) is 1
PASS Math.sign(-10000) is -1
PASS Math.sign(Number.MIN_VALUE) is 1
PASS Math.sign(-Number.MIN_VALUE) is -1
PASS Math.sign(Number.MAX_VALUE) is 1
PASS Math.sign(-Number.MAX_VALUE) is -1
PASS Math.sign(Infinity) is 1
PASS Math.sign(-Infinity) is -1
PASS Math.sin(NaN) is NaN
PASS Math.sin(0) is 0
PASS Math.sin(-0) is -0
PASS Math.sin(Infinity) is NaN
PASS Math.sin(-Infinity) is NaN
PASS Math.sqrt(NaN) is NaN
PASS Math.sqrt(0) is 0
PASS Math.sqrt(-0) is -0
PASS Math.sqrt(1) is 1
PASS Math.sqrt(-1) is NaN
PASS Math.sqrt(Infinity) is Infinity
PASS Math.sqrt(-Infinity) is NaN
PASS Math.tan(NaN) is NaN
PASS Math.tan(0) is 0
PASS Math.tan(-0) is -0
PASS Math.tan(Infinity) is NaN
PASS Math.tan(-Infinity) is NaN
PASS Math.acosh(NaN) is NaN
PASS Math.acosh(0) is NaN
PASS Math.acosh(0.5) is NaN
PASS Math.acosh(-1) is NaN
PASS Math.acosh(Infinity) is Infinity
PASS Math.acosh(-Infinity) is NaN
PASS Math.asinh(NaN) is NaN
PASS Math.asinh(0) is 0
PASS Math.asinh(-0) is -0
PASS Math.asinh(Infinity) is Infinity
PASS Math.asinh(-Infinity) is -Infinity
PASS Math.atanh(NaN) is NaN
PASS Math.atanh(0) is 0
PASS Math.atanh(-0) is -0
PASS Math.atanh(-1) is -Infinity
PASS Math.atanh(1) is Infinity
PASS Math.atanh(Infinity) is NaN
PASS Math.atanh(-Infinity) is NaN
PASS Math.cbrt(NaN) is NaN
PASS Math.cbrt(0) is 0
PASS Math.cbrt(-0) is -0
PASS Math.cbrt(8) is 2
PASS Math.cbrt(-8) is -2
PASS Math.cbrt(Infinity) is Infinity
PASS Math.cbrt(-Infinity) is -Infinity
PASS Math.cosh(NaN) is NaN
PASS Math.cosh(0) is 1
PASS Math.cosh(-0) is 1
PASS Math.cosh(Infinity) is Infinity
PASS Math.cosh(-Infinity) is Infinity
PASS Math.expm1(NaN) is NaN
PASS Math.expm1(0) is 0
PASS Math.expm1(-0) is -0
PASS Math.expm1(Infinity) is Infinity
PASS Math.expm1(-Infinity) is -1
PASS Math.fround(NaN) is NaN
PASS Math.fround(0) is 0
PASS Math.fround(-0) is -0
PASS Math.fround(Infinity) is Infinity
PASS Math.fround(-Infinity) is -Infinity
PASS Math.log1p(NaN) is NaN
PASS Math.log1p(0) is 0
PASS Math.log1p(-0) is -0
PASS Math.log1p(Infinity) is Infinity
PASS Math.log1p(-1) is -Infinity
PASS Math.log1p(-Infinity) is NaN
PASS Math.log10(NaN) is NaN
PASS Math.log10(0) is -Infinity
PASS Math.log10(-0) is -Infinity
PASS Math.log10(10) is 1
PASS Math.log10(-1) is NaN
PASS Math.log10(-Infinity) is NaN
PASS Math.log10(Infinity) is Infinity
PASS Math.log10(1) is 0
PASS Math.log2(NaN) is NaN
PASS Math.log2(0) is -Infinity
PASS Math.log2(-0) is -Infinity
PASS Math.log2(2) is 1
PASS Math.log2(-1) is NaN
PASS Math.log2(-Infinity) is NaN
PASS Math.log2(Infinity) is Infinity
PASS Math.log2(1) is 0
PASS Math.asinh(NaN) is NaN
PASS Math.asinh(0) is 0
PASS Math.asinh(-0) is -0
PASS Math.asinh(Infinity) is Infinity
PASS Math.asinh(-Infinity) is -Infinity
PASS Math.sinh(NaN) is NaN
PASS Math.sinh(0) is 0
PASS Math.sinh(-0) is -0
PASS Math.sinh(Infinity) is Infinity
PASS Math.sinh(-Infinity) is -Infinity
PASS Math.tanh(NaN) is NaN
PASS Math.tanh(0) is 0
PASS Math.tanh(-0) is -0
PASS Math.tanh(Infinity) is 1
PASS Math.tanh(-Infinity) is -1
PASS Math.trunc(NaN) is NaN
PASS Math.trunc(0) is 0
PASS Math.trunc(-0) is -0
PASS Math.trunc(Infinity) is Infinity
PASS Math.trunc(-Infinity) is -Infinity
PASS Math.trunc(-0.5) is -0
PASS Math.trunc(0.5) is 0
PASS Math.trunc(0xFFFFFFFF * 2 + 0.5) is 0xFFFFFFFF * 2
PASS delete Math; is true
PASS 'Math' in global() is false
PASS successfullyParsed is true
TEST COMPLETE