OLD | NEW |
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/compiler.h" | 7 #include "vm/compiler.h" |
7 #include "vm/object.h" | 8 #include "vm/object.h" |
8 #include "vm/unit_test.h" | 9 #include "vm/unit_test.h" |
9 | 10 |
10 namespace dart { | 11 namespace dart { |
11 | 12 |
12 // Compiler only implemented on IA32 and X64 now. | 13 // Compiler only implemented on IA32 and X64 now. |
13 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 14 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
14 | 15 |
15 TEST_CASE(CompileScript) { | 16 TEST_CASE(CompileScript) { |
(...skipping 15 matching lines...) Expand all Loading... |
31 " static foo() { return 42; }\n" | 32 " static foo() { return 42; }\n" |
32 " static moo() {\n" | 33 " static moo() {\n" |
33 " // A.foo();\n" | 34 " // A.foo();\n" |
34 " }\n" | 35 " }\n" |
35 "}\n"; | 36 "}\n"; |
36 String& url = String::Handle(String::New("dart-test:CompileFunction")); | 37 String& url = String::Handle(String::New("dart-test:CompileFunction")); |
37 String& source = String::Handle(String::New(kScriptChars)); | 38 String& source = String::Handle(String::New(kScriptChars)); |
38 Script& script = Script::Handle(Script::New(url, source, RawScript::kSource)); | 39 Script& script = Script::Handle(Script::New(url, source, RawScript::kSource)); |
39 Library& lib = Library::Handle(Library::CoreLibrary()); | 40 Library& lib = Library::Handle(Library::CoreLibrary()); |
40 EXPECT(CompilerTest::TestCompileScript(lib, script)); | 41 EXPECT(CompilerTest::TestCompileScript(lib, script)); |
| 42 EXPECT(ClassFinalizer::FinalizePendingClasses()); |
41 Class& cls = Class::Handle( | 43 Class& cls = Class::Handle( |
42 lib.LookupClass(String::Handle(String::NewSymbol("A")))); | 44 lib.LookupClass(String::Handle(String::NewSymbol("A")))); |
43 EXPECT(!cls.IsNull()); | 45 EXPECT(!cls.IsNull()); |
44 String& function_foo_name = String::Handle(String::New("foo")); | 46 String& function_foo_name = String::Handle(String::New("foo")); |
45 Function& function_foo = | 47 Function& function_foo = |
46 Function::Handle(cls.LookupStaticFunction(function_foo_name)); | 48 Function::Handle(cls.LookupStaticFunction(function_foo_name)); |
47 EXPECT(!function_foo.IsNull()); | 49 EXPECT(!function_foo.IsNull()); |
48 | 50 |
49 EXPECT(CompilerTest::TestCompileFunction(function_foo)); | 51 EXPECT(CompilerTest::TestCompileFunction(function_foo)); |
50 EXPECT(function_foo.HasCode()); | 52 EXPECT(function_foo.HasCode()); |
51 | 53 |
52 String& function_moo_name = String::Handle(String::New("moo")); | 54 String& function_moo_name = String::Handle(String::New("moo")); |
53 Function& function_moo = | 55 Function& function_moo = |
54 Function::Handle(cls.LookupStaticFunction(function_moo_name)); | 56 Function::Handle(cls.LookupStaticFunction(function_moo_name)); |
55 EXPECT(!function_moo.IsNull()); | 57 EXPECT(!function_moo.IsNull()); |
56 | 58 |
57 EXPECT(CompilerTest::TestCompileFunction(function_moo)); | 59 EXPECT(CompilerTest::TestCompileFunction(function_moo)); |
58 EXPECT(function_moo.HasCode()); | 60 EXPECT(function_moo.HasCode()); |
59 } | 61 } |
60 | 62 |
61 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64 | 63 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64 |
62 | 64 |
63 } // namespace dart | 65 } // namespace dart |
OLD | NEW |