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

Side by Side Diff: vm/compiler_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/code_patcher_x64_test.cc ('k') | vm/dart_api_impl.cc » ('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/class_finalizer.h" 6 #include "vm/class_finalizer.h"
7 #include "vm/compiler.h" 7 #include "vm/compiler.h"
8 #include "vm/object.h" 8 #include "vm/object.h"
9 #include "vm/unit_test.h" 9 #include "vm/unit_test.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 // Compiler only implemented on IA32 and X64 now. 13 // Compiler only implemented on IA32 and X64 now.
14 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) 14 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
15 15
16 TEST_CASE(CompileScript) { 16 TEST_CASE(CompileScript) {
17 const char* kScriptChars = 17 const char* kScriptChars =
18 "class A {\n" 18 "class A {\n"
19 " static foo() { return 42; }\n" 19 " static foo() { return 42; }\n"
20 "}\n"; 20 "}\n";
21 String& url = String::Handle(String::New("dart-test:CompileScript")); 21 String& url = String::Handle(String::New("dart-test:CompileScript"));
22 String& source = String::Handle(String::New(kScriptChars)); 22 String& source = String::Handle(String::New(kScriptChars));
23 Script& script = Script::Handle(Script::New(url, source, RawScript::kSource)); 23 Script& script = Script::Handle(Script::New(url,
24 source,
25 RawScript::kSourceTag));
24 Library& lib = Library::Handle(Library::CoreLibrary()); 26 Library& lib = Library::Handle(Library::CoreLibrary());
25 EXPECT(CompilerTest::TestCompileScript(lib, script)); 27 EXPECT(CompilerTest::TestCompileScript(lib, script));
26 } 28 }
27 29
28 30
29 TEST_CASE(CompileFunction) { 31 TEST_CASE(CompileFunction) {
30 const char* kScriptChars = 32 const char* kScriptChars =
31 "class A {\n" 33 "class A {\n"
32 " static foo() { return 42; }\n" 34 " static foo() { return 42; }\n"
33 " static moo() {\n" 35 " static moo() {\n"
34 " // A.foo();\n" 36 " // A.foo();\n"
35 " }\n" 37 " }\n"
36 "}\n"; 38 "}\n";
37 String& url = String::Handle(String::New("dart-test:CompileFunction")); 39 String& url = String::Handle(String::New("dart-test:CompileFunction"));
38 String& source = String::Handle(String::New(kScriptChars)); 40 String& source = String::Handle(String::New(kScriptChars));
39 Script& script = Script::Handle(Script::New(url, source, RawScript::kSource)); 41 Script& script = Script::Handle(Script::New(url,
42 source,
43 RawScript::kSourceTag));
40 Library& lib = Library::Handle(Library::CoreLibrary()); 44 Library& lib = Library::Handle(Library::CoreLibrary());
41 EXPECT(CompilerTest::TestCompileScript(lib, script)); 45 EXPECT(CompilerTest::TestCompileScript(lib, script));
42 EXPECT(ClassFinalizer::FinalizePendingClasses()); 46 EXPECT(ClassFinalizer::FinalizePendingClasses());
43 Class& cls = Class::Handle( 47 Class& cls = Class::Handle(
44 lib.LookupClass(String::Handle(String::NewSymbol("A")))); 48 lib.LookupClass(String::Handle(String::NewSymbol("A"))));
45 EXPECT(!cls.IsNull()); 49 EXPECT(!cls.IsNull());
46 String& function_foo_name = String::Handle(String::New("foo")); 50 String& function_foo_name = String::Handle(String::New("foo"));
47 Function& function_foo = 51 Function& function_foo =
48 Function::Handle(cls.LookupStaticFunction(function_foo_name)); 52 Function::Handle(cls.LookupStaticFunction(function_foo_name));
49 EXPECT(!function_foo.IsNull()); 53 EXPECT(!function_foo.IsNull());
50 54
51 EXPECT(CompilerTest::TestCompileFunction(function_foo)); 55 EXPECT(CompilerTest::TestCompileFunction(function_foo));
52 EXPECT(function_foo.HasCode()); 56 EXPECT(function_foo.HasCode());
53 57
54 String& function_moo_name = String::Handle(String::New("moo")); 58 String& function_moo_name = String::Handle(String::New("moo"));
55 Function& function_moo = 59 Function& function_moo =
56 Function::Handle(cls.LookupStaticFunction(function_moo_name)); 60 Function::Handle(cls.LookupStaticFunction(function_moo_name));
57 EXPECT(!function_moo.IsNull()); 61 EXPECT(!function_moo.IsNull());
58 62
59 EXPECT(CompilerTest::TestCompileFunction(function_moo)); 63 EXPECT(CompilerTest::TestCompileFunction(function_moo));
60 EXPECT(function_moo.HasCode()); 64 EXPECT(function_moo.HasCode());
61 } 65 }
62 66
63 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64 67 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64
64 68
65 } // namespace dart 69 } // namespace dart
OLDNEW
« no previous file with comments | « vm/code_patcher_x64_test.cc ('k') | vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698