OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/assembler.h" | 5 #include "vm/assembler.h" |
6 #include "vm/assert.h" | 6 #include "vm/assert.h" |
7 #include "vm/compiler.h" | 7 #include "vm/compiler.h" |
8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
9 #include "vm/object.h" | 9 #include "vm/object.h" |
10 #include "vm/resolver.h" | 10 #include "vm/resolver.h" |
11 #include "vm/unit_test.h" | 11 #include "vm/unit_test.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 #if defined(TARGET_ARCH_IA32) // only ia32 can run execution tests. | 15 // Only ia32 and x64 can run execution tests. |
| 16 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
16 | 17 |
17 TEST_CASE(DartEntry) { | 18 TEST_CASE(DartEntry) { |
18 const char* kScriptChars = | 19 const char* kScriptChars = |
19 "class A {\n" | 20 "class A {\n" |
20 " static foo() { return 42; }\n" | 21 " static foo() { return 42; }\n" |
21 "}\n"; | 22 "}\n"; |
22 String& url = String::Handle(String::New("dart-test:DartEntry")); | 23 String& url = String::Handle(String::New("dart-test:DartEntry")); |
23 String& source = String::Handle(String::New(kScriptChars)); | 24 String& source = String::Handle(String::New(kScriptChars)); |
24 Script& script = Script::Handle(Script::New(url, source, RawScript::kScript)); | 25 Script& script = Script::Handle(Script::New(url, source, RawScript::kScript)); |
25 Library& lib = Library::Handle(Library::CoreLibrary()); | 26 Library& lib = Library::Handle(Library::CoreLibrary()); |
26 EXPECT_EQ(true, CompilerTest::TestCompileScript(lib, script)); | 27 EXPECT_EQ(true, CompilerTest::TestCompileScript(lib, script)); |
27 Class& cls = Class::Handle( | 28 Class& cls = Class::Handle( |
28 lib.LookupClass(String::Handle(String::NewSymbol("A")))); | 29 lib.LookupClass(String::Handle(String::NewSymbol("A")))); |
29 EXPECT(!cls.IsNull()); | 30 EXPECT(!cls.IsNull()); |
30 String& name = String::Handle(String::New("foo")); | 31 String& name = String::Handle(String::New("foo")); |
31 Function& function = Function::Handle(cls.LookupStaticFunction(name)); | 32 Function& function = Function::Handle(cls.LookupStaticFunction(name)); |
32 EXPECT(!function.IsNull()); | 33 EXPECT(!function.IsNull()); |
33 | 34 |
34 EXPECT(CompilerTest::TestCompileFunction(function)); | 35 EXPECT(CompilerTest::TestCompileFunction(function)); |
35 EXPECT(function.HasCode()); | 36 EXPECT(function.HasCode()); |
36 GrowableArray<const Object*> arguments; | 37 GrowableArray<const Object*> arguments; |
37 const Array& kNoArgumentNames = Array::Handle(); | 38 const Array& kNoArgumentNames = Array::Handle(); |
38 const Smi& retval = Smi::Handle( | 39 const Smi& retval = Smi::Handle( |
39 reinterpret_cast<RawSmi*>(DartEntry::InvokeStatic(function, | 40 reinterpret_cast<RawSmi*>(DartEntry::InvokeStatic(function, |
40 arguments, | 41 arguments, |
41 kNoArgumentNames))); | 42 kNoArgumentNames))); |
42 EXPECT_EQ(Smi::New(42), retval.raw()); | 43 EXPECT_EQ(Smi::New(42), retval.raw()); |
43 } | 44 } |
44 | 45 |
45 #endif // TARGET_ARCH_IA32. | 46 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64. |
46 | 47 |
47 } // namespace dart | 48 } // namespace dart |
OLD | NEW |