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

Side by Side Diff: dart/tests/lib/mirrors/library_metadata_test.dart

Issue 17241002: Reuse existing test instead of duplicating code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 months 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 @string @symbol 5 @string @symbol
6 library test.library_metadata_test; 6 library test.library_metadata_test;
7 7
8 import 'dart:mirrors'; 8 import 'dart:mirrors';
9 9
10 const string = 'a metadata string'; 10 import 'metadata_test.dart';
11
12 const symbol = const Symbol('symbol');
13
14 const hest = 'hest';
15
16 checkMetadata(DeclarationMirror mirror, List expectedMetadata) {
17 List metadata = mirror.metadata.map((m) => m.reflectee).toList();
18 if (metadata == null) {
19 throw 'Null metadata on $mirror';
20 }
21 int expectedLength = expectedMetadata.length;
22 int actualLength = metadata.length;
23 if (expectedLength != actualLength) {
24 throw 'Expected length = $expectedLength, but got length = $actualLength.';
25 }
26 for (int i = 0; i < expectedLength; i++) {
27 if (metadata[i] != expectedMetadata[i]) {
28 throw '${metadata[i]} is not "${expectedMetadata[i]}"'
29 ' in $mirror at index $i';
30 }
31 }
32 print(metadata);
33 }
34 11
35 main() { 12 main() {
36 if (MirrorSystem.getName(symbol) != 'symbol') {
37 // This happened in dart2js due to how early library metadata is
38 // computed.
39 throw 'Bad constant: $symbol';
40 }
41
42 MirrorSystem mirrors = currentMirrorSystem(); 13 MirrorSystem mirrors = currentMirrorSystem();
43 checkMetadata(mirrors.findLibrary(const Symbol('test.library_metadata_test')). first, 14 checkMetadata(mirrors.findLibrary(const Symbol('test.library_metadata_test')). first,
44 [string, symbol]); 15 [string, symbol]);
45 } 16 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698