| OLD | NEW |
| 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/debugger.h" | 10 #include "vm/debugger.h" |
| 11 #include "vm/isolate.h" | 11 #include "vm/isolate.h" |
| 12 #include "vm/object.h" | 12 #include "vm/object.h" |
| 13 #include "vm/object_store.h" | 13 #include "vm/object_store.h" |
| 14 #include "vm/simulator.h" | 14 #include "vm/simulator.h" |
| 15 #include "vm/symbols.h" | 15 #include "vm/symbols.h" |
| 16 #include "vm/unit_test.h" | 16 #include "vm/unit_test.h" |
| 17 | 17 |
| 18 namespace dart { | 18 namespace dart { |
| 19 | 19 |
| 20 static RawLibrary* CreateDummyLibrary(const String& library_name) { | 20 static RawLibrary* CreateDummyLibrary(const String& library_name) { |
| 21 return Library::New(library_name); | 21 return Library::New(library_name); |
| 22 } | 22 } |
| 23 | 23 |
| 24 | 24 |
| 25 static RawClass* CreateDummyClass(const String& class_name, | 25 static RawClass* CreateDummyClass(const String& class_name, |
| 26 const Script& script) { | 26 const Script& script) { |
| 27 const Class& cls = Class::Handle( | 27 const Class& cls = Class::Handle( |
| 28 Class::New(class_name, script, Scanner::kDummyTokenIndex)); | 28 Class::New(class_name, script, Scanner::kNoSourcePos)); |
| 29 cls.set_is_synthesized_class(); // Dummy class for testing. | 29 cls.set_is_synthesized_class(); // Dummy class for testing. |
| 30 return cls.raw(); | 30 return cls.raw(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 | 33 |
| 34 TEST_CASE(Class) { | 34 TEST_CASE(Class) { |
| 35 // Allocate the class first. | 35 // Allocate the class first. |
| 36 const String& class_name = String::Handle(Symbols::New("MyClass")); | 36 const String& class_name = String::Handle(Symbols::New("MyClass")); |
| 37 const Script& script = Script::Handle(); | 37 const Script& script = Script::Handle(); |
| 38 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); | 38 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); |
| (...skipping 2229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2268 LocalScope* parent_scope = | 2268 LocalScope* parent_scope = |
| 2269 new LocalScope(NULL, parent_scope_function_level, 0); | 2269 new LocalScope(NULL, parent_scope_function_level, 0); |
| 2270 | 2270 |
| 2271 const intptr_t local_scope_function_level = 1; | 2271 const intptr_t local_scope_function_level = 1; |
| 2272 LocalScope* local_scope = | 2272 LocalScope* local_scope = |
| 2273 new LocalScope(parent_scope, local_scope_function_level, 0); | 2273 new LocalScope(parent_scope, local_scope_function_level, 0); |
| 2274 | 2274 |
| 2275 const Type& dynamic_type = Type::ZoneHandle(Type::DynamicType()); | 2275 const Type& dynamic_type = Type::ZoneHandle(Type::DynamicType()); |
| 2276 const String& a = String::ZoneHandle(Symbols::New("a")); | 2276 const String& a = String::ZoneHandle(Symbols::New("a")); |
| 2277 LocalVariable* var_a = | 2277 LocalVariable* var_a = |
| 2278 new LocalVariable(Scanner::kDummyTokenIndex, a, dynamic_type); | 2278 new LocalVariable(Scanner::kNoSourcePos, a, dynamic_type); |
| 2279 parent_scope->AddVariable(var_a); | 2279 parent_scope->AddVariable(var_a); |
| 2280 | 2280 |
| 2281 const String& b = String::ZoneHandle(Symbols::New("b")); | 2281 const String& b = String::ZoneHandle(Symbols::New("b")); |
| 2282 LocalVariable* var_b = | 2282 LocalVariable* var_b = |
| 2283 new LocalVariable(Scanner::kDummyTokenIndex, b, dynamic_type); | 2283 new LocalVariable(Scanner::kNoSourcePos, b, dynamic_type); |
| 2284 local_scope->AddVariable(var_b); | 2284 local_scope->AddVariable(var_b); |
| 2285 | 2285 |
| 2286 const String& c = String::ZoneHandle(Symbols::New("c")); | 2286 const String& c = String::ZoneHandle(Symbols::New("c")); |
| 2287 LocalVariable* var_c = | 2287 LocalVariable* var_c = |
| 2288 new LocalVariable(Scanner::kDummyTokenIndex, c, dynamic_type); | 2288 new LocalVariable(Scanner::kNoSourcePos, c, dynamic_type); |
| 2289 parent_scope->AddVariable(var_c); | 2289 parent_scope->AddVariable(var_c); |
| 2290 | 2290 |
| 2291 bool test_only = false; // Please, insert alias. | 2291 bool test_only = false; // Please, insert alias. |
| 2292 var_a = local_scope->LookupVariable(a, test_only); | 2292 var_a = local_scope->LookupVariable(a, test_only); |
| 2293 EXPECT(var_a->is_captured()); | 2293 EXPECT(var_a->is_captured()); |
| 2294 EXPECT_EQ(parent_scope_function_level, var_a->owner()->function_level()); | 2294 EXPECT_EQ(parent_scope_function_level, var_a->owner()->function_level()); |
| 2295 EXPECT(local_scope->LocalLookupVariable(a) == var_a); // Alias. | 2295 EXPECT(local_scope->LocalLookupVariable(a) == var_a); // Alias. |
| 2296 | 2296 |
| 2297 var_b = local_scope->LookupVariable(b, test_only); | 2297 var_b = local_scope->LookupVariable(b, test_only); |
| 2298 EXPECT(!var_b->is_captured()); | 2298 EXPECT(!var_b->is_captured()); |
| (...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3982 // Simple map. | 3982 // Simple map. |
| 3983 // | 3983 // |
| 3984 // TODO(turnidge): Consider showing something like: {1: 2, 2: 'otter'} | 3984 // TODO(turnidge): Consider showing something like: {1: 2, 2: 'otter'} |
| 3985 result = Dart_GetField(lib, NewString("simple_map")); | 3985 result = Dart_GetField(lib, NewString("simple_map")); |
| 3986 EXPECT_VALID(result); | 3986 EXPECT_VALID(result); |
| 3987 obj ^= Api::UnwrapHandle(result); | 3987 obj ^= Api::UnwrapHandle(result); |
| 3988 EXPECT_STREQ("Instance of '_LinkedHashMap'", obj.ToUserCString()); | 3988 EXPECT_STREQ("Instance of '_LinkedHashMap'", obj.ToUserCString()); |
| 3989 } | 3989 } |
| 3990 | 3990 |
| 3991 } // namespace dart | 3991 } // namespace dart |
| OLD | NEW |