OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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 // Tests that malformed types are handled as dynamic, and that types with the | 5 // Tests that malformed types are handled as dynamic, and that types with the |
6 // wrong number of type arguments are handled as raw types. | 6 // wrong number of type arguments are handled as raw types. |
7 | 7 |
8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
9 import 'package:expect/expect.dart' as prefix; // Define 'prefix'. | 9 import 'package:expect/expect.dart' as prefix; // Define 'prefix'. |
10 | 10 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 checkAsUnresolved(''); | 70 checkAsUnresolved(''); |
71 checkAsUnresolved(0); | 71 checkAsUnresolved(0); |
72 checkAsListUnresolved(false, ''); | 72 checkAsListUnresolved(false, ''); |
73 checkAsListUnresolved(true, new List()); | 73 checkAsListUnresolved(true, new List()); |
74 checkAsListUnresolved(true, new List<int>()); | 74 checkAsListUnresolved(true, new List<int>()); |
75 checkAsListUnresolved(true, new List<String>()); | 75 checkAsListUnresolved(true, new List<String>()); |
76 checkAsListUnresolved(true, new List<int, String>()); | 76 checkAsListUnresolved(true, new List<int, String>()); |
77 | 77 |
78 checkIsListDynamic(true, []); | 78 checkIsListDynamic(true, []); |
79 checkIsListDynamic(true, <>[]); /// 01: compile-time error | 79 checkIsListDynamic(true, <>[]); //# 01: compile-time error |
80 checkIsListDynamic(false, <int>[]); | 80 checkIsListDynamic(false, <int>[]); |
81 checkIsListDynamic(true, <Unresolved>[]); | 81 checkIsListDynamic(true, <Unresolved>[]); |
82 checkIsListDynamic(true, <Unresolved<int>>[]); | 82 checkIsListDynamic(true, <Unresolved<int>>[]); |
83 checkIsListDynamic(true, <prefix.Unresolved>[]); | 83 checkIsListDynamic(true, <prefix.Unresolved>[]); |
84 checkIsListDynamic(true, <prefix.Unresolved<int>>[]); | 84 checkIsListDynamic(true, <prefix.Unresolved<int>>[]); |
85 checkIsListDynamic(true, <int, String>[]); | 85 checkIsListDynamic(true, <int, String>[]); |
86 | 86 |
87 checkIsListDynamic(true, new List()); | 87 checkIsListDynamic(true, new List()); |
88 checkIsListDynamic(true, new List<>()); /// 02: compile-time error | 88 checkIsListDynamic(true, new List<>()); //# 02: compile-time error |
89 checkIsListDynamic(true, new List<Unresolved>()); | 89 checkIsListDynamic(true, new List<Unresolved>()); |
90 checkIsListDynamic(true, new List<Unresolved<int>>()); | 90 checkIsListDynamic(true, new List<Unresolved<int>>()); |
91 checkIsListDynamic(true, new List<prefix.Unresolved>()); | 91 checkIsListDynamic(true, new List<prefix.Unresolved>()); |
92 checkIsListDynamic(true, new List<prefix.Unresolved<int>>()); | 92 checkIsListDynamic(true, new List<prefix.Unresolved<int>>()); |
93 checkIsListDynamic(true, new List<int, String>()); | 93 checkIsListDynamic(true, new List<int, String>()); |
94 | 94 |
95 checkIsMapDynamic(true, true, <dynamic, dynamic>{}); | 95 checkIsMapDynamic(true, true, <dynamic, dynamic>{}); |
96 checkIsMapDynamic(true, true, {}); | 96 checkIsMapDynamic(true, true, {}); |
97 checkIsMapDynamic(true, true, <>{}); /// 03: compile-time error | 97 checkIsMapDynamic(true, true, <>{}); //# 03: compile-time error |
98 checkIsMapDynamic(true, true, <int>{}); | 98 checkIsMapDynamic(true, true, <int>{}); |
99 checkIsMapDynamic(false, false, <String, int>{}); | 99 checkIsMapDynamic(false, false, <String, int>{}); |
100 checkIsMapDynamic(true, true, <String, int, String>{}); | 100 checkIsMapDynamic(true, true, <String, int, String>{}); |
101 checkIsMapDynamic(true, false, <Unresolved, int>{}); | 101 checkIsMapDynamic(true, false, <Unresolved, int>{}); |
102 checkIsMapDynamic(false, true, <String, Unresolved<int>>{}); | 102 checkIsMapDynamic(false, true, <String, Unresolved<int>>{}); |
103 checkIsMapDynamic(true, false, <prefix.Unresolved, int>{}); | 103 checkIsMapDynamic(true, false, <prefix.Unresolved, int>{}); |
104 checkIsMapDynamic(false, true, <String, prefix.Unresolved<int>>{}); | 104 checkIsMapDynamic(false, true, <String, prefix.Unresolved<int>>{}); |
105 | 105 |
106 checkIsMapDynamic(true, true, new Map()); | 106 checkIsMapDynamic(true, true, new Map()); |
107 checkIsMapDynamic(true, true, new Map<>); /// 04: compile-time error | 107 checkIsMapDynamic(true, true, new Map<>); //# 04: compile-time error |
108 checkIsMapDynamic(true, true, new Map<int>()); | 108 checkIsMapDynamic(true, true, new Map<int>()); |
109 checkIsMapDynamic(false, false, new Map<String, int>()); | 109 checkIsMapDynamic(false, false, new Map<String, int>()); |
110 checkIsMapDynamic(true, true, new Map<String, int, String>()); | 110 checkIsMapDynamic(true, true, new Map<String, int, String>()); |
111 checkIsMapDynamic(true, false, new Map<Unresolved, int>()); | 111 checkIsMapDynamic(true, false, new Map<Unresolved, int>()); |
112 checkIsMapDynamic(false, true, new Map<String, Unresolved<int>>()); | 112 checkIsMapDynamic(false, true, new Map<String, Unresolved<int>>()); |
113 checkIsMapDynamic(true, false, new Map<prefix.Unresolved, int>()); | 113 checkIsMapDynamic(true, false, new Map<prefix.Unresolved, int>()); |
114 checkIsMapDynamic(false, true, new Map<String, prefix.Unresolved<int>>()); | 114 checkIsMapDynamic(false, true, new Map<String, prefix.Unresolved<int>>()); |
115 | 115 |
116 Expect.throws(() => new Unresolved(), (e) => true); | 116 Expect.throws(() => new Unresolved(), (e) => true); |
117 Expect.throws(() => new Unresolved<int>(), (e) => true); | 117 Expect.throws(() => new Unresolved<int>(), (e) => true); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 throw 'foo'; | 156 throw 'foo'; |
157 } on prefix.Unresolved<int> catch (e) { | 157 } on prefix.Unresolved<int> catch (e) { |
158 Expect.fail("This code shouldn't be executed"); | 158 Expect.fail("This code shouldn't be executed"); |
159 } | 159 } |
160 Expect.fail("This code shouldn't be executed"); | 160 Expect.fail("This code shouldn't be executed"); |
161 } on TypeError catch (e) { | 161 } on TypeError catch (e) { |
162 } | 162 } |
163 try { | 163 try { |
164 throw 'foo'; | 164 throw 'foo'; |
165 } | 165 } |
166 on undeclared_prefix.Unresolved<int> // /// 06: runtime error | 166 on undeclared_prefix.Unresolved<int> // //# 06: runtime error |
167 catch (e) { | 167 catch (e) { |
168 } | 168 } |
169 } | 169 } |
OLD | NEW |