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

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

Issue 16757007: Changes to mirrors in support of metadata access at runtime. Assumes VM changes in flight.… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
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 | « tests/lib/lib.status ('k') | tests/lib/mirrors/metadata_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 @string @symbol
6 library test.library_metadata_test;
7
8 import 'dart:mirrors';
9
10 const string = 'a metadata string';
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
35 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();
43 checkMetadata(mirrors.findLibrary(const Symbol('test.library_metadata_test')). first,
44 [string, symbol]);
45 }
OLDNEW
« no previous file with comments | « tests/lib/lib.status ('k') | tests/lib/mirrors/metadata_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698