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

Unified Diff: third_party/pkg/angular/test/tools/symbol_inspector/symbol_inspector_spec.dart

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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
Index: third_party/pkg/angular/test/tools/symbol_inspector/symbol_inspector_spec.dart
diff --git a/third_party/pkg/angular/test/tools/symbol_inspector/symbol_inspector_spec.dart b/third_party/pkg/angular/test/tools/symbol_inspector/symbol_inspector_spec.dart
new file mode 100644
index 0000000000000000000000000000000000000000..791ea5450800ff47345a6f651fac47e6f9b061b3
--- /dev/null
+++ b/third_party/pkg/angular/test/tools/symbol_inspector/symbol_inspector_spec.dart
@@ -0,0 +1,107 @@
+library angular.tools.symbol_inspector;
+
+import 'package:angular/tools/symbol_inspector/symbol_inspector.dart';
+import 'package:unittest/unittest.dart';
+import 'simple_library.dart';
+
+import '../../jasmine_syntax.dart';
+
+Symbol symbolForName(libraryInfo, String name) =>
+ libraryInfo.names.firstWhere(
+ (x) => unwrapSymbol(x.qualified) == name).qualified;
+
+void main() => describe('symbol inspector', () {
+ it('should extract symbols', () {
+ LibraryInfo libraryInfo = getSymbolsFromLibrary("simple_library");
+
+ expect(libraryInfo.names.map((x) => unwrapSymbol(x.qualified)),
+ unorderedEquals([
+ 'simple_library.A',
+ 'simple_library.TypedefType',
+ 'simple_library.MethodReturnType',
+ 'simple_library.TypedefReturnType',
+ 'simple_library.GetterType',
+ 'simple_library.ParamType',
+ 'simple_library.StaticFieldType',
+ 'simple_library.FieldType',
+ 'simple_library.TypedefParam',
+ 'simple_library.ConsParamType',
+ 'simple_library.ClosureReturn',
+ 'simple_library.ClosureParam',
+ 'simple_library.Generic'
+ ]));
+ });
+
+ it('should extract all used symbols for a class', () {
+ LibraryInfo libraryInfo = getSymbolsFromLibrary("simple_library");
+
+ expect(libraryInfo.symbolsUsedForName[symbolForName(libraryInfo, 'simple_library.A')]
+ .map(unwrapSymbol), unorderedEquals([
+ 'simple_library.A',
+ 'simple_library.FieldType',
+ 'simple_library.StaticFieldType',
+ 'simple_library.GetterType',
+ 'simple_library.ParamType',
+ 'simple_library.MethodReturnType',
+ 'simple_library.ConsParamType',
+ 'simple_library.ClosureReturn',
+ 'simple_library.ClosureParam',
+ 'void'
+ ]));
+ });
+
+ it('should extract all used symbols for a typedef', () {
+ LibraryInfo libraryInfo = getSymbolsFromLibrary("simple_library");
+
+ expect(libraryInfo.symbolsUsedForName[symbolForName(libraryInfo, 'simple_library.TypedefType')]
+ .map(unwrapSymbol), unorderedEquals([
+ 'simple_library.TypedefParam',
+ 'simple_library.TypedefReturnType',
+ 'simple_library.TypedefType'
+ ]));
+ });
+
+ it('should not extract generic types', () {
+ LibraryInfo libraryInfo = getSymbolsFromLibrary("simple_library");
+
+ expect(libraryInfo.symbolsUsedForName[symbolForName(libraryInfo, 'simple_library.Generic')]
+ .map(unwrapSymbol), unorderedEquals([
+ 'simple_library.Generic'
+ ]));
+ });
+
+ describe('assert', () {
+ var SIMPLE_LIBRARY_SYMBOLS = [
+ "simple_library.ClosureParam",
+ "simple_library.StaticFieldType",
+ "simple_library.FieldType",
+ "simple_library.ConsParamType",
+ "simple_library.A",
+ "simple_library.TypedefType",
+ "simple_library.MethodReturnType",
+ "simple_library.TypedefReturnType",
+ "simple_library.GetterType",
+ "simple_library.ParamType",
+ "simple_library.Generic",
+ "simple_library.ClosureReturn",
+ "simple_library.TypedefParam"
+ ];
+ it('should assert symbol names are correct', () {
+ assertSymbolNamesAreOk(SIMPLE_LIBRARY_SYMBOLS,
+ getSymbolsFromLibrary(("simple_library")));
+ });
+
+ it('should throw if the list is missing symbols', () {
+ expect(() => assertSymbolNamesAreOk([],
+ getSymbolsFromLibrary(("simple_library"))),
+ throwsA(contains("These symbols are exported thru the angular "
+ "library, but it shouldn't be")));
+ });
+
+ it('should throw if the list has unused symbols', () {
+ expect(() => assertSymbolNamesAreOk(SIMPLE_LIBRARY_SYMBOLS..add('hello'),
+ getSymbolsFromLibrary(("simple_library"))),
+ throwsA(contains("These whitelisted symbols are not used")));
+ });
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698