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 "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 RawScript::kScriptTag)); | 82 RawScript::kScriptTag)); |
83 Library& lib = Library::Handle(Library::CoreLibrary()); | 83 Library& lib = Library::Handle(Library::CoreLibrary()); |
84 EXPECT_EQ(true, CompilerTest::TestCompileScript(lib, script)); | 84 EXPECT_EQ(true, CompilerTest::TestCompileScript(lib, script)); |
85 EXPECT(ClassFinalizer::ProcessPendingClasses()); | 85 EXPECT(ClassFinalizer::ProcessPendingClasses()); |
86 Class& cls = Class::Handle( | 86 Class& cls = Class::Handle( |
87 lib.LookupClass(String::Handle(Symbols::New("A")))); | 87 lib.LookupClass(String::Handle(Symbols::New("A")))); |
88 EXPECT(!cls.IsNull()); // No ambiguity error expected. | 88 EXPECT(!cls.IsNull()); // No ambiguity error expected. |
89 | 89 |
90 // Invoke the constructor. | 90 // Invoke the constructor. |
91 const Instance& instance = Instance::Handle(Instance::New(cls)); | 91 const Instance& instance = Instance::Handle(Instance::New(cls)); |
92 const Array& constructor_arguments = Array::Handle(Array::New(2)); | 92 const Array& constructor_arguments = Array::Handle(Array::New(1)); |
93 constructor_arguments.SetAt(0, instance); | 93 constructor_arguments.SetAt(0, instance); |
94 constructor_arguments.SetAt( | |
95 1, Smi::Handle(Smi::New(Function::kCtorPhaseAll))); | |
96 String& constructor_name = String::Handle(Symbols::New("A.")); | 94 String& constructor_name = String::Handle(Symbols::New("A.")); |
97 Function& constructor = | 95 Function& constructor = |
98 Function::Handle(cls.LookupConstructor(constructor_name)); | 96 Function::Handle(cls.LookupConstructor(constructor_name)); |
99 ASSERT(!constructor.IsNull()); | 97 ASSERT(!constructor.IsNull()); |
100 DartEntry::InvokeFunction(constructor, constructor_arguments); | 98 DartEntry::InvokeFunction(constructor, constructor_arguments); |
101 | 99 |
102 // Call foo. | 100 // Call foo. |
103 String& name = String::Handle(String::New("foo")); | 101 String& name = String::Handle(String::New("foo")); |
104 Function& function = Function::Handle(cls.LookupDynamicFunction(name)); | 102 Function& function = Function::Handle(cls.LookupDynamicFunction(name)); |
105 EXPECT(!function.IsNull()); | 103 EXPECT(!function.IsNull()); |
106 const Array& args = Array::Handle(Array::New(1)); | 104 const Array& args = Array::Handle(Array::New(1)); |
107 args.SetAt(0, instance); | 105 args.SetAt(0, instance); |
108 const Object& retval = Object::Handle(DartEntry::InvokeFunction(function, | 106 const Object& retval = Object::Handle(DartEntry::InvokeFunction(function, |
109 args)); | 107 args)); |
110 EXPECT(retval.IsError()); | 108 EXPECT(retval.IsError()); |
111 EXPECT_SUBSTRING("++++", Error::Cast(retval).ToErrorCString()); | 109 EXPECT_SUBSTRING("++++", Error::Cast(retval).ToErrorCString()); |
112 } | 110 } |
113 | 111 |
114 } // namespace dart | 112 } // namespace dart |
OLD | NEW |