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

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

Issue 11049038: Change compile-time errors into dynamic errors in instance creation expression (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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/class_finalizer.cc ('k') | runtime/vm/flow_graph_builder.cc » ('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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "platform/json.h" 7 #include "platform/json.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 static Dart_NativeFunction PropagateError_native_lookup( 129 static Dart_NativeFunction PropagateError_native_lookup(
130 Dart_Handle name, int argument_count) { 130 Dart_Handle name, int argument_count) {
131 return reinterpret_cast<Dart_NativeFunction>(&PropagateErrorNative); 131 return reinterpret_cast<Dart_NativeFunction>(&PropagateErrorNative);
132 } 132 }
133 133
134 134
135 TEST_CASE(Dart_PropagateError) { 135 TEST_CASE(Dart_PropagateError) {
136 const char* kScriptChars = 136 const char* kScriptChars =
137 "raiseCompileError() {\n" 137 "raiseCompileError() {\n"
138 " return badIdent;\n" 138 " return missing_semicolon\n"
139 "}\n" 139 "}\n"
140 "\n" 140 "\n"
141 "void throwException() {\n" 141 "void throwException() {\n"
142 " throw new Exception('myException');\n" 142 " throw new Exception('myException');\n"
143 "}\n" 143 "}\n"
144 "\n" 144 "\n"
145 "void nativeFunc(closure) native 'Test_nativeFunc';\n" 145 "void nativeFunc(closure) native 'Test_nativeFunc';\n"
146 "\n" 146 "\n"
147 "void Func1() {\n" 147 "void Func1() {\n"
148 " nativeFunc(() => raiseCompileError());\n" 148 " nativeFunc(() => raiseCompileError());\n"
149 "}\n" 149 "}\n"
150 "\n" 150 "\n"
151 "void Func2() {\n" 151 "void Func2() {\n"
152 " nativeFunc(() => throwException());\n" 152 " nativeFunc(() => throwException());\n"
153 "}\n"; 153 "}\n";
154 Dart_Handle lib = TestCase::LoadTestScript( 154 Dart_Handle lib = TestCase::LoadTestScript(
155 kScriptChars, &PropagateError_native_lookup); 155 kScriptChars, &PropagateError_native_lookup);
156 Dart_Handle result; 156 Dart_Handle result;
157 157
158 result = Dart_Invoke(lib, Dart_NewString("Func1"), 0, NULL); 158 result = Dart_Invoke(lib, Dart_NewString("Func1"), 0, NULL);
159 EXPECT(Dart_IsError(result)); 159 EXPECT(Dart_IsError(result));
160 EXPECT(!Dart_ErrorHasException(result)); 160 EXPECT(!Dart_ErrorHasException(result));
161 EXPECT_SUBSTRING("badIdent", Dart_GetError(result)); 161 EXPECT_SUBSTRING("semicolon expected", Dart_GetError(result));
162 162
163 result = Dart_Invoke(lib, Dart_NewString("Func2"), 0, NULL); 163 result = Dart_Invoke(lib, Dart_NewString("Func2"), 0, NULL);
164 EXPECT(Dart_IsError(result)); 164 EXPECT(Dart_IsError(result));
165 EXPECT(Dart_ErrorHasException(result)); 165 EXPECT(Dart_ErrorHasException(result));
166 EXPECT_SUBSTRING("myException", Dart_GetError(result)); 166 EXPECT_SUBSTRING("myException", Dart_GetError(result));
167 } 167 }
168 168
169 #endif 169 #endif
170 170
171 171
(...skipping 6971 matching lines...) Expand 10 before | Expand all | Expand 10 after
7143 EXPECT(o2 == reinterpret_cast<void*>(&p2)); 7143 EXPECT(o2 == reinterpret_cast<void*>(&p2));
7144 } 7144 }
7145 Dart_ExitScope(); 7145 Dart_ExitScope();
7146 isolate->heap()->CollectGarbage(Heap::kOld); 7146 isolate->heap()->CollectGarbage(Heap::kOld);
7147 EXPECT_EQ(0, isolate->heap()->PeerCount()); 7147 EXPECT_EQ(0, isolate->heap()->PeerCount());
7148 } 7148 }
7149 7149
7150 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 7150 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
7151 7151
7152 } // namespace dart 7152 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698