| 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/globals.h" | 5 #include "platform/globals.h" |
| 6 | 6 |
| 7 #include "vm/assembler.h" | 7 #include "vm/assembler.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 2612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2623 Function& parent = Function::Handle(); | 2623 Function& parent = Function::Handle(); |
| 2624 const String& parent_name = String::Handle(Symbols::New("foo_papa")); | 2624 const String& parent_name = String::Handle(Symbols::New("foo_papa")); |
| 2625 parent = Function::New(parent_name, RawFunction::kRegularFunction, | 2625 parent = Function::New(parent_name, RawFunction::kRegularFunction, |
| 2626 false, false, false, false, false, cls, 0); | 2626 false, false, false, false, false, cls, 0); |
| 2627 functions.SetAt(0, parent); | 2627 functions.SetAt(0, parent); |
| 2628 cls.SetFunctions(functions); | 2628 cls.SetFunctions(functions); |
| 2629 | 2629 |
| 2630 Function& function = Function::Handle(); | 2630 Function& function = Function::Handle(); |
| 2631 const String& function_name = String::Handle(Symbols::New("foo")); | 2631 const String& function_name = String::Handle(Symbols::New("foo")); |
| 2632 function = Function::NewClosureFunction(function_name, parent, 0); | 2632 function = Function::NewClosureFunction(function_name, parent, 0); |
| 2633 const Class& signature_class = Class::Handle( | 2633 const Closure& closure = Closure::Handle(Closure::New(function, context)); |
| 2634 Class::NewSignatureClass(function_name, function, script, 0)); | |
| 2635 const Instance& closure = Instance::Handle(Closure::New(function, context)); | |
| 2636 const Class& closure_class = Class::Handle(closure.clazz()); | 2634 const Class& closure_class = Class::Handle(closure.clazz()); |
| 2637 EXPECT(closure_class.IsSignatureClass()); | 2635 EXPECT_EQ(closure_class.id(), kClosureCid); |
| 2638 EXPECT(closure_class.IsCanonicalSignatureClass()); | 2636 const Function& closure_function = Function::Handle(closure.function()); |
| 2639 EXPECT_EQ(closure_class.raw(), signature_class.raw()); | 2637 EXPECT_EQ(closure_function.raw(), function.raw()); |
| 2640 const Function& signature_function = | 2638 const Context& closure_context = Context::Handle(closure.context()); |
| 2641 Function::Handle(signature_class.signature_function()); | 2639 EXPECT_EQ(closure_context.raw(), context.raw()); |
| 2642 EXPECT_EQ(signature_function.raw(), function.raw()); | |
| 2643 const Context& closure_context = Context::Handle(Closure::context(closure)); | |
| 2644 EXPECT_EQ(closure_context.raw(), closure_context.raw()); | |
| 2645 } | 2640 } |
| 2646 | 2641 |
| 2647 | 2642 |
| 2648 TEST_CASE(ObjectPrinting) { | 2643 TEST_CASE(ObjectPrinting) { |
| 2649 // Simple Smis. | 2644 // Simple Smis. |
| 2650 EXPECT_STREQ("2", Smi::Handle(Smi::New(2)).ToCString()); | 2645 EXPECT_STREQ("2", Smi::Handle(Smi::New(2)).ToCString()); |
| 2651 EXPECT_STREQ("-15", Smi::Handle(Smi::New(-15)).ToCString()); | 2646 EXPECT_STREQ("-15", Smi::Handle(Smi::New(-15)).ToCString()); |
| 2652 | 2647 |
| 2653 // bool class and true/false values. | 2648 // bool class and true/false values. |
| 2654 ObjectStore* object_store = Isolate::Current()->object_store(); | 2649 ObjectStore* object_store = Isolate::Current()->object_store(); |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3085 | 3080 |
| 3086 | 3081 |
| 3087 TEST_CASE(SubtypeTestCache) { | 3082 TEST_CASE(SubtypeTestCache) { |
| 3088 String& class_name = String::Handle(Symbols::New("EmptyClass")); | 3083 String& class_name = String::Handle(Symbols::New("EmptyClass")); |
| 3089 Script& script = Script::Handle(); | 3084 Script& script = Script::Handle(); |
| 3090 const Class& empty_class = | 3085 const Class& empty_class = |
| 3091 Class::Handle(CreateDummyClass(class_name, script)); | 3086 Class::Handle(CreateDummyClass(class_name, script)); |
| 3092 SubtypeTestCache& cache = SubtypeTestCache::Handle(SubtypeTestCache::New()); | 3087 SubtypeTestCache& cache = SubtypeTestCache::Handle(SubtypeTestCache::New()); |
| 3093 EXPECT(!cache.IsNull()); | 3088 EXPECT(!cache.IsNull()); |
| 3094 EXPECT_EQ(0, cache.NumberOfChecks()); | 3089 EXPECT_EQ(0, cache.NumberOfChecks()); |
| 3090 const Object& class_id_or_fun = Object::Handle(Smi::New(empty_class.id())); |
| 3095 const TypeArguments& targ_0 = TypeArguments::Handle(TypeArguments::New(2)); | 3091 const TypeArguments& targ_0 = TypeArguments::Handle(TypeArguments::New(2)); |
| 3096 const TypeArguments& targ_1 = TypeArguments::Handle(TypeArguments::New(3)); | 3092 const TypeArguments& targ_1 = TypeArguments::Handle(TypeArguments::New(3)); |
| 3097 cache.AddCheck(empty_class.id(), targ_0, targ_1, Bool::True()); | 3093 cache.AddCheck(class_id_or_fun, targ_0, targ_1, Bool::True()); |
| 3098 EXPECT_EQ(1, cache.NumberOfChecks()); | 3094 EXPECT_EQ(1, cache.NumberOfChecks()); |
| 3099 intptr_t test_class_id = -1; | 3095 Object& test_class_id_or_fun = Object::Handle(); |
| 3100 TypeArguments& test_targ_0 = TypeArguments::Handle(); | 3096 TypeArguments& test_targ_0 = TypeArguments::Handle(); |
| 3101 TypeArguments& test_targ_1 = TypeArguments::Handle(); | 3097 TypeArguments& test_targ_1 = TypeArguments::Handle(); |
| 3102 Bool& test_result = Bool::Handle(); | 3098 Bool& test_result = Bool::Handle(); |
| 3103 cache.GetCheck(0, &test_class_id, &test_targ_0, &test_targ_1, &test_result); | 3099 cache.GetCheck( |
| 3104 EXPECT_EQ(empty_class.id(), test_class_id); | 3100 0, &test_class_id_or_fun, &test_targ_0, &test_targ_1, &test_result); |
| 3101 EXPECT_EQ(class_id_or_fun.raw(), test_class_id_or_fun.raw()); |
| 3105 EXPECT_EQ(targ_0.raw(), test_targ_0.raw()); | 3102 EXPECT_EQ(targ_0.raw(), test_targ_0.raw()); |
| 3106 EXPECT_EQ(targ_1.raw(), test_targ_1.raw()); | 3103 EXPECT_EQ(targ_1.raw(), test_targ_1.raw()); |
| 3107 EXPECT_EQ(Bool::True().raw(), test_result.raw()); | 3104 EXPECT_EQ(Bool::True().raw(), test_result.raw()); |
| 3108 } | 3105 } |
| 3109 | 3106 |
| 3110 | 3107 |
| 3111 TEST_CASE(FieldTests) { | 3108 TEST_CASE(FieldTests) { |
| 3112 const String& f = String::Handle(String::New("oneField")); | 3109 const String& f = String::Handle(String::New("oneField")); |
| 3113 const String& getter_f = String::Handle(Field::GetterName(f)); | 3110 const String& getter_f = String::Handle(Field::GetterName(f)); |
| 3114 const String& setter_f = String::Handle(Field::SetterName(f)); | 3111 const String& setter_f = String::Handle(Field::SetterName(f)); |
| (...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4681 String& test = String::Handle(); | 4678 String& test = String::Handle(); |
| 4682 String& result = String::Handle(); | 4679 String& result = String::Handle(); |
| 4683 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) { | 4680 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) { |
| 4684 test = String::New(tests[i].in); | 4681 test = String::New(tests[i].in); |
| 4685 result = String::IdentifierPrettyName(test); | 4682 result = String::IdentifierPrettyName(test); |
| 4686 EXPECT_STREQ(tests[i].out, result.ToCString()); | 4683 EXPECT_STREQ(tests[i].out, result.ToCString()); |
| 4687 } | 4684 } |
| 4688 } | 4685 } |
| 4689 | 4686 |
| 4690 } // namespace dart | 4687 } // namespace dart |
| OLD | NEW |