{"action":"created","comment":{"url":"https://api.github.com/repos/angular/angular/pulls/comments/40021246","id":40021246,"diff_hunk":"@@ -15,36 +16,122 @@ var formatter = new DartFormatter();\n main() => allTests();\n \n void allTests() {\n-  var reader = new TestAssetReader();\n-\n-  it('should ensure that dependencies are property chained.', () async {\n-    for (var inputPath in [\n-      'bar.ng_deps.dart',\n-      'foo.ng_deps.dart',\n-      'index.ng_deps.dart'\n-    ]) {\n-      var expected =\n-          readFile('directive_linker/simple_files/expected/$inputPath');\n-      inputPath = 'directive_linker/simple_files/$inputPath';\n-      var actual = formatter\n-          .format(await linkNgDeps(reader, new AssetId('a', inputPath)));\n-      expect(actual).toEqual(formatter.format(expected));\n-    }\n+  var reader;\n+\n+  beforeEach(() {\n+    reader = new TestAssetReader();\n+  });\n+\n+  it('should chain imported dependencies.', () async {\n+    var fooModel = new NgDepsModel()\n+      ..libraryUri = 'test.foo'\n+      ..imports.add(new ImportModel()\n+        ..uri = 'bar.dart'\n+        ..prefix = 'dep');\n+    var barModel = new NgDepsModel()..libraryUri = 'test.bar';\n+\n+    var fooAssetId = new AssetId('a', 'lib/foo.ng_deps.json');\n+    reader\n+      ..addAsset(fooAssetId, fooModel.writeToJson())\n+      ..addAsset(\n+          new AssetId('a', 'lib/bar.ng_deps.json'), barModel.writeToJson());\n+\n+    var linked = await linkNgDeps(reader, fooAssetId);\n+    expect(linked).toBeNotNull();\n+    var linkedImport =\n+        linked.imports.firstWhere((i) => i.uri.endsWith('bar.ng_deps.dart'));\n+    expect(linkedImport).toBeNotNull();\n+    expect(linkedImport.isNgDeps).toBeTrue();\n+    expect(linkedImport.prefix.startsWith('i')).toBeTrue();\n   });\n \n-  it('should ensure that exported dependencies are property chained.',\n-      () async {\n-    for (var inputPath in [\n-      'bar.ng_deps.dart',\n-      'foo.ng_deps.dart',\n-      'index.ng_deps.dart'\n-    ]) {\n-      var expected =\n-          readFile('directive_linker/simple_export_files/expected/$inputPath');\n-      inputPath = 'directive_linker/simple_export_files/$inputPath';\n-      var actual = formatter\n-          .format(await linkNgDeps(reader, new AssetId('a', inputPath)));\n-      expect(actual).toEqual(formatter.format(expected));\n-    }\n+  it('should chain exported dependencies.', () async {\n+    var fooModel = new NgDepsModel()\n+      ..libraryUri = 'test.foo'\n+      ..exports.add(new ExportModel()..uri = 'bar.dart');\n+    var barModel = new NgDepsModel()..libraryUri = 'test.bar';\n+\n+    var fooAssetId = new AssetId('a', 'lib/foo.ng_deps.json');\n+    reader\n+      ..addAsset(fooAssetId, fooModel.writeToJson())\n+      ..addAsset(\n+          new AssetId('a', 'lib/bar.ng_deps.json'), barModel.writeToJson());\n+\n+    var linked = await linkNgDeps(reader, fooAssetId);\n+    expect(linked).toBeNotNull();\n+    var linkedImport =\n+        linked.imports.firstWhere((i) => i.uri.endsWith('bar.ng_deps.dart'));\n+    expect(linkedImport).toBeNotNull();\n+    expect(linkedImport.isNgDeps).toBeTrue();\n+    expect(linkedImport.prefix.startsWith('i')).toBeTrue();\n+  });\n+\n+  describe('isNecessary', () {\n+    it('should drop deps that do no registration and do not import.', () async {\n+      var fooModel = new NgDepsModel()..libraryUri = 'test.foo';\n+\n+      var fooAssetId = new AssetId('a', 'lib/foo.ng_deps.json');\n+      reader.addAsset(fooAssetId, fooModel.writeToJson());\n+      expect(await isNecessary(reader, fooAssetId)).toBeFalse();\n+    });\n+\n+    it('should retain deps that import other deps.', () async {\n+      var fooModel = new NgDepsModel()\n+        ..libraryUri = 'test.foo'\n+        ..imports.add(new ImportModel()..uri = 'bar.dart');\n+      var barModel = new NgDepsModel()..libraryUri = 'test.bar';\n+\n+      var fooAssetId = new AssetId('a', 'lib/foo.ng_deps.json');\n+      reader\n+        ..addAsset(fooAssetId, fooModel.writeToJson())\n+        ..addAsset(\n+            new AssetId('a', 'lib/bar.ng_deps.json'), barModel.writeToJson());\n+\n+      expect(await isNecessary(reader, fooAssetId)).toBeTrue();\n+    });\n+\n+    it('should retain deps that export other deps.', () async {\n+      var fooModel = new NgDepsModel()\n+        ..libraryUri = 'test.foo'\n+        ..exports.add(new ExportModel()..uri = 'bar.dart');\n+      var barModel = new NgDepsModel()..libraryUri = 'test.bar';\n+\n+      var fooAssetId = new AssetId('a', 'lib/foo.ng_deps.json');\n+      reader\n+        ..addAsset(fooAssetId, fooModel.writeToJson())\n+        ..addAsset(\n+            new AssetId('a', 'lib/bar.ng_deps.json'), barModel.writeToJson());\n+\n+      expect(await isNecessary(reader, fooAssetId)).toBeTrue();\n+    });\n+\n+    it('should retain deps that register injectable types.', () async {\n+      var fooModel = new NgDepsModel()\n+        ..libraryUri = 'test.foo'","path":"modules_dart/transform/test/transform/directive_linker/all_tests.dart","position":132,"original_position":132,"commit_id":"91fbe3a045ae546dcb3966a01de564934c15f6d9","original_commit_id":"91fbe3a045ae546dcb3966a01de564934c15f6d9","user":{"login":"jakemac53","id":984921,"avatar_url":"https://avatars.githubusercontent.com/u/984921?v=3","gravatar_id":"","url":"https://api.github.com/users/jakemac53","html_url":"https://github.com/jakemac53","followers_url":"https://api.github.com/users/jakemac53/followers","following_url":"https://api.github.com/users/jakemac53/following{/other_user}","gists_url":"https://api.github.com/users/jakemac53/gists{/gist_id}","starred_url":"https://api.github.com/users/jakemac53/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakemac53/subscriptions","organizations_url":"https://api.github.com/users/jakemac53/orgs","repos_url":"https://api.github.com/users/jakemac53/repos","events_url":"https://api.github.com/users/jakemac53/events{/privacy}","received_events_url":"https://api.github.com/users/jakemac53/received_events","type":"User","site_admin":false},"body":"holy cascades lol","created_at":"2015-09-21T20:26:46Z","updated_at":"2015-09-21T20:26:46Z","html_url":"https://github.com/angular/angular/pull/4292#discussion_r40021246","pull_request_url":"https://api.github.com/repos/angular/angular/pulls/4292","_links":{"self":{"href":"https://api.github.com/repos/angular/angular/pulls/comments/40021246"},"html":{"href":"https://github.com/angular/angular/pull/4292#discussion_r40021246"},"pull_request":{"href":"https://api.github.com/repos/angular/angular/pulls/4292"}}},"pull_request":{"url":"https://api.github.com/repos/angular/angular/pulls/4292","id":45591459,"html_url":"https://github.com/angular/angular/pull/4292","diff_url":"https://github.com/angular/angular/pull/4292.diff","patch_url":"https://github.com/angular/angular/pull/4292.patch","issue_url":"https://api.github.com/repos/angular/angular/issues/4292","number":4292,"state":"open","locked":false,"title":"refactor(dart/transform): Use protos to run & test directive_linker","user":{"login":"kegluneq","id":613610,"avatar_url":"https://avatars.githubusercontent.com/u/613610?v=3","gravatar_id":"","url":"https://api.github.com/users/kegluneq","html_url":"https://github.com/kegluneq","followers_url":"https://api.github.com/users/kegluneq/followers","following_url":"https://api.github.com/users/kegluneq/following{/other_user}","gists_url":"https://api.github.com/users/kegluneq/gists{/gist_id}","starred_url":"https://api.github.com/users/kegluneq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kegluneq/subscriptions","organizations_url":"https://api.github.com/users/kegluneq/orgs","repos_url":"https://api.github.com/users/kegluneq/repos","events_url":"https://api.github.com/users/kegluneq/events{/privacy}","received_events_url":"https://api.github.com/users/kegluneq/received_events","type":"User","site_admin":false},"body":"Use the proto ng_deps model objects internally and while testing the directive\r\nlinker rather than reading & comparing Dart code.","created_at":"2015-09-21T19:50:56Z","updated_at":"2015-09-21T20:26:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e4dddfb5aa5a96753819f19b74fb52ac4a0f1ff7","assignee":{"login":"jakemac53","id":984921,"avatar_url":"https://avatars.githubusercontent.com/u/984921?v=3","gravatar_id":"","url":"https://api.github.com/users/jakemac53","html_url":"https://github.com/jakemac53","followers_url":"https://api.github.com/users/jakemac53/followers","following_url":"https://api.github.com/users/jakemac53/following{/other_user}","gists_url":"https://api.github.com/users/jakemac53/gists{/gist_id}","starred_url":"https://api.github.com/users/jakemac53/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakemac53/subscriptions","organizations_url":"https://api.github.com/users/jakemac53/orgs","repos_url":"https://api.github.com/users/jakemac53/repos","events_url":"https://api.github.com/users/jakemac53/events{/privacy}","received_events_url":"https://api.github.com/users/jakemac53/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/angular/angular/pulls/4292/commits","review_comments_url":"https://api.github.com/repos/angular/angular/pulls/4292/comments","review_comment_url":"https://api.github.com/repos/angular/angular/pulls/comments{/number}","comments_url":"https://api.github.com/repos/angular/angular/issues/4292/comments","statuses_url":"https://api.github.com/repos/angular/angular/statuses/91fbe3a045ae546dcb3966a01de564934c15f6d9","head":{"label":"kegluneq:linker_tests","ref":"linker_tests","sha":"91fbe3a045ae546dcb3966a01de564934c15f6d9","user":{"login":"kegluneq","id":613610,"avatar_url":"https://avatars.githubusercontent.com/u/613610?v=3","gravatar_id":"","url":"https://api.github.com/users/kegluneq","html_url":"https://github.com/kegluneq","followers_url":"https://api.github.com/users/kegluneq/followers","following_url":"https://api.github.com/users/kegluneq/following{/other_user}","gists_url":"https://api.github.com/users/kegluneq/gists{/gist_id}","starred_url":"https://api.github.com/users/kegluneq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kegluneq/subscriptions","organizations_url":"https://api.github.com/users/kegluneq/orgs","repos_url":"https://api.github.com/users/kegluneq/repos","events_url":"https://api.github.com/users/kegluneq/events{/privacy}","received_events_url":"https://api.github.com/users/kegluneq/received_events","type":"User","site_admin":false},"repo":{"id":30424284,"name":"angular","full_name":"kegluneq/angular","owner":{"login":"kegluneq","id":613610,"avatar_url":"https://avatars.githubusercontent.com/u/613610?v=3","gravatar_id":"","url":"https://api.github.com/users/kegluneq","html_url":"https://github.com/kegluneq","followers_url":"https://api.github.com/users/kegluneq/followers","following_url":"https://api.github.com/users/kegluneq/following{/other_user}","gists_url":"https://api.github.com/users/kegluneq/gists{/gist_id}","starred_url":"https://api.github.com/users/kegluneq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kegluneq/subscriptions","organizations_url":"https://api.github.com/users/kegluneq/orgs","repos_url":"https://api.github.com/users/kegluneq/repos","events_url":"https://api.github.com/users/kegluneq/events{/privacy}","received_events_url":"https://api.github.com/users/kegluneq/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kegluneq/angular","description":"","fork":true,"url":"https://api.github.com/repos/kegluneq/angular","forks_url":"https://api.github.com/repos/kegluneq/angular/forks","keys_url":"https://api.github.com/repos/kegluneq/angular/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kegluneq/angular/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kegluneq/angular/teams","hooks_url":"https://api.github.com/repos/kegluneq/angular/hooks","issue_events_url":"https://api.github.com/repos/kegluneq/angular/issues/events{/number}","events_url":"https://api.github.com/repos/kegluneq/angular/events","assignees_url":"https://api.github.com/repos/kegluneq/angular/assignees{/user}","branches_url":"https://api.github.com/repos/kegluneq/angular/branches{/branch}","tags_url":"https://api.github.com/repos/kegluneq/angular/tags","blobs_url":"https://api.github.com/repos/kegluneq/angular/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kegluneq/angular/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kegluneq/angular/git/refs{/sha}","trees_url":"https://api.github.com/repos/kegluneq/angular/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kegluneq/angular/statuses/{sha}","languages_url":"https://api.github.com/repos/kegluneq/angular/languages","stargazers_url":"https://api.github.com/repos/kegluneq/angular/stargazers","contributors_url":"https://api.github.com/repos/kegluneq/angular/contributors","subscribers_url":"https://api.github.com/repos/kegluneq/angular/subscribers","subscription_url":"https://api.github.com/repos/kegluneq/angular/subscription","commits_url":"https://api.github.com/repos/kegluneq/angular/commits{/sha}","git_commits_url":"https://api.github.com/repos/kegluneq/angular/git/commits{/sha}","comments_url":"https://api.github.com/repos/kegluneq/angular/comments{/number}","issue_comment_url":"https://api.github.com/repos/kegluneq/angular/issues/comments{/number}","contents_url":"https://api.github.com/repos/kegluneq/angular/contents/{+path}","compare_url":"https://api.github.com/repos/kegluneq/angular/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kegluneq/angular/merges","archive_url":"https://api.github.com/repos/kegluneq/angular/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kegluneq/angular/downloads","issues_url":"https://api.github.com/repos/kegluneq/angular/issues{/number}","pulls_url":"https://api.github.com/repos/kegluneq/angular/pulls{/number}","milestones_url":"https://api.github.com/repos/kegluneq/angular/milestones{/number}","notifications_url":"https://api.github.com/repos/kegluneq/angular/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kegluneq/angular/labels{/name}","releases_url":"https://api.github.com/repos/kegluneq/angular/releases{/id}","created_at":"2015-02-06T17:30:07Z","updated_at":"2015-05-21T21:37:35Z","pushed_at":"2015-09-21T19:22:07Z","git_url":"git://github.com/kegluneq/angular.git","ssh_url":"git@github.com:kegluneq/angular.git","clone_url":"https://github.com/kegluneq/angular.git","svn_url":"https://github.com/kegluneq/angular","homepage":null,"size":15406,"stargazers_count":1,"watchers_count":1,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":6,"forks":1,"open_issues":6,"watchers":1,"default_branch":"master"}},"base":{"label":"angular:master","ref":"master","sha":"c2a60f1624ad54c424a2a9f6425420edd84e97b8","user":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=3","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"repo":{"id":24195339,"name":"angular","full_name":"angular/angular","owner":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=3","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/angular/angular","description":"","fork":false,"url":"https://api.github.com/repos/angular/angular","forks_url":"https://api.github.com/repos/angular/angular/forks","keys_url":"https://api.github.com/repos/angular/angular/keys{/key_id}","collaborators_url":"https://api.github.com/repos/angular/angular/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/angular/angular/teams","hooks_url":"https://api.github.com/repos/angular/angular/hooks","issue_events_url":"https://api.github.com/repos/angular/angular/issues/events{/number}","events_url":"https://api.github.com/repos/angular/angular/events","assignees_url":"https://api.github.com/repos/angular/angular/assignees{/user}","branches_url":"https://api.github.com/repos/angular/angular/branches{/branch}","tags_url":"https://api.github.com/repos/angular/angular/tags","blobs_url":"https://api.github.com/repos/angular/angular/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/angular/angular/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/angular/angular/git/refs{/sha}","trees_url":"https://api.github.com/repos/angular/angular/git/trees{/sha}","statuses_url":"https://api.github.com/repos/angular/angular/statuses/{sha}","languages_url":"https://api.github.com/repos/angular/angular/languages","stargazers_url":"https://api.github.com/repos/angular/angular/stargazers","contributors_url":"https://api.github.com/repos/angular/angular/contributors","subscribers_url":"https://api.github.com/repos/angular/angular/subscribers","subscription_url":"https://api.github.com/repos/angular/angular/subscription","commits_url":"https://api.github.com/repos/angular/angular/commits{/sha}","git_commits_url":"https://api.github.com/repos/angular/angular/git/commits{/sha}","comments_url":"https://api.github.com/repos/angular/angular/comments{/number}","issue_comment_url":"https://api.github.com/repos/angular/angular/issues/comments{/number}","contents_url":"https://api.github.com/repos/angular/angular/contents/{+path}","compare_url":"https://api.github.com/repos/angular/angular/compare/{base}...{head}","merges_url":"https://api.github.com/repos/angular/angular/merges","archive_url":"https://api.github.com/repos/angular/angular/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/angular/angular/downloads","issues_url":"https://api.github.com/repos/angular/angular/issues{/number}","pulls_url":"https://api.github.com/repos/angular/angular/pulls{/number}","milestones_url":"https://api.github.com/repos/angular/angular/milestones{/number}","notifications_url":"https://api.github.com/repos/angular/angular/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/angular/angular/labels{/name}","releases_url":"https://api.github.com/repos/angular/angular/releases{/id}","created_at":"2014-09-18T16:12:01Z","updated_at":"2015-09-21T19:50:24Z","pushed_at":"2015-09-21T19:57:29Z","git_url":"git://github.com/angular/angular.git","ssh_url":"git@github.com:angular/angular.git","clone_url":"https://github.com/angular/angular.git","svn_url":"https://github.com/angular/angular","homepage":"https://angular.io","size":52408,"stargazers_count":5432,"watchers_count":5432,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1481,"mirror_url":null,"open_issues_count":480,"forks":1481,"open_issues":480,"watchers":5432,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/angular/angular/pulls/4292"},"html":{"href":"https://github.com/angular/angular/pull/4292"},"issue":{"href":"https://api.github.com/repos/angular/angular/issues/4292"},"comments":{"href":"https://api.github.com/repos/angular/angular/issues/4292/comments"},"review_comments":{"href":"https://api.github.com/repos/angular/angular/pulls/4292/comments"},"review_comment":{"href":"https://api.github.com/repos/angular/angular/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/angular/angular/pulls/4292/commits"},"statuses":{"href":"https://api.github.com/repos/angular/angular/statuses/91fbe3a045ae546dcb3966a01de564934c15f6d9"}}}}