Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
test(symbols): Whitelist symbols from angular.animate
Browse files Browse the repository at this point in the history
Closes #823
  • Loading branch information
jbdeboer authored and [email protected] committed Apr 18, 2014
1 parent 39d4f42 commit f79696d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
4 changes: 1 addition & 3 deletions lib/tools/symbol_inspector/symbol_inspector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ getSymbolsFromLibrary(String libraryName) {
};

var lib = currentMirrorSystem().findLibrary(new Symbol(libraryName));
try {
return extractSymbols(lib);
} catch (e,s) { print("EE: $e\nSS: $s"); }
return extractSymbols(lib);
}

var _SYMBOL_NAME = new RegExp('"(.*)"');
Expand Down
38 changes: 29 additions & 9 deletions test/angular_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,34 @@ main() {
});
});

describe('angular symbols', () {
it('should not export symbols that we do not know about', () {
describe('symbols', () {
it('should not export unknown symbols from animate', () {
LibraryInfo libraryInfo;
try {
libraryInfo = getSymbolsFromLibrary("angular.animate");
} on UnimplementedError catch (e) {
return; // Not implemented, quietly skip.
}

var ALLOWED_NAMES = [
"angular.animate.AbstractNgAnimate",
"angular.animate.AnimationLoop",
"angular.animate.AnimationModule",
"angular.animate.AnimationOptimizer",
"angular.animate.CssAnimate",
"angular.animate.CssAnimationMap",
"angular.animate.NgAnimate",
"angular.animate.NgAnimateChildren",
"angular.animate.CssAnimation",
"angular.animate.AnimationFrame",
"angular.animate.AnimationList",
"angular.animate.LoopedAnimation"
];
assertSymbolNamesAreOk(ALLOWED_NAMES, libraryInfo);

});

it('should not export unknown symbols from angular', () {
// Test is failing? Add new symbols to the "ALLOWED_NAMES" list below.
// But make sure that you intend to export the symbol!
// Questions? Talk to @jbdeboer
Expand All @@ -59,18 +85,12 @@ main() {
}

LibraryInfo libraryInfo;
var names;
try { // Not impleneted in Dart VM 1.2
try {
libraryInfo = getSymbolsFromLibrary("angular");
} on UnimplementedError catch (e) {
return; // Not implemented, quietly skip.
} catch (e) {
print("Error: $e");
return; // On VMes <1.2, quietly skip.
}

names = libraryInfo.names;

var ALLOWED_NAMES = [
"angular.app.AngularModule",
"angular.app.Application",
Expand Down

0 comments on commit f79696d

Please sign in to comment.