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 | 4 |
5 // TODO(rmacnak): Move the existing mirror tests here (a place for | 5 // TODO(rmacnak): Move the existing mirror tests here (a place for |
6 // cross-implementation tests). | 6 // cross-implementation tests). |
7 | 7 |
8 library MirrorsTest; | 8 library MirrorsTest; |
9 import "dart:mirrors"; | 9 import "dart:mirrors"; |
10 import "../../../pkg/unittest/lib/unittest.dart"; | 10 import "../../../pkg/unittest/lib/unittest.dart"; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 equals(const Symbol('MirrorsTest.Class.field'))); | 193 equals(const Symbol('MirrorsTest.Class.field'))); |
194 } | 194 } |
195 | 195 |
196 testLibraryUri(var value, bool check(Uri)) { | 196 testLibraryUri(var value, bool check(Uri)) { |
197 var valueMirror = reflect(value); | 197 var valueMirror = reflect(value); |
198 ClassMirror valueClass = valueMirror.type; | 198 ClassMirror valueClass = valueMirror.type; |
199 LibraryMirror valueLibrary = valueClass.owner; | 199 LibraryMirror valueLibrary = valueClass.owner; |
200 expect(check(valueLibrary.uri), isTrue); | 200 expect(check(valueLibrary.uri), isTrue); |
201 } | 201 } |
202 | 202 |
203 mainWithArgument({bool isDart2js}) { | 203 mainWithArgument({bool isDart2js: false, bool isMinified: false}) { |
204 var mirrors = currentMirrorSystem(); | 204 var mirrors = currentMirrorSystem(); |
205 test("Test reflective method invocation", () { testInvoke(mirrors); }); | 205 test("Test reflective method invocation", () { testInvoke(mirrors); }); |
| 206 if (isMinified) return; |
206 test("Test instance field access", () { testInstanceFieldAccess(mirrors); }); | 207 test("Test instance field access", () { testInstanceFieldAccess(mirrors); }); |
207 test('Test intercepted objects', () { testIntercepted(mirrors); }); | 208 test('Test intercepted objects', () { testIntercepted(mirrors); }); |
208 test("Test field access", () { testFieldAccess(mirrors); }); | 209 test("Test field access", () { testFieldAccess(mirrors); }); |
209 test("Test closure mirrors", () { testClosureMirrors(mirrors); }); | 210 test("Test closure mirrors", () { testClosureMirrors(mirrors); }); |
210 test("Test invoke constructor", () { testInvokeConstructor(mirrors); }); | 211 test("Test invoke constructor", () { testInvokeConstructor(mirrors); }); |
211 test("Test current library uri", () { | 212 test("Test current library uri", () { |
212 testLibraryUri(new Class(), | 213 testLibraryUri(new Class(), |
213 (Uri uri) => uri.path.endsWith('/mirrors_test.dart')); | 214 (Uri uri) => uri.path.endsWith('/mirrors_test.dart')); |
214 }); | 215 }); |
215 test("Test dart library uri", () { | 216 test("Test dart library uri", () { |
216 testLibraryUri("test", (Uri uri) => uri == Uri.parse('dart:core')); | 217 testLibraryUri("test", (Uri uri) => uri == Uri.parse('dart:core')); |
217 }); | 218 }); |
218 test("Test simple and qualifiedName", () { testNames(mirrors, isDart2js); }); | 219 test("Test simple and qualifiedName", () { testNames(mirrors, isDart2js); }); |
219 if (isDart2js) return; // TODO(ahe): Remove this line. | 220 if (isDart2js) return; // TODO(ahe): Remove this line. |
220 test("Test reflect type", () { testReflectClass(mirrors); }); | 221 test("Test reflect type", () { testReflectClass(mirrors); }); |
221 } | 222 } |
222 | 223 |
223 main() { | 224 main() { |
224 mainWithArgument(isDart2js: false); | 225 mainWithArgument(); |
225 } | 226 } |
OLD | NEW |