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

Side by Side Diff: vm/object_test.cc

Issue 10808064: Rename some of the enum definitions inside classes to avoid conflict with the ObjectKind enum. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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 | « vm/object.cc ('k') | vm/parser.h » ('j') | 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/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/object_store.h" 10 #include "vm/object_store.h"
(...skipping 11 matching lines...) Expand all
22 // Class has no fields. 22 // Class has no fields.
23 const Array& no_fields = Array::Handle(Array::Empty()); 23 const Array& no_fields = Array::Handle(Array::Empty());
24 cls.SetFields(no_fields); 24 cls.SetFields(no_fields);
25 25
26 // Create and populate the function arrays. 26 // Create and populate the function arrays.
27 const Array& functions = Array::Handle(Array::New(6)); 27 const Array& functions = Array::Handle(Array::New(6));
28 Function& function = Function::Handle(); 28 Function& function = Function::Handle();
29 String& function_name = String::Handle(); 29 String& function_name = String::Handle();
30 function_name = String::NewSymbol("foo"); 30 function_name = String::NewSymbol("foo");
31 function = Function::New( 31 function = Function::New(
32 function_name, RawFunction::kFunction, false, false, 0); 32 function_name, RawFunction::kRegularFunction, false, false, 0);
33 functions.SetAt(0, function); 33 functions.SetAt(0, function);
34 function_name = String::NewSymbol("bar"); 34 function_name = String::NewSymbol("bar");
35 function = Function::New( 35 function = Function::New(
36 function_name, RawFunction::kFunction, false, false, 0); 36 function_name, RawFunction::kRegularFunction, false, false, 0);
37 37
38 const int kNumFixedParameters = 2; 38 const int kNumFixedParameters = 2;
39 const int kNumOptionalParameters = 3; 39 const int kNumOptionalParameters = 3;
40 function.set_num_fixed_parameters(kNumFixedParameters); 40 function.set_num_fixed_parameters(kNumFixedParameters);
41 function.set_num_optional_parameters(kNumOptionalParameters); 41 function.set_num_optional_parameters(kNumOptionalParameters);
42 functions.SetAt(1, function); 42 functions.SetAt(1, function);
43 43
44 function_name = String::NewSymbol("baz"); 44 function_name = String::NewSymbol("baz");
45 function = Function::New( 45 function = Function::New(
46 function_name, RawFunction::kFunction, false, false, 0); 46 function_name, RawFunction::kRegularFunction, false, false, 0);
47 functions.SetAt(2, function); 47 functions.SetAt(2, function);
48 48
49 function_name = String::NewSymbol("Foo"); 49 function_name = String::NewSymbol("Foo");
50 function = Function::New( 50 function = Function::New(
51 function_name, RawFunction::kFunction, true, false, 0); 51 function_name, RawFunction::kRegularFunction, true, false, 0);
52 functions.SetAt(3, function); 52 functions.SetAt(3, function);
53 function_name = String::NewSymbol("Bar"); 53 function_name = String::NewSymbol("Bar");
54 function = Function::New( 54 function = Function::New(
55 function_name, RawFunction::kFunction, true, false, 0); 55 function_name, RawFunction::kRegularFunction, true, false, 0);
56 functions.SetAt(4, function); 56 functions.SetAt(4, function);
57 function_name = String::NewSymbol("BaZ"); 57 function_name = String::NewSymbol("BaZ");
58 function = Function::New( 58 function = Function::New(
59 function_name, RawFunction::kFunction, true, false, 0); 59 function_name, RawFunction::kRegularFunction, true, false, 0);
60 functions.SetAt(5, function); 60 functions.SetAt(5, function);
61 61
62 // Setup the functions in the class. 62 // Setup the functions in the class.
63 cls.SetFunctions(functions); 63 cls.SetFunctions(functions);
64 64
65 function_name = String::New("Foo"); 65 function_name = String::New("Foo");
66 function = cls.LookupDynamicFunction(function_name); 66 function = cls.LookupDynamicFunction(function_name);
67 EXPECT(function.IsNull()); 67 EXPECT(function.IsNull());
68 function = cls.LookupStaticFunction(function_name); 68 function = cls.LookupStaticFunction(function_name);
69 EXPECT(!function.IsNull()); 69 EXPECT(!function.IsNull());
(...skipping 2105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2175 } 2175 }
2176 2176
2177 2177
2178 TEST_CASE(Script) { 2178 TEST_CASE(Script) {
2179 const char* url_chars = "builtin:test-case"; 2179 const char* url_chars = "builtin:test-case";
2180 const char* source_chars = "This will not compile."; 2180 const char* source_chars = "This will not compile.";
2181 const String& url = String::Handle(String::New(url_chars)); 2181 const String& url = String::Handle(String::New(url_chars));
2182 const String& source = String::Handle(String::New(source_chars)); 2182 const String& source = String::Handle(String::New(source_chars));
2183 const Script& script = Script::Handle(Script::New(url, 2183 const Script& script = Script::Handle(Script::New(url,
2184 source, 2184 source,
2185 RawScript::kSource)); 2185 RawScript::kSourceTag));
2186 EXPECT(!script.IsNull()); 2186 EXPECT(!script.IsNull());
2187 EXPECT(script.IsScript()); 2187 EXPECT(script.IsScript());
2188 String& str = String::Handle(script.url()); 2188 String& str = String::Handle(script.url());
2189 EXPECT_EQ(17, str.Length()); 2189 EXPECT_EQ(17, str.Length());
2190 EXPECT_EQ('b', str.CharAt(0)); 2190 EXPECT_EQ('b', str.CharAt(0));
2191 EXPECT_EQ(':', str.CharAt(7)); 2191 EXPECT_EQ(':', str.CharAt(7));
2192 EXPECT_EQ('e', str.CharAt(16)); 2192 EXPECT_EQ('e', str.CharAt(16));
2193 str = script.Source(); 2193 str = script.Source();
2194 EXPECT_EQ(22, str.Length()); 2194 EXPECT_EQ(22, str.Length());
2195 EXPECT_EQ('T', str.CharAt(0)); 2195 EXPECT_EQ('T', str.CharAt(0));
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2316 // Allocate the class first. 2316 // Allocate the class first.
2317 const String& class_name = String::Handle(String::NewSymbol("MyClass")); 2317 const String& class_name = String::Handle(String::NewSymbol("MyClass"));
2318 const Script& script = Script::Handle(); 2318 const Script& script = Script::Handle();
2319 const Class& cls = 2319 const Class& cls =
2320 Class::Handle(Class::New(class_name, script, Scanner::kDummyTokenIndex)); 2320 Class::Handle(Class::New(class_name, script, Scanner::kDummyTokenIndex));
2321 const Array& functions = Array::Handle(Array::New(1)); 2321 const Array& functions = Array::Handle(Array::New(1));
2322 2322
2323 const Context& context = Context::Handle(Context::New(0)); 2323 const Context& context = Context::Handle(Context::New(0));
2324 Function& parent = Function::Handle(); 2324 Function& parent = Function::Handle();
2325 const String& parent_name = String::Handle(String::NewSymbol("foo_papa")); 2325 const String& parent_name = String::Handle(String::NewSymbol("foo_papa"));
2326 parent = Function::New(parent_name, RawFunction::kFunction, false, false, 0); 2326 parent = Function::New(parent_name, RawFunction::kRegularFunction,
2327 false, false, 0);
2327 functions.SetAt(0, parent); 2328 functions.SetAt(0, parent);
2328 cls.SetFunctions(functions); 2329 cls.SetFunctions(functions);
2329 2330
2330 Function& function = Function::Handle(); 2331 Function& function = Function::Handle();
2331 const String& function_name = String::Handle(String::NewSymbol("foo")); 2332 const String& function_name = String::Handle(String::NewSymbol("foo"));
2332 function = Function::NewClosureFunction(function_name, parent, 0); 2333 function = Function::NewClosureFunction(function_name, parent, 0);
2333 const Class& signature_class = Class::Handle( 2334 const Class& signature_class = Class::Handle(
2334 Class::NewSignatureClass(function_name, function, script)); 2335 Class::NewSignatureClass(function_name, function, script));
2335 const Closure& closure = Closure::Handle(Closure::New(function, context)); 2336 const Closure& closure = Closure::Handle(Closure::New(function, context));
2336 const Class& closure_class = Class::Handle(closure.clazz()); 2337 const Class& closure_class = Class::Handle(closure.clazz());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2385 EXPECT(!str3.IsOneByteString()); 2386 EXPECT(!str3.IsOneByteString());
2386 } 2387 }
2387 2388
2388 2389
2389 // only ia32 and x64 can run execution tests. 2390 // only ia32 and x64 can run execution tests.
2390 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) 2391 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
2391 2392
2392 static Function* CreateFunction(const char* name) { 2393 static Function* CreateFunction(const char* name) {
2393 const String& function_name = String::ZoneHandle(String::NewSymbol(name)); 2394 const String& function_name = String::ZoneHandle(String::NewSymbol(name));
2394 Function& function = Function::ZoneHandle( 2395 Function& function = Function::ZoneHandle(
2395 Function::New(function_name, RawFunction::kFunction, true, false, 0)); 2396 Function::New(function_name, RawFunction::kRegularFunction,
2397 true, false, 0));
2396 return &function; 2398 return &function;
2397 } 2399 }
2398 2400
2399 // Test for Code and Instruction object creation. 2401 // Test for Code and Instruction object creation.
2400 TEST_CASE(Code) { 2402 TEST_CASE(Code) {
2401 extern void GenerateIncrement(Assembler* assembler); 2403 extern void GenerateIncrement(Assembler* assembler);
2402 Assembler _assembler_; 2404 Assembler _assembler_;
2403 GenerateIncrement(&_assembler_); 2405 GenerateIncrement(&_assembler_);
2404 Code& code = Code::Handle(Code::FinalizeCode( 2406 Code& code = Code::Handle(Code::FinalizeCode(
2405 *CreateFunction("Test_Code"), &_assembler_)); 2407 *CreateFunction("Test_Code"), &_assembler_));
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
2569 } 2571 }
2570 ASSERT(count == 2); 2572 ASSERT(count == 2);
2571 } 2573 }
2572 2574
2573 2575
2574 static RawFunction* GetDummyTarget(const char* name) { 2576 static RawFunction* GetDummyTarget(const char* name) {
2575 const String& function_name = String::Handle(String::NewSymbol(name)); 2577 const String& function_name = String::Handle(String::NewSymbol(name));
2576 const bool is_static = false; 2578 const bool is_static = false;
2577 const bool is_const = false; 2579 const bool is_const = false;
2578 return Function::New(function_name, 2580 return Function::New(function_name,
2579 RawFunction::kFunction, 2581 RawFunction::kRegularFunction,
2580 is_static, 2582 is_static,
2581 is_const, 2583 is_const,
2582 0); 2584 0);
2583 } 2585 }
2584 2586
2585 2587
2586 TEST_CASE(ICData) { 2588 TEST_CASE(ICData) {
2587 Function& function = Function::Handle(GetDummyTarget("Bern")); 2589 Function& function = Function::Handle(GetDummyTarget("Bern"));
2588 const intptr_t id = 12; 2590 const intptr_t id = 12;
2589 const intptr_t num_args_tested = 1; 2591 const intptr_t num_args_tested = 1;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
2777 // Named double-private constructor mismatch. 2779 // Named double-private constructor mismatch.
2778 mangled_name = OneByteString::New("foo@12345.named@12345"); 2780 mangled_name = OneByteString::New("foo@12345.named@12345");
2779 bare_name = OneByteString::New("foo.name"); 2781 bare_name = OneByteString::New("foo.name");
2780 EXPECT(!mangled_name.EqualsIgnoringPrivateKey(bare_name)); 2782 EXPECT(!mangled_name.EqualsIgnoringPrivateKey(bare_name));
2781 } 2783 }
2782 2784
2783 2785
2784 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 2786 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
2785 2787
2786 } // namespace dart 2788 } // namespace dart
OLDNEW
« no previous file with comments | « vm/object.cc ('k') | vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698