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

Side by Side Diff: tests/language/src/DynamicTest.dart

Issue 8403005: Add support for 'Dynamic' type in the VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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/language.status ('k') | tests/language/src/GenericTest.dart » ('j') | 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) 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
3 // BSD-style license that can be found in the LICENSE file.
4 //
5 // Dart test program testing the use of 'Dynamic' in generic types.
6
7 class M1<K, V> implements Map<K, V> {
8 }
9
10 class M2<K> implements Map<K, Dynamic> {
11 }
12
13 class M3 implements Map<String, Dynamic> {
14 }
15
16 typedef Dynamic F1<T>(Dynamic x, T y);
17
18 class HasFieldDynamic {
19 HasFieldDynamic() : Dynamic = "Dynamic" { }
20 var Dynamic; // Field named Dynamic is allowed.
21 }
22
23 class HasMethodDynamic {
24 Dynamic() => "Dynamic"; // Method named Dynamic is allowed.
25 }
26
27 main() {
28 M1<Dynamic, Dynamic> m1 = new M1<Dynamic, Dynamic>();
29 Expect.isTrue(m1 is Map<Dynamic, num>);
30 Expect.isTrue(m1 is Map<String, Dynamic>);
31 Expect.isTrue(m1 is Map<String, num>);
32 Expect.isTrue(m1 is Map<num, String>);
33
34 M2<Dynamic> m2 = new M2<Dynamic>();
35 Expect.isTrue(m2 is Map<Dynamic, num>);
36 Expect.isTrue(m2 is Map<String, Dynamic>);
37 Expect.isTrue(m2 is Map<String, num>);
38 Expect.isTrue(m2 is Map<num, String>);
39
40 M3 m3 = new M3();
41 Expect.isTrue(m3 is Map<Dynamic, num>);
42 Expect.isTrue(m3 is Map<String, Dynamic>);
43 Expect.isTrue(m3 is Map<String, num>);
44 Expect.isTrue(m3 is !Map<num, String>);
45
46 F1<int> f1 = (String s, int i) => s[i];
47 Expect.isTrue(f1 is F1<int>);
48
49 HasFieldDynamic has_field = new HasFieldDynamic();
50 Expect.equals("Dynamic", has_field.Dynamic);
51
52 HasMethodDynamic has_method = new HasMethodDynamic();
53 Expect.equals("Dynamic", has_method.Dynamic());
54
55 {
56 int Dynamic = 0; // Local variable named Dynamic is allowed.
57 Expect.equals(0, Dynamic);
58 }
59 }
OLDNEW
« no previous file with comments | « tests/language/language.status ('k') | tests/language/src/GenericTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698