{"action":"created","comment":{"url":"https://api.github.com/repos/akka/akka-stream-contrib/pulls/comments/76745497","id":76745497,"diff_hunk":"@@ -0,0 +1,198 @@\n+/*\n+ * Copyright (C) 2016 Lightbend Inc. <http://www.lightbend.com>\n+ */\n+package akka.stream.contrib\n+\n+import akka.stream.scaladsl._\n+import akka.stream.{ KillSwitches, FlowShape }\n+import akka.stream.testkit.scaladsl.TestSink\n+\n+class UnfoldFlowSpecAutoFusingOn extends { val autoFusing = true } with UnfoldFlowSpec\n+class UnfoldFlowSpecAutoFusingOff extends { val autoFusing = false } with UnfoldFlowSpec\n+\n+trait UnfoldFlowSpec extends BaseStreamSpec {\n+\n+  \"unfoldFlow\" should {\n+\n+    \"unfold Collatz conjecture with a sequence of 111 elements\" should {\n+\n+      val done = new Exception(\"done\")\n+      val outputs = List(27, 82, 41, 124, 62, 31, 94, 47, 142, 71, 214, 107, 322, 161, 484, 242, 121, 364, 182, 91, 274, 137, 412, 206, 103, 310, 155, 466, 233, 700, 350, 175, 526, 263, 790, 395, 1186, 593, 1780, 890, 445, 1336, 668, 334, 167, 502, 251, 754, 377, 1132, 566, 283, 850, 425, 1276, 638, 319, 958, 479, 1438, 719, 2158, 1079, 3238, 1619, 4858, 2429, 7288, 3644, 1822, 911, 2734, 1367, 4102, 2051, 6154, 3077, 9232, 4616, 2308, 1154, 577, 1732, 866, 433, 1300, 650, 325, 976, 488, 244, 122, 61, 184, 92, 46, 23, 70, 35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2)\n+\n+      \"with flow\" in {\n+\n+        val source = SourceGen.unfoldFlow(27)(Flow.fromFunction[Int, (Int, Int)] {\n+          case 1               => throw done\n+          case n if n % 2 == 0 => (n / 2, n)\n+          case n               => (n * 3 + 1, n)\n+        }.recover {\n+          case `done` => (1, 1)\n+        })\n+\n+        val sink = source.runWith(TestSink.probe)\n+        outputs.foreach { output =>\n+          sink.request(1)\n+          sink.expectNext(output)\n+        }\n+        sink.request(1)\n+        sink.expectNext(1)\n+        sink.expectComplete()\n+      }\n+\n+      \"with function\" in {\n+\n+        val source = SourceGen.unfoldFlowWith(27, Flow.fromFunction(identity[Int])) {\n+          case 1               => None\n+          case n if n % 2 == 0 => Some((n / 2, n))\n+          case n               => Some((n * 3 + 1, n))\n+        }\n+\n+        val sink = source.runWith(TestSink.probe)\n+        outputs.foreach { output =>\n+          sink.request(1)\n+          sink.expectNext(output)\n+        }\n+        sink.request(1)\n+        sink.expectComplete()\n+      }\n+    }\n+\n+    \"increment integers & handle KillSwitch\" should {\n+\n+      \"with simple flow\" should {\n+\n+        \"killSwitch prepended to flow\" should {\n+          val source = SourceGen.unfoldFlow(1)(Flow.fromGraph(KillSwitches.single[Int]).map { n =>\n+            (n + 1, n)\n+          })\n+\n+          \"fail instantly when aborted\" in {\n+            val (killSwitch, sink) = source.toMat(TestSink.probe)(Keep.both).run()\n+            val kill = new Exception(\"KILL!\")\n+            sink.ensureSubscription()\n+            killSwitch.abort(kill)\n+            sink.expectError(kill)\n+          }\n+\n+          \"fail when inner stream is canceled and pulled before completion\" in {\n+            val (killSwitch, sink) = source.toMat(TestSink.probe)(Keep.both).run()\n+            val kill = new Exception(\"KILL!\")\n+            sink.ensureSubscription()\n+            killSwitch.abort(kill)\n+            sink.request(1)\n+            sink.expectError(kill)\n+          }\n+\n+          \"fail after 3 elements when aborted\" in {\n+            val (killSwitch, sink) = source.toMat(TestSink.probe)(Keep.both).run()\n+            val kill = new Exception(\"KILL!\")\n+            sink.requestNext(1)\n+            sink.requestNext(2)\n+            sink.requestNext(3)\n+            killSwitch.abort(kill)\n+            sink.expectError(kill)\n+          }\n+\n+          \"complete gracefully when stopped\" in {\n+            val (killSwitch, sink) = source.toMat(TestSink.probe)(Keep.both).run()\n+            sink.ensureSubscription()\n+            killSwitch.shutdown()\n+            sink.expectComplete()\n+          }\n+\n+          \"complete gracefully after 3 elements when stopped\" in {\n+            val (killSwitch, sink) = source.toMat(TestSink.probe)(Keep.both).run()\n+            sink.requestNext(1)\n+            sink.requestNext(2)\n+            sink.requestNext(3)\n+            killSwitch.shutdown()\n+            sink.expectComplete()\n+          }\n+        }\n+\n+        \"killSwitch appended to flow\" should {\n+\n+          val source = SourceGen.unfoldFlow(1)(Flow[Int].map { n =>\n+            (n + 1, n)\n+          }.viaMat(KillSwitches.single)(Keep.right))\n+\n+          \"fail instantly when aborted\" in {\n+            val (killSwitch, sink) = source.toMat(TestSink.probe)(Keep.both).run()\n+            val kill = new Exception(\"KILL!\")\n+            sink.ensureSubscription()\n+            killSwitch.abort(kill)\n+            sink.expectError(kill)\n+          }\n+\n+          \"fail after 3 elements when aborted\" in {\n+            val (killSwitch, sink) = source.toMat(TestSink.probe)(Keep.both).run()\n+            val kill = new Exception(\"KILL!\")\n+            sink.requestNext(1)\n+            sink.requestNext(2)\n+            sink.requestNext(3)\n+            killSwitch.abort(kill)\n+            sink.expectError(kill)\n+          }\n+\n+          \"complete gracefully when stopped\" in {\n+            val (killSwitch, sink) = source.toMat(TestSink.probe)(Keep.both).run()\n+            sink.ensureSubscription()\n+            killSwitch.shutdown()\n+            sink.expectComplete()\n+          }\n+\n+          \"complete gracefully after 3 elements when stopped\" in {\n+            val (killSwitch, sink) = source.toMat(TestSink.probe)(Keep.both).run()\n+            sink.requestNext(1)\n+            sink.requestNext(2)\n+            sink.requestNext(3)\n+            killSwitch.shutdown()\n+            sink.expectComplete()\n+\n+          }\n+        }\n+      }\n+","path":"contrib/src/test/scala/akka/stream/contrib/UnfoldFlowSpec.scala","position":155,"original_position":155,"commit_id":"7eb7bcc1d676f2c1e36bb379845c71f7155c6d44","original_commit_id":"7eb7bcc1d676f2c1e36bb379845c71f7155c6d44","user":{"login":"drewhk","id":932285,"avatar_url":"https://avatars.githubusercontent.com/u/932285?v=3","gravatar_id":"","url":"https://api.github.com/users/drewhk","html_url":"https://github.com/drewhk","followers_url":"https://api.github.com/users/drewhk/followers","following_url":"https://api.github.com/users/drewhk/following{/other_user}","gists_url":"https://api.github.com/users/drewhk/gists{/gist_id}","starred_url":"https://api.github.com/users/drewhk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drewhk/subscriptions","organizations_url":"https://api.github.com/users/drewhk/orgs","repos_url":"https://api.github.com/users/drewhk/repos","events_url":"https://api.github.com/users/drewhk/events{/privacy}","received_events_url":"https://api.github.com/users/drewhk/received_events","type":"User","site_admin":false},"body":"Please also add a test case where the inner Flow has a buffer (i.e. just prepend or append a buffer stage). That exercises more paths.","created_at":"2016-08-30T07:54:05Z","updated_at":"2016-08-30T07:54:05Z","html_url":"https://github.com/akka/akka-stream-contrib/pull/33#discussion_r76745497","pull_request_url":"https://api.github.com/repos/akka/akka-stream-contrib/pulls/33","_links":{"self":{"href":"https://api.github.com/repos/akka/akka-stream-contrib/pulls/comments/76745497"},"html":{"href":"https://github.com/akka/akka-stream-contrib/pull/33#discussion_r76745497"},"pull_request":{"href":"https://api.github.com/repos/akka/akka-stream-contrib/pulls/33"}}},"pull_request":{"url":"https://api.github.com/repos/akka/akka-stream-contrib/pulls/33","id":77916121,"html_url":"https://github.com/akka/akka-stream-contrib/pull/33","diff_url":"https://github.com/akka/akka-stream-contrib/pull/33.diff","patch_url":"https://github.com/akka/akka-stream-contrib/pull/33.patch","issue_url":"https://api.github.com/repos/akka/akka-stream-contrib/issues/33","number":33,"state":"open","locked":false,"title":"unfoldFlow & unfoldFlowWith Source generators added","user":{"login":"hochgi","id":881075,"avatar_url":"https://avatars.githubusercontent.com/u/881075?v=3","gravatar_id":"","url":"https://api.github.com/users/hochgi","html_url":"https://github.com/hochgi","followers_url":"https://api.github.com/users/hochgi/followers","following_url":"https://api.github.com/users/hochgi/following{/other_user}","gists_url":"https://api.github.com/users/hochgi/gists{/gist_id}","starred_url":"https://api.github.com/users/hochgi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hochgi/subscriptions","organizations_url":"https://api.github.com/users/hochgi/orgs","repos_url":"https://api.github.com/users/hochgi/repos","events_url":"https://api.github.com/users/hochgi/events{/privacy}","received_events_url":"https://api.github.com/users/hochgi/received_events","type":"User","site_admin":false},"body":"PR for https://github.com/akka/akka-stream-contrib/issues/32\r\nthis is still a WIP. no tests & complete docs yet.\r\nalso, concerns raised in the issue need to be discussed.","created_at":"2016-07-19T04:26:32Z","updated_at":"2016-08-30T07:54:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b4a69b50692f66b4884530a87e9bec55c3199c11","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/akka/akka-stream-contrib/pulls/33/commits","review_comments_url":"https://api.github.com/repos/akka/akka-stream-contrib/pulls/33/comments","review_comment_url":"https://api.github.com/repos/akka/akka-stream-contrib/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akka/akka-stream-contrib/issues/33/comments","statuses_url":"https://api.github.com/repos/akka/akka-stream-contrib/statuses/7eb7bcc1d676f2c1e36bb379845c71f7155c6d44","head":{"label":"hochgi:32-hochgi-unfold-flow","ref":"32-hochgi-unfold-flow","sha":"7eb7bcc1d676f2c1e36bb379845c71f7155c6d44","user":{"login":"hochgi","id":881075,"avatar_url":"https://avatars.githubusercontent.com/u/881075?v=3","gravatar_id":"","url":"https://api.github.com/users/hochgi","html_url":"https://github.com/hochgi","followers_url":"https://api.github.com/users/hochgi/followers","following_url":"https://api.github.com/users/hochgi/following{/other_user}","gists_url":"https://api.github.com/users/hochgi/gists{/gist_id}","starred_url":"https://api.github.com/users/hochgi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hochgi/subscriptions","organizations_url":"https://api.github.com/users/hochgi/orgs","repos_url":"https://api.github.com/users/hochgi/repos","events_url":"https://api.github.com/users/hochgi/events{/privacy}","received_events_url":"https://api.github.com/users/hochgi/received_events","type":"User","site_admin":false},"repo":{"id":60439872,"name":"akka-stream-contrib","full_name":"hochgi/akka-stream-contrib","owner":{"login":"hochgi","id":881075,"avatar_url":"https://avatars.githubusercontent.com/u/881075?v=3","gravatar_id":"","url":"https://api.github.com/users/hochgi","html_url":"https://github.com/hochgi","followers_url":"https://api.github.com/users/hochgi/followers","following_url":"https://api.github.com/users/hochgi/following{/other_user}","gists_url":"https://api.github.com/users/hochgi/gists{/gist_id}","starred_url":"https://api.github.com/users/hochgi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hochgi/subscriptions","organizations_url":"https://api.github.com/users/hochgi/orgs","repos_url":"https://api.github.com/users/hochgi/repos","events_url":"https://api.github.com/users/hochgi/events{/privacy}","received_events_url":"https://api.github.com/users/hochgi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hochgi/akka-stream-contrib","description":"Add-ons to Akka Stream","fork":true,"url":"https://api.github.com/repos/hochgi/akka-stream-contrib","forks_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/forks","keys_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/teams","hooks_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/hooks","issue_events_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/issues/events{/number}","events_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/events","assignees_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/assignees{/user}","branches_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/branches{/branch}","tags_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/tags","blobs_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/git/refs{/sha}","trees_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/statuses/{sha}","languages_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/languages","stargazers_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/stargazers","contributors_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/contributors","subscribers_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/subscribers","subscription_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/subscription","commits_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/commits{/sha}","git_commits_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/git/commits{/sha}","comments_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/comments{/number}","issue_comment_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/issues/comments{/number}","contents_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/contents/{+path}","compare_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/merges","archive_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/downloads","issues_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/issues{/number}","pulls_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/pulls{/number}","milestones_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/milestones{/number}","notifications_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/labels{/name}","releases_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/releases{/id}","deployments_url":"https://api.github.com/repos/hochgi/akka-stream-contrib/deployments","created_at":"2016-06-05T02:37:05Z","updated_at":"2016-06-05T02:37:06Z","pushed_at":"2016-08-30T07:21:30Z","git_url":"git://github.com/hochgi/akka-stream-contrib.git","ssh_url":"git@github.com:hochgi/akka-stream-contrib.git","clone_url":"https://github.com/hochgi/akka-stream-contrib.git","svn_url":"https://github.com/hochgi/akka-stream-contrib","homepage":null,"size":63,"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":"akka:master","ref":"master","sha":"3f2a1d8e463422ba851a55cd22378e2ea7629979","user":{"login":"akka","id":1496237,"avatar_url":"https://avatars.githubusercontent.com/u/1496237?v=3","gravatar_id":"","url":"https://api.github.com/users/akka","html_url":"https://github.com/akka","followers_url":"https://api.github.com/users/akka/followers","following_url":"https://api.github.com/users/akka/following{/other_user}","gists_url":"https://api.github.com/users/akka/gists{/gist_id}","starred_url":"https://api.github.com/users/akka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akka/subscriptions","organizations_url":"https://api.github.com/users/akka/orgs","repos_url":"https://api.github.com/users/akka/repos","events_url":"https://api.github.com/users/akka/events{/privacy}","received_events_url":"https://api.github.com/users/akka/received_events","type":"Organization","site_admin":false},"repo":{"id":58454852,"name":"akka-stream-contrib","full_name":"akka/akka-stream-contrib","owner":{"login":"akka","id":1496237,"avatar_url":"https://avatars.githubusercontent.com/u/1496237?v=3","gravatar_id":"","url":"https://api.github.com/users/akka","html_url":"https://github.com/akka","followers_url":"https://api.github.com/users/akka/followers","following_url":"https://api.github.com/users/akka/following{/other_user}","gists_url":"https://api.github.com/users/akka/gists{/gist_id}","starred_url":"https://api.github.com/users/akka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akka/subscriptions","organizations_url":"https://api.github.com/users/akka/orgs","repos_url":"https://api.github.com/users/akka/repos","events_url":"https://api.github.com/users/akka/events{/privacy}","received_events_url":"https://api.github.com/users/akka/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/akka/akka-stream-contrib","description":"Add-ons to Akka Stream","fork":false,"url":"https://api.github.com/repos/akka/akka-stream-contrib","forks_url":"https://api.github.com/repos/akka/akka-stream-contrib/forks","keys_url":"https://api.github.com/repos/akka/akka-stream-contrib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akka/akka-stream-contrib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akka/akka-stream-contrib/teams","hooks_url":"https://api.github.com/repos/akka/akka-stream-contrib/hooks","issue_events_url":"https://api.github.com/repos/akka/akka-stream-contrib/issues/events{/number}","events_url":"https://api.github.com/repos/akka/akka-stream-contrib/events","assignees_url":"https://api.github.com/repos/akka/akka-stream-contrib/assignees{/user}","branches_url":"https://api.github.com/repos/akka/akka-stream-contrib/branches{/branch}","tags_url":"https://api.github.com/repos/akka/akka-stream-contrib/tags","blobs_url":"https://api.github.com/repos/akka/akka-stream-contrib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akka/akka-stream-contrib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akka/akka-stream-contrib/git/refs{/sha}","trees_url":"https://api.github.com/repos/akka/akka-stream-contrib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akka/akka-stream-contrib/statuses/{sha}","languages_url":"https://api.github.com/repos/akka/akka-stream-contrib/languages","stargazers_url":"https://api.github.com/repos/akka/akka-stream-contrib/stargazers","contributors_url":"https://api.github.com/repos/akka/akka-stream-contrib/contributors","subscribers_url":"https://api.github.com/repos/akka/akka-stream-contrib/subscribers","subscription_url":"https://api.github.com/repos/akka/akka-stream-contrib/subscription","commits_url":"https://api.github.com/repos/akka/akka-stream-contrib/commits{/sha}","git_commits_url":"https://api.github.com/repos/akka/akka-stream-contrib/git/commits{/sha}","comments_url":"https://api.github.com/repos/akka/akka-stream-contrib/comments{/number}","issue_comment_url":"https://api.github.com/repos/akka/akka-stream-contrib/issues/comments{/number}","contents_url":"https://api.github.com/repos/akka/akka-stream-contrib/contents/{+path}","compare_url":"https://api.github.com/repos/akka/akka-stream-contrib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akka/akka-stream-contrib/merges","archive_url":"https://api.github.com/repos/akka/akka-stream-contrib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akka/akka-stream-contrib/downloads","issues_url":"https://api.github.com/repos/akka/akka-stream-contrib/issues{/number}","pulls_url":"https://api.github.com/repos/akka/akka-stream-contrib/pulls{/number}","milestones_url":"https://api.github.com/repos/akka/akka-stream-contrib/milestones{/number}","notifications_url":"https://api.github.com/repos/akka/akka-stream-contrib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akka/akka-stream-contrib/labels{/name}","releases_url":"https://api.github.com/repos/akka/akka-stream-contrib/releases{/id}","deployments_url":"https://api.github.com/repos/akka/akka-stream-contrib/deployments","created_at":"2016-05-10T11:13:49Z","updated_at":"2016-08-30T06:47:49Z","pushed_at":"2016-08-30T04:52:24Z","git_url":"git://github.com/akka/akka-stream-contrib.git","ssh_url":"git@github.com:akka/akka-stream-contrib.git","clone_url":"https://github.com/akka/akka-stream-contrib.git","svn_url":"https://github.com/akka/akka-stream-contrib","homepage":null,"size":168,"stargazers_count":54,"watchers_count":54,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":22,"mirror_url":null,"open_issues_count":18,"forks":22,"open_issues":18,"watchers":54,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akka/akka-stream-contrib/pulls/33"},"html":{"href":"https://github.com/akka/akka-stream-contrib/pull/33"},"issue":{"href":"https://api.github.com/repos/akka/akka-stream-contrib/issues/33"},"comments":{"href":"https://api.github.com/repos/akka/akka-stream-contrib/issues/33/comments"},"review_comments":{"href":"https://api.github.com/repos/akka/akka-stream-contrib/pulls/33/comments"},"review_comment":{"href":"https://api.github.com/repos/akka/akka-stream-contrib/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akka/akka-stream-contrib/pulls/33/commits"},"statuses":{"href":"https://api.github.com/repos/akka/akka-stream-contrib/statuses/7eb7bcc1d676f2c1e36bb379845c71f7155c6d44"}}}}
{"actor":{"display_login":"drewhk"}}