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

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

Issue 2699073003: Support `void` as generic argument.
Patch Set: Shuffle things around to have a better `voidRti` locality. Created 3 years, 7 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
« no previous file with comments | « tests/language/void_type4_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 class A<T> {
10 T x;
11 foo(T x) {}
12 T bar(T f()) {
13 T tmp = f();
14 return tmp;
15 }
16
17 gee(T f()) {
18 x = bar(f);
19 }
20
21 Object xAsObject() => x;
22 }
23
24 void voidFun() => 499;
25 int intFun() => 42;
26
27 main() {
28 A<void> a = new A<void>();
29 a.foo(a.x); /// 00: static type warning
30 a.bar(voidFun);
31 Expect.equals(null, a.xAsObject());
32 a.x = a.bar(voidFun); /// 01: static type warning
33 a.gee(voidFun); // But we can do it through `gee`.
34 Expect.equals(499, a.xAsObject());
35 a.gee(intFun); // We can also pass in an int function.
36 Expect.equals(42, a.xAsObject());
37 }
OLDNEW
« no previous file with comments | « tests/language/void_type4_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698