{"action":"created","comment":{"url":"https://api.github.com/repos/scala-js/scala-js/pulls/comments/44520026","id":44520026,"diff_hunk":"@@ -2168,6 +2168,66 @@ private[optimizer] abstract class OptimizerCore(\n     }\n   }\n \n+  /** Translate litterals to there ScalaJS String representation. */\n+  private def foldToStringForString_+(tree: Tree)(implicit pos : Position): Tree = tree match {\n+    case FloatLiteral(value)   => StringLiteral(jsNumberToString(value.toDouble))\n+    case DoubleLiteral(value)  => StringLiteral(jsNumberToString(value))\n+    case LongLiteral(value)    => StringLiteral(value.toString)\n+    case IntLiteral(value)     => StringLiteral(value.toString)\n+    case BooleanLiteral(value) => StringLiteral(value.toString)\n+    case Null()                => StringLiteral(\"null\")\n+    case Undefined()           => StringLiteral(\"undefined\")\n+\n+    case _ => tree\n+  }\n+\n+  /* Following the ECMAScript 6 specification */\n+  private def jsNumberToString(value: Double): String = {","path":"tools/shared/src/main/scala/org/scalajs/core/tools/optimizer/OptimizerCore.scala","position":18,"original_position":18,"commit_id":"82346e0d6b9c52535b8238ea741773886b0308b0","original_commit_id":"82346e0d6b9c52535b8238ea741773886b0308b0","user":{"login":"sjrd","id":535934,"avatar_url":"https://avatars.githubusercontent.com/u/535934?v=3","gravatar_id":"","url":"https://api.github.com/users/sjrd","html_url":"https://github.com/sjrd","followers_url":"https://api.github.com/users/sjrd/followers","following_url":"https://api.github.com/users/sjrd/following{/other_user}","gists_url":"https://api.github.com/users/sjrd/gists{/gist_id}","starred_url":"https://api.github.com/users/sjrd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjrd/subscriptions","organizations_url":"https://api.github.com/users/sjrd/orgs","repos_url":"https://api.github.com/users/sjrd/repos","events_url":"https://api.github.com/users/sjrd/events{/privacy}","received_events_url":"https://api.github.com/users/sjrd/received_events","type":"User","site_admin":false},"body":"If you decide to keep the full algorithm, you need to thoroughly test it, by having a good test with\r\n```scala\r\n@noinline def toStringNoInline(v: Double): String = v.toString\r\n@inline def test(v: Double): Unit =\r\n  expect(v.toString).toEqual(toStringNoInline(v))\r\n\r\n// Specials\r\ntest(0.0)\r\ntest(-0.0)\r\ntest(Double.NaN)\r\ntest(Double.PositiveInfinity)\r\ntest(Double.NegativeInfinity)\r\n\r\n// k <= n <= 21\r\ntest(1.0)\r\ntest(1e10)\r\ntest(1e20)\r\n...\r\n```\r\netc., with a section for each case of the algorithm (that's called whitebox testing).","created_at":"2015-11-11T10:41:10Z","updated_at":"2015-11-11T10:41:10Z","html_url":"https://github.com/scala-js/scala-js/pull/2007#discussion_r44520026","pull_request_url":"https://api.github.com/repos/scala-js/scala-js/pulls/2007","_links":{"self":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/comments/44520026"},"html":{"href":"https://github.com/scala-js/scala-js/pull/2007#discussion_r44520026"},"pull_request":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/2007"}}},"pull_request":{"url":"https://api.github.com/repos/scala-js/scala-js/pulls/2007","id":50064428,"html_url":"https://github.com/scala-js/scala-js/pull/2007","diff_url":"https://github.com/scala-js/scala-js/pull/2007.diff","patch_url":"https://github.com/scala-js/scala-js/pull/2007.patch","issue_url":"https://api.github.com/repos/scala-js/scala-js/issues/2007","number":2007,"state":"open","locked":false,"title":"Fix #1524: Implement constant folding for +[string].","user":{"login":"tOverney","id":5649878,"avatar_url":"https://avatars.githubusercontent.com/u/5649878?v=3","gravatar_id":"","url":"https://api.github.com/users/tOverney","html_url":"https://github.com/tOverney","followers_url":"https://api.github.com/users/tOverney/followers","following_url":"https://api.github.com/users/tOverney/following{/other_user}","gists_url":"https://api.github.com/users/tOverney/gists{/gist_id}","starred_url":"https://api.github.com/users/tOverney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tOverney/subscriptions","organizations_url":"https://api.github.com/users/tOverney/orgs","repos_url":"https://api.github.com/users/tOverney/repos","events_url":"https://api.github.com/users/tOverney/events{/privacy}","received_events_url":"https://api.github.com/users/tOverney/received_events","type":"User","site_admin":false},"body":"/cc @paullepoulpe","created_at":"2015-11-08T17:04:27Z","updated_at":"2015-11-11T10:41:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"82b80811e6fa2625428f9a08c0eecf19756bdd40","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scala-js/scala-js/pulls/2007/commits","review_comments_url":"https://api.github.com/repos/scala-js/scala-js/pulls/2007/comments","review_comment_url":"https://api.github.com/repos/scala-js/scala-js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scala-js/scala-js/issues/2007/comments","statuses_url":"https://api.github.com/repos/scala-js/scala-js/statuses/82346e0d6b9c52535b8238ea741773886b0308b0","head":{"label":"SebsLittleHelpers:string-plus-cst-fold","ref":"string-plus-cst-fold","sha":"82346e0d6b9c52535b8238ea741773886b0308b0","user":{"login":"SebsLittleHelpers","id":14347777,"avatar_url":"https://avatars.githubusercontent.com/u/14347777?v=3","gravatar_id":"","url":"https://api.github.com/users/SebsLittleHelpers","html_url":"https://github.com/SebsLittleHelpers","followers_url":"https://api.github.com/users/SebsLittleHelpers/followers","following_url":"https://api.github.com/users/SebsLittleHelpers/following{/other_user}","gists_url":"https://api.github.com/users/SebsLittleHelpers/gists{/gist_id}","starred_url":"https://api.github.com/users/SebsLittleHelpers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SebsLittleHelpers/subscriptions","organizations_url":"https://api.github.com/users/SebsLittleHelpers/orgs","repos_url":"https://api.github.com/users/SebsLittleHelpers/repos","events_url":"https://api.github.com/users/SebsLittleHelpers/events{/privacy}","received_events_url":"https://api.github.com/users/SebsLittleHelpers/received_events","type":"Organization","site_admin":false},"repo":{"id":44560954,"name":"scala-js","full_name":"SebsLittleHelpers/scala-js","owner":{"login":"SebsLittleHelpers","id":14347777,"avatar_url":"https://avatars.githubusercontent.com/u/14347777?v=3","gravatar_id":"","url":"https://api.github.com/users/SebsLittleHelpers","html_url":"https://github.com/SebsLittleHelpers","followers_url":"https://api.github.com/users/SebsLittleHelpers/followers","following_url":"https://api.github.com/users/SebsLittleHelpers/following{/other_user}","gists_url":"https://api.github.com/users/SebsLittleHelpers/gists{/gist_id}","starred_url":"https://api.github.com/users/SebsLittleHelpers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SebsLittleHelpers/subscriptions","organizations_url":"https://api.github.com/users/SebsLittleHelpers/orgs","repos_url":"https://api.github.com/users/SebsLittleHelpers/repos","events_url":"https://api.github.com/users/SebsLittleHelpers/events{/privacy}","received_events_url":"https://api.github.com/users/SebsLittleHelpers/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SebsLittleHelpers/scala-js","description":"Scala.js, the Scala to JavaScript compiler","fork":true,"url":"https://api.github.com/repos/SebsLittleHelpers/scala-js","forks_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/forks","keys_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/teams","hooks_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/hooks","issue_events_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/issues/events{/number}","events_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/events","assignees_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/assignees{/user}","branches_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/branches{/branch}","tags_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/tags","blobs_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/statuses/{sha}","languages_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/languages","stargazers_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/stargazers","contributors_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/contributors","subscribers_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/subscribers","subscription_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/subscription","commits_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/contents/{+path}","compare_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/merges","archive_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/downloads","issues_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/issues{/number}","pulls_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/pulls{/number}","milestones_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/milestones{/number}","notifications_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/labels{/name}","releases_url":"https://api.github.com/repos/SebsLittleHelpers/scala-js/releases{/id}","created_at":"2015-10-19T20:09:45Z","updated_at":"2015-10-19T20:09:50Z","pushed_at":"2015-11-10T22:35:44Z","git_url":"git://github.com/SebsLittleHelpers/scala-js.git","ssh_url":"git@github.com:SebsLittleHelpers/scala-js.git","clone_url":"https://github.com/SebsLittleHelpers/scala-js.git","svn_url":"https://github.com/SebsLittleHelpers/scala-js","homepage":"http://www.scala-js.org/","size":9654,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"scala-js:master","ref":"master","sha":"f7474c1338730f79b55e3d7301146df73ccb5d2b","user":{"login":"scala-js","id":6039724,"avatar_url":"https://avatars.githubusercontent.com/u/6039724?v=3","gravatar_id":"","url":"https://api.github.com/users/scala-js","html_url":"https://github.com/scala-js","followers_url":"https://api.github.com/users/scala-js/followers","following_url":"https://api.github.com/users/scala-js/following{/other_user}","gists_url":"https://api.github.com/users/scala-js/gists{/gist_id}","starred_url":"https://api.github.com/users/scala-js/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scala-js/subscriptions","organizations_url":"https://api.github.com/users/scala-js/orgs","repos_url":"https://api.github.com/users/scala-js/repos","events_url":"https://api.github.com/users/scala-js/events{/privacy}","received_events_url":"https://api.github.com/users/scala-js/received_events","type":"Organization","site_admin":false},"repo":{"id":8272315,"name":"scala-js","full_name":"scala-js/scala-js","owner":{"login":"scala-js","id":6039724,"avatar_url":"https://avatars.githubusercontent.com/u/6039724?v=3","gravatar_id":"","url":"https://api.github.com/users/scala-js","html_url":"https://github.com/scala-js","followers_url":"https://api.github.com/users/scala-js/followers","following_url":"https://api.github.com/users/scala-js/following{/other_user}","gists_url":"https://api.github.com/users/scala-js/gists{/gist_id}","starred_url":"https://api.github.com/users/scala-js/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scala-js/subscriptions","organizations_url":"https://api.github.com/users/scala-js/orgs","repos_url":"https://api.github.com/users/scala-js/repos","events_url":"https://api.github.com/users/scala-js/events{/privacy}","received_events_url":"https://api.github.com/users/scala-js/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scala-js/scala-js","description":"Scala.js, the Scala to JavaScript compiler","fork":false,"url":"https://api.github.com/repos/scala-js/scala-js","forks_url":"https://api.github.com/repos/scala-js/scala-js/forks","keys_url":"https://api.github.com/repos/scala-js/scala-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scala-js/scala-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scala-js/scala-js/teams","hooks_url":"https://api.github.com/repos/scala-js/scala-js/hooks","issue_events_url":"https://api.github.com/repos/scala-js/scala-js/issues/events{/number}","events_url":"https://api.github.com/repos/scala-js/scala-js/events","assignees_url":"https://api.github.com/repos/scala-js/scala-js/assignees{/user}","branches_url":"https://api.github.com/repos/scala-js/scala-js/branches{/branch}","tags_url":"https://api.github.com/repos/scala-js/scala-js/tags","blobs_url":"https://api.github.com/repos/scala-js/scala-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scala-js/scala-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scala-js/scala-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/scala-js/scala-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scala-js/scala-js/statuses/{sha}","languages_url":"https://api.github.com/repos/scala-js/scala-js/languages","stargazers_url":"https://api.github.com/repos/scala-js/scala-js/stargazers","contributors_url":"https://api.github.com/repos/scala-js/scala-js/contributors","subscribers_url":"https://api.github.com/repos/scala-js/scala-js/subscribers","subscription_url":"https://api.github.com/repos/scala-js/scala-js/subscription","commits_url":"https://api.github.com/repos/scala-js/scala-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/scala-js/scala-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/scala-js/scala-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/scala-js/scala-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/scala-js/scala-js/contents/{+path}","compare_url":"https://api.github.com/repos/scala-js/scala-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scala-js/scala-js/merges","archive_url":"https://api.github.com/repos/scala-js/scala-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scala-js/scala-js/downloads","issues_url":"https://api.github.com/repos/scala-js/scala-js/issues{/number}","pulls_url":"https://api.github.com/repos/scala-js/scala-js/pulls{/number}","milestones_url":"https://api.github.com/repos/scala-js/scala-js/milestones{/number}","notifications_url":"https://api.github.com/repos/scala-js/scala-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scala-js/scala-js/labels{/name}","releases_url":"https://api.github.com/repos/scala-js/scala-js/releases{/id}","created_at":"2013-02-18T16:33:55Z","updated_at":"2015-11-11T05:18:29Z","pushed_at":"2015-11-10T22:35:44Z","git_url":"git://github.com/scala-js/scala-js.git","ssh_url":"git@github.com:scala-js/scala-js.git","clone_url":"https://github.com/scala-js/scala-js.git","svn_url":"https://github.com/scala-js/scala-js","homepage":"http://www.scala-js.org/","size":18227,"stargazers_count":1931,"watchers_count":1931,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":172,"mirror_url":null,"open_issues_count":82,"forks":172,"open_issues":82,"watchers":1931,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/2007"},"html":{"href":"https://github.com/scala-js/scala-js/pull/2007"},"issue":{"href":"https://api.github.com/repos/scala-js/scala-js/issues/2007"},"comments":{"href":"https://api.github.com/repos/scala-js/scala-js/issues/2007/comments"},"review_comments":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/2007/comments"},"review_comment":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/2007/commits"},"statuses":{"href":"https://api.github.com/repos/scala-js/scala-js/statuses/82346e0d6b9c52535b8238ea741773886b0308b0"}}}}