Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/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 $ERROR('#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 $ERROR('#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 $ERROR('#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 $ERROR('#2.2: String.fromCharCode(0).charCodeAt(0) === +0. Actual: -0');
24 }
25
26 // CHECK#3
27 if (String.fromCharCode(0).charCodeAt(0) !== +0) {
28 $ERROR('#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 $ERROR('#3.2: String.fromCharCode(0).charCodeAt(0) === +0. Actual: -0');
31 }
32
33 // CHECK#4
34 if (String.fromCharCode(-0).charCodeAt(0) !== +0) {
35 $ERROR("#4.1: String.fromCharCode(-0).charCodeAt(0) === +0");
36 } else if (1 / String.fromCharCode(-0).charCodeAt(0) !== Number.POSITIVE_INFINITY) {
37 $ERROR("#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 $ERROR('#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 $ERROR('#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 $ERROR("#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 $ERROR("#6.2: String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0) === +0. Actual: -0");
52 }