{"action":"created","comment":{"url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/pulls/comments/206534181","pull_request_review_id":141962427,"id":206534181,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNjUzNDE4MQ==","diff_hunk":"@@ -129,4 +131,52 @@ public void commands() throws Exception {\n \t\t\t}\n \t\t}\n \t}\n+\n+\t@Test\n+\tpublic void iterator() throws Exception {\n+\t\tAlloy ai = new AlloyClassicFacade();\n+\t\tAlloyModule module = ai.compiler().compileSource(\"some sig B {}\\n run show{} for 3\");\n+\t\tAlloySolver solver = ai.getSolvers().get(0);\n+\t\tTRun run = module.getRuns().get(0);\n+\t\tAlloySolution solution = solver.run(module, null, run);\n+\t\tTSig B = module.getSig(\"B\").get();\n+\n+\t\tArrayList<Integer> atom_counts = new ArrayList();\n+\t\tfor (AlloyInstance instance : solution) {\n+                  System.out.println(instance.getAtoms(B));\n+\t\t\tatom_counts.add(instance.getAtoms(B).size());\n+\t\t}\n+\n+\t\t//We should see three solutions (one B atom, two B atoms, three B atoms)\n+\t\tassertEquals(3, atom_counts.size());\n+\t\tassert(atom_counts.contains(1));\n+\t\tassert(atom_counts.contains(2));\n+\t\tassert(atom_counts.contains(3));\n+\t}\n+\n+\t@Test\n+\tpublic void iteratorImmutable() throws Exception {\n+\t\tAlloy ai = new AlloyClassicFacade();\n+\t\tAlloyModule module = ai.compiler().compileSource(\"some sig B {}\\n run show{} for 3\");\n+\t\tAlloySolver solver = ai.getSolvers().get(0);\n+\t\tTRun run = module.getRuns().get(0);\n+\t\tAlloySolution solution = solver.run(module, null, run);\n+\t\tTSig B = module.getSig(\"B\").get();\n+\n+\t\t//Advancing the iterator shouldn't change previously returned instances.\n+\t\t//Test this by comparing atoms between instances from an exhausted iterator with instances from an in-progress iterator.\n+\t\tArrayList<AlloyInstance> instances = new ArrayList();\n+\t\tfor(AlloyInstance instance : solution) {\n+\t\t\tinstances.add(instance);\n+\t\t}\n+\n+\t\tint i = 0;\n+\t\tfor(AlloyInstance instance : solution) {\n+\t\t\tITupleSet ts = instance.getAtoms(B);\n+\t\t\tITupleSet ts_old = instances.get(i).getAtoms(B);\n+\t\t\t//Comparing strings since value-based equality isn't implemented for tuple sets\n+\t\t\tassertEquals(ts.toString(), ts_old.toString());","path":"org.alloytools.alloy.classic.test/src/test/java/org/alloytools/alloy/classic/test/AlloyImplTest.java","position":178,"original_position":61,"commit_id":"80346438e3021c1ad75d7e5ec49ab01f3dfeb971","original_commit_id":"80346438e3021c1ad75d7e5ec49ab01f3dfeb971","user":{"login":"aleksandarmilicevic","id":3605293,"node_id":"MDQ6VXNlcjM2MDUyOTM=","avatar_url":"https://avatars0.githubusercontent.com/u/3605293?v=4","gravatar_id":"","url":"https://api.github.com/users/aleksandarmilicevic","html_url":"https://github.com/aleksandarmilicevic","followers_url":"https://api.github.com/users/aleksandarmilicevic/followers","following_url":"https://api.github.com/users/aleksandarmilicevic/following{/other_user}","gists_url":"https://api.github.com/users/aleksandarmilicevic/gists{/gist_id}","starred_url":"https://api.github.com/users/aleksandarmilicevic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aleksandarmilicevic/subscriptions","organizations_url":"https://api.github.com/users/aleksandarmilicevic/orgs","repos_url":"https://api.github.com/users/aleksandarmilicevic/repos","events_url":"https://api.github.com/users/aleksandarmilicevic/events{/privacy}","received_events_url":"https://api.github.com/users/aleksandarmilicevic/received_events","type":"User","site_admin":false},"body":"comparing `toString()` representations here is totally fine","created_at":"2018-07-31T13:48:05Z","updated_at":"2018-07-31T13:59:33Z","html_url":"https://github.com/AlloyTools/org.alloytools.alloy/pull/66#discussion_r206534181","pull_request_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/pulls/66","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/pulls/comments/206534181"},"html":{"href":"https://github.com/AlloyTools/org.alloytools.alloy/pull/66#discussion_r206534181"},"pull_request":{"href":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/pulls/66"}}},"pull_request":{"url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/pulls/66","id":205089448,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA1MDg5NDQ4","html_url":"https://github.com/AlloyTools/org.alloytools.alloy/pull/66","diff_url":"https://github.com/AlloyTools/org.alloytools.alloy/pull/66.diff","patch_url":"https://github.com/AlloyTools/org.alloytools.alloy/pull/66.patch","issue_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/issues/66","number":66,"state":"open","locked":false,"title":"Fix solutions iterator","user":{"login":"lynaghk","id":147919,"node_id":"MDQ6VXNlcjE0NzkxOQ==","avatar_url":"https://avatars3.githubusercontent.com/u/147919?v=4","gravatar_id":"","url":"https://api.github.com/users/lynaghk","html_url":"https://github.com/lynaghk","followers_url":"https://api.github.com/users/lynaghk/followers","following_url":"https://api.github.com/users/lynaghk/following{/other_user}","gists_url":"https://api.github.com/users/lynaghk/gists{/gist_id}","starred_url":"https://api.github.com/users/lynaghk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lynaghk/subscriptions","organizations_url":"https://api.github.com/users/lynaghk/orgs","repos_url":"https://api.github.com/users/lynaghk/repos","events_url":"https://api.github.com/users/lynaghk/events{/privacy}","received_events_url":"https://api.github.com/users/lynaghk/received_events","type":"User","site_admin":false},"body":"Hi @pkriens, this pull request follows up on our email conversation.\r\nThere are two commits/changes:\r\n\r\n1. Add a test to ensure that instances returned from the solutions iterator are not coupled to the iterator state (as they accidentally were before a39b993). I'm not sure if there's an idiomatic way to compare tuple sets by value, so the test compares the `toString` representations --- would love feedback on this if there's a proper way to do it w/ the existing methods.\r\n\r\n2. Fix the solutions iterator to return the correct number of solutions (that is, match the Alloy GUI).\r\n\r\nThis is also my first pull request, so a few other notes in case I'm doing something wrong:\r\n\r\n+ I ran the tests via: `./gradlew --info org.alloytools.alloy.classic.test:test`\r\n\r\n+ I edited the source with IntelliJ. Hopefully that's smart enough to match the existing formatting. I don't have Eclipse installed and so couldn't do the autoformatting alluded to in the contribution guidelines. I'm on OS X and would be happy to install run some kind of command-line formatter if there are specific instructions or a shell script somewhere.","created_at":"2018-07-31T12:04:13Z","updated_at":"2018-07-31T13:59:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"01486ac03618ec3df0139931497f9e9950065041","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/pulls/66/commits","review_comments_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/pulls/66/comments","review_comment_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/issues/66/comments","statuses_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/statuses/80346438e3021c1ad75d7e5ec49ab01f3dfeb971","head":{"label":"lynaghk:lynaghk/api","ref":"lynaghk/api","sha":"80346438e3021c1ad75d7e5ec49ab01f3dfeb971","user":{"login":"lynaghk","id":147919,"node_id":"MDQ6VXNlcjE0NzkxOQ==","avatar_url":"https://avatars3.githubusercontent.com/u/147919?v=4","gravatar_id":"","url":"https://api.github.com/users/lynaghk","html_url":"https://github.com/lynaghk","followers_url":"https://api.github.com/users/lynaghk/followers","following_url":"https://api.github.com/users/lynaghk/following{/other_user}","gists_url":"https://api.github.com/users/lynaghk/gists{/gist_id}","starred_url":"https://api.github.com/users/lynaghk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lynaghk/subscriptions","organizations_url":"https://api.github.com/users/lynaghk/orgs","repos_url":"https://api.github.com/users/lynaghk/repos","events_url":"https://api.github.com/users/lynaghk/events{/privacy}","received_events_url":"https://api.github.com/users/lynaghk/received_events","type":"User","site_admin":false},"repo":{"id":143004124,"node_id":"MDEwOlJlcG9zaXRvcnkxNDMwMDQxMjQ=","name":"org.alloytools.alloy","full_name":"lynaghk/org.alloytools.alloy","owner":{"login":"lynaghk","id":147919,"node_id":"MDQ6VXNlcjE0NzkxOQ==","avatar_url":"https://avatars3.githubusercontent.com/u/147919?v=4","gravatar_id":"","url":"https://api.github.com/users/lynaghk","html_url":"https://github.com/lynaghk","followers_url":"https://api.github.com/users/lynaghk/followers","following_url":"https://api.github.com/users/lynaghk/following{/other_user}","gists_url":"https://api.github.com/users/lynaghk/gists{/gist_id}","starred_url":"https://api.github.com/users/lynaghk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lynaghk/subscriptions","organizations_url":"https://api.github.com/users/lynaghk/orgs","repos_url":"https://api.github.com/users/lynaghk/repos","events_url":"https://api.github.com/users/lynaghk/events{/privacy}","received_events_url":"https://api.github.com/users/lynaghk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lynaghk/org.alloytools.alloy","description":"Alloy is a language for describing structures and a tool for exploring them. It has been used in a wide range of applications from finding holes in security mechanisms to designing telephone switching networks. This repository contains the code for the tool.","fork":true,"url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy","forks_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/forks","keys_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/teams","hooks_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/hooks","issue_events_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/issues/events{/number}","events_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/events","assignees_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/assignees{/user}","branches_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/branches{/branch}","tags_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/tags","blobs_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/git/refs{/sha}","trees_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/statuses/{sha}","languages_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/languages","stargazers_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/stargazers","contributors_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/contributors","subscribers_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/subscribers","subscription_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/subscription","commits_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/commits{/sha}","git_commits_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/git/commits{/sha}","comments_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/comments{/number}","issue_comment_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/issues/comments{/number}","contents_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/contents/{+path}","compare_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/merges","archive_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/downloads","issues_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/issues{/number}","pulls_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/pulls{/number}","milestones_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/milestones{/number}","notifications_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/labels{/name}","releases_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/releases{/id}","deployments_url":"https://api.github.com/repos/lynaghk/org.alloytools.alloy/deployments","created_at":"2018-07-31T11:17:26Z","updated_at":"2018-07-31T11:17:31Z","pushed_at":"2018-07-31T12:22:21Z","git_url":"git://github.com/lynaghk/org.alloytools.alloy.git","ssh_url":"git@github.com:lynaghk/org.alloytools.alloy.git","clone_url":"https://github.com/lynaghk/org.alloytools.alloy.git","svn_url":"https://github.com/lynaghk/org.alloytools.alloy","homepage":null,"size":19570,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"AlloyTools:pkriens/api","ref":"pkriens/api","sha":"8a6c478bcba99e81918f25cafe0b5a6ba725c58b","user":{"login":"AlloyTools","id":30268214,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMwMjY4MjE0","avatar_url":"https://avatars2.githubusercontent.com/u/30268214?v=4","gravatar_id":"","url":"https://api.github.com/users/AlloyTools","html_url":"https://github.com/AlloyTools","followers_url":"https://api.github.com/users/AlloyTools/followers","following_url":"https://api.github.com/users/AlloyTools/following{/other_user}","gists_url":"https://api.github.com/users/AlloyTools/gists{/gist_id}","starred_url":"https://api.github.com/users/AlloyTools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlloyTools/subscriptions","organizations_url":"https://api.github.com/users/AlloyTools/orgs","repos_url":"https://api.github.com/users/AlloyTools/repos","events_url":"https://api.github.com/users/AlloyTools/events{/privacy}","received_events_url":"https://api.github.com/users/AlloyTools/received_events","type":"Organization","site_admin":false},"repo":{"id":97738923,"node_id":"MDEwOlJlcG9zaXRvcnk5NzczODkyMw==","name":"org.alloytools.alloy","full_name":"AlloyTools/org.alloytools.alloy","owner":{"login":"AlloyTools","id":30268214,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMwMjY4MjE0","avatar_url":"https://avatars2.githubusercontent.com/u/30268214?v=4","gravatar_id":"","url":"https://api.github.com/users/AlloyTools","html_url":"https://github.com/AlloyTools","followers_url":"https://api.github.com/users/AlloyTools/followers","following_url":"https://api.github.com/users/AlloyTools/following{/other_user}","gists_url":"https://api.github.com/users/AlloyTools/gists{/gist_id}","starred_url":"https://api.github.com/users/AlloyTools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlloyTools/subscriptions","organizations_url":"https://api.github.com/users/AlloyTools/orgs","repos_url":"https://api.github.com/users/AlloyTools/repos","events_url":"https://api.github.com/users/AlloyTools/events{/privacy}","received_events_url":"https://api.github.com/users/AlloyTools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AlloyTools/org.alloytools.alloy","description":"Alloy is a language for describing structures and a tool for exploring them. It has been used in a wide range of applications from finding holes in security mechanisms to designing telephone switching networks. This repository contains the code for the tool.","fork":false,"url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy","forks_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/forks","keys_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/teams","hooks_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/hooks","issue_events_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/issues/events{/number}","events_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/events","assignees_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/assignees{/user}","branches_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/branches{/branch}","tags_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/tags","blobs_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/git/refs{/sha}","trees_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/statuses/{sha}","languages_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/languages","stargazers_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/stargazers","contributors_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/contributors","subscribers_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/subscribers","subscription_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/subscription","commits_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/commits{/sha}","git_commits_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/git/commits{/sha}","comments_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/comments{/number}","issue_comment_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/issues/comments{/number}","contents_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/contents/{+path}","compare_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/merges","archive_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/downloads","issues_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/issues{/number}","pulls_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/pulls{/number}","milestones_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/milestones{/number}","notifications_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/labels{/name}","releases_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/releases{/id}","deployments_url":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/deployments","created_at":"2017-07-19T16:33:02Z","updated_at":"2018-07-31T13:37:02Z","pushed_at":"2018-07-31T13:43:40Z","git_url":"git://github.com/AlloyTools/org.alloytools.alloy.git","ssh_url":"git@github.com:AlloyTools/org.alloytools.alloy.git","clone_url":"https://github.com/AlloyTools/org.alloytools.alloy.git","svn_url":"https://github.com/AlloyTools/org.alloytools.alloy","homepage":null,"size":19564,"stargazers_count":45,"watchers_count":45,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"archived":false,"open_issues_count":24,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":16,"open_issues":24,"watchers":45,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/pulls/66"},"html":{"href":"https://github.com/AlloyTools/org.alloytools.alloy/pull/66"},"issue":{"href":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/issues/66"},"comments":{"href":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/issues/66/comments"},"review_comments":{"href":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/pulls/66/comments"},"review_comment":{"href":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/pulls/66/commits"},"statuses":{"href":"https://api.github.com/repos/AlloyTools/org.alloytools.alloy/statuses/80346438e3021c1ad75d7e5ec49ab01f3dfeb971"}},"author_association":"NONE"}}
{"actor":{"display_login":"aleksandarmilicevic"}}