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) { |
| 21 return Library::New(library_name); |
| 22 } |
| 23 |
| 24 |
20 static RawClass* CreateDummyClass(const String& class_name, | 25 static RawClass* CreateDummyClass(const String& class_name, |
21 const Script& script) { | 26 const Script& script) { |
22 const Class& cls = Class::Handle( | 27 const Class& cls = Class::Handle( |
23 Class::New(class_name, script, Scanner::kDummyTokenIndex)); | 28 Class::New(class_name, script, Scanner::kDummyTokenIndex)); |
24 cls.set_is_synthesized_class(); // Dummy class for testing. | 29 cls.set_is_synthesized_class(); // Dummy class for testing. |
25 return cls.raw(); | 30 return cls.raw(); |
26 } | 31 } |
27 | 32 |
28 | 33 |
29 TEST_CASE(Class) { | 34 TEST_CASE(Class) { |
(...skipping 2359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2389 EXPECT(str3.IsString()); | 2394 EXPECT(str3.IsString()); |
2390 EXPECT(str3.IsOneByteString()); | 2395 EXPECT(str3.IsOneByteString()); |
2391 str3 = OneByteString::null(); | 2396 str3 = OneByteString::null(); |
2392 EXPECT(str3.IsString()); | 2397 EXPECT(str3.IsString()); |
2393 EXPECT(!str3.IsOneByteString()); | 2398 EXPECT(!str3.IsOneByteString()); |
2394 } | 2399 } |
2395 | 2400 |
2396 | 2401 |
2397 static Function* CreateFunction(const char* name) { | 2402 static Function* CreateFunction(const char* name) { |
2398 const String& class_name = String::Handle(Symbols::New("ownerClass")); | 2403 const String& class_name = String::Handle(Symbols::New("ownerClass")); |
| 2404 const String& lib_name = String::Handle(Symbols::New("ownerLibrary")); |
2399 const Script& script = Script::Handle(); | 2405 const Script& script = Script::Handle(); |
2400 const Class& owner_class = | 2406 const Class& owner_class = |
2401 Class::Handle(CreateDummyClass(class_name, script)); | 2407 Class::Handle(CreateDummyClass(class_name, script)); |
| 2408 const Library& owner_library = |
| 2409 Library::Handle(CreateDummyLibrary(lib_name)); |
| 2410 owner_class.set_library(owner_library); |
2402 const String& function_name = String::ZoneHandle(Symbols::New(name)); | 2411 const String& function_name = String::ZoneHandle(Symbols::New(name)); |
2403 Function& function = Function::ZoneHandle( | 2412 Function& function = Function::ZoneHandle( |
2404 Function::New(function_name, RawFunction::kRegularFunction, | 2413 Function::New(function_name, RawFunction::kRegularFunction, |
2405 true, false, false, false, owner_class, 0)); | 2414 true, false, false, false, owner_class, 0)); |
2406 return &function; | 2415 return &function; |
2407 } | 2416 } |
2408 | 2417 |
2409 | 2418 |
2410 // Test for Code and Instruction object creation. | 2419 // Test for Code and Instruction object creation. |
2411 TEST_CASE(Code) { | 2420 TEST_CASE(Code) { |
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3610 cls = Object::dynamic_class(); | 3619 cls = Object::dynamic_class(); |
3611 array = cls.fields(); | 3620 array = cls.fields(); |
3612 EXPECT(!array.IsNull()); | 3621 EXPECT(!array.IsNull()); |
3613 EXPECT(array.IsArray()); | 3622 EXPECT(array.IsArray()); |
3614 array = cls.functions(); | 3623 array = cls.functions(); |
3615 EXPECT(!array.IsNull()); | 3624 EXPECT(!array.IsNull()); |
3616 EXPECT(array.IsArray()); | 3625 EXPECT(array.IsArray()); |
3617 } | 3626 } |
3618 | 3627 |
3619 } // namespace dart | 3628 } // namespace dart |
OLD | NEW |