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

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

Issue 16147005: Version 0.5.14.3 . (Closed) Base URL: http://dart.googlecode.com/svn/trunk/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 | « sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart ('k') | tools/VERSION » ('j') | 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.metadata_test; 6 library test.metadata_test;
7 7
8 import 'dart:mirrors'; 8 import 'dart:mirrors';
9 9
10 const string = 'a metadata string'; 10 const string = 'a metadata string';
11 11
12 const symbol = const Symbol('symbol'); 12 const symbol = const Symbol('symbol');
13 13
14 const hest = 'hest'; 14 const hest = 'hest';
15 15
16 @symbol @string 16 @symbol @string
17 class MyClass { 17 class MyClass {
18 @hest @hest @symbol 18 @hest @hest @symbol
19 var x; 19 var x;
20 var y;
20 21
21 @string @symbol @string 22 @string @symbol @string
22 myMethod() => 1; 23 myMethod() => 1;
23 } 24 }
24 25
25 checkMetadata(DeclarationMirror mirror, List expectedMetadata) { 26 checkMetadata(DeclarationMirror mirror, List expectedMetadata) {
26 List metadata = mirror.metadata.map((m) => m.reflectee).toList(); 27 List metadata = mirror.metadata.map((m) => m.reflectee).toList();
27 if (metadata == null) { 28 if (metadata == null) {
28 throw 'Null metadata on $mirror'; 29 throw 'Null metadata on $mirror';
29 } 30 }
(...skipping 25 matching lines...) Expand all
55 ClassMirror myClassMirror = reflectClass(MyClass); 56 ClassMirror myClassMirror = reflectClass(MyClass);
56 checkMetadata(myClassMirror, [symbol, string]); 57 checkMetadata(myClassMirror, [symbol, string]);
57 ClosureMirror closure = reflect(main); 58 ClosureMirror closure = reflect(main);
58 checkMetadata(closure.function, [symbol, string, symbol]); 59 checkMetadata(closure.function, [symbol, string, symbol]);
59 closure = reflect(new MyClass().myMethod); 60 closure = reflect(new MyClass().myMethod);
60 checkMetadata(closure.function, [string, symbol, string]); 61 checkMetadata(closure.function, [string, symbol, string]);
61 62
62 VariableMirror xMirror = myClassMirror.variables[const Symbol('x')]; 63 VariableMirror xMirror = myClassMirror.variables[const Symbol('x')];
63 checkMetadata(xMirror, [hest, hest, symbol]); 64 checkMetadata(xMirror, [hest, hest, symbol]);
64 65
66 VariableMirror yMirror = myClassMirror.variables[const Symbol('y')];
67 checkMetadata(yMirror, []);
68
65 // TODO(ahe): Test local functions. 69 // TODO(ahe): Test local functions.
66 } 70 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart ('k') | tools/VERSION » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698