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