OLD | NEW |
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 // Test that instanceof works correctly with type variables. | 4 // Test that instanceof works correctly with type variables. |
5 | 5 |
6 class Foo<T> { | 6 class Foo<T> { |
7 Foo() {} | 7 Foo() {} |
8 | 8 |
9 bool isT(x) { // Untyped parameter to ensure that the static type | 9 bool isT(x) { // Untyped parameter to ensure that the static type |
10 // does not affect the result. | 10 // does not affect the result. |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 // Not providing a type argument to ensure that the static type | 31 // Not providing a type argument to ensure that the static type |
32 // does not affect the result. | 32 // does not affect the result. |
33 { | 33 { |
34 Foo foo = new Foo<String>(); | 34 Foo foo = new Foo<String>(); |
35 Expect.equals(true, foo.isT("string")); | 35 Expect.equals(true, foo.isT("string")); |
36 Expect.equals(false, foo.isT(1)); | 36 Expect.equals(false, foo.isT(1)); |
37 } | 37 } |
38 { | 38 { |
39 Foo foo = new Foo(); | 39 Foo foo = new Foo(); |
40 Expect.equals(true, foo.isT(new List.fixedLength(5))); | 40 Expect.equals(true, foo.isT(new List(5))); |
41 Expect.equals(true, foo.isT(new List<Object>.fixedLength(5))); | 41 Expect.equals(true, foo.isT(new List<Object>(5))); |
42 Expect.equals(true, foo.isT(new List<int>.fixedLength(5))); | 42 Expect.equals(true, foo.isT(new List<int>(5))); |
43 Expect.equals(true, foo.isT(new List<num>.fixedLength(5))); | 43 Expect.equals(true, foo.isT(new List<num>(5))); |
44 Expect.equals(true, foo.isT(new List<String>.fixedLength(5))); | 44 Expect.equals(true, foo.isT(new List<String>(5))); |
45 } | 45 } |
46 { | 46 { |
47 Foo foo = new Foo<List>(); | 47 Foo foo = new Foo<List>(); |
48 Expect.equals(true, foo.isT(new List.fixedLength(5))); | 48 Expect.equals(true, foo.isT(new List(5))); |
49 Expect.equals(true, foo.isT(new List<Object>.fixedLength(5))); | 49 Expect.equals(true, foo.isT(new List<Object>(5))); |
50 Expect.equals(true, foo.isT(new List<int>.fixedLength(5))); | 50 Expect.equals(true, foo.isT(new List<int>(5))); |
51 Expect.equals(true, foo.isT(new List<num>.fixedLength(5))); | 51 Expect.equals(true, foo.isT(new List<num>(5))); |
52 Expect.equals(true, foo.isT(new List<String>.fixedLength(5))); | 52 Expect.equals(true, foo.isT(new List<String>(5))); |
53 } | 53 } |
54 { | 54 { |
55 Foo foo = new Foo<List<Object>>(); | 55 Foo foo = new Foo<List<Object>>(); |
56 Expect.equals(true, foo.isT(new List.fixedLength(5))); | 56 Expect.equals(true, foo.isT(new List(5))); |
57 Expect.equals(true, foo.isT(new List<Object>.fixedLength(5))); | 57 Expect.equals(true, foo.isT(new List<Object>(5))); |
58 Expect.equals(true, foo.isT(new List<int>.fixedLength(5))); | 58 Expect.equals(true, foo.isT(new List<int>(5))); |
59 Expect.equals(true, foo.isT(new List<num>.fixedLength(5))); | 59 Expect.equals(true, foo.isT(new List<num>(5))); |
60 Expect.equals(true, foo.isT(new List<String>.fixedLength(5))); | 60 Expect.equals(true, foo.isT(new List<String>(5))); |
61 } | 61 } |
62 { | 62 { |
63 Foo foo = new Foo<List<int>>(); | 63 Foo foo = new Foo<List<int>>(); |
64 Expect.equals(true, foo.isT(new List.fixedLength(5))); | 64 Expect.equals(true, foo.isT(new List(5))); |
65 Expect.equals(false, foo.isT(new List<Object>.fixedLength(5))); | 65 Expect.equals(false, foo.isT(new List<Object>(5))); |
66 Expect.equals(true, foo.isT(new List<int>.fixedLength(5))); | 66 Expect.equals(true, foo.isT(new List<int>(5))); |
67 Expect.equals(false, foo.isT(new List<num>.fixedLength(5))); | 67 Expect.equals(false, foo.isT(new List<num>(5))); |
68 Expect.equals(false, foo.isT(new List<String>.fixedLength(5))); | 68 Expect.equals(false, foo.isT(new List<String>(5))); |
69 } | 69 } |
70 { | 70 { |
71 Foo foo = new Foo<List<num>>(); | 71 Foo foo = new Foo<List<num>>(); |
72 Expect.equals(true, foo.isT(new List.fixedLength(5))); | 72 Expect.equals(true, foo.isT(new List(5))); |
73 Expect.equals(false, foo.isT(new List<Object>.fixedLength(5))); | 73 Expect.equals(false, foo.isT(new List<Object>(5))); |
74 Expect.equals(true, foo.isT(new List<int>.fixedLength(5))); | 74 Expect.equals(true, foo.isT(new List<int>(5))); |
75 Expect.equals(true, foo.isT(new List<num>.fixedLength(5))); | 75 Expect.equals(true, foo.isT(new List<num>(5))); |
76 Expect.equals(false, foo.isT(new List<String>.fixedLength(5))); | 76 Expect.equals(false, foo.isT(new List<String>(5))); |
77 } | 77 } |
78 { | 78 { |
79 Foo foo = new Foo<List<String>>(); | 79 Foo foo = new Foo<List<String>>(); |
80 Expect.equals(true, foo.isT(new List.fixedLength(5))); | 80 Expect.equals(true, foo.isT(new List(5))); |
81 Expect.equals(false, foo.isT(new List<Object>.fixedLength(5))); | 81 Expect.equals(false, foo.isT(new List<Object>(5))); |
82 Expect.equals(false, foo.isT(new List<int>.fixedLength(5))); | 82 Expect.equals(false, foo.isT(new List<int>(5))); |
83 Expect.equals(false, foo.isT(new List<num>.fixedLength(5))); | 83 Expect.equals(false, foo.isT(new List<num>(5))); |
84 Expect.equals(true, foo.isT(new List<String>.fixedLength(5))); | 84 Expect.equals(true, foo.isT(new List<String>(5))); |
85 } | 85 } |
86 { | 86 { |
87 Foo foo = new Foo(); | 87 Foo foo = new Foo(); |
88 Expect.equals(true, foo.isListT(new List.fixedLength(5))); | 88 Expect.equals(true, foo.isListT(new List(5))); |
89 Expect.equals(true, foo.isListT(new List<Object>.fixedLength(5))); | 89 Expect.equals(true, foo.isListT(new List<Object>(5))); |
90 Expect.equals(true, foo.isListT(new List<int>.fixedLength(5))); | 90 Expect.equals(true, foo.isListT(new List<int>(5))); |
91 Expect.equals(true, foo.isListT(new List<num>.fixedLength(5))); | 91 Expect.equals(true, foo.isListT(new List<num>(5))); |
92 Expect.equals(true, foo.isListT(new List<String>.fixedLength(5))); | 92 Expect.equals(true, foo.isListT(new List<String>(5))); |
93 } | 93 } |
94 { | 94 { |
95 Foo foo = new Foo<Object>(); | 95 Foo foo = new Foo<Object>(); |
96 Expect.equals(true, foo.isListT(new List.fixedLength(5))); | 96 Expect.equals(true, foo.isListT(new List(5))); |
97 Expect.equals(true, foo.isListT(new List<Object>.fixedLength(5))); | 97 Expect.equals(true, foo.isListT(new List<Object>(5))); |
98 Expect.equals(true, foo.isListT(new List<int>.fixedLength(5))); | 98 Expect.equals(true, foo.isListT(new List<int>(5))); |
99 Expect.equals(true, foo.isListT(new List<num>.fixedLength(5))); | 99 Expect.equals(true, foo.isListT(new List<num>(5))); |
100 Expect.equals(true, foo.isListT(new List<String>.fixedLength(5))); | 100 Expect.equals(true, foo.isListT(new List<String>(5))); |
101 } | 101 } |
102 { | 102 { |
103 Foo foo = new Foo<int>(); | 103 Foo foo = new Foo<int>(); |
104 Expect.equals(true, foo.isListT(new List.fixedLength(5))); | 104 Expect.equals(true, foo.isListT(new List(5))); |
105 Expect.equals(false, foo.isListT(new List<Object>.fixedLength(5))); | 105 Expect.equals(false, foo.isListT(new List<Object>(5))); |
106 Expect.equals(true, foo.isListT(new List<int>.fixedLength(5))); | 106 Expect.equals(true, foo.isListT(new List<int>(5))); |
107 Expect.equals(false, foo.isListT(new List<num>.fixedLength(5))); | 107 Expect.equals(false, foo.isListT(new List<num>(5))); |
108 Expect.equals(false, foo.isListT(new List<String>.fixedLength(5))); | 108 Expect.equals(false, foo.isListT(new List<String>(5))); |
109 } | 109 } |
110 { | 110 { |
111 Foo foo = new Foo<num>(); | 111 Foo foo = new Foo<num>(); |
112 Expect.equals(true, foo.isListT(new List.fixedLength(5))); | 112 Expect.equals(true, foo.isListT(new List(5))); |
113 Expect.equals(false, foo.isListT(new List<Object>.fixedLength(5))); | 113 Expect.equals(false, foo.isListT(new List<Object>(5))); |
114 Expect.equals(true, foo.isListT(new List<int>.fixedLength(5))); | 114 Expect.equals(true, foo.isListT(new List<int>(5))); |
115 Expect.equals(true, foo.isListT(new List<num>.fixedLength(5))); | 115 Expect.equals(true, foo.isListT(new List<num>(5))); |
116 Expect.equals(false, foo.isListT(new List<String>.fixedLength(5))); | 116 Expect.equals(false, foo.isListT(new List<String>(5))); |
117 } | 117 } |
118 { | 118 { |
119 Foo foo = new Foo<String>(); | 119 Foo foo = new Foo<String>(); |
120 Expect.equals(true, foo.isListT(new List.fixedLength(5))); | 120 Expect.equals(true, foo.isListT(new List(5))); |
121 Expect.equals(false, foo.isListT(new List<Object>.fixedLength(5))); | 121 Expect.equals(false, foo.isListT(new List<Object>(5))); |
122 Expect.equals(false, foo.isListT(new List<int>.fixedLength(5))); | 122 Expect.equals(false, foo.isListT(new List<int>(5))); |
123 Expect.equals(false, foo.isListT(new List<num>.fixedLength(5))); | 123 Expect.equals(false, foo.isListT(new List<num>(5))); |
124 Expect.equals(true, foo.isListT(new List<String>.fixedLength(5))); | 124 Expect.equals(true, foo.isListT(new List<String>(5))); |
125 } | 125 } |
126 } | 126 } |
127 } | 127 } |
OLD | NEW |