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

Side by Side Diff: tests/language_strong/call_through_null_getter_test.dart

Issue 2998493002: Migrate language block 45 - call_argument ... call_with. (Closed)
Patch Set: Merge branch 'master' into migrate-45 Created 3 years, 4 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
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
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.
4
5 import "package:expect/expect.dart";
6
7 // Tests that we can call functions through getters which return null.
8
9 const TOP_LEVEL_NULL = null;
10
11 var topLevel;
12
13 class CallThroughNullGetterTest {
14 static void testMain() {
15 testTopLevel();
16 testField();
17 testGetter();
18 testMethod();
19 }
20
21 static void testTopLevel() {
22 topLevel = null;
23 expectThrowsNoSuchMethodError(() {
24 topLevel();
25 });
26 expectThrowsNoSuchMethodError(() {
27 (topLevel)();
28 });
29 expectThrowsNoSuchMethodError(() {
30 TOP_LEVEL_NULL();
31 });
32 expectThrowsNoSuchMethodError(() {
33 (TOP_LEVEL_NULL)();
34 });
35 }
36
37 static void testField() {
38 A a = new A();
39
40 a.field = null;
41 expectThrowsNoSuchMethodError(() {
42 a.field();
43 });
44 expectThrowsNoSuchMethodError(() {
45 (a.field)();
46 });
47 }
48
49 static void testGetter() {
50 A a = new A();
51
52 a.field = null;
53 expectThrowsNoSuchMethodError(() {
54 a.getter();
55 });
56 expectThrowsNoSuchMethodError(() {
57 (a.getter)();
58 });
59 }
60
61 static void testMethod() {
62 A a = new A();
63
64 a.field = null;
65 expectThrowsNoSuchMethodError(() {
66 a.method()();
67 });
68 }
69
70 static void expectThrowsNoSuchMethodError(fn) {
71 Expect.throws(
72 fn, (e) => e is NoSuchMethodError, "Should throw NoSuchMethodError");
73 }
74 }
75
76 class A {
77 A() {}
78 var field;
79 get getter {
80 return field;
81 }
82
83 method() {
84 return field;
85 }
86 }
87
88 main() {
89 CallThroughNullGetterTest.testMain();
90 }
OLDNEW
« no previous file with comments | « tests/language_strong/call_through_getter_test.dart ('k') | tests/language_strong/call_type_literal_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698