{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/35363414","id":35363414,"diff_hunk":"@@ -0,0 +1,454 @@\n+/// <reference path=\"..\\..\\..\\src\\harness\\harness.ts\" />\r\n+\r\n+module ts.server {\r\n+    let lastWrittenToHost: string;\r\n+    const mockHost: ServerHost = {\r\n+        args: [],\r\n+        newLine: \"\\n\",\r\n+        useCaseSensitiveFileNames: true,\r\n+        write(s): void { lastWrittenToHost = s; },\r\n+        readFile(): string { return void 0; },\r\n+        writeFile(): void {},\r\n+        resolvePath(): string { return void 0; },\r\n+        fileExists: () => false,\r\n+        directoryExists: () => false,\r\n+        createDirectory(): void {},\r\n+        getExecutingFilePath(): string { return void 0; },\r\n+        getCurrentDirectory(): string { return void 0; },\r\n+        readDirectory(): string[] { return []; },\r\n+        exit(): void {}\r\n+    };\r\n+    const mockLogger: Logger = {\r\n+        close(): void {},\r\n+        isVerbose(): boolean { return false; },\r\n+        loggingEnabled(): boolean { return false; },\r\n+        perftrc(s: string): void {},\r\n+        info(s: string): void {},\r\n+        startGroup(): void {},\r\n+        endGroup(): void {},\r\n+        msg(s: string, type?: string): void {},\r\n+    };\r\n+    \r\n+    describe(\"the Session class\", () => {\r\n+        let session: Session;\r\n+        let lastSent: protocol.Message;\r\n+\r\n+        beforeEach(() => {\r\n+            session = new Session(mockHost, Buffer.byteLength, process.hrtime, mockLogger);\r\n+            session.send = (msg: protocol.Message) => {\r\n+                lastSent = msg;\r\n+            };\r\n+        });\r\n+\r\n+        describe(\"executeCommand\", () => {\r\n+            it(\"should throw when commands are executed with invalid arguments\", () => {\r\n+                const req: protocol.FileRequest = {\r\n+                    command: CommandNames.Open,\r\n+                    seq: 0,\r\n+                    type: \"command\",\r\n+                    arguments: {\r\n+                        file: undefined\r\n+                    }\r\n+                };\r\n+\r\n+                expect(() => session.executeCommand(req)).to.throw();\r\n+            });\r\n+            it(\"should output an error response when a command does not exist\", () => {\r\n+                const req: protocol.Request = {\r\n+                    command: \"foobar\",\r\n+                    seq: 0,\r\n+                    type: \"command\"\r\n+                };\r\n+\r\n+                session.executeCommand(req);\r\n+\r\n+                expect(lastSent).to.deep.equal(<protocol.Response>{\r\n+                    command: CommandNames.Unknown,\r\n+                    type: \"response\",\r\n+                    seq: 0,\r\n+                    message: \"Unrecognized JSON command: foobar\",\r\n+                    request_seq: 0,\r\n+                    success: false\r\n+                });\r\n+            });\r\n+            it(\"should return a tuple containing the response and if a response is required on success\", () => {\r\n+                const req: protocol.ConfigureRequest = {\r\n+                    command: CommandNames.Configure,\r\n+                    seq: 0,\r\n+                    type: \"command\",\r\n+                    arguments: {\r\n+                        hostInfo: \"unit test\",\r\n+                        formatOptions: {\r\n+                            newLineCharacter: \"`n\"\r\n+                        }\r\n+                    }\r\n+                };\r\n+\r\n+                expect(session.executeCommand(req)).to.deep.equal({\r\n+                    responseRequired: false\r\n+                });\r\n+                expect(lastSent).to.deep.equal({\r\n+                    command: CommandNames.Configure,\r\n+                    type: \"response\",\r\n+                    success: true,\r\n+                    request_seq: 0,\r\n+                    seq: 0,\r\n+                    body: undefined\r\n+                });\r\n+            });\r\n+        });\r\n+\r\n+        describe(\"onMessage\", () => {\r\n+            it(\"should not throw when commands are executed with invalid arguments\", () => {\r\n+                let i = 0;\r\n+                for (name in CommandNames) {\r\n+                    if (!Object.prototype.hasOwnProperty.call(CommandNames, name)) {\r\n+                        continue;\r\n+                    }\r\n+                    const req: protocol.Request = {\r\n+                        command: name,\r\n+                        seq: i++,\r\n+                        type: \"command\"\r\n+                    };\r\n+                    session.onMessage(JSON.stringify(req));\r\n+                    req.seq = i++;\r\n+                    req.arguments = {};\r\n+                    session.onMessage(JSON.stringify(req));\r\n+                    req.seq = i++;\r\n+                    req.arguments = null;\r\n+                    session.onMessage(JSON.stringify(req));\r\n+                    req.seq = i++;\r\n+                    req.arguments = \"\";\r\n+                    session.onMessage(JSON.stringify(req));\r\n+                    req.seq = i++;\r\n+                    req.arguments = 0;\r\n+                    session.onMessage(JSON.stringify(req));\r\n+                    req.seq = i++;\r\n+                    req.arguments = [];\r\n+                    session.onMessage(JSON.stringify(req));\r\n+                }\r\n+                session.onMessage(\"GARBAGE NON_JSON DATA\");\r\n+            });\r\n+            it(\"should output the response for a correctly handled message\", () => {\r\n+                const req: protocol.ConfigureRequest = {\r\n+                    command: CommandNames.Configure,\r\n+                    seq: 0,\r\n+                    type: \"command\",\r\n+                    arguments: {\r\n+                        hostInfo: \"unit test\",\r\n+                        formatOptions: {\r\n+                            newLineCharacter: \"`n\"\r\n+                        }\r\n+                    }\r\n+                };\r\n+\r\n+                session.onMessage(JSON.stringify(req));\r\n+\r\n+                expect(lastSent).to.deep.equal(<protocol.ConfigureResponse>{\r\n+                    command: CommandNames.Configure,\r\n+                    type: \"response\",\r\n+                    success: true,\r\n+                    request_seq: 0,\r\n+                    seq: 0,\r\n+                    body: undefined\r\n+                });\r\n+            });\r\n+        });\r\n+\r\n+        describe(\"exit\", () => {\r\n+            it(\"is a noop which can be handled by subclasses\", () => {\r\n+                session.exit(); // Does nothing, should keep running tests\r\n+                expect(session).to.exist;\r","path":"tests/cases/unittests/session.ts","position":161,"original_position":161,"commit_id":"90bbb7fb3c94300a406fc9deb6e3dcafdefed83b","original_commit_id":"5fb5b244fbd9c1360b539798dd36ec9ab868badf","user":{"login":"weswigham","id":2932786,"avatar_url":"https://avatars.githubusercontent.com/u/2932786?v=3","gravatar_id":"","url":"https://api.github.com/users/weswigham","html_url":"https://github.com/weswigham","followers_url":"https://api.github.com/users/weswigham/followers","following_url":"https://api.github.com/users/weswigham/following{/other_user}","gists_url":"https://api.github.com/users/weswigham/gists{/gist_id}","starred_url":"https://api.github.com/users/weswigham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weswigham/subscriptions","organizations_url":"https://api.github.com/users/weswigham/orgs","repos_url":"https://api.github.com/users/weswigham/repos","events_url":"https://api.github.com/users/weswigham/events{/privacy}","received_events_url":"https://api.github.com/users/weswigham/received_events","type":"User","site_admin":false},"body":"Got it.","created_at":"2015-07-23T19:49:28Z","updated_at":"2015-07-23T19:49:28Z","html_url":"https://github.com/Microsoft/TypeScript/pull/3967#discussion_r35363414","pull_request_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/3967","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/35363414"},"html":{"href":"https://github.com/Microsoft/TypeScript/pull/3967#discussion_r35363414"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/3967"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/3967","id":40515034,"html_url":"https://github.com/Microsoft/TypeScript/pull/3967","diff_url":"https://github.com/Microsoft/TypeScript/pull/3967.diff","patch_url":"https://github.com/Microsoft/TypeScript/pull/3967.patch","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3967","number":3967,"state":"open","locked":false,"title":"Tests for the Session API","user":{"login":"weswigham","id":2932786,"avatar_url":"https://avatars.githubusercontent.com/u/2932786?v=3","gravatar_id":"","url":"https://api.github.com/users/weswigham","html_url":"https://github.com/weswigham","followers_url":"https://api.github.com/users/weswigham/followers","following_url":"https://api.github.com/users/weswigham/following{/other_user}","gists_url":"https://api.github.com/users/weswigham/gists{/gist_id}","starred_url":"https://api.github.com/users/weswigham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weswigham/subscriptions","organizations_url":"https://api.github.com/users/weswigham/orgs","repos_url":"https://api.github.com/users/weswigham/repos","events_url":"https://api.github.com/users/weswigham/events{/privacy}","received_events_url":"https://api.github.com/users/weswigham/received_events","type":"User","site_admin":false},"body":"Additionally, I added visibility modifiers to all the members, so we declare public as little as is required.\r\n\r\nWhen merged, this should close issue #3813.","created_at":"2015-07-21T23:08:52Z","updated_at":"2015-07-23T19:49:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1dbd8af8d188cf376380c81674d23e6295ade26b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/3967/commits","review_comments_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/3967/comments","review_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3967/comments","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/90bbb7fb3c94300a406fc9deb6e3dcafdefed83b","head":{"label":"weswigham:issues/3813","ref":"issues/3813","sha":"90bbb7fb3c94300a406fc9deb6e3dcafdefed83b","user":{"login":"weswigham","id":2932786,"avatar_url":"https://avatars.githubusercontent.com/u/2932786?v=3","gravatar_id":"","url":"https://api.github.com/users/weswigham","html_url":"https://github.com/weswigham","followers_url":"https://api.github.com/users/weswigham/followers","following_url":"https://api.github.com/users/weswigham/following{/other_user}","gists_url":"https://api.github.com/users/weswigham/gists{/gist_id}","starred_url":"https://api.github.com/users/weswigham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weswigham/subscriptions","organizations_url":"https://api.github.com/users/weswigham/orgs","repos_url":"https://api.github.com/users/weswigham/repos","events_url":"https://api.github.com/users/weswigham/events{/privacy}","received_events_url":"https://api.github.com/users/weswigham/received_events","type":"User","site_admin":false},"repo":{"id":37160442,"name":"TypeScript","full_name":"weswigham/TypeScript","owner":{"login":"weswigham","id":2932786,"avatar_url":"https://avatars.githubusercontent.com/u/2932786?v=3","gravatar_id":"","url":"https://api.github.com/users/weswigham","html_url":"https://github.com/weswigham","followers_url":"https://api.github.com/users/weswigham/followers","following_url":"https://api.github.com/users/weswigham/following{/other_user}","gists_url":"https://api.github.com/users/weswigham/gists{/gist_id}","starred_url":"https://api.github.com/users/weswigham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weswigham/subscriptions","organizations_url":"https://api.github.com/users/weswigham/orgs","repos_url":"https://api.github.com/users/weswigham/repos","events_url":"https://api.github.com/users/weswigham/events{/privacy}","received_events_url":"https://api.github.com/users/weswigham/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/weswigham/TypeScript","description":"TypeScript is a superset of JavaScript that compiles to clean JavaScript output.","fork":true,"url":"https://api.github.com/repos/weswigham/TypeScript","forks_url":"https://api.github.com/repos/weswigham/TypeScript/forks","keys_url":"https://api.github.com/repos/weswigham/TypeScript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/weswigham/TypeScript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/weswigham/TypeScript/teams","hooks_url":"https://api.github.com/repos/weswigham/TypeScript/hooks","issue_events_url":"https://api.github.com/repos/weswigham/TypeScript/issues/events{/number}","events_url":"https://api.github.com/repos/weswigham/TypeScript/events","assignees_url":"https://api.github.com/repos/weswigham/TypeScript/assignees{/user}","branches_url":"https://api.github.com/repos/weswigham/TypeScript/branches{/branch}","tags_url":"https://api.github.com/repos/weswigham/TypeScript/tags","blobs_url":"https://api.github.com/repos/weswigham/TypeScript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/weswigham/TypeScript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/weswigham/TypeScript/git/refs{/sha}","trees_url":"https://api.github.com/repos/weswigham/TypeScript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/weswigham/TypeScript/statuses/{sha}","languages_url":"https://api.github.com/repos/weswigham/TypeScript/languages","stargazers_url":"https://api.github.com/repos/weswigham/TypeScript/stargazers","contributors_url":"https://api.github.com/repos/weswigham/TypeScript/contributors","subscribers_url":"https://api.github.com/repos/weswigham/TypeScript/subscribers","subscription_url":"https://api.github.com/repos/weswigham/TypeScript/subscription","commits_url":"https://api.github.com/repos/weswigham/TypeScript/commits{/sha}","git_commits_url":"https://api.github.com/repos/weswigham/TypeScript/git/commits{/sha}","comments_url":"https://api.github.com/repos/weswigham/TypeScript/comments{/number}","issue_comment_url":"https://api.github.com/repos/weswigham/TypeScript/issues/comments{/number}","contents_url":"https://api.github.com/repos/weswigham/TypeScript/contents/{+path}","compare_url":"https://api.github.com/repos/weswigham/TypeScript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/weswigham/TypeScript/merges","archive_url":"https://api.github.com/repos/weswigham/TypeScript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/weswigham/TypeScript/downloads","issues_url":"https://api.github.com/repos/weswigham/TypeScript/issues{/number}","pulls_url":"https://api.github.com/repos/weswigham/TypeScript/pulls{/number}","milestones_url":"https://api.github.com/repos/weswigham/TypeScript/milestones{/number}","notifications_url":"https://api.github.com/repos/weswigham/TypeScript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/weswigham/TypeScript/labels{/name}","releases_url":"https://api.github.com/repos/weswigham/TypeScript/releases{/id}","created_at":"2015-06-09T21:48:48Z","updated_at":"2015-06-09T21:49:23Z","pushed_at":"2015-07-23T19:49:07Z","git_url":"git://github.com/weswigham/TypeScript.git","ssh_url":"git@github.com:weswigham/TypeScript.git","clone_url":"https://github.com/weswigham/TypeScript.git","svn_url":"https://github.com/weswigham/TypeScript","homepage":"http://www.typescriptlang.org","size":183960,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"6f00275b04378cf9004ea524d30d9a385c7322d8","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":20929025,"name":"TypeScript","full_name":"Microsoft/TypeScript","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/TypeScript","description":"TypeScript is a superset of JavaScript that compiles to clean JavaScript output.","fork":false,"url":"https://api.github.com/repos/Microsoft/TypeScript","forks_url":"https://api.github.com/repos/Microsoft/TypeScript/forks","keys_url":"https://api.github.com/repos/Microsoft/TypeScript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/TypeScript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/TypeScript/teams","hooks_url":"https://api.github.com/repos/Microsoft/TypeScript/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/TypeScript/events","assignees_url":"https://api.github.com/repos/Microsoft/TypeScript/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/TypeScript/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/TypeScript/tags","blobs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/TypeScript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/TypeScript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/TypeScript/languages","stargazers_url":"https://api.github.com/repos/Microsoft/TypeScript/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/TypeScript/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/TypeScript/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/TypeScript/subscription","commits_url":"https://api.github.com/repos/Microsoft/TypeScript/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/TypeScript/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/TypeScript/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/TypeScript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/TypeScript/merges","archive_url":"https://api.github.com/repos/Microsoft/TypeScript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/TypeScript/downloads","issues_url":"https://api.github.com/repos/Microsoft/TypeScript/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/TypeScript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/TypeScript/releases{/id}","created_at":"2014-06-17T15:28:39Z","updated_at":"2015-07-23T18:11:57Z","pushed_at":"2015-07-23T19:49:08Z","git_url":"git://github.com/Microsoft/TypeScript.git","ssh_url":"git@github.com:Microsoft/TypeScript.git","clone_url":"https://github.com/Microsoft/TypeScript.git","svn_url":"https://github.com/Microsoft/TypeScript","homepage":"http://www.typescriptlang.org","size":945378,"stargazers_count":6021,"watchers_count":6021,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":662,"mirror_url":null,"open_issues_count":713,"forks":662,"open_issues":713,"watchers":6021,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/3967"},"html":{"href":"https://github.com/Microsoft/TypeScript/pull/3967"},"issue":{"href":"https://api.github.com/repos/Microsoft/TypeScript/issues/3967"},"comments":{"href":"https://api.github.com/repos/Microsoft/TypeScript/issues/3967/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/3967/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/3967/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/TypeScript/statuses/90bbb7fb3c94300a406fc9deb6e3dcafdefed83b"}}}}