Debian Codegraph @

rhino/testsrc/tests/ecma/Expressions/11.4.7-01.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 gTestfile = '11.4.7-01.js';
7
8 /**
9 File Name: 11.4.7-01.js
10 ECMA Section: 11.4.7 Unary - Operator
11 Description: convert operand to Number type and change sign
12 Author: [email protected]
13 Date: 7 july 1997
14 */
15
16 var SECTION = "11.4.7";
17 var VERSION = "ECMA_1";
18 var BUGNUMBER="77391";
19
20 startTest();
21
22 writeHeaderToLog( SECTION + " Unary + operator");
23
24 new TestCase( SECTION, "-('')", -0, -("") );
25 new TestCase( SECTION, "-(' ')", -0, -(" ") );
26 new TestCase( SECTION, "-(\\t)", -0, -("\t") );
27 new TestCase( SECTION, "-(\\n)", -0, -("\n") );
28 new TestCase( SECTION, "-(\\r)", -0, -("\r") );
29 new TestCase( SECTION, "-(\\f)", -0, -("\f") );
30
31 new TestCase( SECTION, "-(String.fromCharCode(0x0009)", -0, -(String.fromCharCode(0x0009)) );
32 new TestCase( SECTION, "-(String.fromCharCode(0x0020)", -0, -(String.fromCharCode(0x0020)) );
33 new TestCase( SECTION, "-(String.fromCharCode(0x000C)", -0, -(String.fromCharCode(0x000C)) );
34 new TestCase( SECTION, "-(String.fromCharCode(0x000B)", -0, -(String.fromCharCode(0x000B)) );
35 new TestCase( SECTION, "-(String.fromCharCode(0x000D)", -0, -(String.fromCharCode(0x000D)) );
36 new TestCase( SECTION, "-(String.fromCharCode(0x000A)", -0, -(String.fromCharCode(0x000A)) );
37
38 // a StringNumericLiteral may be preceeded or followed by whitespace and/or
39 // line terminators
40
41 new TestCase( SECTION, "-( ' ' + 999 )", -999, -( ' '+999) );
42 new TestCase( SECTION, "-( '\\n' + 999 )", -999, -( '\n' +999) );
43 new TestCase( SECTION, "-( '\\r' + 999 )", -999, -( '\r' +999) );
44 new TestCase( SECTION, "-( '\\t' + 999 )", -999, -( '\t' +999) );
45 new TestCase( SECTION, "-( '\\f' + 999 )", -999, -( '\f' +999) );
46
47 new TestCase( SECTION, "-( 999 + ' ' )", -999, -( 999+' ') );
48 new TestCase( SECTION, "-( 999 + '\\n' )", -999, -( 999+'\n' ) );
49 new TestCase( SECTION, "-( 999 + '\\r' )", -999, -( 999+'\r' ) );
50 new TestCase( SECTION, "-( 999 + '\\t' )", -999, -( 999+'\t' ) );
51 new TestCase( SECTION, "-( 999 + '\\f' )", -999, -( 999+'\f' ) );
52
53 new TestCase( SECTION, "-( '\\n' + 999 + '\\n' )", -999, -( '\n' +999+'\n' ) );
54 new TestCase( SECTION, "-( '\\r' + 999 + '\\r' )", -999, -( '\r' +999+'\r' ) );
55 new TestCase( SECTION, "-( '\\t' + 999 + '\\t' )", -999, -( '\t' +999+'\t' ) );
56 new TestCase( SECTION, "-( '\\f' + 999 + '\\f' )", -999, -( '\f' +999+'\f' ) );
57
58 new TestCase( SECTION, "-( ' ' + '999' )", -999, -( ' '+'999') );
59 new TestCase( SECTION, "-( '\\n' + '999' )", -999, -( '\n' +'999') );
60 new TestCase( SECTION, "-( '\\r' + '999' )", -999, -( '\r' +'999') );
61 new TestCase( SECTION, "-( '\\t' + '999' )", -999, -( '\t' +'999') );
62 new TestCase( SECTION, "-( '\\f' + '999' )", -999, -( '\f' +'999') );
63
64 new TestCase( SECTION, "-( '999' + ' ' )", -999, -( '999'+' ') );
65 new TestCase( SECTION, "-( '999' + '\\n' )", -999, -( '999'+'\n' ) );
66 new TestCase( SECTION, "-( '999' + '\\r' )", -999, -( '999'+'\r' ) );
67 new TestCase( SECTION, "-( '999' + '\\t' )", -999, -( '999'+'\t' ) );
68 new TestCase( SECTION, "-( '999' + '\\f' )", -999, -( '999'+'\f' ) );
69
70 new TestCase( SECTION, "-( '\\n' + '999' + '\\n' )", -999, -( '\n' +'999'+'\n' ) );
71 new TestCase( SECTION, "-( '\\r' + '999' + '\\r' )", -999, -( '\r' +'999'+'\r' ) );
72 new TestCase( SECTION, "-( '\\t' + '999' + '\\t' )", -999, -( '\t' +'999'+'\t' ) );
73 new TestCase( SECTION, "-( '\\f' + '999' + '\\f' )", -999, -( '\f' +'999'+'\f' ) );
74
75 new TestCase( SECTION, "-( String.fromCharCode(0x0009) + '99' )", -99, -( String.fromCharCode(0x0009) + '99' ) );
76 new TestCase( SECTION, "-( String.fromCharCode(0x0020) + '99' )", -99, -( String.fromCharCode(0x0020) + '99' ) );
77 new TestCase( SECTION, "-( String.fromCharCode(0x000C) + '99' )", -99, -( String.fromCharCode(0x000C) + '99' ) );
78 new TestCase( SECTION, "-( String.fromCharCode(0x000B) + '99' )", -99, -( String.fromCharCode(0x000B) + '99' ) );
79 new TestCase( SECTION, "-( String.fromCharCode(0x000D) + '99' )", -99, -( String.fromCharCode(0x000D) + '99' ) );
80 new TestCase( SECTION, "-( String.fromCharCode(0x000A) + '99' )", -99, -( String.fromCharCode(0x000A) + '99' ) );
81
82 new TestCase( SECTION, "-( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)", -99, -( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)) );
83 new TestCase( SECTION, "-( String.fromCharCode(0x0020) + '99' + String.fromCharCode(0x0020)", -99, -( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0020)) );
84 new TestCase( SECTION, "-( String.fromCharCode(0x000C) + '99' + String.fromCharCode(0x000C)", -99, -( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000C)) );
85 new TestCase( SECTION, "-( String.fromCharCode(0x000D) + '99' + String.fromCharCode(0x000D)", -99, -( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000D)) );
86 new TestCase( SECTION, "-( String.fromCharCode(0x000B) + '99' + String.fromCharCode(0x000B)", -99, -( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000B)) );
87 new TestCase( SECTION, "-( String.fromCharCode(0x000A) + '99' + String.fromCharCode(0x000A)", -99, -( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000A)) );
88
89 new TestCase( SECTION, "-( '99' + String.fromCharCode(0x0009)", -99, -( '99' + String.fromCharCode(0x0009)) );
90 new TestCase( SECTION, "-( '99' + String.fromCharCode(0x0020)", -99, -( '99' + String.fromCharCode(0x0020)) );
91 new TestCase( SECTION, "-( '99' + String.fromCharCode(0x000C)", -99, -( '99' + String.fromCharCode(0x000C)) );
92 new TestCase( SECTION, "-( '99' + String.fromCharCode(0x000D)", -99, -( '99' + String.fromCharCode(0x000D)) );
93 new TestCase( SECTION, "-( '99' + String.fromCharCode(0x000B)", -99, -( '99' + String.fromCharCode(0x000B)) );
94 new TestCase( SECTION, "-( '99' + String.fromCharCode(0x000A)", -99, -( '99' + String.fromCharCode(0x000A)) );
95
96 new TestCase( SECTION, "-( String.fromCharCode(0x0009) + 99 )", -99, -( String.fromCharCode(0x0009) + 99 ) );
97 new TestCase( SECTION, "-( String.fromCharCode(0x0020) + 99 )", -99, -( String.fromCharCode(0x0020) + 99 ) );
98 new TestCase( SECTION, "-( String.fromCharCode(0x000C) + 99 )", -99, -( String.fromCharCode(0x000C) + 99 ) );
99 new TestCase( SECTION, "-( String.fromCharCode(0x000B) + 99 )", -99, -( String.fromCharCode(0x000B) + 99 ) );
100 new TestCase( SECTION, "-( String.fromCharCode(0x000D) + 99 )", -99, -( String.fromCharCode(0x000D) + 99 ) );
101 new TestCase( SECTION, "-( String.fromCharCode(0x000A) + 99 )", -99, -( String.fromCharCode(0x000A) + 99 ) );
102
103 new TestCase( SECTION, "-( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)", -99, -( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)) );
104 new TestCase( SECTION, "-( String.fromCharCode(0x0020) + 99 + String.fromCharCode(0x0020)", -99, -( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0020)) );
105 new TestCase( SECTION, "-( String.fromCharCode(0x000C) + 99 + String.fromCharCode(0x000C)", -99, -( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000C)) );
106 new TestCase( SECTION, "-( String.fromCharCode(0x000D) + 99 + String.fromCharCode(0x000D)", -99, -( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000D)) );
107 new TestCase( SECTION, "-( String.fromCharCode(0x000B) + 99 + String.fromCharCode(0x000B)", -99, -( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000B)) );
108 new TestCase( SECTION, "-( String.fromCharCode(0x000A) + 99 + String.fromCharCode(0x000A)", -99, -( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000A)) );
109
110 new TestCase( SECTION, "-( 99 + String.fromCharCode(0x0009)", -99, -( 99 + String.fromCharCode(0x0009)) );
111 new TestCase( SECTION, "-( 99 + String.fromCharCode(0x0020)", -99, -( 99 + String.fromCharCode(0x0020)) );
112 new TestCase( SECTION, "-( 99 + String.fromCharCode(0x000C)", -99, -( 99 + String.fromCharCode(0x000C)) );
113 new TestCase( SECTION, "-( 99 + String.fromCharCode(0x000D)", -99, -( 99 + String.fromCharCode(0x000D)) );
114 new TestCase( SECTION, "-( 99 + String.fromCharCode(0x000B)", -99, -( 99 + String.fromCharCode(0x000B)) );
115 new TestCase( SECTION, "-( 99 + String.fromCharCode(0x000A)", -99, -( 99 + String.fromCharCode(0x000A)) );
116
117
118 // StrNumericLiteral:::StrDecimalLiteral:::Infinity
119
120 new TestCase( SECTION, "-('Infinity')", -Math.pow(10,10000), -("Infinity") );
121 new TestCase( SECTION, "-('-Infinity')", +Math.pow(10,10000), -("-Infinity") );
122 new TestCase( SECTION, "-('+Infinity')", -Math.pow(10,10000), -("+Infinity") );
123
124 // StrNumericLiteral::: StrDecimalLiteral ::: DecimalDigits . DecimalDigits opt ExponentPart opt
125
126 new TestCase( SECTION, "-('0')", -0, -("0") );
127 new TestCase( SECTION, "-('-0')", +0, -("-0") );
128 new TestCase( SECTION, "-('+0')", -0, -("+0") );
129
130 new TestCase( SECTION, "-('1')", -1, -("1") );
131 new TestCase( SECTION, "-('-1')", +1, -("-1") );
132 new TestCase( SECTION, "-('+1')", -1, -("+1") );
133
134 new TestCase( SECTION, "-('2')", -2, -("2") );
135 new TestCase( SECTION, "-('-2')", +2, -("-2") );
136 new TestCase( SECTION, "-('+2')", -2, -("+2") );
137
138 new TestCase( SECTION, "-('3')", -3, -("3") );
139 new TestCase( SECTION, "-('-3')", +3, -("-3") );
140 new TestCase( SECTION, "-('+3')", -3, -("+3") );
141
142 new TestCase( SECTION, "-('4')", -4, -("4") );
143 new TestCase( SECTION, "-('-4')", +4, -("-4") );
144 new TestCase( SECTION, "-('+4')", -4, -("+4") );
145
146 new TestCase( SECTION, "-('5')", -5, -("5") );
147 new TestCase( SECTION, "-('-5')", +5, -("-5") );
148 new TestCase( SECTION, "-('+5')", -5, -("+5") );
149
150 new TestCase( SECTION, "-('6')", -6, -("6") );
151 new TestCase( SECTION, "-('-6')", +6, -("-6") );
152 new TestCase( SECTION, "-('+6')", -6, -("+6") );
153
154 new TestCase( SECTION, "-('7')", -7, -("7") );
155 new TestCase( SECTION, "-('-7')", +7, -("-7") );
156 new TestCase( SECTION, "-('+7')", -7, -("+7") );
157
158 new TestCase( SECTION, "-('8')", -8, -("8") );
159 new TestCase( SECTION, "-('-8')", +8, -("-8") );
160 new TestCase( SECTION, "-('+8')", -8, -("+8") );
161
162 new TestCase( SECTION, "-('9')", -9, -("9") );
163 new TestCase( SECTION, "-('-9')", +9, -("-9") );
164 new TestCase( SECTION, "-('+9')", -9, -("+9") );
165
166 new TestCase( SECTION, "-('3.14159')", -3.14159, -("3.14159") );
167 new TestCase( SECTION, "-('-3.14159')", +3.14159, -("-3.14159") );
168 new TestCase( SECTION, "-('+3.14159')", -3.14159, -("+3.14159") );
169
170 new TestCase( SECTION, "-('3.')", -3, -("3.") );
171 new TestCase( SECTION, "-('-3.')", +3, -("-3.") );
172 new TestCase( SECTION, "-('+3.')", -3, -("+3.") );
173
174 new TestCase( SECTION, "-('3.e1')", -30, -("3.e1") );
175 new TestCase( SECTION, "-('-3.e1')", +30, -("-3.e1") );
176 new TestCase( SECTION, "-('+3.e1')", -30, -("+3.e1") );
177
178 new TestCase( SECTION, "-('3.e+1')", -30, -("3.e+1") );
179 new TestCase( SECTION, "-('-3.e+1')", +30, -("-3.e+1") );
180 new TestCase( SECTION, "-('+3.e+1')", -30, -("+3.e+1") );
181
182 new TestCase( SECTION, "-('3.e-1')", -.30, -("3.e-1") );
183 new TestCase( SECTION, "-('-3.e-1')", +.30, -("-3.e-1") );
184 new TestCase( SECTION, "-('+3.e-1')", -.30, -("+3.e-1") );
185
186 // StrDecimalLiteral::: .DecimalDigits ExponentPart opt
187
188 new TestCase( SECTION, "-('.00001')", -0.00001, -(".00001") );
189 new TestCase( SECTION, "-('+.00001')", -0.00001, -("+.00001") );
190 new TestCase( SECTION, "-('-0.0001')", +0.00001, -("-.00001") );
191
192 new TestCase( SECTION, "-('.01e2')", -1, -(".01e2") );
193 new TestCase( SECTION, "-('+.01e2')", -1, -("+.01e2") );
194 new TestCase( SECTION, "-('-.01e2')", +1, -("-.01e2") );
195
196 new TestCase( SECTION, "-('.01e+2')", -1, -(".01e+2") );
197 new TestCase( SECTION, "-('+.01e+2')", -1, -("+.01e+2") );
198 new TestCase( SECTION, "-('-.01e+2')", +1, -("-.01e+2") );
199
200 new TestCase( SECTION, "-('.01e-2')", -0.0001, -(".01e-2") );
201 new TestCase( SECTION, "-('+.01e-2')", -0.0001, -("+.01e-2") );
202 new TestCase( SECTION, "-('-.01e-2')", +0.0001, -("-.01e-2") );
203
204 // StrDecimalLiteral::: DecimalDigits ExponentPart opt
205
206 new TestCase( SECTION, "-('1234e5')", -123400000, -("1234e5") );
207 new TestCase( SECTION, "-('+1234e5')", -123400000, -("+1234e5") );
208 new TestCase( SECTION, "-('-1234e5')", +123400000, -("-1234e5") );
209
210 new TestCase( SECTION, "-('1234e+5')", -123400000, -("1234e+5") );
211 new TestCase( SECTION, "-('+1234e+5')", -123400000, -("+1234e+5") );
212 new TestCase( SECTION, "-('-1234e+5')", +123400000, -("-1234e+5") );
213
214 new TestCase( SECTION, "-('1234e-5')", -0.01234, -("1234e-5") );
215 new TestCase( SECTION, "-('+1234e-5')", -0.01234, -("+1234e-5") );
216 new TestCase( SECTION, "-('-1234e-5')", +0.01234, -("-1234e-5") );
217
218 // StrNumericLiteral::: HexIntegerLiteral
219
220 new TestCase( SECTION, "-('0x0')", -0, -("0x0"));
221 new TestCase( SECTION, "-('0x1')", -1, -("0x1"));
222 new TestCase( SECTION, "-('0x2')", -2, -("0x2"));
223 new TestCase( SECTION, "-('0x3')", -3, -("0x3"));
224 new TestCase( SECTION, "-('0x4')", -4, -("0x4"));
225 new TestCase( SECTION, "-('0x5')", -5, -("0x5"));
226 new TestCase( SECTION, "-('0x6')", -6, -("0x6"));
227 new TestCase( SECTION, "-('0x7')", -7, -("0x7"));
228 new TestCase( SECTION, "-('0x8')", -8, -("0x8"));
229 new TestCase( SECTION, "-('0x9')", -9, -("0x9"));
230 new TestCase( SECTION, "-('0xa')", -10, -("0xa"));
231 new TestCase( SECTION, "-('0xb')", -11, -("0xb"));
232 new TestCase( SECTION, "-('0xc')", -12, -("0xc"));
233 new TestCase( SECTION, "-('0xd')", -13, -("0xd"));
234 new TestCase( SECTION, "-('0xe')", -14, -("0xe"));
235 new TestCase( SECTION, "-('0xf')", -15, -("0xf"));
236 new TestCase( SECTION, "-('0xA')", -10, -("0xA"));
237 new TestCase( SECTION, "-('0xB')", -11, -("0xB"));
238 new TestCase( SECTION, "-('0xC')", -12, -("0xC"));
239 new TestCase( SECTION, "-('0xD')", -13, -("0xD"));
240 new TestCase( SECTION, "-('0xE')", -14, -("0xE"));
241 new TestCase( SECTION, "-('0xF')", -15, -("0xF"));
242
243 new TestCase( SECTION, "-('0X0')", -0, -("0X0"));
244 new TestCase( SECTION, "-('0X1')", -1, -("0X1"));
245 new TestCase( SECTION, "-('0X2')", -2, -("0X2"));
246 new TestCase( SECTION, "-('0X3')", -3, -("0X3"));
247 new TestCase( SECTION, "-('0X4')", -4, -("0X4"));
248 new TestCase( SECTION, "-('0X5')", -5, -("0X5"));
249 new TestCase( SECTION, "-('0X6')", -6, -("0X6"));
250 new TestCase( SECTION, "-('0X7')", -7, -("0X7"));
251 new TestCase( SECTION, "-('0X8')", -8, -("0X8"));
252 new TestCase( SECTION, "-('0X9')", -9, -("0X9"));
253 new TestCase( SECTION, "-('0Xa')", -10, -("0Xa"));
254 new TestCase( SECTION, "-('0Xb')", -11, -("0Xb"));
255 new TestCase( SECTION, "-('0Xc')", -12, -("0Xc"));
256 new TestCase( SECTION, "-('0Xd')", -13, -("0Xd"));
257 new TestCase( SECTION, "-('0Xe')", -14, -("0Xe"));
258 new TestCase( SECTION, "-('0Xf')", -15, -("0Xf"));
259 new TestCase( SECTION, "-('0XA')", -10, -("0XA"));
260 new TestCase( SECTION, "-('0XB')", -11, -("0XB"));
261 new TestCase( SECTION, "-('0XC')", -12, -("0XC"));
262 new TestCase( SECTION, "-('0XD')", -13, -("0XD"));
263 new TestCase( SECTION, "-('0XE')", -14, -("0XE"));
264 new TestCase( SECTION, "-('0XF')", -15, -("0XF"));
265
266 test();