Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: runtime/vm/resolver_test.cc

Issue 19200002: Change resolving of instance methods to check early for name mismatch. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/resolver.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 ASSERT(!lib.IsNull()); 163 ASSERT(!lib.IsNull());
164 const Class& cls = Class::Handle(lib.LookupClass( 164 const Class& cls = Class::Handle(lib.LookupClass(
165 String::Handle(Symbols::New(test_class_name)))); 165 String::Handle(Symbols::New(test_class_name))));
166 EXPECT(!cls.IsNull()); 166 EXPECT(!cls.IsNull());
167 167
168 Instance& receiver = Instance::Handle(Instance::New(cls)); 168 Instance& receiver = Instance::Handle(Instance::New(cls));
169 const String& function_name = String::Handle(String::New(test_function_name)); 169 const String& function_name = String::Handle(String::New(test_function_name));
170 170
171 // Now try to resolve and invoke the instance function in this class. 171 // Now try to resolve and invoke the instance function in this class.
172 { 172 {
173 const int kNumPositionalArguments = 3; 173 const int kNumArguments = 3;
174 const int kNumNamedArguments = 0; 174 ArgumentsDescriptor args_desc(
175 Array::Handle(ArgumentsDescriptor::New(kNumArguments)));
175 const Function& function = Function::Handle( 176 const Function& function = Function::Handle(
176 Resolver::ResolveDynamic(receiver, 177 Resolver::ResolveDynamic(receiver,
177 function_name, 178 function_name,
178 kNumPositionalArguments, 179 args_desc));
179 kNumNamedArguments));
180 EXPECT(!function.IsNull()); 180 EXPECT(!function.IsNull());
181 const Array& args = Array::Handle(Array::New(kNumPositionalArguments)); 181 const Array& args = Array::Handle(Array::New(kNumArguments));
182 args.SetAt(0, receiver); 182 args.SetAt(0, receiver);
183 const String& arg0 = String::Handle(String::New("junk")); 183 const String& arg0 = String::Handle(String::New("junk"));
184 args.SetAt(1, arg0); 184 args.SetAt(1, arg0);
185 const Smi& arg1 = Smi::Handle(Smi::New(kTestValue)); 185 const Smi& arg1 = Smi::Handle(Smi::New(kTestValue));
186 args.SetAt(2, arg1); 186 args.SetAt(2, arg1);
187 const Smi& retval = Smi::Handle( 187 const Smi& retval = Smi::Handle(
188 reinterpret_cast<RawSmi*>(DartEntry::InvokeFunction(function, args))); 188 reinterpret_cast<RawSmi*>(DartEntry::InvokeFunction(function, args)));
189 EXPECT_EQ(kTestValue, retval.Value()); 189 EXPECT_EQ(kTestValue, retval.Value());
190 } 190 }
191 191
192 // Now try to resolve an instance function with invalid argument count. 192 // Now try to resolve an instance function with invalid argument count.
193 { 193 {
194 const int kNumPositionalArguments = 1; 194 const int kNumArguments = 1;
195 const int kNumNamedArguments = 0; 195 ArgumentsDescriptor args_desc(
196 Array::Handle(ArgumentsDescriptor::New(kNumArguments)));
196 const Function& bad_function = Function::Handle( 197 const Function& bad_function = Function::Handle(
197 Resolver::ResolveDynamic(receiver, 198 Resolver::ResolveDynamic(receiver,
198 function_name, 199 function_name,
199 kNumPositionalArguments, 200 args_desc));
200 kNumNamedArguments));
201 EXPECT(bad_function.IsNull()); 201 EXPECT(bad_function.IsNull());
202 } 202 }
203 203
204 // Hierarchy walking. 204 // Hierarchy walking.
205 { 205 {
206 const int kNumPositionalArguments = 1; 206 const int kNumArguments = 1;
207 const int kNumNamedArguments = 0; 207 ArgumentsDescriptor args_desc(
208 Array::Handle(ArgumentsDescriptor::New(kNumArguments)));
208 const String& super_function_name = 209 const String& super_function_name =
209 String::Handle(String::New("dynCall")); 210 String::Handle(String::New("dynCall"));
210 const Function& super_function = Function::Handle( 211 const Function& super_function = Function::Handle(
211 Resolver::ResolveDynamic(receiver, 212 Resolver::ResolveDynamic(receiver,
212 super_function_name, 213 super_function_name,
213 kNumPositionalArguments, 214 args_desc));
214 kNumNamedArguments));
215 EXPECT(!super_function.IsNull()); 215 EXPECT(!super_function.IsNull());
216 } 216 }
217 } 217 }
218 218
219 } // namespace dart 219 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/resolver.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698