Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: runtime/vm/dart_entry_test.cc

Issue 10871005: Make ClassFinalizer indifferent on whether we are generating a snapshot or not. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 11 matching lines...) Expand all
22 "class A {\n" 22 "class A {\n"
23 " static foo() { return 42; }\n" 23 " static foo() { return 42; }\n"
24 "}\n"; 24 "}\n";
25 String& url = String::Handle(String::New("dart-test:DartEntry")); 25 String& url = String::Handle(String::New("dart-test:DartEntry"));
26 String& source = String::Handle(String::New(kScriptChars)); 26 String& source = String::Handle(String::New(kScriptChars));
27 Script& script = Script::Handle(Script::New(url, 27 Script& script = Script::Handle(Script::New(url,
28 source, 28 source,
29 RawScript::kScriptTag)); 29 RawScript::kScriptTag));
30 Library& lib = Library::Handle(Library::CoreLibrary()); 30 Library& lib = Library::Handle(Library::CoreLibrary());
31 EXPECT_EQ(true, CompilerTest::TestCompileScript(lib, script)); 31 EXPECT_EQ(true, CompilerTest::TestCompileScript(lib, script));
32 EXPECT(ClassFinalizer::FinalizePendingClasses()); 32 EXPECT(ClassFinalizer::FinalizeAllClasses());
33 Class& cls = Class::Handle( 33 Class& cls = Class::Handle(
34 lib.LookupClass(String::Handle(Symbols::New("A")))); 34 lib.LookupClass(String::Handle(Symbols::New("A"))));
35 EXPECT(!cls.IsNull()); 35 EXPECT(!cls.IsNull());
36 String& name = String::Handle(String::New("foo")); 36 String& name = String::Handle(String::New("foo"));
37 Function& function = Function::Handle(cls.LookupStaticFunction(name)); 37 Function& function = Function::Handle(cls.LookupStaticFunction(name));
38 EXPECT(!function.IsNull()); 38 EXPECT(!function.IsNull());
39 39
40 EXPECT(CompilerTest::TestCompileFunction(function)); 40 EXPECT(CompilerTest::TestCompileFunction(function));
41 EXPECT(function.HasCode()); 41 EXPECT(function.HasCode());
42 GrowableArray<const Object*> arguments; 42 GrowableArray<const Object*> arguments;
(...skipping 11 matching lines...) Expand all
54 "class A {\n" 54 "class A {\n"
55 " static foo() { return ++++; }\n" 55 " static foo() { return ++++; }\n"
56 "}\n"; 56 "}\n";
57 String& url = String::Handle(String::New("dart-test:DartEntry")); 57 String& url = String::Handle(String::New("dart-test:DartEntry"));
58 String& source = String::Handle(String::New(kScriptChars)); 58 String& source = String::Handle(String::New(kScriptChars));
59 Script& script = Script::Handle(Script::New(url, 59 Script& script = Script::Handle(Script::New(url,
60 source, 60 source,
61 RawScript::kScriptTag)); 61 RawScript::kScriptTag));
62 Library& lib = Library::Handle(Library::CoreLibrary()); 62 Library& lib = Library::Handle(Library::CoreLibrary());
63 EXPECT_EQ(true, CompilerTest::TestCompileScript(lib, script)); 63 EXPECT_EQ(true, CompilerTest::TestCompileScript(lib, script));
64 EXPECT(ClassFinalizer::FinalizePendingClasses()); 64 EXPECT(ClassFinalizer::FinalizeAllClasses());
65 Class& cls = Class::Handle( 65 Class& cls = Class::Handle(
66 lib.LookupClass(String::Handle(Symbols::New("A")))); 66 lib.LookupClass(String::Handle(Symbols::New("A"))));
67 EXPECT(!cls.IsNull()); 67 EXPECT(!cls.IsNull());
68 String& name = String::Handle(String::New("foo")); 68 String& name = String::Handle(String::New("foo"));
69 Function& function = Function::Handle(cls.LookupStaticFunction(name)); 69 Function& function = Function::Handle(cls.LookupStaticFunction(name));
70 EXPECT(!function.IsNull()); 70 EXPECT(!function.IsNull());
71 GrowableArray<const Object*> arguments; 71 GrowableArray<const Object*> arguments;
72 const Array& kNoArgumentNames = Array::Handle(); 72 const Array& kNoArgumentNames = Array::Handle();
73 const Object& retval = Object::Handle( 73 const Object& retval = Object::Handle(
74 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); 74 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
75 EXPECT(retval.IsError()); 75 EXPECT(retval.IsError());
76 EXPECT_SUBSTRING("++++", Error::Cast(retval).ToErrorCString()); 76 EXPECT_SUBSTRING("++++", Error::Cast(retval).ToErrorCString());
77 } 77 }
78 78
79 79
80 TEST_CASE(InvokeDynamic_CompileError) { 80 TEST_CASE(InvokeDynamic_CompileError) {
81 const char* kScriptChars = 81 const char* kScriptChars =
82 "class A {\n" 82 "class A {\n"
83 " foo() { return ++++; }\n" 83 " foo() { return ++++; }\n"
84 "}\n"; 84 "}\n";
85 String& url = String::Handle(String::New("dart-test:DartEntry")); 85 String& url = String::Handle(String::New("dart-test:DartEntry"));
86 String& source = String::Handle(String::New(kScriptChars)); 86 String& source = String::Handle(String::New(kScriptChars));
87 Script& script = Script::Handle(Script::New(url, 87 Script& script = Script::Handle(Script::New(url,
88 source, 88 source,
89 RawScript::kScriptTag)); 89 RawScript::kScriptTag));
90 Library& lib = Library::Handle(Library::CoreLibrary()); 90 Library& lib = Library::Handle(Library::CoreLibrary());
91 EXPECT_EQ(true, CompilerTest::TestCompileScript(lib, script)); 91 EXPECT_EQ(true, CompilerTest::TestCompileScript(lib, script));
92 EXPECT(ClassFinalizer::FinalizePendingClasses()); 92 EXPECT(ClassFinalizer::FinalizeAllClasses());
93 Class& cls = Class::Handle( 93 Class& cls = Class::Handle(
94 lib.LookupClass(String::Handle(Symbols::New("A")))); 94 lib.LookupClass(String::Handle(Symbols::New("A"))));
95 EXPECT(!cls.IsNull()); 95 EXPECT(!cls.IsNull());
96 96
97 // Invoke the constructor. 97 // Invoke the constructor.
98 const Instance& instance = Instance::Handle(Instance::New(cls)); 98 const Instance& instance = Instance::Handle(Instance::New(cls));
99 GrowableArray<const Object*> constructor_arguments(2); 99 GrowableArray<const Object*> constructor_arguments(2);
100 constructor_arguments.Add(&instance); 100 constructor_arguments.Add(&instance);
101 constructor_arguments.Add(&Smi::Handle(Smi::New(Function::kCtorPhaseAll))); 101 constructor_arguments.Add(&Smi::Handle(Smi::New(Function::kCtorPhaseAll)));
102 String& constructor_name = String::Handle(Symbols::New("A.")); 102 String& constructor_name = String::Handle(Symbols::New("A."));
(...skipping 11 matching lines...) Expand all
114 const Object& retval = Object::Handle( 114 const Object& retval = Object::Handle(
115 DartEntry::InvokeDynamic( 115 DartEntry::InvokeDynamic(
116 instance, function, arguments, kNoArgumentNames)); 116 instance, function, arguments, kNoArgumentNames));
117 EXPECT(retval.IsError()); 117 EXPECT(retval.IsError());
118 EXPECT_SUBSTRING("++++", Error::Cast(retval).ToErrorCString()); 118 EXPECT_SUBSTRING("++++", Error::Cast(retval).ToErrorCString());
119 } 119 }
120 120
121 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64. 121 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64.
122 122
123 } // namespace dart 123 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698