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

Unified Diff: tests/language/call_through_null_getter_test.dart

Issue 11415028: Remove NullPointerException. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed VM bugs. Created 8 years, 1 month 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: tests/language/call_through_null_getter_test.dart
diff --git a/tests/language/call_through_null_getter_test.dart b/tests/language/call_through_null_getter_test.dart
index 05024964b817595059a0ad24df89482e4a4cbea8..24edb033c28689378035b91e40b2182f80e83c84 100644
--- a/tests/language/call_through_null_getter_test.dart
+++ b/tests/language/call_through_null_getter_test.dart
@@ -19,57 +19,39 @@ class CallThroughNullGetterTest {
static void testTopLevel() {
topLevel = null;
- expectThrowsNullPointerException(() { topLevel(); });
- expectThrowsNullPointerException(() { (topLevel)(); });
- expectThrowsNullPointerException(() { TOP_LEVEL_NULL(); });
- expectThrowsNullPointerException(() { (TOP_LEVEL_NULL)(); });
+ expectThrowsNoSuchMethodError(() { topLevel(); });
+ expectThrowsNoSuchMethodError(() { (topLevel)(); });
+ expectThrowsNoSuchMethodError(() { TOP_LEVEL_NULL(); });
+ expectThrowsNoSuchMethodError(() { (TOP_LEVEL_NULL)(); });
}
static void testField() {
A a = new A();
a.field = null;
- expectThrowsNullPointerException(() { a.field(); });
- expectThrowsNullPointerException(() { (a.field)(); });
+ expectThrowsNoSuchMethodError(() { a.field(); });
+ expectThrowsNoSuchMethodError(() { (a.field)(); });
}
static void testGetter() {
A a = new A();
a.field = null;
- expectThrowsNullPointerException(() { a.getter(); });
- expectThrowsNullPointerException(() { (a.getter)(); });
+ expectThrowsNoSuchMethodError(() { a.getter(); });
+ expectThrowsNoSuchMethodError(() { (a.getter)(); });
}
static void testMethod() {
A a = new A();
a.field = null;
- expectThrowsNullPointerException(() { a.method()(); });
+ expectThrowsNoSuchMethodError(() { a.method()(); });
}
- static void expectThrowsNullPointerException(fn) {
- var exception = catchException(fn);
- if (exception is! NullPointerException) {
- Expect.fail("Wrong exception. Expected: NullPointerException"
- " got: ${exception}");
- }
+ static void expectThrowsNoSuchMethodError(fn) {
+ Expect.throws(fn, (e) => e is NoSuchMethodError,
+ "Should throw NoSuchMethodError");
}
-
- static catchException(fn) {
- bool caught = false;
- var result = null;
- try {
- fn();
- Expect.equals(true, false); // Shouldn't reach this.
- } catch (e) {
- caught = true;
- result = e;
- }
- Expect.equals(true, caught);
- return result;
- }
-
}

Powered by Google App Engine
This is Rietveld 408576698