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

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

Issue 14791005: BREAKING CHANGE: enforce part of directive (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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/code_generator_test.cc ('k') | runtime/vm/dart_api_impl_test.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/symbols.h" 9 #include "vm/symbols.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
11 11
12 namespace dart { 12 namespace dart {
13 13
14 // Compiler only implemented on IA32, X64, and ARM. 14 // Compiler only implemented on IA32, X64, and ARM.
15 #if defined(TARGET_ARCH_IA32) || \ 15 #if defined(TARGET_ARCH_IA32) || \
16 defined(TARGET_ARCH_X64) || \ 16 defined(TARGET_ARCH_X64) || \
17 defined(TARGET_ARCH_ARM) 17 defined(TARGET_ARCH_ARM)
18 18
19 TEST_CASE(CompileScript) { 19 TEST_CASE(CompileScript) {
20 const char* kScriptChars = 20 const char* kScriptChars =
21 "class A {\n" 21 "class A {\n"
22 " static foo() { return 42; }\n" 22 " static foo() { return 42; }\n"
23 "}\n"; 23 "}\n";
24 String& url = String::Handle(String::New("dart-test:CompileScript")); 24 String& url = String::Handle(String::New("dart-test:CompileScript"));
25 String& source = String::Handle(String::New(kScriptChars)); 25 String& source = String::Handle(String::New(kScriptChars));
26 Script& script = Script::Handle(Script::New(url, 26 Script& script = Script::Handle(Script::New(url,
27 source, 27 source,
28 RawScript::kSourceTag)); 28 RawScript::kScriptTag));
29 Library& lib = Library::Handle(Library::CoreLibrary()); 29 Library& lib = Library::Handle(Library::CoreLibrary());
30 EXPECT(CompilerTest::TestCompileScript(lib, script)); 30 EXPECT(CompilerTest::TestCompileScript(lib, script));
31 } 31 }
32 32
33 33
34 TEST_CASE(CompileFunction) { 34 TEST_CASE(CompileFunction) {
35 const char* kScriptChars = 35 const char* kScriptChars =
36 "class A {\n" 36 "class A {\n"
37 " static foo() { return 42; }\n" 37 " static foo() { return 42; }\n"
38 " static moo() {\n" 38 " static moo() {\n"
39 " // A.foo();\n" 39 " // A.foo();\n"
40 " }\n" 40 " }\n"
41 "}\n"; 41 "}\n";
42 String& url = String::Handle(String::New("dart-test:CompileFunction")); 42 String& url = String::Handle(String::New("dart-test:CompileFunction"));
43 String& source = String::Handle(String::New(kScriptChars)); 43 String& source = String::Handle(String::New(kScriptChars));
44 Script& script = Script::Handle(Script::New(url, 44 Script& script = Script::Handle(Script::New(url,
45 source, 45 source,
46 RawScript::kSourceTag)); 46 RawScript::kScriptTag));
47 Library& lib = Library::Handle(Library::CoreLibrary()); 47 Library& lib = Library::Handle(Library::CoreLibrary());
48 EXPECT(CompilerTest::TestCompileScript(lib, script)); 48 EXPECT(CompilerTest::TestCompileScript(lib, script));
49 EXPECT(ClassFinalizer::FinalizePendingClasses()); 49 EXPECT(ClassFinalizer::FinalizePendingClasses());
50 Class& cls = Class::Handle( 50 Class& cls = Class::Handle(
51 lib.LookupClass(String::Handle(Symbols::New("A")))); 51 lib.LookupClass(String::Handle(Symbols::New("A"))));
52 EXPECT(!cls.IsNull()); 52 EXPECT(!cls.IsNull());
53 String& function_foo_name = String::Handle(String::New("foo")); 53 String& function_foo_name = String::Handle(String::New("foo"));
54 Function& function_foo = 54 Function& function_foo =
55 Function::Handle(cls.LookupStaticFunction(function_foo_name)); 55 Function::Handle(cls.LookupStaticFunction(function_foo_name));
56 EXPECT(!function_foo.IsNull()); 56 EXPECT(!function_foo.IsNull());
57 57
58 EXPECT(CompilerTest::TestCompileFunction(function_foo)); 58 EXPECT(CompilerTest::TestCompileFunction(function_foo));
59 EXPECT(function_foo.HasCode()); 59 EXPECT(function_foo.HasCode());
60 60
61 String& function_moo_name = String::Handle(String::New("moo")); 61 String& function_moo_name = String::Handle(String::New("moo"));
62 Function& function_moo = 62 Function& function_moo =
63 Function::Handle(cls.LookupStaticFunction(function_moo_name)); 63 Function::Handle(cls.LookupStaticFunction(function_moo_name));
64 EXPECT(!function_moo.IsNull()); 64 EXPECT(!function_moo.IsNull());
65 65
66 EXPECT(CompilerTest::TestCompileFunction(function_moo)); 66 EXPECT(CompilerTest::TestCompileFunction(function_moo));
67 EXPECT(function_moo.HasCode()); 67 EXPECT(function_moo.HasCode());
68 } 68 }
69 69
70 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64 || TARGET_ARCH_ARM 70 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64 || TARGET_ARCH_ARM
71 71
72 } // namespace dart 72 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_generator_test.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698