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

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

Issue 148503002: A64: Synchronize with r15545. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 using ::v8::TryCatch; 60 using ::v8::TryCatch;
61 using ::v8::Undefined; 61 using ::v8::Undefined;
62 using ::v8::V8; 62 using ::v8::V8;
63 using ::v8::Value; 63 using ::v8::Value;
64 64
65 static void ExpectBoolean(bool expected, Local<Value> result) { 65 static void ExpectBoolean(bool expected, Local<Value> result) {
66 CHECK(result->IsBoolean()); 66 CHECK(result->IsBoolean());
67 CHECK_EQ(expected, result->BooleanValue()); 67 CHECK_EQ(expected, result->BooleanValue());
68 } 68 }
69 69
70
70 static void ExpectInt32(int32_t expected, Local<Value> result) { 71 static void ExpectInt32(int32_t expected, Local<Value> result) {
71 CHECK(result->IsInt32()); 72 CHECK(result->IsInt32());
72 CHECK_EQ(expected, result->Int32Value()); 73 CHECK_EQ(expected, result->Int32Value());
73 } 74 }
74 75
76
75 static void ExpectNumber(double expected, Local<Value> result) { 77 static void ExpectNumber(double expected, Local<Value> result) {
76 CHECK(result->IsNumber()); 78 CHECK(result->IsNumber());
77 CHECK_EQ(expected, result->NumberValue()); 79 CHECK_EQ(expected, result->NumberValue());
78 } 80 }
79 81
82
80 static void ExpectUndefined(Local<Value> result) { 83 static void ExpectUndefined(Local<Value> result) {
81 CHECK(result->IsUndefined()); 84 CHECK(result->IsUndefined());
82 } 85 }
83 86
87
84 // Tests are sorted by order of implementation. 88 // Tests are sorted by order of implementation.
85 89
86 TEST(simple_value) { 90 TEST(simple_value) {
87 v8::HandleScope scope; 91 v8::HandleScope scope;
88 LocalContext env; 92 LocalContext env;
89 Local<Value> result = CompileRun("0x271828;"); 93 Local<Value> result = CompileRun("0x271828;");
90 ExpectInt32(0x271828, result); 94 ExpectInt32(0x271828, result);
91 } 95 }
92 96
93 97
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 168
165 if_comparison_testcontext_helper(op, "1", "3", expect_when_lt); 169 if_comparison_testcontext_helper(op, "1", "3", expect_when_lt);
166 if_comparison_testcontext_helper(op, "5", "5", expect_when_eq); 170 if_comparison_testcontext_helper(op, "5", "5", expect_when_eq);
167 if_comparison_testcontext_helper(op, "9", "7", expect_when_gt); 171 if_comparison_testcontext_helper(op, "9", "7", expect_when_gt);
168 172
169 if_comparison_effectcontext_helper(op, "1", "3", expect_when_lt); 173 if_comparison_effectcontext_helper(op, "1", "3", expect_when_lt);
170 if_comparison_effectcontext_helper(op, "5", "5", expect_when_eq); 174 if_comparison_effectcontext_helper(op, "5", "5", expect_when_eq);
171 if_comparison_effectcontext_helper(op, "9", "7", expect_when_gt); 175 if_comparison_effectcontext_helper(op, "9", "7", expect_when_gt);
172 } 176 }
173 177
178
174 TEST(if_comparison) { 179 TEST(if_comparison) {
175 v8::HandleScope scope; 180 v8::HandleScope scope;
176 LocalContext env; 181 LocalContext env;
177 182
178 if_comparison_helper("<", 1, 0, 0); 183 if_comparison_helper("<", 1, 0, 0);
179 if_comparison_helper("<=", 1, 1, 0); 184 if_comparison_helper("<=", 1, 1, 0);
180 if_comparison_helper("==", 0, 1, 0); 185 if_comparison_helper("==", 0, 1, 0);
181 if_comparison_helper("===", 0, 1, 0); 186 if_comparison_helper("===", 0, 1, 0);
182 if_comparison_helper(">=", 0, 1, 1); 187 if_comparison_helper(">=", 0, 1, 1);
183 if_comparison_helper(">", 0, 0, 1); 188 if_comparison_helper(">", 0, 0, 1);
184 if_comparison_helper("!=", 1, 0, 1); 189 if_comparison_helper("!=", 1, 0, 1);
185 if_comparison_helper("!==", 1, 0, 1); 190 if_comparison_helper("!==", 1, 0, 1);
186 } 191 }
187 192
193
188 TEST(unary_plus) { 194 TEST(unary_plus) {
189 v8::HandleScope scope; 195 v8::HandleScope scope;
190 LocalContext env; 196 LocalContext env;
191 Local<Value> result; 197 Local<Value> result;
192 // SMI 198 // SMI
193 result = CompileRun("var a = 1234; +a"); 199 result = CompileRun("var a = 1234; +a");
194 ExpectInt32(1234, result); 200 ExpectInt32(1234, result);
195 // Number 201 // Number
196 result = CompileRun("var a = 1234.5; +a"); 202 result = CompileRun("var a = 1234.5; +a");
197 ExpectNumber(1234.5, result); 203 ExpectNumber(1234.5, result);
198 // String (SMI) 204 // String (SMI)
199 result = CompileRun("var a = '1234'; +a"); 205 result = CompileRun("var a = '1234'; +a");
200 ExpectInt32(1234, result); 206 ExpectInt32(1234, result);
201 // String (Number) 207 // String (Number)
202 result = CompileRun("var a = '1234.5'; +a"); 208 result = CompileRun("var a = '1234.5'; +a");
203 ExpectNumber(1234.5, result); 209 ExpectNumber(1234.5, result);
204 // Check side effects. 210 // Check side effects.
205 result = CompileRun("var a = 1234; +(a = 4321); a"); 211 result = CompileRun("var a = 1234; +(a = 4321); a");
206 ExpectInt32(4321, result); 212 ExpectInt32(4321, result);
207 } 213 }
208 214
215
209 TEST(unary_minus) { 216 TEST(unary_minus) {
210 v8::HandleScope scope; 217 v8::HandleScope scope;
211 LocalContext env; 218 LocalContext env;
212 Local<Value> result; 219 Local<Value> result;
213 result = CompileRun("var a = 1234; -a"); 220 result = CompileRun("var a = 1234; -a");
214 ExpectInt32(-1234, result); 221 ExpectInt32(-1234, result);
215 result = CompileRun("var a = 1234.5; -a"); 222 result = CompileRun("var a = 1234.5; -a");
216 ExpectNumber(-1234.5, result); 223 ExpectNumber(-1234.5, result);
217 result = CompileRun("var a = 1234; -(a = 4321); a"); 224 result = CompileRun("var a = 1234; -(a = 4321); a");
218 ExpectInt32(4321, result); 225 ExpectInt32(4321, result);
219 result = CompileRun("var a = '1234'; -a"); 226 result = CompileRun("var a = '1234'; -a");
220 ExpectInt32(-1234, result); 227 ExpectInt32(-1234, result);
221 result = CompileRun("var a = '1234.5'; -a"); 228 result = CompileRun("var a = '1234.5'; -a");
222 ExpectNumber(-1234.5, result); 229 ExpectNumber(-1234.5, result);
223 } 230 }
224 231
232
225 TEST(unary_void) { 233 TEST(unary_void) {
226 v8::HandleScope scope; 234 v8::HandleScope scope;
227 LocalContext env; 235 LocalContext env;
228 Local<Value> result; 236 Local<Value> result;
229 result = CompileRun("var a = 1234; void (a);"); 237 result = CompileRun("var a = 1234; void (a);");
230 ExpectUndefined(result); 238 ExpectUndefined(result);
231 result = CompileRun("var a = 0; void (a = 42); a"); 239 result = CompileRun("var a = 0; void (a = 42); a");
232 ExpectInt32(42, result); 240 ExpectInt32(42, result);
233 result = CompileRun("var a = 0; void (a = 42);"); 241 result = CompileRun("var a = 0; void (a = 42);");
234 ExpectUndefined(result); 242 ExpectUndefined(result);
235 } 243 }
236 244
245
237 TEST(unary_not) { 246 TEST(unary_not) {
238 v8::HandleScope scope; 247 v8::HandleScope scope;
239 LocalContext env; 248 LocalContext env;
240 Local<Value> result; 249 Local<Value> result;
241 result = CompileRun("var a = 1234; !a"); 250 result = CompileRun("var a = 1234; !a");
242 ExpectBoolean(false, result); 251 ExpectBoolean(false, result);
243 result = CompileRun("var a = 0; !a"); 252 result = CompileRun("var a = 0; !a");
244 ExpectBoolean(true, result); 253 ExpectBoolean(true, result);
245 result = CompileRun("var a = 0; !(a = 1234); a"); 254 result = CompileRun("var a = 0; !(a = 1234); a");
246 ExpectInt32(1234, result); 255 ExpectInt32(1234, result);
247 result = CompileRun("var a = '1234'; !a"); 256 result = CompileRun("var a = '1234'; !a");
248 ExpectBoolean(false, result); 257 ExpectBoolean(false, result);
249 result = CompileRun("var a = ''; !a"); 258 result = CompileRun("var a = ''; !a");
250 ExpectBoolean(true, result); 259 ExpectBoolean(true, result);
251 result = CompileRun("var a = 1234; !!a"); 260 result = CompileRun("var a = 1234; !!a");
252 ExpectBoolean(true, result); 261 ExpectBoolean(true, result);
253 result = CompileRun("var a = 0; !!a"); 262 result = CompileRun("var a = 0; !!a");
254 ExpectBoolean(false, result); 263 ExpectBoolean(false, result);
255 result = CompileRun("var a = 0; if ( !a ) { 1; } else { 0; }"); 264 result = CompileRun("var a = 0; if ( !a ) { 1; } else { 0; }");
256 ExpectInt32(1, result); 265 ExpectInt32(1, result);
257 result = CompileRun("var a = 1; if ( !a ) { 1; } else { 0; }"); 266 result = CompileRun("var a = 1; if ( !a ) { 1; } else { 0; }");
258 ExpectInt32(0, result); 267 ExpectInt32(0, result);
259 } 268 }
260 269
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