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

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

Issue 50523018: Cleanup StaticResolveType, it does not seem to be used anywhere. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 test_function_name, 72 test_function_name,
73 false); 73 false);
74 } 74 }
75 75
76 76
77 TEST_CASE(DartStaticResolve) { 77 TEST_CASE(DartStaticResolve) {
78 const char* test_library_name = "ResolverApp"; 78 const char* test_library_name = "ResolverApp";
79 const char* test_class_name = "A"; 79 const char* test_class_name = "A";
80 const char* test_static_function_name = "static_foo"; 80 const char* test_static_function_name = "static_foo";
81 const int kTestValue = 42; 81 const int kTestValue = 42;
82 const Resolver::StaticResolveType kResolveType = Resolver::kIsQualified;
83 82
84 // Setup a static function which can be invoked. 83 // Setup a static function which can be invoked.
85 SetupStaticFunction(test_library_name, 84 SetupStaticFunction(test_library_name,
86 test_class_name, 85 test_class_name,
87 test_static_function_name); 86 test_static_function_name);
88 87
89 const String& library_name = String::Handle(String::New(test_library_name)); 88 const String& library_name = String::Handle(String::New(test_library_name));
90 const Library& library = 89 const Library& library =
91 Library::Handle(Library::LookupLibrary(library_name)); 90 Library::Handle(Library::LookupLibrary(library_name));
92 const String& class_name = String::Handle(String::New(test_class_name)); 91 const String& class_name = String::Handle(String::New(test_class_name));
93 const String& static_function_name = 92 const String& static_function_name =
94 String::Handle(String::New(test_static_function_name)); 93 String::Handle(String::New(test_static_function_name));
95 94
96 // Now try to resolve and invoke the static function in this class. 95 // Now try to resolve and invoke the static function in this class.
97 { 96 {
98 const int kNumArguments = 2; 97 const int kNumArguments = 2;
99 const Function& function = Function::Handle( 98 const Function& function = Function::Handle(
100 Resolver::ResolveStatic(library, 99 Resolver::ResolveStatic(library,
101 class_name, 100 class_name,
102 static_function_name, 101 static_function_name,
103 kNumArguments, 102 kNumArguments,
104 Object::empty_array(), 103 Object::empty_array()));
105 kResolveType));
106 EXPECT(!function.IsNull()); // No ambiguity error expected. 104 EXPECT(!function.IsNull()); // No ambiguity error expected.
107 const Array& args = Array::Handle(Array::New(kNumArguments)); 105 const Array& args = Array::Handle(Array::New(kNumArguments));
108 const String& arg0 = String::Handle(String::New("junk")); 106 const String& arg0 = String::Handle(String::New("junk"));
109 args.SetAt(0, arg0); 107 args.SetAt(0, arg0);
110 const Smi& arg1 = Smi::Handle(Smi::New(kTestValue)); 108 const Smi& arg1 = Smi::Handle(Smi::New(kTestValue));
111 args.SetAt(1, arg1); 109 args.SetAt(1, arg1);
112 const Smi& retval = Smi::Handle( 110 const Smi& retval = Smi::Handle(
113 reinterpret_cast<RawSmi*>(DartEntry::InvokeFunction(function, args))); 111 reinterpret_cast<RawSmi*>(DartEntry::InvokeFunction(function, args)));
114 EXPECT_EQ(kTestValue, retval.Value()); 112 EXPECT_EQ(kTestValue, retval.Value());
115 } 113 }
116 114
117 // Now try to resolve a static function with invalid argument count. 115 // Now try to resolve a static function with invalid argument count.
118 { 116 {
119 const int kNumArguments = 1; 117 const int kNumArguments = 1;
120 const Function& bad_function = Function::Handle( 118 const Function& bad_function = Function::Handle(
121 Resolver::ResolveStatic(library, 119 Resolver::ResolveStatic(library,
122 class_name, 120 class_name,
123 static_function_name, 121 static_function_name,
124 kNumArguments, 122 kNumArguments,
125 Object::empty_array(), 123 Object::empty_array()));
126 kResolveType));
127 EXPECT(bad_function.IsNull()); // No ambiguity error expected. 124 EXPECT(bad_function.IsNull()); // No ambiguity error expected.
128 } 125 }
129 126
130 // Hierarchy walking. 127 // Hierarchy walking.
131 { 128 {
132 const String& super_static_function_name = 129 const String& super_static_function_name =
133 String::Handle(String::New("statCall")); 130 String::Handle(String::New("statCall"));
134 const String& super_class_name = String::Handle(String::New("Base")); 131 const String& super_class_name = String::Handle(String::New("Base"));
135 const int kNumArguments = 0; 132 const int kNumArguments = 0;
136 const Function& super_function = Function::Handle( 133 const Function& super_function = Function::Handle(
137 Resolver::ResolveStatic(library, 134 Resolver::ResolveStatic(library,
138 super_class_name, 135 super_class_name,
139 super_static_function_name, 136 super_static_function_name,
140 kNumArguments, 137 kNumArguments,
141 Object::empty_array(), 138 Object::empty_array()));
142 kResolveType));
143 EXPECT(!super_function.IsNull()); // No ambiguity error expected. 139 EXPECT(!super_function.IsNull()); // No ambiguity error expected.
144 } 140 }
145 } 141 }
146 142
147 143
148 TEST_CASE(DartDynamicResolve) { 144 TEST_CASE(DartDynamicResolve) {
149 const char* test_library_name = "ResolverApp"; 145 const char* test_library_name = "ResolverApp";
150 const char* test_class_name = "A"; 146 const char* test_class_name = "A";
151 const char* test_function_name = "foo"; 147 const char* test_function_name = "foo";
152 const int kTestValue = 42; 148 const int kTestValue = 42;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 String::Handle(String::New("dynCall")); 206 String::Handle(String::New("dynCall"));
211 const Function& super_function = Function::Handle( 207 const Function& super_function = Function::Handle(
212 Resolver::ResolveDynamic(receiver, 208 Resolver::ResolveDynamic(receiver,
213 super_function_name, 209 super_function_name,
214 args_desc)); 210 args_desc));
215 EXPECT(!super_function.IsNull()); 211 EXPECT(!super_function.IsNull());
216 } 212 }
217 } 213 }
218 214
219 } // namespace dart 215 } // 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