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

Side by Side Diff: pkg/docgen/test/metadata_test.dart

Issue 716913005: Replace ResolvedNode by ConstantExpression. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add unittest Created 6 years, 1 month 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) 2014, 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 library async_await_test;
6
7 import 'dart:io';
8
9 import 'package:path/path.dart' as path;
10 import 'package:unittest/unittest.dart';
11
12 import '../lib/src/exports/mirrors_util.dart' as dart2js_util;
13 import '../lib/src/models/annotation.dart';
14 import '../lib/docgen.dart';
15
16 const Map<String, String> SOURCES = const <String, String>{
17 'main.dart': '''
18 import 'lib.dart' as lib;
19
20 @lib.Annotation("foo", 42)
21 main() {
22 }
23 ''',
24 'lib.dart': '''
25 class Annotation {
26 final String arg1;
27 final int arg2;
28 const Annotation(this.arg1, this.arg2);
29 }
30 '''};
31
32 main() {
33 group('Generate docs for', () {
34 test('files with annotations', () {
35 var temporaryDir = Directory.systemTemp.createTempSync('metadata_');
36 var uris = <Uri>[];
37 SOURCES.forEach((name, code) {
38 var fileName = path.join(temporaryDir.path, name);
39 var file = new File(fileName);
40 file.writeAsStringSync(code);
41 uris.add(new Uri.file(fileName));
42 });
43
44 return getMirrorSystem(uris, false)
45 .then((mirrorSystem) {
sigurdm 2014/11/12 12:10:23 Indentation
Johnni Winther 2014/11/13 10:16:42 Done.
46 var library = new Library(mirrorSystem.libraries[uris[0]]);
47 expect(library is Library, isTrue);
48
49 var main = library.functions['main'];
50 expect(main is Method, isTrue);
51
52 var annotations = main.annotations;
53 expect(annotations.length, equals(1));
54
55 var annotation = annotations[0];
56 expect(annotation is Annotation, isTrue);
57
58 var map = annotation.toMap();
59 expect(map['name'], equals('lib-dart.Annotation.Annotation-'));
60 expect(map['parameters'].length, equals(2));
61 expect(map['parameters'][0], equals('"foo"'));
62 expect(map['parameters'][1], equals('42'));
63 }).whenComplete(() => temporaryDir.deleteSync(recursive: true));
64 });
65 });
66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698