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

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

Issue 1589643002: Source positions for constructors and lots of async machinery (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/parser.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 (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 "platform/globals.h" 5 #include "platform/globals.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 11 matching lines...) Expand all
22 DECLARE_FLAG(bool, write_protect_code); 22 DECLARE_FLAG(bool, write_protect_code);
23 23
24 static RawLibrary* CreateDummyLibrary(const String& library_name) { 24 static RawLibrary* CreateDummyLibrary(const String& library_name) {
25 return Library::New(library_name); 25 return Library::New(library_name);
26 } 26 }
27 27
28 28
29 static RawClass* CreateDummyClass(const String& class_name, 29 static RawClass* CreateDummyClass(const String& class_name,
30 const Script& script) { 30 const Script& script) {
31 const Class& cls = Class::Handle( 31 const Class& cls = Class::Handle(
32 Class::New(class_name, script, Scanner::kNoSourcePos)); 32 Class::New(class_name, script, Token::kNoSourcePos));
33 cls.set_is_synthesized_class(); // Dummy class for testing. 33 cls.set_is_synthesized_class(); // Dummy class for testing.
34 return cls.raw(); 34 return cls.raw();
35 } 35 }
36 36
37 37
38 TEST_CASE(Class) { 38 TEST_CASE(Class) {
39 // Allocate the class first. 39 // Allocate the class first.
40 const String& class_name = String::Handle(Symbols::New("MyClass")); 40 const String& class_name = String::Handle(Symbols::New("MyClass"));
41 const Script& script = Script::Handle(); 41 const Script& script = Script::Handle();
42 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); 42 const Class& cls = Class::Handle(CreateDummyClass(class_name, script));
(...skipping 2487 matching lines...) Expand 10 before | Expand all | Expand 10 after
2530 LocalScope* parent_scope = 2530 LocalScope* parent_scope =
2531 new LocalScope(NULL, parent_scope_function_level, 0); 2531 new LocalScope(NULL, parent_scope_function_level, 0);
2532 2532
2533 const intptr_t local_scope_function_level = 1; 2533 const intptr_t local_scope_function_level = 1;
2534 LocalScope* local_scope = 2534 LocalScope* local_scope =
2535 new LocalScope(parent_scope, local_scope_function_level, 0); 2535 new LocalScope(parent_scope, local_scope_function_level, 0);
2536 2536
2537 const Type& dynamic_type = Type::ZoneHandle(Type::DynamicType()); 2537 const Type& dynamic_type = Type::ZoneHandle(Type::DynamicType());
2538 const String& a = String::ZoneHandle(Symbols::New("a")); 2538 const String& a = String::ZoneHandle(Symbols::New("a"));
2539 LocalVariable* var_a = 2539 LocalVariable* var_a =
2540 new LocalVariable(Scanner::kNoSourcePos, a, dynamic_type); 2540 new LocalVariable(Token::kNoSourcePos, a, dynamic_type);
2541 parent_scope->AddVariable(var_a); 2541 parent_scope->AddVariable(var_a);
2542 2542
2543 const String& b = String::ZoneHandle(Symbols::New("b")); 2543 const String& b = String::ZoneHandle(Symbols::New("b"));
2544 LocalVariable* var_b = 2544 LocalVariable* var_b =
2545 new LocalVariable(Scanner::kNoSourcePos, b, dynamic_type); 2545 new LocalVariable(Token::kNoSourcePos, b, dynamic_type);
2546 local_scope->AddVariable(var_b); 2546 local_scope->AddVariable(var_b);
2547 2547
2548 const String& c = String::ZoneHandle(Symbols::New("c")); 2548 const String& c = String::ZoneHandle(Symbols::New("c"));
2549 LocalVariable* var_c = 2549 LocalVariable* var_c =
2550 new LocalVariable(Scanner::kNoSourcePos, c, dynamic_type); 2550 new LocalVariable(Token::kNoSourcePos, c, dynamic_type);
2551 parent_scope->AddVariable(var_c); 2551 parent_scope->AddVariable(var_c);
2552 2552
2553 bool test_only = false; // Please, insert alias. 2553 bool test_only = false; // Please, insert alias.
2554 var_a = local_scope->LookupVariable(a, test_only); 2554 var_a = local_scope->LookupVariable(a, test_only);
2555 EXPECT(var_a->is_captured()); 2555 EXPECT(var_a->is_captured());
2556 EXPECT_EQ(parent_scope_function_level, var_a->owner()->function_level()); 2556 EXPECT_EQ(parent_scope_function_level, var_a->owner()->function_level());
2557 EXPECT(local_scope->LocalLookupVariable(a) == var_a); // Alias. 2557 EXPECT(local_scope->LocalLookupVariable(a) == var_a); // Alias.
2558 2558
2559 var_b = local_scope->LookupVariable(b, test_only); 2559 var_b = local_scope->LookupVariable(b, test_only);
2560 EXPECT(!var_b->is_captured()); 2560 EXPECT(!var_b->is_captured());
(...skipping 2120 matching lines...) Expand 10 before | Expand all | Expand 10 after
4681 String& test = String::Handle(); 4681 String& test = String::Handle();
4682 String& result = String::Handle(); 4682 String& result = String::Handle();
4683 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) { 4683 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) {
4684 test = String::New(tests[i].in); 4684 test = String::New(tests[i].in);
4685 result = String::IdentifierPrettyName(test); 4685 result = String::IdentifierPrettyName(test);
4686 EXPECT_STREQ(tests[i].out, result.ToCString()); 4686 EXPECT_STREQ(tests[i].out, result.ToCString());
4687 } 4687 }
4688 } 4688 }
4689 4689
4690 } // namespace dart 4690 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698