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

Unified Diff: tests/lib/mirrors/library_declarations_test.dart

Issue 36023003: Add LibraryMirror.declarations and ClassMirror.declarations to the API and both implementations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/lib/mirrors/declarations_model.dart ('k') | tests/lib/mirrors/stringify.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/mirrors/library_declarations_test.dart
diff --git a/tests/lib/mirrors/library_declarations_test.dart b/tests/lib/mirrors/library_declarations_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d91e727db2cd5dd1eb069f2826636c8ecb689a5c
--- /dev/null
+++ b/tests/lib/mirrors/library_declarations_test.dart
@@ -0,0 +1,122 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library test.library_declarations_test;
+
+import 'dart:mirrors';
+import 'package:expect/expect.dart';
+
+import 'stringify.dart';
+import 'declarations_model.dart' as declarations_model;
+
+main() {
+ LibraryMirror lm =
+ currentMirrorSystem().findLibrary(#test.declarations_model).single;
+
+ Expect.setEquals(
+ ['Variable(s(_libraryVariable)'
+ ' in s(test.declarations_model), private, top-level, static)',
+ 'Variable(s(libraryVariable)'
+ ' in s(test.declarations_model), top-level, static)'],
+ lm.declarations.values.where((dm) => dm is VariableMirror).map(stringify),
+ 'variables');
+
+ // dart2js stops testing here.
+ return; /// 01: ok
+
+ Expect.setEquals(
+ ['Method(s(_libraryGetter)'
+ ' in s(test.declarations_model), private, top-level, static, getter)',
+ 'Method(s(libraryGetter)'
+ ' in s(test.declarations_model), top-level, static, getter)'],
+ lm.declarations.values
+ .where((dm) => dm is MethodMirror && dm.isGetter).map(stringify),
+ 'getters');
+
+ Expect.setEquals(
+ ['Method(s(_librarySetter=)'
+ ' in s(test.declarations_model), private, top-level, static, setter)',
+ 'Method(s(librarySetter=)'
+ ' in s(test.declarations_model), top-level, static, setter)'],
+ lm.declarations.values
+ .where((dm) => dm is MethodMirror && dm.isSetter).map(stringify),
+ 'setters');
+
+ Expect.setEquals(
+ ['Method(s(_libraryMethod)'
+ ' in s(test.declarations_model), private, top-level, static)',
+ 'Method(s(libraryMethod)'
+ ' in s(test.declarations_model), top-level, static)'],
+ lm.declarations.values
+ .where((dm) => dm is MethodMirror && dm.isRegularMethod).map(stringify),
+ 'regular methods');
+
+ Expect.setEquals(
+ ['Class(s(Class) in s(test.declarations_model), top-level)',
+ 'Class(s(ConcreteClass) in s(test.declarations_model), top-level)',
+ 'Class(s(Interface) in s(test.declarations_model), top-level)',
+ 'Class(s(Mixin) in s(test.declarations_model), top-level)',
+ 'Class(s(Superclass) in s(test.declarations_model), top-level)',
+ 'Class(s(_PrivateClass)'
+ ' in s(test.declarations_model), private, top-level)'],
+ lm.declarations.values
+ .where((dm) => dm is ClassMirror).map(stringify),
+ 'classes');
+
+ Expect.setEquals(
+ ['Class(s(Class) in s(test.declarations_model), top-level)',
+ 'Class(s(ConcreteClass) in s(test.declarations_model), top-level)',
+ 'Class(s(Interface) in s(test.declarations_model), top-level)',
+ 'Class(s(Mixin) in s(test.declarations_model), top-level)',
+ 'Type(s(Predicate) in s(test.declarations_model), top-level)',
+ 'Class(s(Superclass) in s(test.declarations_model), top-level)',
+ 'Class(s(_PrivateClass)'
+ ' in s(test.declarations_model), private, top-level)'],
+ lm.declarations.values.where((dm) => dm is TypeMirror).map(stringify),
+ 'types');
+
+ Expect.setEquals(
+ ['Class(s(Class) in s(test.declarations_model), top-level)',
+ 'Class(s(ConcreteClass) in s(test.declarations_model), top-level)',
+ 'Class(s(Interface) in s(test.declarations_model), top-level)',
+ 'Class(s(Mixin) in s(test.declarations_model), top-level)',
+ 'Type(s(Predicate) in s(test.declarations_model), top-level)',
+ 'Class(s(Superclass) in s(test.declarations_model), top-level)',
+ 'Method(s(libraryGetter)'
+ ' in s(test.declarations_model), top-level, static, getter)',
+ 'Method(s(libraryMethod)'
+ ' in s(test.declarations_model), top-level, static)',
+ 'Method(s(librarySetter=)'
+ ' in s(test.declarations_model), top-level, static, setter)',
+ 'Variable(s(libraryVariable)'
+ ' in s(test.declarations_model), top-level, static)'],
+ lm.declarations.values.where((dm) => !dm.isPrivate).map(stringify),
+ 'public');
+
+ Expect.setEquals(
+ ['Class(s(Class) in s(test.declarations_model), top-level)',
+ 'Class(s(ConcreteClass) in s(test.declarations_model), top-level)',
+ 'Class(s(Interface) in s(test.declarations_model), top-level)',
+ 'Class(s(Mixin) in s(test.declarations_model), top-level)',
+ 'Type(s(Predicate) in s(test.declarations_model), top-level)',
+ 'Class(s(Superclass) in s(test.declarations_model), top-level)',
+ 'Class(s(_PrivateClass) in s(test.declarations_model), private, top-level)',
+ 'Method(s(_libraryGetter)'
+ ' in s(test.declarations_model), private, top-level, static, getter)',
+ 'Method(s(_libraryMethod)'
+ ' in s(test.declarations_model), private, top-level, static)',
+ 'Method(s(_librarySetter=)'
+ ' in s(test.declarations_model), private, top-level, static, setter)',
+ 'Variable(s(_libraryVariable)'
+ ' in s(test.declarations_model), private, top-level, static)',
+ 'Method(s(libraryGetter)'
+ ' in s(test.declarations_model), top-level, static, getter)',
+ 'Method(s(libraryMethod) in s(test.declarations_model), top-level, static)',
+ 'Method(s(librarySetter=)'
+ ' in s(test.declarations_model), top-level, static, setter)',
+ 'Variable(s(libraryVariable)'
+ ' in s(test.declarations_model), top-level, static)'],
+ lm.declarations.values.map(stringify),
+ 'all declarations');
+}
« no previous file with comments | « tests/lib/mirrors/declarations_model.dart ('k') | tests/lib/mirrors/stringify.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698