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

Unified Diff: dart/tests/compiler/dart2js_native/type_error_decode_test.dart

Issue 11973018: Improve decoding of JS TypeError. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update status files Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: dart/tests/compiler/dart2js_native/type_error_decode_test.dart
diff --git a/dart/tests/compiler/dart2js_native/type_error_decode_test.dart b/dart/tests/compiler/dart2js_native/type_error_decode_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5b70c4dc64089b386a94e8e9478c0715713fdb3a
--- /dev/null
+++ b/dart/tests/compiler/dart2js_native/type_error_decode_test.dart
@@ -0,0 +1,51 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library test.type_error_decode_test;
+
+import 'package:expect/expect.dart';
+
+import 'dart:_js_helper';
+
+class Foo {
+ var field;
+}
+
+isNullError(e, trace) {
+ print('$e\nTrace: $trace');
+ return e is NullError;
+}
+
+isJsNoSuchMethodError(e, trace) {
+ print('$e\nTrace: $trace');
+ return e is JsNoSuchMethodError;
+}
+
+expectThrows(f, check) {
+ try {
+ f();
+ } catch (e, trace) {
+ if (check(e, trace)) {
+ return;
+ }
+ throw 'Unexpected exception: $e\n$trace';
+ }
+ throw 'No exception thrown';
+}
+
+main() {
+ var x = null;
+ var z = new Object();
+ var v = new List(1)[0];
+ var s = "Cannot call method 'foo' of null";
+ var nul = null;
+ var f = new Foo();
+ [].forEach((y) => f.field = nul = s = x = z = v = y);
ngeoffray 2013/07/22 09:08:56 What is this line for? Please add a comment.
ahe 2013/07/22 10:45:27 Done.
+ expectThrows(() => x.fisk(), isNullError);
+ expectThrows(() => v.fisk(), isNullError);
+ expectThrows(() => z.fisk(), isJsNoSuchMethodError);
+ expectThrows(() => s.fisk(), isJsNoSuchMethodError);
+ expectThrows(() => null(), isNullError);
+ expectThrows(() => f.field(), isNullError);
+}

Powered by Google App Engine
This is Rietveld 408576698