| 1 |
// Copyright 2009 the Sputnik authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
info: | |
| 6 |
Result of number conversion from number value equals to the input |
| 7 |
argument (no conversion) |
| 8 |
es5id: 9.3_A4.2_T1 |
| 9 |
description: > |
| 10 |
Number.NaN, +0, -0, Number.POSITIVE_INFINITY, |
| 11 |
Number.NEGATIVE_INFINITY, Number.MAX_VALUE and Number.MIN_VALUE |
| 12 |
convert to Number by explicit transformation |
| 13 |
---*/ |
| 14 |
|
| 15 |
// CHECK#1 |
| 16 |
assert.sameValue(Number(NaN), NaN, "NaN"); |
| 17 |
|
| 18 |
// CHECK#2 |
| 19 |
if (Number(+0) !== +0) { |
| 20 |
$ERROR('#2.1: Number(+0) === 0. Actual: ' + (Number(+0))); |
| 21 |
} else { |
| 22 |
if (1 / Number(+0) !== Number.POSITIVE_INFINITY) { |
| 23 |
$ERROR('#2.2: Number(+0) === +0. Actual: -0'); |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
// CHECK#3 |
| 28 |
if (Number(-0) !== -0) { |
| 29 |
$ERROR('#3.1: Number(-0) === 0. Actual: ' + (Number(-0))); |
| 30 |
} else { |
| 31 |
if (1 / Number(-0) !== Number.NEGATIVE_INFINITY) { |
| 32 |
$ERROR('#3.2: Number(-0) === -0. Actual: +0'); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
// CHECK#4 |
| 37 |
if (Number(Number.POSITIVE_INFINITY) !== Number.POSITIVE_INFINITY) { |
| 38 |
$ERROR('#4: Number(+Infinity) === +Infinity. Actual: ' + (Number(+Infinity))); |
| 39 |
} |
| 40 |
|
| 41 |
// CHECK#5 |
| 42 |
if (Number(Number.NEGATIVE_INFINITY) !== Number.NEGATIVE_INFINITY) { |
| 43 |
$ERROR('#5: Number(-Infinity) === -Infinity. Actual: ' + (Number(-Infinity))); |
| 44 |
} |
| 45 |
|
| 46 |
// CHECK#6 |
| 47 |
if (Number(Number.MAX_VALUE) !== Number.MAX_VALUE) { |
| 48 |
$ERROR('#6: Number(Number.MAX_VALUE) === Number.MAX_VALUE. Actual: ' + (Number(Number.MAX_VALUE))); |
| 49 |
} |
| 50 |
|
| 51 |
// CHECK#7 |
| 52 |
if (Number(Number.MIN_VALUE) !== Number.MIN_VALUE) { |
| 53 |
$ERROR('#7: Number(Number.MIN_VALUE) === Number.MIN_VALUE. Actual: ' + (Number(Number.MIN_VALUE))); |
| 54 |
} |