| 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/assembler.h" | 6 #include "vm/assembler.h" |
| 7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
| 8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| 11 #include "vm/resolver.h" | 11 #include "vm/resolver.h" |
| 12 #include "vm/unit_test.h" | 12 #include "vm/unit_test.h" |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 | 15 |
| 16 // Only ia32 and x64 can run execution tests. | 16 // Only ia32 and x64 can run execution tests. |
| 17 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 17 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
| 18 | 18 |
| 19 TEST_CASE(DartEntry) { | 19 TEST_CASE(DartEntry) { |
| 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:DartEntry")); | 24 String& url = String::Handle(String::New("dart-test:DartEntry")); |
| 25 String& source = String::Handle(String::New(kScriptChars)); | 25 String& source = String::Handle(String::New(kScriptChars)); |
| 26 Script& script = Script::Handle(Script::New(url, source, RawScript::kScript)); | 26 Script& script = Script::Handle(Script::New(url, source, RawScript::kScript)); |
| 27 Library& lib = Library::Handle(Library::CoreLibrary()); | 27 Library& lib = Library::Handle(Library::CoreLibrary()); |
| 28 EXPECT_EQ(true, CompilerTest::TestCompileScript(lib, script)); | 28 EXPECT_EQ(true, CompilerTest::TestCompileScript(lib, script)); |
| 29 EXPECT(ClassFinalizer::FinalizePendingClasses()); |
| 29 Class& cls = Class::Handle( | 30 Class& cls = Class::Handle( |
| 30 lib.LookupClass(String::Handle(String::NewSymbol("A")))); | 31 lib.LookupClass(String::Handle(String::NewSymbol("A")))); |
| 31 EXPECT(!cls.IsNull()); | 32 EXPECT(!cls.IsNull()); |
| 32 String& name = String::Handle(String::New("foo")); | 33 String& name = String::Handle(String::New("foo")); |
| 33 Function& function = Function::Handle(cls.LookupStaticFunction(name)); | 34 Function& function = Function::Handle(cls.LookupStaticFunction(name)); |
| 34 EXPECT(!function.IsNull()); | 35 EXPECT(!function.IsNull()); |
| 35 | 36 |
| 36 EXPECT(CompilerTest::TestCompileFunction(function)); | 37 EXPECT(CompilerTest::TestCompileFunction(function)); |
| 37 EXPECT(function.HasCode()); | 38 EXPECT(function.HasCode()); |
| 38 GrowableArray<const Object*> arguments; | 39 GrowableArray<const Object*> arguments; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 instance, function, arguments, kNoArgumentNames)); | 111 instance, function, arguments, kNoArgumentNames)); |
| 111 EXPECT(retval.IsError()); | 112 EXPECT(retval.IsError()); |
| 112 Error& error = Error::Handle(); | 113 Error& error = Error::Handle(); |
| 113 error ^= retval.raw(); | 114 error ^= retval.raw(); |
| 114 EXPECT_SUBSTRING("++++", error.ToErrorCString()); | 115 EXPECT_SUBSTRING("++++", error.ToErrorCString()); |
| 115 } | 116 } |
| 116 | 117 |
| 117 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64. | 118 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64. |
| 118 | 119 |
| 119 } // namespace dart | 120 } // namespace dart |
| OLD | NEW |