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

Side by Side Diff: tests/language/void_type5_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 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: error
30 a.bar(voidFun);
31 Expect.equals(null, a.xAsObject());
32 a.x = a.bar(voidFun); /// 01: error
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
« tests/language/void_type4_test.dart ('K') | « tests/language/void_type4_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698