Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: test/cctest/test-javascript-a64.cc

Issue 153773002: A64: Synchronize with r16679. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-heap-profiler.cc ('k') | test/cctest/test-js-a64-variables.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 80
81 static void ExpectUndefined(Local<Value> result) { 81 static void ExpectUndefined(Local<Value> result) {
82 CHECK(result->IsUndefined()); 82 CHECK(result->IsUndefined());
83 } 83 }
84 84
85 85
86 // Tests are sorted by order of implementation. 86 // Tests are sorted by order of implementation.
87 87
88 TEST(simple_value) { 88 TEST(simple_value) {
89 v8::HandleScope scope;
90 LocalContext env; 89 LocalContext env;
90 v8::HandleScope scope(env->GetIsolate());
91 Local<Value> result = CompileRun("0x271828;"); 91 Local<Value> result = CompileRun("0x271828;");
92 ExpectInt32(0x271828, result); 92 ExpectInt32(0x271828, result);
93 } 93 }
94 94
95 95
96 TEST(global_variable) { 96 TEST(global_variable) {
97 v8::HandleScope scope;
98 LocalContext env; 97 LocalContext env;
98 v8::HandleScope scope(env->GetIsolate());
99 Local<Value> result = CompileRun("var my_global_var = 0x123; my_global_var;"); 99 Local<Value> result = CompileRun("var my_global_var = 0x123; my_global_var;");
100 ExpectInt32(0x123, result); 100 ExpectInt32(0x123, result);
101 } 101 }
102 102
103 103
104 TEST(simple_function_call) { 104 TEST(simple_function_call) {
105 v8::HandleScope scope;
106 LocalContext env; 105 LocalContext env;
106 v8::HandleScope scope(env->GetIsolate());
107 Local<Value> result = CompileRun( 107 Local<Value> result = CompileRun(
108 "function foo() { return 0x314; }" 108 "function foo() { return 0x314; }"
109 "foo();"); 109 "foo();");
110 ExpectInt32(0x314, result); 110 ExpectInt32(0x314, result);
111 } 111 }
112 112
113 113
114 TEST(binary_op) { 114 TEST(binary_op) {
115 v8::HandleScope scope;
116 LocalContext env; 115 LocalContext env;
116 v8::HandleScope scope(env->GetIsolate());
117 Local<Value> result = CompileRun( 117 Local<Value> result = CompileRun(
118 "function foo() {" 118 "function foo() {"
119 " var a = 0x1200;" 119 " var a = 0x1200;"
120 " var b = 0x0035;" 120 " var b = 0x0035;"
121 " return 2 * (a + b - 1);" 121 " return 2 * (a + b - 1);"
122 "}" 122 "}"
123 "foo();"); 123 "foo();");
124 ExpectInt32(0x2468, result); 124 ExpectInt32(0x2468, result);
125 } 125 }
126 126
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 if_comparison_testcontext_helper(op, "5", "5", expect_when_eq); 168 if_comparison_testcontext_helper(op, "5", "5", expect_when_eq);
169 if_comparison_testcontext_helper(op, "9", "7", expect_when_gt); 169 if_comparison_testcontext_helper(op, "9", "7", expect_when_gt);
170 170
171 if_comparison_effectcontext_helper(op, "1", "3", expect_when_lt); 171 if_comparison_effectcontext_helper(op, "1", "3", expect_when_lt);
172 if_comparison_effectcontext_helper(op, "5", "5", expect_when_eq); 172 if_comparison_effectcontext_helper(op, "5", "5", expect_when_eq);
173 if_comparison_effectcontext_helper(op, "9", "7", expect_when_gt); 173 if_comparison_effectcontext_helper(op, "9", "7", expect_when_gt);
174 } 174 }
175 175
176 176
177 TEST(if_comparison) { 177 TEST(if_comparison) {
178 v8::HandleScope scope;
179 LocalContext env; 178 LocalContext env;
179 v8::HandleScope scope(env->GetIsolate());
180 180
181 if_comparison_helper("<", 1, 0, 0); 181 if_comparison_helper("<", 1, 0, 0);
182 if_comparison_helper("<=", 1, 1, 0); 182 if_comparison_helper("<=", 1, 1, 0);
183 if_comparison_helper("==", 0, 1, 0); 183 if_comparison_helper("==", 0, 1, 0);
184 if_comparison_helper("===", 0, 1, 0); 184 if_comparison_helper("===", 0, 1, 0);
185 if_comparison_helper(">=", 0, 1, 1); 185 if_comparison_helper(">=", 0, 1, 1);
186 if_comparison_helper(">", 0, 0, 1); 186 if_comparison_helper(">", 0, 0, 1);
187 if_comparison_helper("!=", 1, 0, 1); 187 if_comparison_helper("!=", 1, 0, 1);
188 if_comparison_helper("!==", 1, 0, 1); 188 if_comparison_helper("!==", 1, 0, 1);
189 } 189 }
190 190
191 191
192 TEST(unary_plus) { 192 TEST(unary_plus) {
193 v8::HandleScope scope;
194 LocalContext env; 193 LocalContext env;
194 v8::HandleScope scope(env->GetIsolate());
195 Local<Value> result; 195 Local<Value> result;
196 // SMI 196 // SMI
197 result = CompileRun("var a = 1234; +a"); 197 result = CompileRun("var a = 1234; +a");
198 ExpectInt32(1234, result); 198 ExpectInt32(1234, result);
199 // Number 199 // Number
200 result = CompileRun("var a = 1234.5; +a"); 200 result = CompileRun("var a = 1234.5; +a");
201 ExpectNumber(1234.5, result); 201 ExpectNumber(1234.5, result);
202 // String (SMI) 202 // String (SMI)
203 result = CompileRun("var a = '1234'; +a"); 203 result = CompileRun("var a = '1234'; +a");
204 ExpectInt32(1234, result); 204 ExpectInt32(1234, result);
205 // String (Number) 205 // String (Number)
206 result = CompileRun("var a = '1234.5'; +a"); 206 result = CompileRun("var a = '1234.5'; +a");
207 ExpectNumber(1234.5, result); 207 ExpectNumber(1234.5, result);
208 // Check side effects. 208 // Check side effects.
209 result = CompileRun("var a = 1234; +(a = 4321); a"); 209 result = CompileRun("var a = 1234; +(a = 4321); a");
210 ExpectInt32(4321, result); 210 ExpectInt32(4321, result);
211 } 211 }
212 212
213 213
214 TEST(unary_minus) { 214 TEST(unary_minus) {
215 v8::HandleScope scope;
216 LocalContext env; 215 LocalContext env;
216 v8::HandleScope scope(env->GetIsolate());
217 Local<Value> result; 217 Local<Value> result;
218 result = CompileRun("var a = 1234; -a"); 218 result = CompileRun("var a = 1234; -a");
219 ExpectInt32(-1234, result); 219 ExpectInt32(-1234, result);
220 result = CompileRun("var a = 1234.5; -a"); 220 result = CompileRun("var a = 1234.5; -a");
221 ExpectNumber(-1234.5, result); 221 ExpectNumber(-1234.5, result);
222 result = CompileRun("var a = 1234; -(a = 4321); a"); 222 result = CompileRun("var a = 1234; -(a = 4321); a");
223 ExpectInt32(4321, result); 223 ExpectInt32(4321, result);
224 result = CompileRun("var a = '1234'; -a"); 224 result = CompileRun("var a = '1234'; -a");
225 ExpectInt32(-1234, result); 225 ExpectInt32(-1234, result);
226 result = CompileRun("var a = '1234.5'; -a"); 226 result = CompileRun("var a = '1234.5'; -a");
227 ExpectNumber(-1234.5, result); 227 ExpectNumber(-1234.5, result);
228 } 228 }
229 229
230 230
231 TEST(unary_void) { 231 TEST(unary_void) {
232 v8::HandleScope scope;
233 LocalContext env; 232 LocalContext env;
233 v8::HandleScope scope(env->GetIsolate());
234 Local<Value> result; 234 Local<Value> result;
235 result = CompileRun("var a = 1234; void (a);"); 235 result = CompileRun("var a = 1234; void (a);");
236 ExpectUndefined(result); 236 ExpectUndefined(result);
237 result = CompileRun("var a = 0; void (a = 42); a"); 237 result = CompileRun("var a = 0; void (a = 42); a");
238 ExpectInt32(42, result); 238 ExpectInt32(42, result);
239 result = CompileRun("var a = 0; void (a = 42);"); 239 result = CompileRun("var a = 0; void (a = 42);");
240 ExpectUndefined(result); 240 ExpectUndefined(result);
241 } 241 }
242 242
243 243
244 TEST(unary_not) { 244 TEST(unary_not) {
245 v8::HandleScope scope;
246 LocalContext env; 245 LocalContext env;
246 v8::HandleScope scope(env->GetIsolate());
247 Local<Value> result; 247 Local<Value> result;
248 result = CompileRun("var a = 1234; !a"); 248 result = CompileRun("var a = 1234; !a");
249 ExpectBoolean(false, result); 249 ExpectBoolean(false, result);
250 result = CompileRun("var a = 0; !a"); 250 result = CompileRun("var a = 0; !a");
251 ExpectBoolean(true, result); 251 ExpectBoolean(true, result);
252 result = CompileRun("var a = 0; !(a = 1234); a"); 252 result = CompileRun("var a = 0; !(a = 1234); a");
253 ExpectInt32(1234, result); 253 ExpectInt32(1234, result);
254 result = CompileRun("var a = '1234'; !a"); 254 result = CompileRun("var a = '1234'; !a");
255 ExpectBoolean(false, result); 255 ExpectBoolean(false, result);
256 result = CompileRun("var a = ''; !a"); 256 result = CompileRun("var a = ''; !a");
257 ExpectBoolean(true, result); 257 ExpectBoolean(true, result);
258 result = CompileRun("var a = 1234; !!a"); 258 result = CompileRun("var a = 1234; !!a");
259 ExpectBoolean(true, result); 259 ExpectBoolean(true, result);
260 result = CompileRun("var a = 0; !!a"); 260 result = CompileRun("var a = 0; !!a");
261 ExpectBoolean(false, result); 261 ExpectBoolean(false, result);
262 result = CompileRun("var a = 0; if ( !a ) { 1; } else { 0; }"); 262 result = CompileRun("var a = 0; if ( !a ) { 1; } else { 0; }");
263 ExpectInt32(1, result); 263 ExpectInt32(1, result);
264 result = CompileRun("var a = 1; if ( !a ) { 1; } else { 0; }"); 264 result = CompileRun("var a = 1; if ( !a ) { 1; } else { 0; }");
265 ExpectInt32(0, result); 265 ExpectInt32(0, result);
266 } 266 }
267 267
OLDNEW
« no previous file with comments | « test/cctest/test-heap-profiler.cc ('k') | test/cctest/test-js-a64-variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698