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/code_patcher.h" | 7 #include "vm/code_patcher.h" |
8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 EXPECT(CompilerTest::TestCompileScript(lib, script)); | 47 EXPECT(CompilerTest::TestCompileScript(lib, script)); |
48 EXPECT(ClassFinalizer::ProcessPendingClasses()); | 48 EXPECT(ClassFinalizer::ProcessPendingClasses()); |
49 Class& cls = Class::Handle( | 49 Class& cls = Class::Handle( |
50 lib.LookupClass(String::Handle(Symbols::New("A")))); | 50 lib.LookupClass(String::Handle(Symbols::New("A")))); |
51 EXPECT(!cls.IsNull()); | 51 EXPECT(!cls.IsNull()); |
52 String& function_foo_name = String::Handle(String::New("foo")); | 52 String& function_foo_name = String::Handle(String::New("foo")); |
53 Function& function_foo = | 53 Function& function_foo = |
54 Function::Handle(cls.LookupStaticFunction(function_foo_name)); | 54 Function::Handle(cls.LookupStaticFunction(function_foo_name)); |
55 EXPECT(!function_foo.IsNull()); | 55 EXPECT(!function_foo.IsNull()); |
56 String& function_source = String::Handle(function_foo.GetSource()); | 56 String& function_source = String::Handle(function_foo.GetSource()); |
57 EXPECT_STREQ("static foo() { return 42; }\n ", function_source.ToCString()); | 57 EXPECT_STREQ("static foo() { return 42; }", function_source.ToCString()); |
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 function_source = function_moo.GetSource(); | 68 function_source = function_moo.GetSource(); |
69 EXPECT_STREQ("static moo() {\n // A.foo();\n }\n", | 69 EXPECT_STREQ("static moo() {\n // A.foo();\n }", |
70 function_source.ToCString()); | 70 function_source.ToCString()); |
siva
2015/04/14 18:00:45
maybe better to retain the new line as it would lo
| |
71 } | 71 } |
72 | 72 |
73 | 73 |
74 TEST_CASE(RegenerateAllocStubs) { | 74 TEST_CASE(RegenerateAllocStubs) { |
75 const char* kScriptChars = | 75 const char* kScriptChars = |
76 "class A {\n" | 76 "class A {\n" |
77 "}\n" | 77 "}\n" |
78 "unOpt() => new A(); \n" | 78 "unOpt() => new A(); \n" |
79 "optIt() => new A(); \n" | 79 "optIt() => new A(); \n" |
80 "A main() {\n" | 80 "A main() {\n" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 val = lib.Evaluate(expression, Array::empty_array(), Array::empty_array()); | 173 val = lib.Evaluate(expression, Array::empty_array(), Array::empty_array()); |
174 } | 174 } |
175 | 175 |
176 EXPECT(!val.IsNull()); | 176 EXPECT(!val.IsNull()); |
177 EXPECT(!val.IsError()); | 177 EXPECT(!val.IsError()); |
178 EXPECT(val.IsInteger()); | 178 EXPECT(val.IsInteger()); |
179 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); | 179 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); |
180 } | 180 } |
181 | 181 |
182 } // namespace dart | 182 } // namespace dart |
OLD | NEW |