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

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

Issue 9314053: Revert Dart_PropagateError until I can track down the problems in (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 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
« no previous file with comments | « runtime/vm/dart_entry.cc ('k') | runtime/vm/debugger.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
8 #include "vm/compiler.h" 7 #include "vm/compiler.h"
9 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
10 #include "vm/object.h" 9 #include "vm/object.h"
11 #include "vm/resolver.h" 10 #include "vm/resolver.h"
12 #include "vm/unit_test.h" 11 #include "vm/unit_test.h"
13 12
14 namespace dart { 13 namespace dart {
15 14
16 // Only ia32 and x64 can run execution tests. 15 // Only ia32 and x64 can run execution tests.
17 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) 16 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
(...skipping 19 matching lines...) Expand all
37 EXPECT(function.HasCode()); 36 EXPECT(function.HasCode());
38 GrowableArray<const Object*> arguments; 37 GrowableArray<const Object*> arguments;
39 const Array& kNoArgumentNames = Array::Handle(); 38 const Array& kNoArgumentNames = Array::Handle();
40 const Smi& retval = Smi::Handle( 39 const Smi& retval = Smi::Handle(
41 reinterpret_cast<RawSmi*>(DartEntry::InvokeStatic(function, 40 reinterpret_cast<RawSmi*>(DartEntry::InvokeStatic(function,
42 arguments, 41 arguments,
43 kNoArgumentNames))); 42 kNoArgumentNames)));
44 EXPECT_EQ(Smi::New(42), retval.raw()); 43 EXPECT_EQ(Smi::New(42), retval.raw());
45 } 44 }
46 45
47
48 TEST_CASE(InvokeStatic_CompileError) {
49 const char* kScriptChars =
50 "class A {\n"
51 " static foo() { return ++++; }\n"
52 "}\n";
53 String& url = String::Handle(String::New("dart-test:DartEntry"));
54 String& source = String::Handle(String::New(kScriptChars));
55 Script& script = Script::Handle(Script::New(url, source, RawScript::kScript));
56 Library& lib = Library::Handle(Library::CoreLibrary());
57 EXPECT_EQ(true, CompilerTest::TestCompileScript(lib, script));
58 EXPECT(ClassFinalizer::FinalizePendingClasses());
59 Class& cls = Class::Handle(
60 lib.LookupClass(String::Handle(String::NewSymbol("A"))));
61 EXPECT(!cls.IsNull());
62 String& name = String::Handle(String::New("foo"));
63 Function& function = Function::Handle(cls.LookupStaticFunction(name));
64 EXPECT(!function.IsNull());
65 GrowableArray<const Object*> arguments;
66 const Array& kNoArgumentNames = Array::Handle();
67 const Object& retval = Object::Handle(
68 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
69 EXPECT(retval.IsError());
70 Error& error = Error::Handle();
71 error ^= retval.raw();
72 EXPECT_SUBSTRING("++++", error.ToErrorCString());
73 }
74
75
76 TEST_CASE(InvokeDynamic_CompileError) {
77 const char* kScriptChars =
78 "class A {\n"
79 " foo() { return ++++; }\n"
80 "}\n";
81 String& url = String::Handle(String::New("dart-test:DartEntry"));
82 String& source = String::Handle(String::New(kScriptChars));
83 Script& script = Script::Handle(Script::New(url, source, RawScript::kScript));
84 Library& lib = Library::Handle(Library::CoreLibrary());
85 EXPECT_EQ(true, CompilerTest::TestCompileScript(lib, script));
86 EXPECT(ClassFinalizer::FinalizePendingClasses());
87 Class& cls = Class::Handle(
88 lib.LookupClass(String::Handle(String::NewSymbol("A"))));
89 EXPECT(!cls.IsNull());
90
91 // Invoke the constructor.
92 const Instance& instance = Instance::Handle(Instance::New(cls));
93 GrowableArray<const Object*> constructor_arguments(2);
94 constructor_arguments.Add(&instance);
95 constructor_arguments.Add(&Smi::Handle(Smi::New(Function::kCtorPhaseAll)));
96 String& constructor_name = String::Handle(String::NewSymbol("A."));
97 Function& constructor =
98 Function::Handle(cls.LookupConstructor(constructor_name));
99 ASSERT(!constructor.IsNull());
100 const Array& kNoArgumentNames = Array::Handle();
101 DartEntry::InvokeStatic(constructor, constructor_arguments, kNoArgumentNames);
102
103 // Call foo.
104 String& name = String::Handle(String::New("foo"));
105 Function& function = Function::Handle(cls.LookupDynamicFunction(name));
106 EXPECT(!function.IsNull());
107 GrowableArray<const Object*> arguments;
108 const Object& retval = Object::Handle(
109 DartEntry::InvokeDynamic(
110 instance, function, arguments, kNoArgumentNames));
111 EXPECT(retval.IsError());
112 Error& error = Error::Handle();
113 error ^= retval.raw();
114 EXPECT_SUBSTRING("++++", error.ToErrorCString());
115 }
116
117 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64. 46 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64.
118 47
119 } // namespace dart 48 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_entry.cc ('k') | runtime/vm/debugger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698