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

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

Issue 11125005: Support for type dynamic in VM (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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
« no previous file with comments | « tests/language/closure_type_test.dart ('k') | tests/language/factory2_negative_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 // 4 //
5 // Dart test program testing the use of 'Dynamic' in generic types. 5 // Dart test program testing the use of 'dynamic' in generic types.
6 // @static-clean 6 // @static-clean
7 7
8 interface Iface<K,V> { 8 interface Iface<K,V> {
9 } 9 }
10 10
11 class M1<K, V> implements Iface<K, V> { 11 class M1<K, V> implements Iface<K, V> {
12 } 12 }
13 13
14 class M2<K> implements Iface<K, Dynamic> { 14 class M2<K> implements Iface<K, dynamic> {
15 } 15 }
16 16
17 class M3 implements Iface<String, Dynamic> { 17 class M3 implements Iface<String, dynamic> {
18 } 18 }
19 19
20 typedef Dynamic F1<T>(Dynamic x, T y); 20 typedef dynamic F1<T>(dynamic x, T y);
21 21
22 class HasFieldDynamic { 22 class HasFieldDynamic {
23 HasFieldDynamic() : Dynamic = "Dynamic" { } 23 HasFieldDynamic() : dynamic = "dynamic" { }
24 var Dynamic; // Field named Dynamic is allowed. 24 var dynamic; // Field named dynamic is allowed.
25 } 25 }
26 26
27 class HasMethodDynamic { 27 class HasMethodDynamic {
28 Dynamic() => "Dynamic"; // Method named Dynamic is allowed. 28 dynamic() => "dynamic"; // Method named dynamic is allowed.
29 } 29 }
30 30
31 main() { 31 main() {
32 M1<Dynamic, Dynamic> m1 = new M1<Dynamic, Dynamic>(); 32 M1<dynamic, dynamic> m1 = new M1<dynamic, dynamic>();
33 Expect.isTrue(m1 is Iface<Dynamic, num>); 33 Expect.isTrue(m1 is Iface<dynamic, num>);
34 Expect.isTrue(m1 is Iface<String, Dynamic>); 34 Expect.isTrue(m1 is Iface<String, dynamic>);
35 Expect.isTrue(m1 is Iface<String, num>); 35 Expect.isTrue(m1 is Iface<String, num>);
36 Expect.isTrue(m1 is Iface<num, String>); 36 Expect.isTrue(m1 is Iface<num, String>);
37 37
38 M2<Dynamic> m2 = new M2<Dynamic>(); 38 M2<dynamic> m2 = new M2<dynamic>();
39 Expect.isTrue(m2 is Iface<Dynamic, num>); 39 Expect.isTrue(m2 is Iface<dynamic, num>);
40 Expect.isTrue(m2 is Iface<String, Dynamic>); 40 Expect.isTrue(m2 is Iface<String, dynamic>);
41 Expect.isTrue(m2 is Iface<String, num>); 41 Expect.isTrue(m2 is Iface<String, num>);
42 Expect.isTrue(m2 is Iface<num, String>); 42 Expect.isTrue(m2 is Iface<num, String>);
43 43
44 M3 m3 = new M3(); 44 M3 m3 = new M3();
45 Expect.isTrue(m3 is Iface<Dynamic, num>); 45 Expect.isTrue(m3 is Iface<dynamic, num>);
46 Expect.isTrue(m3 is Iface<String, Dynamic>); 46 Expect.isTrue(m3 is Iface<String, dynamic>);
47 Expect.isTrue(m3 is Iface<String, num>); 47 Expect.isTrue(m3 is Iface<String, num>);
48 Expect.isTrue(m3 is !Iface<num, String>); 48 Expect.isTrue(m3 is !Iface<num, String>);
49 49
50 F1<int> f1 = (String s, int i) => s[i]; 50 F1<int> f1 = (String s, int i) => s[i];
51 Expect.isTrue(f1 is F1<int>); 51 Expect.isTrue(f1 is F1<int>);
52 52
53 HasFieldDynamic has_field = new HasFieldDynamic(); 53 HasFieldDynamic has_field = new HasFieldDynamic();
54 Expect.equals("Dynamic", has_field.Dynamic); 54 Expect.equals("dynamic", has_field.dynamic);
55 55
56 HasMethodDynamic has_method = new HasMethodDynamic(); 56 HasMethodDynamic has_method = new HasMethodDynamic();
57 Expect.equals("Dynamic", has_method.Dynamic()); 57 Expect.equals("dynamic", has_method.dynamic());
58 58
59 { 59 {
60 int Dynamic = 0; // Local variable named Dynamic is allowed. 60 int dynamic = 0; // Local variable named dynamic is allowed.
61 Expect.equals(0, Dynamic); 61 Expect.equals(0, dynamic);
62 } 62 }
63 } 63 }
OLDNEW
« no previous file with comments | « tests/language/closure_type_test.dart ('k') | tests/language/factory2_negative_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698