Debian Codegraph @

js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A1.js

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