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

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

Issue 12334070: Support runtime check of function types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor fix 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 for local functions on generic type against generic
7 // typedefs.
8
9 import 'package:expect/expect.dart';
10
11 typedef int Foo<T>(T a, [String b]);
12 typedef int Bar<T>(T a, [String b]);
13 typedef int Baz<T>(T a, {String b});
14 typedef int Boz<T>(T a);
15 typedef int Biz<T>(T a, int b);
16
17 class C<T> {
18 void test(String nameOfT, bool expectedResult) {
19 int foo(bool a, [String b]) => null;
20 int baz(bool a, {String b}) => null;
21
22 Expect.equals(expectedResult, foo is Foo<T>, 'foo is Foo<$nameOfT>');
23 Expect.equals(expectedResult, foo is Bar<T>, 'foo is Bar<$nameOfT>');
24 Expect.isFalse(foo is Baz<T>, 'foo is Baz<$nameOfT>');
25 Expect.equals(expectedResult, foo is Boz<T>, 'foo is Boz<$nameOfT>');
26 Expect.isFalse(foo is Biz<T>, 'foo is Biz<$nameOfT>');
27
28 Expect.isFalse(baz is Foo<T>, 'baz is Foo<$nameOfT>');
29 Expect.isFalse(baz is Bar<T>, 'baz is Bar<$nameOfT>');
30 Expect.equals(expectedResult, baz is Baz<T>, 'baz is Baz<$nameOfT>');
31 Expect.equals(expectedResult, baz is Boz<T>, 'baz is Boz<$nameOfT>');
32 Expect.isFalse(baz is Biz<T>, 'bar is Biz<$nameOfT>');
33 }
34 }
35
36 class D<S,T> extends C<T> {}
37
38 main() {
39 new D<String, bool>().test('bool', true);
40 new D<bool, int>().test('int', false);
41 new D().test('dynamic', true);
42 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698