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

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

Issue 12334070: Support runtime check of function types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013, 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 // Dart test program for constructors and initializers.
5
6 // Check function subtyping.
7
8 import 'package:expect/expect.dart';
9
10 class C<T> {}
11
12 typedef _();
13 typedef void void_();
14 typedef void void_2();
15 typedef int int_();
16 typedef int int_2();
17 typedef Object Object_();
18 typedef double double_();
19 typedef void void__int(int i);
20 typedef int int__int(int i);
21 typedef int int__int2(int i);
22 typedef int int__Object(Object o);
23 typedef Object Object__int(int i);
24 typedef int int__double(double d);
25 typedef int int__int_int(int i1, int i2);
26 typedef void inline_void_(void f());
27 typedef void inline_void__int(void f(int i));
28
29 main() {
30 // () -> int <: Function
31 Expect.isTrue(new C<int_>() is C<Function>);
32 // Function <: () -> int
33 Expect.isFalse(new C<Function>() is C<int_>);
34 // () -> dynamic <: () -> dynamic
35 Expect.isTrue(new C<_>() is C<_>);
36 // () -> dynamic <: () -> void
37 Expect.isTrue(new C<_>() is C<void_>);
38 // () -> void <: () -> dynamic
39 Expect.isTrue(new C<void_>() is C<_>);
40 // () -> int <: () -> void
41 Expect.isTrue(new C<int_>() is C<void_>);
42 // () -> void <: () -> int
43 Expect.isFalse(new C<void_>() is C<int_>);
44 // () -> void <: () -> void
45 Expect.isTrue(new C<void_>() is C<void_2>);
46 // () -> int <: () -> int
47 Expect.isTrue(new C<int_>() is C<int_2>);
48 // () -> int <: () -> Object
49 Expect.isTrue(new C<int_>() is C<Object_>);
50 // () -> int <: () -> double
51 Expect.isFalse(new C<int_>() is C<double_>);
52 // () -> int <: (int) -> void
53 Expect.isFalse(new C<int_>() is C<void__int>);
54 // () -> void <: (int) -> int
55 Expect.isFalse(new C<void_>() is C<int__int>);
56 // () -> void <: (int) -> void
57 Expect.isFalse(new C<void_>() is C<void__int>);
58 // (int) -> int <: (int) -> int
59 Expect.isTrue(new C<int__int>() is C<int__int2>);
60 // (Object) -> int <: (int) -> Object
61 Expect.isTrue(new C<int__Object>() is C<Object__int>);
62 // (int) -> int <: (double) -> int
63 Expect.isFalse(new C<int__int>() is C<int__double>);
64 // () -> int <: (int) -> int
65 Expect.isFalse(new C<int_>() is C<int__int>);
66 // (int) -> int <: (int,int) -> int
67 Expect.isFalse(new C<int__int>() is C<int__int_int>);
68 // (int,int) -> int <: (int) -> int
69 Expect.isFalse(new C<int__int_int>() is C<int__int>);
70 // (()->void) -> void <: ((int)->void) -> void
71 Expect.isFalse(new C<inline_void_>() is C<inline_void__int>);
72 // ((int)->void) -> void <: (()->void) -> void
73 Expect.isFalse(new C<inline_void__int>() is C<inline_void_>);
74 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698