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" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 lib.LookupClass(String::Handle(String::NewSymbol("A")))); | 61 lib.LookupClass(String::Handle(String::NewSymbol("A")))); |
62 EXPECT(!cls.IsNull()); | 62 EXPECT(!cls.IsNull()); |
63 String& name = String::Handle(String::New("foo")); | 63 String& name = String::Handle(String::New("foo")); |
64 Function& function = Function::Handle(cls.LookupStaticFunction(name)); | 64 Function& function = Function::Handle(cls.LookupStaticFunction(name)); |
65 EXPECT(!function.IsNull()); | 65 EXPECT(!function.IsNull()); |
66 GrowableArray<const Object*> arguments; | 66 GrowableArray<const Object*> arguments; |
67 const Array& kNoArgumentNames = Array::Handle(); | 67 const Array& kNoArgumentNames = Array::Handle(); |
68 const Object& retval = Object::Handle( | 68 const Object& retval = Object::Handle( |
69 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); | 69 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); |
70 EXPECT(retval.IsError()); | 70 EXPECT(retval.IsError()); |
71 Error& error = Error::Handle(); | 71 EXPECT_SUBSTRING("++++", Error::Cast(retval).ToErrorCString()); |
72 error ^= retval.raw(); | |
73 EXPECT_SUBSTRING("++++", error.ToErrorCString()); | |
74 } | 72 } |
75 | 73 |
76 | 74 |
77 TEST_CASE(InvokeDynamic_CompileError) { | 75 TEST_CASE(InvokeDynamic_CompileError) { |
78 const char* kScriptChars = | 76 const char* kScriptChars = |
79 "class A {\n" | 77 "class A {\n" |
80 " foo() { return ++++; }\n" | 78 " foo() { return ++++; }\n" |
81 "}\n"; | 79 "}\n"; |
82 String& url = String::Handle(String::New("dart-test:DartEntry")); | 80 String& url = String::Handle(String::New("dart-test:DartEntry")); |
83 String& source = String::Handle(String::New(kScriptChars)); | 81 String& source = String::Handle(String::New(kScriptChars)); |
(...skipping 19 matching lines...) Expand all Loading... |
103 | 101 |
104 // Call foo. | 102 // Call foo. |
105 String& name = String::Handle(String::New("foo")); | 103 String& name = String::Handle(String::New("foo")); |
106 Function& function = Function::Handle(cls.LookupDynamicFunction(name)); | 104 Function& function = Function::Handle(cls.LookupDynamicFunction(name)); |
107 EXPECT(!function.IsNull()); | 105 EXPECT(!function.IsNull()); |
108 GrowableArray<const Object*> arguments; | 106 GrowableArray<const Object*> arguments; |
109 const Object& retval = Object::Handle( | 107 const Object& retval = Object::Handle( |
110 DartEntry::InvokeDynamic( | 108 DartEntry::InvokeDynamic( |
111 instance, function, arguments, kNoArgumentNames)); | 109 instance, function, arguments, kNoArgumentNames)); |
112 EXPECT(retval.IsError()); | 110 EXPECT(retval.IsError()); |
113 Error& error = Error::Handle(); | 111 EXPECT_SUBSTRING("++++", Error::Cast(retval).ToErrorCString()); |
114 error ^= retval.raw(); | |
115 EXPECT_SUBSTRING("++++", error.ToErrorCString()); | |
116 } | 112 } |
117 | 113 |
118 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64. | 114 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64. |
119 | 115 |
120 } // namespace dart | 116 } // namespace dart |
OLD | NEW |