| 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/unit_test.h" | 8 #include "vm/unit_test.h" |
| 8 | 9 |
| 9 namespace dart { | 10 namespace dart { |
| 10 | 11 |
| 11 | 12 |
| 12 static RawClass* CreateTestClass(const char* name) { | 13 static RawClass* CreateTestClass(const char* name) { |
| 13 const Array& empty_array = Array::Handle(Array::Empty()); | 14 const Array& empty_array = Array::Handle(Array::Empty()); |
| 14 const String& class_name = String::Handle(String::NewSymbol(name)); | 15 const String& class_name = String::Handle(Symbols::New(name)); |
| 15 const Script& script = Script::Handle(); | 16 const Script& script = Script::Handle(); |
| 16 const Class& cls = | 17 const Class& cls = |
| 17 Class::Handle(Class::New(class_name, script, Scanner::kDummyTokenIndex)); | 18 Class::Handle(Class::New(class_name, script, Scanner::kDummyTokenIndex)); |
| 18 cls.set_interfaces(empty_array); | 19 cls.set_interfaces(empty_array); |
| 19 cls.SetFunctions(empty_array); | 20 cls.SetFunctions(empty_array); |
| 20 cls.SetFields(empty_array); | 21 cls.SetFields(empty_array); |
| 21 return cls.raw(); | 22 return cls.raw(); |
| 22 } | 23 } |
| 23 | 24 |
| 24 | 25 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // Create a cycle. | 65 // Create a cycle. |
| 65 classes[0]->set_super_type( | 66 classes[0]->set_super_type( |
| 66 Type::Handle(Type::NewNonParameterizedType(*classes[1]))); | 67 Type::Handle(Type::NewNonParameterizedType(*classes[1]))); |
| 67 classes[1]->set_super_type( | 68 classes[1]->set_super_type( |
| 68 Type::Handle(Type::NewNonParameterizedType(*classes[0]))); | 69 Type::Handle(Type::NewNonParameterizedType(*classes[0]))); |
| 69 EXPECT(!ClassFinalizer::FinalizePendingClasses()); | 70 EXPECT(!ClassFinalizer::FinalizePendingClasses()); |
| 70 } | 71 } |
| 71 | 72 |
| 72 | 73 |
| 73 static RawLibrary* NewLib(const char* url_chars) { | 74 static RawLibrary* NewLib(const char* url_chars) { |
| 74 String& url = String::ZoneHandle(String::NewSymbol(url_chars)); | 75 String& url = String::ZoneHandle(Symbols::New(url_chars)); |
| 75 return Library::New(url); | 76 return Library::New(url); |
| 76 } | 77 } |
| 77 | 78 |
| 78 | 79 |
| 79 TEST_CASE(ClassFinalize_Resolve) { | 80 TEST_CASE(ClassFinalize_Resolve) { |
| 80 Isolate* isolate = Isolate::Current(); | 81 Isolate* isolate = Isolate::Current(); |
| 81 ObjectStore* object_store = isolate->object_store(); | 82 ObjectStore* object_store = isolate->object_store(); |
| 82 const GrowableObjectArray& pending_classes = | 83 const GrowableObjectArray& pending_classes = |
| 83 GrowableObjectArray::Handle(isolate, object_store->pending_classes()); | 84 GrowableObjectArray::Handle(isolate, object_store->pending_classes()); |
| 84 Class& rhb = Class::Handle(CreateTestClass("RhB")); | 85 Class& rhb = Class::Handle(CreateTestClass("RhB")); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 95 Scanner::kDummyTokenIndex)); | 96 Scanner::kDummyTokenIndex)); |
| 96 const TypeArguments& type_arguments = TypeArguments::Handle(); | 97 const TypeArguments& type_arguments = TypeArguments::Handle(); |
| 97 rhb.set_super_type(Type::Handle( | 98 rhb.set_super_type(Type::Handle( |
| 98 Type::New(Object::Handle(unresolved.raw()), | 99 Type::New(Object::Handle(unresolved.raw()), |
| 99 type_arguments, | 100 type_arguments, |
| 100 Scanner::kDummyTokenIndex))); | 101 Scanner::kDummyTokenIndex))); |
| 101 EXPECT(ClassFinalizer::FinalizePendingClasses()); | 102 EXPECT(ClassFinalizer::FinalizePendingClasses()); |
| 102 } | 103 } |
| 103 | 104 |
| 104 } // namespace dart | 105 } // namespace dart |
| OLD | NEW |