| 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/assembler.h" | 6 #include "vm/assembler.h" |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.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 3161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3172 weak2.set_value(value2); | 3172 weak2.set_value(value2); |
| 3173 } | 3173 } |
| 3174 isolate->heap()->CollectAllGarbage(); | 3174 isolate->heap()->CollectAllGarbage(); |
| 3175 EXPECT(weak1.key() == Object::null()); | 3175 EXPECT(weak1.key() == Object::null()); |
| 3176 EXPECT(weak1.value() == Object::null()); | 3176 EXPECT(weak1.value() == Object::null()); |
| 3177 EXPECT(weak2.key() == Object::null()); | 3177 EXPECT(weak2.key() == Object::null()); |
| 3178 EXPECT(weak2.value() == Object::null()); | 3178 EXPECT(weak2.value() == Object::null()); |
| 3179 } | 3179 } |
| 3180 | 3180 |
| 3181 | 3181 |
| 3182 TEST_CASE(MirrorReference) { |
| 3183 const MirrorReference& reference = |
| 3184 MirrorReference::Handle(MirrorReference::New()); |
| 3185 Object& initial_referent = Object::Handle(reference.referent()); |
| 3186 EXPECT(initial_referent.IsNull()); |
| 3187 |
| 3188 Library& library = Library::Handle(Library::CoreLibrary()); |
| 3189 EXPECT(!library.IsNull()); |
| 3190 EXPECT(library.IsLibrary()); |
| 3191 reference.set_referent(library); |
| 3192 const Object& returned_referent = Object::Handle(reference.referent()); |
| 3193 EXPECT(returned_referent.IsLibrary()); |
| 3194 EXPECT_EQ(returned_referent.raw(), library.raw()); |
| 3195 |
| 3196 const MirrorReference& other_reference = |
| 3197 MirrorReference::Handle(MirrorReference::New()); |
| 3198 EXPECT_NE(reference.raw(), other_reference.raw()); |
| 3199 other_reference.set_referent(library); |
| 3200 EXPECT_NE(reference.raw(), other_reference.raw()); |
| 3201 EXPECT_EQ(reference.referent(), other_reference.referent()); |
| 3202 |
| 3203 Object& obj = Object::Handle(reference.raw()); |
| 3204 ASSERT(obj.IsMirrorReference()); |
| 3205 } |
| 3206 |
| 3207 |
| 3182 static RawFunction* GetFunction(const Class& cls, const char* name) { | 3208 static RawFunction* GetFunction(const Class& cls, const char* name) { |
| 3183 const Function& result = Function::Handle(cls.LookupDynamicFunction( | 3209 const Function& result = Function::Handle(cls.LookupDynamicFunction( |
| 3184 String::Handle(String::New(name)))); | 3210 String::Handle(String::New(name)))); |
| 3185 ASSERT(!result.IsNull()); | 3211 ASSERT(!result.IsNull()); |
| 3186 return result.raw(); | 3212 return result.raw(); |
| 3187 } | 3213 } |
| 3188 | 3214 |
| 3189 | 3215 |
| 3190 static RawField* GetField(const Class& cls, const char* name) { | 3216 static RawField* GetField(const Class& cls, const char* name) { |
| 3191 const Field& field = | 3217 const Field& field = |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3336 const Function& test7 = Function::Handle(GetFunction(class_a, "test7")); | 3362 const Function& test7 = Function::Handle(GetFunction(class_a, "test7")); |
| 3337 EXPECT_EQ(test1.SourceFingerprint(), test2.SourceFingerprint()); | 3363 EXPECT_EQ(test1.SourceFingerprint(), test2.SourceFingerprint()); |
| 3338 EXPECT_NE(test1.SourceFingerprint(), test3.SourceFingerprint()); | 3364 EXPECT_NE(test1.SourceFingerprint(), test3.SourceFingerprint()); |
| 3339 EXPECT_NE(test3.SourceFingerprint(), test4.SourceFingerprint()); | 3365 EXPECT_NE(test3.SourceFingerprint(), test4.SourceFingerprint()); |
| 3340 EXPECT_NE(test4.SourceFingerprint(), test5.SourceFingerprint()); | 3366 EXPECT_NE(test4.SourceFingerprint(), test5.SourceFingerprint()); |
| 3341 EXPECT_NE(test5.SourceFingerprint(), test6.SourceFingerprint()); | 3367 EXPECT_NE(test5.SourceFingerprint(), test6.SourceFingerprint()); |
| 3342 EXPECT_EQ(test6.SourceFingerprint(), test7.SourceFingerprint()); | 3368 EXPECT_EQ(test6.SourceFingerprint(), test7.SourceFingerprint()); |
| 3343 } | 3369 } |
| 3344 | 3370 |
| 3345 } // namespace dart | 3371 } // namespace dart |
| OLD | NEW |