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 "platform/assert.h" | 5 #include "platform/assert.h" |
6 #include "vm/class_finalizer.h" | 6 #include "vm/class_finalizer.h" |
7 #include "vm/symbols.h" | 7 #include "vm/symbols.h" |
8 #include "vm/unit_test.h" | 8 #include "vm/unit_test.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
11 | 11 |
12 | 12 |
13 static RawClass* CreateTestClass(const char* name) { | 13 static RawClass* CreateTestClass(const char* name) { |
14 const String& class_name = String::Handle(Symbols::New(Thread::Current(), | 14 const String& class_name = |
15 name)); | 15 String::Handle(Symbols::New(Thread::Current(), name)); |
16 const Script& script = Script::Handle(); | 16 const Script& script = Script::Handle(); |
17 const Class& cls = Class::Handle( | 17 const Class& cls = Class::Handle(Class::New( |
18 Class::New(Library::Handle(), class_name, script, | 18 Library::Handle(), class_name, script, TokenPosition::kNoSource)); |
19 TokenPosition::kNoSource)); | |
20 cls.set_interfaces(Object::empty_array()); | 19 cls.set_interfaces(Object::empty_array()); |
21 cls.SetFunctions(Object::empty_array()); | 20 cls.SetFunctions(Object::empty_array()); |
22 cls.SetFields(Object::empty_array()); | 21 cls.SetFields(Object::empty_array()); |
23 return cls.raw(); | 22 return cls.raw(); |
24 } | 23 } |
25 | 24 |
26 | 25 |
27 TEST_CASE(ClassFinalizer) { | 26 TEST_CASE(ClassFinalizer) { |
28 Zone* zone = thread->zone(); | 27 Zone* zone = thread->zone(); |
29 Isolate* isolate = thread->isolate(); | 28 Isolate* isolate = thread->isolate(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 const GrowableObjectArray& pending_classes = | 87 const GrowableObjectArray& pending_classes = |
89 GrowableObjectArray::Handle(zone, object_store->pending_classes()); | 88 GrowableObjectArray::Handle(zone, object_store->pending_classes()); |
90 Class& rhb = Class::Handle(CreateTestClass("RhB")); | 89 Class& rhb = Class::Handle(CreateTestClass("RhB")); |
91 pending_classes.Add(rhb); | 90 pending_classes.Add(rhb); |
92 Class& sbb = Class::Handle(CreateTestClass("SBB")); | 91 Class& sbb = Class::Handle(CreateTestClass("SBB")); |
93 pending_classes.Add(sbb); | 92 pending_classes.Add(sbb); |
94 Library& lib = Library::Handle(NewLib("TestLib")); | 93 Library& lib = Library::Handle(NewLib("TestLib")); |
95 lib.AddClass(rhb); | 94 lib.AddClass(rhb); |
96 lib.AddClass(sbb); | 95 lib.AddClass(sbb); |
97 const String& superclass_name = String::Handle(sbb.Name()); | 96 const String& superclass_name = String::Handle(sbb.Name()); |
98 const UnresolvedClass& unresolved = UnresolvedClass::Handle( | 97 const UnresolvedClass& unresolved = |
99 UnresolvedClass::New(LibraryPrefix::Handle(), | 98 UnresolvedClass::Handle(UnresolvedClass::New( |
100 superclass_name, | 99 LibraryPrefix::Handle(), superclass_name, TokenPosition::kNoSource)); |
101 TokenPosition::kNoSource)); | |
102 const TypeArguments& type_arguments = TypeArguments::Handle(); | 100 const TypeArguments& type_arguments = TypeArguments::Handle(); |
103 rhb.set_super_type(Type::Handle( | 101 rhb.set_super_type( |
104 Type::New(Object::Handle(unresolved.raw()), | 102 Type::Handle(Type::New(Object::Handle(unresolved.raw()), type_arguments, |
105 type_arguments, | 103 TokenPosition::kNoSource))); |
106 TokenPosition::kNoSource))); | |
107 EXPECT(ClassFinalizer::ProcessPendingClasses()); | 104 EXPECT(ClassFinalizer::ProcessPendingClasses()); |
108 } | 105 } |
109 | 106 |
110 } // namespace dart | 107 } // namespace dart |
OLD | NEW |