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

Side by Side Diff: runtime/vm/object_test.cc

Issue 22916006: Move the begin token of explicit functions to the start of the function declaration. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase + hoist out func check Created 7 years, 4 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 | « runtime/vm/intrinsifier.h ('k') | runtime/vm/parser.h » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/assembler.h" 5 #include "vm/assembler.h"
6 #include "vm/bigint_operations.h" 6 #include "vm/bigint_operations.h"
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 3211 matching lines...) Expand 10 before | Expand all | Expand 10 after
3222 3222
3223 3223
3224 static RawFunction* GetFunction(const Class& cls, const char* name) { 3224 static RawFunction* GetFunction(const Class& cls, const char* name) {
3225 const Function& result = Function::Handle(cls.LookupDynamicFunction( 3225 const Function& result = Function::Handle(cls.LookupDynamicFunction(
3226 String::Handle(String::New(name)))); 3226 String::Handle(String::New(name))));
3227 EXPECT(!result.IsNull()); 3227 EXPECT(!result.IsNull());
3228 return result.raw(); 3228 return result.raw();
3229 } 3229 }
3230 3230
3231 3231
3232 static RawFunction* GetStaticFunction(const Class& cls, const char* name) {
3233 const Function& result = Function::Handle(cls.LookupStaticFunction(
3234 String::Handle(String::New(name))));
3235 EXPECT(!result.IsNull());
3236 return result.raw();
3237 }
3238
3239
3232 static RawField* GetField(const Class& cls, const char* name) { 3240 static RawField* GetField(const Class& cls, const char* name) {
3233 const Field& field = 3241 const Field& field =
3234 Field::Handle(cls.LookupField(String::Handle(String::New(name)))); 3242 Field::Handle(cls.LookupField(String::Handle(String::New(name))));
3235 EXPECT(!field.IsNull()); 3243 EXPECT(!field.IsNull());
3236 return field.raw(); 3244 return field.raw();
3237 } 3245 }
3238 3246
3239 3247
3240 static RawClass* GetClass(const Library& lib, const char* name) { 3248 static RawClass* GetClass(const Library& lib, const char* name) {
3241 String& ambiguity_error_msg = String::Handle(); 3249 String& ambiguity_error_msg = String::Handle();
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
3333 field = lib.LookupLocalField(String::Handle(Symbols::New("gVar"))); 3341 field = lib.LookupLocalField(String::Handle(Symbols::New("gVar")));
3334 EXPECT(!field.IsNull()); 3342 EXPECT(!field.IsNull());
3335 res = lib.GetMetadata(field); 3343 res = lib.GetMetadata(field);
3336 PrintMetadata("gVar", res); 3344 PrintMetadata("gVar", res);
3337 } 3345 }
3338 3346
3339 3347
3340 TEST_CASE(FunctionSourceFingerprint) { 3348 TEST_CASE(FunctionSourceFingerprint) {
3341 const char* kScriptChars = 3349 const char* kScriptChars =
3342 "class A {\n" 3350 "class A {\n"
3343 " void test1(int a) {\n" 3351 " static void test1(int a) {\n"
3344 " return a > 1 ? a + 1 : a;\n" 3352 " return a > 1 ? a + 1 : a;\n"
3345 " }\n" 3353 " }\n"
3346 " void test2(int a) {\n" 3354 " static void test2(a) {\n"
3347 " return a > 1 ? a + 1 : a;\n" 3355 " return a > 1 ? a + 1 : a;\n"
3348 " }\n" 3356 " }\n"
3349 " void test3(a) {\n" 3357 " static void test3(b) {\n"
3358 " return b > 1 ? b + 1 : b;\n"
3359 " }\n"
3360 " static void test4(b) {\n"
3361 " return b > 1 ? b - 1 : b;\n"
3362 " }\n"
3363 " static void test5(b) {\n"
3364 " return b > 1 ? b - 2 : b;\n"
3365 " }\n"
3366 " void test6(int a) {\n"
3350 " return a > 1 ? a + 1 : a;\n" 3367 " return a > 1 ? a + 1 : a;\n"
3351 " }\n" 3368 " }\n"
3352 " void test4(b) {\n" 3369 "}\n"
3353 " return b > 1 ? b + 1 : b;\n" 3370 "class B {\n"
3371 " static void /* Different declaration style. */\n"
3372 " test1(int a) {\n"
3373 " /* Returns a + 1 for a > 1, a otherwise. */\n"
3374 " return a > 1 ?\n"
3375 " a + 1 :\n"
3376 " a;\n"
3354 " }\n" 3377 " }\n"
3355 " void test5(b) {\n" 3378 " static void test5(b) {\n"
3356 " return b > 1 ? b - 1 : b;\n"
3357 " }\n"
3358 " void test6(b) {\n"
3359 " return b > 1 ? b - 2 : b;\n"
3360 " }\n"
3361 " void test7(b) {\n"
3362 " return b > 1 ?\n" 3379 " return b > 1 ?\n"
3363 " b - 2 : b;\n" 3380 " b - 2 : b;\n"
3364 " }\n" 3381 " }\n"
3382 " void test6(int a) {\n"
3383 " return a > 1 ? a + 1 : a;\n"
3384 " }\n"
3365 "}"; 3385 "}";
3366 TestCase::LoadTestScript(kScriptChars, NULL); 3386 TestCase::LoadTestScript(kScriptChars, NULL);
3367 EXPECT(ClassFinalizer::FinalizePendingClasses()); 3387 EXPECT(ClassFinalizer::FinalizePendingClasses());
3368 const String& name = String::Handle(String::New(TestCase::url())); 3388 const String& name = String::Handle(String::New(TestCase::url()));
3369 const Library& lib = Library::Handle(Library::LookupLibrary(name)); 3389 const Library& lib = Library::Handle(Library::LookupLibrary(name));
3370 EXPECT(!lib.IsNull()); 3390 EXPECT(!lib.IsNull());
3371 3391
3372 const Class& class_a = Class::Handle( 3392 const Class& class_a = Class::Handle(
3373 lib.LookupClass(String::Handle(Symbols::New("A")), NULL)); 3393 lib.LookupClass(String::Handle(Symbols::New("A")), NULL));
3374 const Function& test1 = Function::Handle(GetFunction(class_a, "test1")); 3394 const Class& class_b = Class::Handle(
3375 const Function& test2 = Function::Handle(GetFunction(class_a, "test2")); 3395 lib.LookupClass(String::Handle(Symbols::New("B")), NULL));
3376 const Function& test3 = Function::Handle(GetFunction(class_a, "test3")); 3396 const Function& a_test1 =
3377 const Function& test4 = Function::Handle(GetFunction(class_a, "test4")); 3397 Function::Handle(GetStaticFunction(class_a, "test1"));
3378 const Function& test5 = Function::Handle(GetFunction(class_a, "test5")); 3398 const Function& b_test1 =
3379 const Function& test6 = Function::Handle(GetFunction(class_a, "test6")); 3399 Function::Handle(GetStaticFunction(class_b, "test1"));
3380 const Function& test7 = Function::Handle(GetFunction(class_a, "test7")); 3400 const Function& a_test2 =
3381 EXPECT_EQ(test1.SourceFingerprint(), test2.SourceFingerprint()); 3401 Function::Handle(GetStaticFunction(class_a, "test2"));
3382 EXPECT_NE(test1.SourceFingerprint(), test3.SourceFingerprint()); 3402 const Function& a_test3 =
3383 EXPECT_NE(test3.SourceFingerprint(), test4.SourceFingerprint()); 3403 Function::Handle(GetStaticFunction(class_a, "test3"));
3384 EXPECT_NE(test4.SourceFingerprint(), test5.SourceFingerprint()); 3404 const Function& a_test4 =
3385 EXPECT_NE(test5.SourceFingerprint(), test6.SourceFingerprint()); 3405 Function::Handle(GetStaticFunction(class_a, "test4"));
3386 EXPECT_EQ(test6.SourceFingerprint(), test7.SourceFingerprint()); 3406 const Function& a_test5 =
3407 Function::Handle(GetStaticFunction(class_a, "test5"));
3408 const Function& b_test5 =
3409 Function::Handle(GetStaticFunction(class_b, "test5"));
3410 const Function& a_test6 =
3411 Function::Handle(GetFunction(class_a, "test6"));
3412 const Function& b_test6 =
3413 Function::Handle(GetFunction(class_b, "test6"));
3414
3415 EXPECT_EQ(a_test1.SourceFingerprint(), b_test1.SourceFingerprint());
3416 EXPECT_NE(a_test1.SourceFingerprint(), a_test2.SourceFingerprint());
3417 EXPECT_NE(a_test2.SourceFingerprint(), a_test3.SourceFingerprint());
3418 EXPECT_NE(a_test3.SourceFingerprint(), a_test4.SourceFingerprint());
3419 EXPECT_NE(a_test4.SourceFingerprint(), a_test5.SourceFingerprint());
3420 EXPECT_EQ(a_test5.SourceFingerprint(), b_test5.SourceFingerprint());
3421 EXPECT_NE(a_test6.SourceFingerprint(), b_test6.SourceFingerprint());
3387 } 3422 }
3388 3423
3389 3424
3390 TEST_CASE(SpecialClassesHaveEmptyArrays) { 3425 TEST_CASE(SpecialClassesHaveEmptyArrays) {
3391 ObjectStore* object_store = Isolate::Current()->object_store(); 3426 ObjectStore* object_store = Isolate::Current()->object_store();
3392 Class& cls = Class::Handle(); 3427 Class& cls = Class::Handle();
3393 Object& array = Object::Handle(); 3428 Object& array = Object::Handle();
3394 3429
3395 cls = object_store->null_class(); 3430 cls = object_store->null_class();
3396 array = cls.fields(); 3431 array = cls.fields();
(...skipping 14 matching lines...) Expand all
3411 cls = Object::dynamic_class(); 3446 cls = Object::dynamic_class();
3412 array = cls.fields(); 3447 array = cls.fields();
3413 EXPECT(!array.IsNull()); 3448 EXPECT(!array.IsNull());
3414 EXPECT(array.IsArray()); 3449 EXPECT(array.IsArray());
3415 array = cls.functions(); 3450 array = cls.functions();
3416 EXPECT(!array.IsNull()); 3451 EXPECT(!array.IsNull());
3417 EXPECT(array.IsArray()); 3452 EXPECT(array.IsArray());
3418 } 3453 }
3419 3454
3420 } // namespace dart 3455 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698