OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #import("../../../pkg/dartdoc/mirrors/mirrors.dart"); | 5 #import("../../../pkg/dartdoc/mirrors/mirrors.dart"); |
6 #import("../../../pkg/dartdoc/mirrors/mirrors_util.dart"); | 6 #import("../../../pkg/dartdoc/mirrors/mirrors_util.dart"); |
7 | 7 |
8 #import('dart:io'); | 8 #import('dart:io'); |
9 | 9 |
10 int count(Iterable iterable) { | 10 int count(Iterable iterable) { |
(...skipping 11 matching lines...) Expand all Loading... |
22 } | 22 } |
23 } | 23 } |
24 return false; | 24 return false; |
25 } | 25 } |
26 | 26 |
27 main() { | 27 main() { |
28 var scriptPath = new Path.fromNative(new Options().script); | 28 var scriptPath = new Path.fromNative(new Options().script); |
29 var dirPath = scriptPath.directoryPath; | 29 var dirPath = scriptPath.directoryPath; |
30 var libPath = dirPath.join(new Path.fromNative('../../../')); | 30 var libPath = dirPath.join(new Path.fromNative('../../../')); |
31 var inputPath = dirPath.join(new Path.fromNative('mirrors_helper.dart')); | 31 var inputPath = dirPath.join(new Path.fromNative('mirrors_helper.dart')); |
32 var compilation = new Compilation(inputPath, libPath); | 32 var compilation = new Compilation.library([inputPath], libPath); |
33 Expect.isNotNull(compilation, "No compilation created"); | 33 Expect.isNotNull(compilation, "No compilation created"); |
34 | 34 |
35 var mirrors = compilation.mirrors; | 35 var mirrors = compilation.mirrors; |
36 Expect.isNotNull(mirrors, "No mirror system returned from compilation"); | 36 Expect.isNotNull(mirrors, "No mirror system returned from compilation"); |
37 | 37 |
38 var libraries = mirrors.libraries; | 38 var libraries = mirrors.libraries; |
39 Expect.isNotNull(libraries, "No libraries map returned"); | 39 Expect.isNotNull(libraries, "No libraries map returned"); |
40 Expect.isFalse(libraries.isEmpty(), "Empty libraries map returned"); | 40 Expect.isFalse(libraries.isEmpty(), "Empty libraries map returned"); |
41 | 41 |
42 var helperLibrary = findMirror(libraries, "mirrors_helper"); | 42 var helperLibrary = findMirror(libraries, "mirrors_helper"); |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 Expect.isFalse(funcTypedef.isClass, "Typedef is class"); | 546 Expect.isFalse(funcTypedef.isClass, "Typedef is class"); |
547 Expect.isFalse(funcTypedef.isInterface, "Typedef is interface"); | 547 Expect.isFalse(funcTypedef.isInterface, "Typedef is interface"); |
548 Expect.isFalse(funcTypedef.isPrivate, "Typedef is private"); | 548 Expect.isFalse(funcTypedef.isPrivate, "Typedef is private"); |
549 Expect.isNull(funcTypedef.defaultType, | 549 Expect.isNull(funcTypedef.defaultType, |
550 "Typedef default type is non-null"); | 550 "Typedef default type is non-null"); |
551 // TODO(johnniwinther): Should not throw an exception since the type should | 551 // TODO(johnniwinther): Should not throw an exception since the type should |
552 // not be the declaration. | 552 // not be the declaration. |
553 Expect.throws(() => funcTypedef.typeArguments, | 553 Expect.throws(() => funcTypedef.typeArguments, |
554 (exception) => true, | 554 (exception) => true, |
555 "Typedef has type arguments"); | 555 "Typedef has type arguments"); |
556 Expect.isNotNull(funcTypedef.typeVariables, "Type variables is null"); | 556 var funcTypedefTypeVariables = funcTypedef.typeVariables; |
557 // TODO(johnniwinther): Should return a non-empty map. | 557 Expect.isNotNull(funcTypedefTypeVariables); |
558 Expect.isTrue(funcTypedef.typeVariables.isEmpty(), | 558 Expect.equals(2, funcTypedefTypeVariables.length); |
559 "Type variables is non-empty"); | 559 |
560 // TODO(johnniwinther): Provide access to the definition type. | 560 var funcTypedefDefinition = funcTypedef.definition; |
561 Expect.isNull(funcTypedef.definition, "Typedef definition is not null"); | 561 Expect.isNotNull(funcTypedefDefinition); |
| 562 Expect.isTrue(funcTypedefDefinition is FunctionTypeMirror); |
562 | 563 |
563 Expect.stringEquals("func2", method3Parameter2.simpleName, | 564 Expect.stringEquals("func2", method3Parameter2.simpleName, |
564 "Unexpected parameter simpleName"); | 565 "Unexpected parameter simpleName"); |
565 Expect.stringEquals("mirrors_helper.Baz.method3#func2", | 566 Expect.stringEquals("mirrors_helper.Baz.method3#func2", |
566 method3Parameter2.qualifiedName, | 567 method3Parameter2.qualifiedName, |
567 "Unexpected parameter qualifiedName"); | 568 "Unexpected parameter qualifiedName"); |
568 Expect.isFalse(method3Parameter2.hasDefaultValue, | 569 Expect.isFalse(method3Parameter2.hasDefaultValue, |
569 "Parameter 'func2' has default value: " | 570 "Parameter 'func2' has default value: " |
570 "${method3Parameter2.defaultValue}"); | 571 "${method3Parameter2.defaultValue}"); |
571 Expect.isNull(method3Parameter2.defaultValue, | 572 Expect.isNull(method3Parameter2.defaultValue, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 Expect.stringEquals('negate', operator_negate.operatorName, | 633 Expect.stringEquals('negate', operator_negate.operatorName, |
633 "Unexpected operatorName"); | 634 "Unexpected operatorName"); |
634 | 635 |
635 | 636 |
636 var bazClassConstructors = bazClass.constructors; | 637 var bazClassConstructors = bazClass.constructors; |
637 Expect.isNotNull(bazClassConstructors, "Constructors map is null"); | 638 Expect.isNotNull(bazClassConstructors, "Constructors map is null"); |
638 Expect.equals(3, bazClassConstructors.length, | 639 Expect.equals(3, bazClassConstructors.length, |
639 "Unexpected number of constructors"); | 640 "Unexpected number of constructors"); |
640 // TODO(johnniwinther): Add tests of constructors. | 641 // TODO(johnniwinther): Add tests of constructors. |
641 } | 642 } |
OLD | NEW |