Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
7 /**
8 File Name: 11.4.6.js
9 ECMA Section: 11.4.6 Unary + Operator
10 Description: convert operand to Number type
11 Author: christine@netscape.com
12 Date: 7 july 1997
13 */
15 var SECTION = "11.4.6";
16 var VERSION = "ECMA_1";
17 var BUGNUMBER="77391";
19 startTest();
21 writeHeaderToLog( SECTION + " Unary + operator");
23 new TestCase( SECTION, "+('')", 0, +("") );
24 new TestCase( SECTION, "+(' ')", 0, +(" ") );
25 new TestCase( SECTION, "+(\\t)", 0, +("\t") );
26 new TestCase( SECTION, "+(\\n)", 0, +("\n") );
27 new TestCase( SECTION, "+(\\r)", 0, +("\r") );
28 new TestCase( SECTION, "+(\\f)", 0, +("\f") );
30 new TestCase( SECTION, "+(String.fromCharCode(0x0009)", 0, +(String.fromCharCode(0x0009)) );
31 new TestCase( SECTION, "+(String.fromCharCode(0x0020)", 0, +(String.fromCharCode(0x0020)) );
32 new TestCase( SECTION, "+(String.fromCharCode(0x000C)", 0, +(String.fromCharCode(0x000C)) );
33 new TestCase( SECTION, "+(String.fromCharCode(0x000B)", 0, +(String.fromCharCode(0x000B)) );
34 new TestCase( SECTION, "+(String.fromCharCode(0x000D)", 0, +(String.fromCharCode(0x000D)) );
35 new TestCase( SECTION, "+(String.fromCharCode(0x000A)", 0, +(String.fromCharCode(0x000A)) );
37 // a StringNumericLiteral may be preceeded or followed by whitespace and/or
38 // line terminators
40 new TestCase( SECTION, "+( ' ' + 999 )", 999, +( ' '+999) );
41 new TestCase( SECTION, "+( '\\n' + 999 )", 999, +( '\n' +999) );
42 new TestCase( SECTION, "+( '\\r' + 999 )", 999, +( '\r' +999) );
43 new TestCase( SECTION, "+( '\\t' + 999 )", 999, +( '\t' +999) );
44 new TestCase( SECTION, "+( '\\f' + 999 )", 999, +( '\f' +999) );
46 new TestCase( SECTION, "+( 999 + ' ' )", 999, +( 999+' ') );
47 new TestCase( SECTION, "+( 999 + '\\n' )", 999, +( 999+'\n' ) );
48 new TestCase( SECTION, "+( 999 + '\\r' )", 999, +( 999+'\r' ) );
49 new TestCase( SECTION, "+( 999 + '\\t' )", 999, +( 999+'\t' ) );
50 new TestCase( SECTION, "+( 999 + '\\f' )", 999, +( 999+'\f' ) );
52 new TestCase( SECTION, "+( '\\n' + 999 + '\\n' )", 999, +( '\n' +999+'\n' ) );
53 new TestCase( SECTION, "+( '\\r' + 999 + '\\r' )", 999, +( '\r' +999+'\r' ) );
54 new TestCase( SECTION, "+( '\\t' + 999 + '\\t' )", 999, +( '\t' +999+'\t' ) );
55 new TestCase( SECTION, "+( '\\f' + 999 + '\\f' )", 999, +( '\f' +999+'\f' ) );
57 new TestCase( SECTION, "+( ' ' + '999' )", 999, +( ' '+'999') );
58 new TestCase( SECTION, "+( '\\n' + '999' )", 999, +( '\n' +'999') );
59 new TestCase( SECTION, "+( '\\r' + '999' )", 999, +( '\r' +'999') );
60 new TestCase( SECTION, "+( '\\t' + '999' )", 999, +( '\t' +'999') );
61 new TestCase( SECTION, "+( '\\f' + '999' )", 999, +( '\f' +'999') );
63 new TestCase( SECTION, "+( '999' + ' ' )", 999, +( '999'+' ') );
64 new TestCase( SECTION, "+( '999' + '\\n' )", 999, +( '999'+'\n' ) );
65 new TestCase( SECTION, "+( '999' + '\\r' )", 999, +( '999'+'\r' ) );
66 new TestCase( SECTION, "+( '999' + '\\t' )", 999, +( '999'+'\t' ) );
67 new TestCase( SECTION, "+( '999' + '\\f' )", 999, +( '999'+'\f' ) );
69 new TestCase( SECTION, "+( '\\n' + '999' + '\\n' )", 999, +( '\n' +'999'+'\n' ) );
70 new TestCase( SECTION, "+( '\\r' + '999' + '\\r' )", 999, +( '\r' +'999'+'\r' ) );
71 new TestCase( SECTION, "+( '\\t' + '999' + '\\t' )", 999, +( '\t' +'999'+'\t' ) );
72 new TestCase( SECTION, "+( '\\f' + '999' + '\\f' )", 999, +( '\f' +'999'+'\f' ) );
74 new TestCase( SECTION, "+( String.fromCharCode(0x0009) + '99' )", 99, +( String.fromCharCode(0x0009) + '99' ) );
75 new TestCase( SECTION, "+( String.fromCharCode(0x0020) + '99' )", 99, +( String.fromCharCode(0x0020) + '99' ) );
76 new TestCase( SECTION, "+( String.fromCharCode(0x000C) + '99' )", 99, +( String.fromCharCode(0x000C) + '99' ) );
77 new TestCase( SECTION, "+( String.fromCharCode(0x000B) + '99' )", 99, +( String.fromCharCode(0x000B) + '99' ) );
78 new TestCase( SECTION, "+( String.fromCharCode(0x000D) + '99' )", 99, +( String.fromCharCode(0x000D) + '99' ) );
79 new TestCase( SECTION, "+( String.fromCharCode(0x000A) + '99' )", 99, +( String.fromCharCode(0x000A) + '99' ) );
81 new TestCase( SECTION, "+( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)) );
82 new TestCase( SECTION, "+( String.fromCharCode(0x0020) + '99' + String.fromCharCode(0x0020)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0020)) );
83 new TestCase( SECTION, "+( String.fromCharCode(0x000C) + '99' + String.fromCharCode(0x000C)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000C)) );
84 new TestCase( SECTION, "+( String.fromCharCode(0x000D) + '99' + String.fromCharCode(0x000D)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000D)) );
85 new TestCase( SECTION, "+( String.fromCharCode(0x000B) + '99' + String.fromCharCode(0x000B)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000B)) );
86 new TestCase( SECTION, "+( String.fromCharCode(0x000A) + '99' + String.fromCharCode(0x000A)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000A)) );
88 new TestCase( SECTION, "+( '99' + String.fromCharCode(0x0009)", 99, +( '99' + String.fromCharCode(0x0009)) );
89 new TestCase( SECTION, "+( '99' + String.fromCharCode(0x0020)", 99, +( '99' + String.fromCharCode(0x0020)) );
90 new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000C)", 99, +( '99' + String.fromCharCode(0x000C)) );
91 new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000D)", 99, +( '99' + String.fromCharCode(0x000D)) );
92 new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000B)", 99, +( '99' + String.fromCharCode(0x000B)) );
93 new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000A)", 99, +( '99' + String.fromCharCode(0x000A)) );
95 new TestCase( SECTION, "+( String.fromCharCode(0x0009) + 99 )", 99, +( String.fromCharCode(0x0009) + 99 ) );
96 new TestCase( SECTION, "+( String.fromCharCode(0x0020) + 99 )", 99, +( String.fromCharCode(0x0020) + 99 ) );
97 new TestCase( SECTION, "+( String.fromCharCode(0x000C) + 99 )", 99, +( String.fromCharCode(0x000C) + 99 ) );
98 new TestCase( SECTION, "+( String.fromCharCode(0x000B) + 99 )", 99, +( String.fromCharCode(0x000B) + 99 ) );
99 new TestCase( SECTION, "+( String.fromCharCode(0x000D) + 99 )", 99, +( String.fromCharCode(0x000D) + 99 ) );
100 new TestCase( SECTION, "+( String.fromCharCode(0x000A) + 99 )", 99, +( String.fromCharCode(0x000A) + 99 ) );
102 new TestCase( SECTION, "+( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)) );
103 new TestCase( SECTION, "+( String.fromCharCode(0x0020) + 99 + String.fromCharCode(0x0020)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0020)) );
104 new TestCase( SECTION, "+( String.fromCharCode(0x000C) + 99 + String.fromCharCode(0x000C)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000C)) );
105 new TestCase( SECTION, "+( String.fromCharCode(0x000D) + 99 + String.fromCharCode(0x000D)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000D)) );
106 new TestCase( SECTION, "+( String.fromCharCode(0x000B) + 99 + String.fromCharCode(0x000B)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000B)) );
107 new TestCase( SECTION, "+( String.fromCharCode(0x000A) + 99 + String.fromCharCode(0x000A)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000A)) );
109 new TestCase( SECTION, "+( 99 + String.fromCharCode(0x0009)", 99, +( 99 + String.fromCharCode(0x0009)) );
110 new TestCase( SECTION, "+( 99 + String.fromCharCode(0x0020)", 99, +( 99 + String.fromCharCode(0x0020)) );
111 new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000C)", 99, +( 99 + String.fromCharCode(0x000C)) );
112 new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000D)", 99, +( 99 + String.fromCharCode(0x000D)) );
113 new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000B)", 99, +( 99 + String.fromCharCode(0x000B)) );
114 new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000A)", 99, +( 99 + String.fromCharCode(0x000A)) );
117 // StrNumericLiteral:::StrDecimalLiteral:::Infinity
119 new TestCase( SECTION, "+('Infinity')", Math.pow(10,10000), +("Infinity") );
120 new TestCase( SECTION, "+('-Infinity')", -Math.pow(10,10000), +("-Infinity") );
121 new TestCase( SECTION, "+('+Infinity')", Math.pow(10,10000), +("+Infinity") );
123 // StrNumericLiteral::: StrDecimalLiteral ::: DecimalDigits . DecimalDigits opt ExponentPart opt
125 new TestCase( SECTION, "+('0')", 0, +("0") );
126 new TestCase( SECTION, "+('-0')", -0, +("-0") );
127 new TestCase( SECTION, "+('+0')", 0, +("+0") );
129 new TestCase( SECTION, "+('1')", 1, +("1") );
130 new TestCase( SECTION, "+('-1')", -1, +("-1") );
131 new TestCase( SECTION, "+('+1')", 1, +("+1") );
133 new TestCase( SECTION, "+('2')", 2, +("2") );
134 new TestCase( SECTION, "+('-2')", -2, +("-2") );
135 new TestCase( SECTION, "+('+2')", 2, +("+2") );
137 new TestCase( SECTION, "+('3')", 3, +("3") );
138 new TestCase( SECTION, "+('-3')", -3, +("-3") );
139 new TestCase( SECTION, "+('+3')", 3, +("+3") );
141 new TestCase( SECTION, "+('4')", 4, +("4") );
142 new TestCase( SECTION, "+('-4')", -4, +("-4") );
143 new TestCase( SECTION, "+('+4')", 4, +("+4") );
145 new TestCase( SECTION, "+('5')", 5, +("5") );
146 new TestCase( SECTION, "+('-5')", -5, +("-5") );
147 new TestCase( SECTION, "+('+5')", 5, +("+5") );
149 new TestCase( SECTION, "+('6')", 6, +("6") );
150 new TestCase( SECTION, "+('-6')", -6, +("-6") );
151 new TestCase( SECTION, "+('+6')", 6, +("+6") );
153 new TestCase( SECTION, "+('7')", 7, +("7") );
154 new TestCase( SECTION, "+('-7')", -7, +("-7") );
155 new TestCase( SECTION, "+('+7')", 7, +("+7") );
157 new TestCase( SECTION, "+('8')", 8, +("8") );
158 new TestCase( SECTION, "+('-8')", -8, +("-8") );
159 new TestCase( SECTION, "+('+8')", 8, +("+8") );
161 new TestCase( SECTION, "+('9')", 9, +("9") );
162 new TestCase( SECTION, "+('-9')", -9, +("-9") );
163 new TestCase( SECTION, "+('+9')", 9, +("+9") );
165 new TestCase( SECTION, "+('3.14159')", 3.14159, +("3.14159") );
166 new TestCase( SECTION, "+('-3.14159')", -3.14159, +("-3.14159") );
167 new TestCase( SECTION, "+('+3.14159')", 3.14159, +("+3.14159") );
169 new TestCase( SECTION, "+('3.')", 3, +("3.") );
170 new TestCase( SECTION, "+('-3.')", -3, +("-3.") );
171 new TestCase( SECTION, "+('+3.')", 3, +("+3.") );
173 new TestCase( SECTION, "+('3.e1')", 30, +("3.e1") );
174 new TestCase( SECTION, "+('-3.e1')", -30, +("-3.e1") );
175 new TestCase( SECTION, "+('+3.e1')", 30, +("+3.e1") );
177 new TestCase( SECTION, "+('3.e+1')", 30, +("3.e+1") );
178 new TestCase( SECTION, "+('-3.e+1')", -30, +("-3.e+1") );
179 new TestCase( SECTION, "+('+3.e+1')", 30, +("+3.e+1") );
181 new TestCase( SECTION, "+('3.e-1')", .30, +("3.e-1") );
182 new TestCase( SECTION, "+('-3.e-1')", -.30, +("-3.e-1") );
183 new TestCase( SECTION, "+('+3.e-1')", .30, +("+3.e-1") );
185 // StrDecimalLiteral::: .DecimalDigits ExponentPart opt
187 new TestCase( SECTION, "+('.00001')", 0.00001, +(".00001") );
188 new TestCase( SECTION, "+('+.00001')", 0.00001, +("+.00001") );
189 new TestCase( SECTION, "+('-0.0001')", -0.00001, +("-.00001") );
191 new TestCase( SECTION, "+('.01e2')", 1, +(".01e2") );
192 new TestCase( SECTION, "+('+.01e2')", 1, +("+.01e2") );
193 new TestCase( SECTION, "+('-.01e2')", -1, +("-.01e2") );
195 new TestCase( SECTION, "+('.01e+2')", 1, +(".01e+2") );
196 new TestCase( SECTION, "+('+.01e+2')", 1, +("+.01e+2") );
197 new TestCase( SECTION, "+('-.01e+2')", -1, +("-.01e+2") );
199 new TestCase( SECTION, "+('.01e-2')", 0.0001, +(".01e-2") );
200 new TestCase( SECTION, "+('+.01e-2')", 0.0001, +("+.01e-2") );
201 new TestCase( SECTION, "+('-.01e-2')", -0.0001, +("-.01e-2") );
203 // StrDecimalLiteral::: DecimalDigits ExponentPart opt
205 new TestCase( SECTION, "+('1234e5')", 123400000, +("1234e5") );
206 new TestCase( SECTION, "+('+1234e5')", 123400000, +("+1234e5") );
207 new TestCase( SECTION, "+('-1234e5')", -123400000, +("-1234e5") );
209 new TestCase( SECTION, "+('1234e+5')", 123400000, +("1234e+5") );
210 new TestCase( SECTION, "+('+1234e+5')", 123400000, +("+1234e+5") );
211 new TestCase( SECTION, "+('-1234e+5')", -123400000, +("-1234e+5") );
213 new TestCase( SECTION, "+('1234e-5')", 0.01234, +("1234e-5") );
214 new TestCase( SECTION, "+('+1234e-5')", 0.01234, +("+1234e-5") );
215 new TestCase( SECTION, "+('-1234e-5')", -0.01234, +("-1234e-5") );
217 // StrNumericLiteral::: HexIntegerLiteral
219 new TestCase( SECTION, "+('0x0')", 0, +("0x0"));
220 new TestCase( SECTION, "+('0x1')", 1, +("0x1"));
221 new TestCase( SECTION, "+('0x2')", 2, +("0x2"));
222 new TestCase( SECTION, "+('0x3')", 3, +("0x3"));
223 new TestCase( SECTION, "+('0x4')", 4, +("0x4"));
224 new TestCase( SECTION, "+('0x5')", 5, +("0x5"));
225 new TestCase( SECTION, "+('0x6')", 6, +("0x6"));
226 new TestCase( SECTION, "+('0x7')", 7, +("0x7"));
227 new TestCase( SECTION, "+('0x8')", 8, +("0x8"));
228 new TestCase( SECTION, "+('0x9')", 9, +("0x9"));
229 new TestCase( SECTION, "+('0xa')", 10, +("0xa"));
230 new TestCase( SECTION, "+('0xb')", 11, +("0xb"));
231 new TestCase( SECTION, "+('0xc')", 12, +("0xc"));
232 new TestCase( SECTION, "+('0xd')", 13, +("0xd"));
233 new TestCase( SECTION, "+('0xe')", 14, +("0xe"));
234 new TestCase( SECTION, "+('0xf')", 15, +("0xf"));
235 new TestCase( SECTION, "+('0xA')", 10, +("0xA"));
236 new TestCase( SECTION, "+('0xB')", 11, +("0xB"));
237 new TestCase( SECTION, "+('0xC')", 12, +("0xC"));
238 new TestCase( SECTION, "+('0xD')", 13, +("0xD"));
239 new TestCase( SECTION, "+('0xE')", 14, +("0xE"));
240 new TestCase( SECTION, "+('0xF')", 15, +("0xF"));
242 new TestCase( SECTION, "+('0X0')", 0, +("0X0"));
243 new TestCase( SECTION, "+('0X1')", 1, +("0X1"));
244 new TestCase( SECTION, "+('0X2')", 2, +("0X2"));
245 new TestCase( SECTION, "+('0X3')", 3, +("0X3"));
246 new TestCase( SECTION, "+('0X4')", 4, +("0X4"));
247 new TestCase( SECTION, "+('0X5')", 5, +("0X5"));
248 new TestCase( SECTION, "+('0X6')", 6, +("0X6"));
249 new TestCase( SECTION, "+('0X7')", 7, +("0X7"));
250 new TestCase( SECTION, "+('0X8')", 8, +("0X8"));
251 new TestCase( SECTION, "+('0X9')", 9, +("0X9"));
252 new TestCase( SECTION, "+('0Xa')", 10, +("0Xa"));
253 new TestCase( SECTION, "+('0Xb')", 11, +("0Xb"));
254 new TestCase( SECTION, "+('0Xc')", 12, +("0Xc"));
255 new TestCase( SECTION, "+('0Xd')", 13, +("0Xd"));
256 new TestCase( SECTION, "+('0Xe')", 14, +("0Xe"));
257 new TestCase( SECTION, "+('0Xf')", 15, +("0Xf"));
258 new TestCase( SECTION, "+('0XA')", 10, +("0XA"));
259 new TestCase( SECTION, "+('0XB')", 11, +("0XB"));
260 new TestCase( SECTION, "+('0XC')", 12, +("0XC"));
261 new TestCase( SECTION, "+('0XD')", 13, +("0XD"));
262 new TestCase( SECTION, "+('0XE')", 14, +("0XE"));
263 new TestCase( SECTION, "+('0XF')", 15, +("0XF"));
265 test();