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

Side by Side Diff: vm/resolver_test.cc

Issue 11667012: Convert all symbols accessor to return read only handles so that it is not necessary to create a ne… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 11 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 | « vm/parser.cc ('k') | vm/scanner.cc » ('j') | vm/symbols.h » ('J')
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 const String& library_name = String::Handle(String::New(test_library_name)); 92 const String& library_name = String::Handle(String::New(test_library_name));
93 const Library& library = 93 const Library& library =
94 Library::Handle(Library::LookupLibrary(library_name)); 94 Library::Handle(Library::LookupLibrary(library_name));
95 const String& class_name = String::Handle(String::New(test_class_name)); 95 const String& class_name = String::Handle(String::New(test_class_name));
96 const String& static_function_name = 96 const String& static_function_name =
97 String::Handle(String::New(test_static_function_name)); 97 String::Handle(String::New(test_static_function_name));
98 98
99 // Now try to resolve and invoke the static function in this class. 99 // Now try to resolve and invoke the static function in this class.
100 { 100 {
101 const int kNumArguments = 2; 101 const int kNumArguments = 2;
102 const Array& kNoArgumentNames = Array::Handle();
103 const Function& function = Function::Handle( 102 const Function& function = Function::Handle(
104 Resolver::ResolveStatic(library, 103 Resolver::ResolveStatic(library,
105 class_name, 104 class_name,
106 static_function_name, 105 static_function_name,
107 kNumArguments, 106 kNumArguments,
108 kNoArgumentNames, 107 Object::empty_array(),
109 kResolveType)); 108 kResolveType));
110 EXPECT(!function.IsNull()); 109 EXPECT(!function.IsNull());
111 const Array& args = Array::Handle(Array::New(kNumArguments)); 110 const Array& args = Array::Handle(Array::New(kNumArguments));
112 const String& arg0 = String::Handle(String::New("junk")); 111 const String& arg0 = String::Handle(String::New("junk"));
113 args.SetAt(0, arg0); 112 args.SetAt(0, arg0);
114 const Smi& arg1 = Smi::Handle(Smi::New(kTestValue)); 113 const Smi& arg1 = Smi::Handle(Smi::New(kTestValue));
115 args.SetAt(1, arg1); 114 args.SetAt(1, arg1);
116 const Smi& retval = Smi::Handle( 115 const Smi& retval = Smi::Handle(
117 reinterpret_cast<RawSmi*>(DartEntry::InvokeStatic(function, args))); 116 reinterpret_cast<RawSmi*>(DartEntry::InvokeStatic(function, args)));
118 EXPECT_EQ(kTestValue, retval.Value()); 117 EXPECT_EQ(kTestValue, retval.Value());
119 } 118 }
120 119
121 // Now try to resolve a static function with invalid argument count. 120 // Now try to resolve a static function with invalid argument count.
122 { 121 {
123 const int kNumArguments = 1; 122 const int kNumArguments = 1;
124 const Array& kNoArgumentNames = Array::Handle();
125 const Function& bad_function = Function::Handle( 123 const Function& bad_function = Function::Handle(
126 Resolver::ResolveStatic(library, 124 Resolver::ResolveStatic(library,
127 class_name, 125 class_name,
128 static_function_name, 126 static_function_name,
129 kNumArguments, 127 kNumArguments,
130 kNoArgumentNames, 128 Object::empty_array(),
131 kResolveType)); 129 kResolveType));
132 EXPECT(bad_function.IsNull()); 130 EXPECT(bad_function.IsNull());
133 } 131 }
134 132
135 // Hierarchy walking. 133 // Hierarchy walking.
136 { 134 {
137 const String& super_static_function_name = 135 const String& super_static_function_name =
138 String::Handle(String::New("statCall")); 136 String::Handle(String::New("statCall"));
139 const String& super_class_name = String::Handle(String::New("Base")); 137 const String& super_class_name = String::Handle(String::New("Base"));
140 const int kNumArguments = 0; 138 const int kNumArguments = 0;
141 const Array& kNoArgumentNames = Array::Handle();
142 const Function& super_function = Function::Handle( 139 const Function& super_function = Function::Handle(
143 Resolver::ResolveStatic(library, 140 Resolver::ResolveStatic(library,
144 super_class_name, 141 super_class_name,
145 super_static_function_name, 142 super_static_function_name,
146 kNumArguments, 143 kNumArguments,
147 kNoArgumentNames, 144 Object::empty_array(),
148 kResolveType)); 145 kResolveType));
149 EXPECT(!super_function.IsNull()); 146 EXPECT(!super_function.IsNull());
150 } 147 }
151 } 148 }
152 149
153 150
154 TEST_CASE(DartDynamicResolve) { 151 TEST_CASE(DartDynamicResolve) {
155 const char* test_library_name = "ResolverApp"; 152 const char* test_library_name = "ResolverApp";
156 const char* test_class_name = "A"; 153 const char* test_class_name = "A";
157 const char* test_function_name = "foo"; 154 const char* test_function_name = "foo";
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 super_function_name, 215 super_function_name,
219 kNumPositionalArguments, 216 kNumPositionalArguments,
220 kNumNamedArguments)); 217 kNumNamedArguments));
221 EXPECT(!super_function.IsNull()); 218 EXPECT(!super_function.IsNull());
222 } 219 }
223 } 220 }
224 221
225 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 222 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
226 223
227 } // namespace dart 224 } // namespace dart
OLDNEW
« no previous file with comments | « vm/parser.cc ('k') | vm/scanner.cc » ('j') | vm/symbols.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698