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

Side by Side Diff: tests/language/void_type3_test.dart

Issue 2707933002: Tests for `void`.
Patch Set: Address comments. Created 3 years, 10 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) 2017, 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 // Dart test for type checks involving the void type.
6
7 import 'package:expect/expect.dart';
8
9 typedef F = void Function(Object);
10 typedef F2 = void Function([Object]);
11 typedef F3 = void Function({Object x});
12
13 typedef G = void Function(void);
14 typedef G2 = void Function([void]);
15 typedef G3 = void Function({void x});
16
17 typedef H = int Function(void);
18 typedef H2 = int Function([void]);
19 typedef H3 = int Function({void x});
20
21 void f(Object x) {}
22 void f2([Object x]) {}
23 void f3({Object x}) {}
24
25 void g(void x) {}
26 void g2([void x]) {}
27 void g3({void x}) {}
28
29 int h(void x) => 499;
30 int h2([void x]) => 499;
31 int h3({void x}) => 499;
32
33 void expectsF(F f) {}
34 void expectsG(G g) {}
35 void expectsH(H h) {}
36
37 void expectsF2(F2 f) {}
38 void expectsG2(G2 g) {}
39 void expectsH2(H2 h) {}
40
41 void expectsF3(F3 f) {}
42 void expectsG3(G3 g) {}
43 void expectsH3(H3 h) {}
44
45 main() {
46 Expect.isTrue(f is F);
47 Expect.isTrue(f is G);
48 Expect.isFalse(f is H);
49 expectsF(f);
50 expectsG(f);
51 expectsH(f); /// 00: error
52
53 Expect.isTrue(f2 is F2);
54 Expect.isTrue(f2 is G2);
55 Expect.isFalse(f2 is H2);
56 expectsF2(f2);
57 expectsG2(f2);
58 expectsH2(f2); /// 01: error
59
60 Expect.isTrue(f3 is F3);
61 Expect.isTrue(f3 is G3);
62 Expect.isFalse(f3 is H3);
63 expectsF3(f3);
64 expectsG3(f3);
65 expectsH3(f3); /// 03: error
66
67 Expect.isTrue(g is F);
68 Expect.isTrue(g is G);
69 Expect.isFalse(g is H);
70 expectsF(g); /// 04: error
eernst 2017/07/10 16:05:34 I cannot see how this could be an error. It would
71 expectsG(g);
72 expectsH(g); /// 05: error
73
74 Expect.isTrue(g2 is F2);
75 Expect.isTrue(g2 is G2);
76 Expect.isFalse(g2 is H2);
77 expectsF2(g2); /// 06: error
eernst 2017/07/10 16:05:34 Same as line 70.
78 expectsG2(g2);
79 expectsH2(g2); /// 07: error
80
81 Expect.isTrue(g3 is F3);
82 Expect.isTrue(g3 is G3);
83 Expect.isFalse(g3 is H3);
84 expectsF3(g3); /// 08: error
eernst 2017/07/10 16:05:34 Same as line 70.
85 expectsG3(g3);
86 expectsH3(g3); /// 09: error
87
88 Expect.isTrue(h is F);
89 Expect.isTrue(h is G);
90 Expect.isTrue(h is H);
91 expectsF(h);
92 expectsG(h);
93 expectsH(h);
94
95 Expect.isTrue(h2 is H2);
96 Expect.isTrue(h2 is G2);
97 Expect.isTrue(h2 is H2);
98 expectsF(h2);
99 expectsG(h2);
100 expectsH(h2);
101
102 Expect.isTrue(h3 is H3);
103 Expect.isTrue(h3 is G3);
104 Expect.isTrue(h3 is H3);
105 expectsF(h3);
106 expectsG(h3);
107 expectsH(h3);
108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698