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

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

Issue 11106011: Test that built-in identifiers can be used as library prefixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Updated test expectations Created 8 years 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) 2012, 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 // Test that built-in identifiers can be used as library prefixes.
6
7 // From The Dart Programming Language Specification, section 11.30
8 // "Identifier Reference":
9 //
10 // "A built-in identifier is one of the identifiers produced by the
11 // production BUILT IN IDENTIFIER. It is a compile-time error if a
12 // built-in identifier is used as the declared name of a class, type
13 // parameter or type alias. It is a compile-time error to use a
14 // built-in identifier other than dynamic as a type annotation."
15 //
16 // Observation: it is not illegal to use a built-in identifier as a library
17 // prefix.
18 //
19 // Observation: it is not legal to use a built-in identifer as a type
20 // annotation. A type annotation is not fully defined in the
21 // specification, so we assume this means that the grammar production
22 // "type" cannot match a built-in identifier. Unfortunately, this
23 // doesn't prevent us from using built-in identifiers *in* type
24 // annotations. For example, "final abstract foo;" is illegal as
25 // "abstract" is used as a type annotation. However, "final
26 // abstract<dynamic> foo;" is not illegal because "abstract" is used
27 // as a typeName.
28
29 import 'built_in_identifier_prefix_library_abstract.dart' as abstract;
30 import 'built_in_identifier_prefix_library_as.dart' as as;
31 import 'built_in_identifier_prefix_library_dynamic.dart' as dynamic;
32 import 'built_in_identifier_prefix_library_export.dart' as export;
33 import 'built_in_identifier_prefix_library_external.dart' as external;
34 import 'built_in_identifier_prefix_library_factory.dart' as factory;
35 import 'built_in_identifier_prefix_library_get.dart' as get;
36 import 'built_in_identifier_prefix_library_implements.dart' as implements;
37 import 'built_in_identifier_prefix_library_import.dart' as import;
38 import 'built_in_identifier_prefix_library_library.dart' as library;
39 import 'built_in_identifier_prefix_library_operator.dart' as operator;
40 import 'built_in_identifier_prefix_library_part.dart' as part;
41 import 'built_in_identifier_prefix_library_set.dart' as set;
42 import 'built_in_identifier_prefix_library_static.dart' as static;
43 import 'built_in_identifier_prefix_library_typedef.dart' as typedef;
44
45 abstract.A _abstract = new abstract.A();
46 as.A _as = new as.A();
47 dynamic.A _dynamic = new dynamic.A();
48 export.A _export = new export.A();
49 external.A _external = new external.A();
50 factory.A _factory = new factory.A();
51 get.A _get = new get.A();
52 implements.A _implements = new implements.A();
53 import.A _import = new import.A();
54 library.A _library = new library.A();
55 operator.A _operator = new operator.A();
56 part.A _part = new part.A();
57 set.A _set = new set.A();
58 static.A _static = new static.A();
59 typedef.A _typedef = new typedef.A();
60
61 abstract<dynamic> generic_abstract = new abstract.A();
62 as<dynamic> generic_as = new as.A();
63 dynamic<dynamic> generic_dynamic = new dynamic.A();
64 export<dynamic> generic_export = new export.A();
65 external<dynamic> generic_external = new external.A();
66 factory<dynamic> generic_factory = new factory.A();
67 get<dynamic> generic_get = new get.A();
68 implements<dynamic> generic_implements = new implements.A();
69 import<dynamic> generic_import = new import.A();
70 library<dynamic> generic_library = new library.A();
71 operator<dynamic> generic_operator = new operator.A();
72 part<dynamic> generic_part = new part.A();
73 set<dynamic> generic_set = new set.A();
74 static<dynamic> generic_static = new static.A();
75 typedef<dynamic> generic_typedef = new typedef.A();
76
77 abstract.B<dynamic> dynamic_B_abstract = new abstract.B();
78 as.B<dynamic> dynamic_B_as = new as.B();
79 dynamic.B<dynamic> dynamic_B_dynamic = new dynamic.B();
80 export.B<dynamic> dynamic_B_export = new export.B();
81 external.B<dynamic> dynamic_B_external = new external.B();
82 factory.B<dynamic> dynamic_B_factory = new factory.B();
83 get.B<dynamic> dynamic_B_get = new get.B();
84 implements.B<dynamic> dynamic_B_implements = new implements.B();
85 import.B<dynamic> dynamic_B_import = new import.B();
86 library.B<dynamic> dynamic_B_library = new library.B();
87 operator.B<dynamic> dynamic_B_operator = new operator.B();
88 part.B<dynamic> dynamic_B_part = new part.B();
89 set.B<dynamic> dynamic_B_set = new set.B();
90 static.B<dynamic> dynamic_B_static = new static.B();
91 typedef.B<dynamic> dynamic_B_typedef = new typedef.B();
92
93 abstract.B<abstract<dynamic>> parameterized_B_abstract = new abstract.B();
94 as.B<as<dynamic>> parameterized_B_as = new as.B();
95 dynamic.B<dynamic<dynamic>> parameterized_B_dynamic = new dynamic.B();
96 export.B<export<dynamic>> parameterized_B_export = new export.B();
97 external.B<external<dynamic>> parameterized_B_external = new external.B();
98 factory.B<factory<dynamic>> parameterized_B_factory = new factory.B();
99 get.B<get<dynamic>> parameterized_B_get = new get.B();
100 implements.B<implements<dynamic>> parameterized_B_implements =
101 new implements.B();
102 import.B<import<dynamic>> parameterized_B_import = new import.B();
103 library.B<library<dynamic>> parameterized_B_library = new library.B();
104 operator.B<operator<dynamic>> parameterized_B_operator = new operator.B();
105 part.B<part<dynamic>> parameterized_B_part = new part.B();
106 set.B<set<dynamic>> parameterized_B_set = new set.B();
107 static.B<static<dynamic>> parameterized_B_static = new static.B();
108 typedef.B<typedef<dynamic>> parameterized_B_typedef = new typedef.B();
109
110 class UseA {
111 abstract.A abstract = new abstract.A();
112 as.A as = new as.A();
113 dynamic.A dynamic = new dynamic.A();
114 export.A export = new export.A();
115 external.A external = new external.A();
116 factory.A factory = new factory.A();
117 get.A get = new get.A();
118 implements.A implements = new implements.A();
119 import.A import = new import.A();
120 library.A library = new library.A();
121 operator.A operator = new operator.A();
122 part.A part = new part.A();
123 set.A set = new set.A();
124 static.A static = new static.A();
125 typedef.A typedef = new typedef.A();
126 }
127
128 main() {
129 bool assertionsEnabled = false;
130 assert(assertionsEnabled = true);
131
132 Expect.isTrue(_abstract is abstract.A);
133 Expect.isTrue(_as is as.A);
134 Expect.isTrue(_dynamic is dynamic.A);
135 Expect.isTrue(_export is export.A);
136 Expect.isTrue(_external is external.A);
137 Expect.isTrue(_factory is factory.A);
138 Expect.isTrue(_get is get.A);
139 Expect.isTrue(_implements is implements.A);
140 Expect.isTrue(_import is import.A);
141 Expect.isTrue(_library is library.A);
142 Expect.isTrue(_operator is operator.A);
143 Expect.isTrue(_part is part.A);
144 Expect.isTrue(_set is set.A);
145 Expect.isTrue(_static is static.A);
146 Expect.isTrue(_typedef is typedef.A);
147
148 Expect.isTrue(dynamic_B_abstract is abstract.B);
149 Expect.isTrue(dynamic_B_as is as.B);
150 Expect.isTrue(dynamic_B_dynamic is dynamic.B);
151 Expect.isTrue(dynamic_B_export is export.B);
152 Expect.isTrue(dynamic_B_external is external.B);
153 Expect.isTrue(dynamic_B_factory is factory.B);
154 Expect.isTrue(dynamic_B_get is get.B);
155 Expect.isTrue(dynamic_B_implements is implements.B);
156 Expect.isTrue(dynamic_B_import is import.B);
157 Expect.isTrue(dynamic_B_library is library.B);
158 Expect.isTrue(dynamic_B_operator is operator.B);
159 Expect.isTrue(dynamic_B_part is part.B);
160 Expect.isTrue(dynamic_B_set is set.B);
161 Expect.isTrue(dynamic_B_static is static.B);
162 Expect.isTrue(dynamic_B_typedef is typedef.B);
163
164 var x = new UseA();
165 Expect.isTrue(x.abstract is abstract.A);
166 Expect.isTrue(x.as is as.A);
167 Expect.isTrue(x.dynamic is dynamic.A);
168 Expect.isTrue(x.export is export.A);
169 Expect.isTrue(x.external is external.A);
170 Expect.isTrue(x.factory is factory.A);
171 Expect.isTrue(x.get is get.A);
172 Expect.isTrue(x.implements is implements.A);
173 Expect.isTrue(x.import is import.A);
174 Expect.isTrue(x.library is library.A);
175 Expect.isTrue(x.operator is operator.A);
176 Expect.isTrue(x.part is part.A);
177 Expect.isTrue(x.set is set.A);
178 Expect.isTrue(x.static is static.A);
179 Expect.isTrue(x.typedef is typedef.A);
180
181 // Most of the following variables have malformed type annotations.
182 if (assertionsEnabled) return;
183
184 Expect.isTrue(generic_abstract is abstract.A);
185 Expect.isTrue(generic_as is as.A);
186 Expect.isTrue(generic_dynamic is dynamic.A);
187 Expect.isTrue(generic_export is export.A);
188 Expect.isTrue(generic_external is external.A);
189 Expect.isTrue(generic_factory is factory.A);
190 Expect.isTrue(generic_get is get.A);
191 Expect.isTrue(generic_implements is implements.A);
192 Expect.isTrue(generic_import is import.A);
193 Expect.isTrue(generic_library is library.A);
194 Expect.isTrue(generic_operator is operator.A);
195 Expect.isTrue(generic_part is part.A);
196 Expect.isTrue(generic_set is set.A);
197 Expect.isTrue(generic_static is static.A);
198 Expect.isTrue(generic_typedef is typedef.A);
199
200 Expect.isTrue(parameterized_B_abstract is abstract.B);
201 Expect.isTrue(parameterized_B_as is as.B);
202 Expect.isTrue(parameterized_B_dynamic is dynamic.B);
203 Expect.isTrue(parameterized_B_export is export.B);
204 Expect.isTrue(parameterized_B_external is external.B);
205 Expect.isTrue(parameterized_B_factory is factory.B);
206 Expect.isTrue(parameterized_B_get is get.B);
207 Expect.isTrue(parameterized_B_implements is implements.B);
208 Expect.isTrue(parameterized_B_import is import.B);
209 Expect.isTrue(parameterized_B_library is library.B);
210 Expect.isTrue(parameterized_B_operator is operator.B);
211 Expect.isTrue(parameterized_B_part is part.B);
212 Expect.isTrue(parameterized_B_set is set.B);
213 Expect.isTrue(parameterized_B_static is static.B);
214 Expect.isTrue(parameterized_B_typedef is typedef.B);
215 }
OLDNEW
« no previous file with comments | « dart/tests/language/built_in_identifier_prefix_library_typedef.dart ('k') | dart/tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698