js/src/tests/test262/ch09/9.7/S9.7_A1.js

branch
TOR_BUG_3246
changeset 5
4ab42b5ab56c
equal deleted inserted replaced
-1:000000000000 0:3aa989b7f911
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 * If value is NaN, +0, -0, +Infinity, or -Infinity, return +0
6 *
7 * @path ch09/9.7/S9.7_A1.js
8 * @description For testing use String.fromCharCode(Number).charCodeAt(0) construction
9 */
10
11 // CHECK#1
12 if (String.fromCharCode(Number.NaN).charCodeAt(0) !== +0) {
13 $ERROR('#1.1: String.fromCharCode(Number.NaN).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(Number.NaN).charCodeAt(0)));
14 } else if (1/String.fromCharCode(Number.NaN).charCodeAt(0) !== Number.POSITIVE_INFINITY) {
15 $ERROR('#1.2: String.fromCharCode(Number.NaN).charCodeAt(0) === +0. Actual: -0');
16 }
17
18 // CHECK#2
19 if (String.fromCharCode(Number("abc")).charCodeAt(0) !== +0) {
20 $ERROR('#2.1: String.fromCharCode(Number("abc")).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(Number("abc")).charCodeAt(0)));
21 } else if (1/String.fromCharCode(0).charCodeAt(0) !== Number.POSITIVE_INFINITY) {
22 $ERROR('#2.2: String.fromCharCode(0).charCodeAt(0) === +0. Actual: -0');
23 }
24
25 // CHECK#3
26 if (String.fromCharCode(0).charCodeAt(0) !== +0) {
27 $ERROR('#3.1: String.fromCharCode(0).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(0).charCodeAt(0)));
28 } else if (1/String.fromCharCode(0).charCodeAt(0) !== Number.POSITIVE_INFINITY) {
29 $ERROR('#3.2: String.fromCharCode(0).charCodeAt(0) === +0. Actual: -0');
30 }
31
32 // CHECK#4
33 if (String.fromCharCode(-0).charCodeAt(0) !== +0) {
34 $ERROR("#4.1: String.fromCharCode(-0).charCodeAt(0) === +0");
35 } else if (1/String.fromCharCode(-0).charCodeAt(0) !== Number.POSITIVE_INFINITY) {
36 $ERROR("#4.2: String.fromCharCode(-0).charCodeAt(0) === +0. Actual: -0");
37 }
38
39 // CHECK#5
40 if (String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0) !== +0) {
41 $ERROR('#5.1: String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0)));
42 } else if (1/String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0) !== Number.POSITIVE_INFINITY) {
43 $ERROR('#5.2: String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0) === +0. Actual: -0');
44 }
45
46 // CHECK#6
47 if (String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0) !== +0) {
48 $ERROR("#6.1: String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0) === +0");
49 } else if (1/String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0) !== Number.POSITIVE_INFINITY) {
50 $ERROR("#6.2: String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0) === +0. Actual: -0");
51 }
52
53
54

mercurial