GitHub PullRequestEvent at 2014-05-04 18:31:54
Repository: xelixir
Actor: andrewsardone
Payload: {"action":"opened","number":5,"pull_request":{"url":"https://api.github.com/repos/exercism/xelixir/pulls/5","id":15474062,"html_url":"https://github.com/exercism/xelixir/pull/5","diff_url":"https://github.com/exercism/xelixir/pull/5.diff","patch_url":"https://github.com/exercism/xelixir/pull/5.patch","issue_url":"https://api.github.com/repos/exercism/xelixir/issues/5","number":5,"state":"open","title":"Fix the order of some test assertions","user":{"login":"andrewsardone","id":14554,"avatar_url":"https://avatars.githubusercontent.com/u/14554?","gravatar_id":"f3c52a0537360c85b46e043711cab0c6","url":"https://api.github.com/users/andrewsardone","html_url":"https://github.com/andrewsardone","followers_url":"https://api.github.com/users/andrewsardone/followers","following_url":"https://api.github.com/users/andrewsardone/following{/other_user}","gists_url":"https://api.github.com/users/andrewsardone/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewsardone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewsardone/subscriptions","organizations_url":"https://api.github.com/users/andrewsardone/orgs","repos_url":"https://api.github.com/users/andrewsardone/repos","events_url":"https://api.github.com/users/andrewsardone/events{/privacy}","received_events_url":"https://api.github.com/users/andrewsardone/received_events","type":"User","site_admin":false},"body":"Several [exercism/xelixir][xel] assertions seem to be flip-flopped, making their failure messages a bit confusing.\r\n\r\nThe [`assert/1` macro][as] will format failing scenarios in a helpful manner of comparing actual and expected values. Given a script with a failing test:\r\n\r\n```elixir\r\n\r\ndefmodule Math do\r\n  def add(x, y), do: 0\r\nend\r\n\r\nExUnit.start\r\n\r\ndefmodule MathTest do\r\n  use ExUnit.Case, async: true\r\n\r\n  test \"addition works\" do\r\n    assert Math.add(1, 1) == 2\r\n  end\r\nend\r\n```\r\n\r\n…running `elixir example.exs` produces a helpful failure message:\r\n\r\n```\r\n  1) test addition works (MathTest)\r\n     ** (ExUnit.ExpectationError)\r\n                  expected: 0\r\n       to be equal to (==): 2\r\n     at example.exs:11\r\n\r\nFinished in 0.02 seconds (0.02s on load, 0.00s on tests)\r\n1 tests, 1 failures\r\n```\r\n\r\nThe proper form of writing an assertion seems to be:\r\n\r\n```elixir\r\nassert actual_value == expected_value\r\n```\r\n\r\nSeveral [exercism/xelixir][xel] tests have swapped the actual and expected values. For example, if you look at the [the first test of point_mutations_test.exs][pntmut], the `actual_value` is on the right-hand-side of the `==`, which produces a confusing failure message:\r\n\r\n```\r\n  1) test no difference between empty strands (DNATest)\r\n     ** (ExUnit.ExpectationError)\r\n                  expected: 0\r\n       to be equal to (==): nil\r\n     at point_mutations_test.exs:14\r\n```\r\n\r\nThe message is not describing the correct failure of `DNA.hamming_distance/2`, namely, that it's an empty implementation that's returning `nil` when the caclulation should return 0. Instead, this message leads the implementer to believe that the function is returning 0 when `nil` is what one wants.\r\n\r\nSwitching up the order of these assertions improves the failure messages and makes it easier to TDD an exercise solution.\r\n\r\n[xel]: https://github.com/exercism/xelixir\r\n[as]: http://elixir-lang.org/docs/stable/ExUnit.Assertions.html#assert/1\r\n[pntmut]: https://github.com/exercism/xelixir/blob/8584070f5d8436816c9d7b1480b687947b383bc3/point-mutations/point_mutations_test.exs#L13-L15\r\n\r\n## How to test\r\n\r\nYou could check if the test results for the example solutions match between `master` and the PR. Here's a quick script that will compare the results:\r\n\r\n```sh\r\n# TODO: Assign the name of your local branch\r\npr_branch=assertion-order\r\n\r\nfunction md5_of_test_results {\r\n for i in $(echo */); do pushd>/dev/null $i; EXERCISM_TEST_EXAMPLES=1 elixir *test.exs | tail -1; popd>/dev/null; done | md5\r\n}\r\n\r\necho \"\"\r\necho \"=== Running tests on master === \"\r\ngit checkout master\r\nmaster_md5=$( md5_of_test_results )\r\n\r\necho \"\"\r\necho \"=== Running the tests on $pr_branch ===\"\r\ngit checkout $pr_branch\r\nbranch_md5=$( md5_of_test_results )\r\n\r\necho \"\"\r\nif [ \"$master_md5\" = \"$branch_md5\" ]; then\r\n echo \"✔︎ Same test results\"\r\nelse\r\n echo \"𝗫 Different test results\"\r\nfi\r\n```\r\n\r\nThanks! I think [exercism.io](http://exercism.io/) is a fantastic project!","created_at":"2014-05-04T18:31:54Z","updated_at":"2014-05-04T18:31:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/exercism/xelixir/pulls/5/commits","review_comments_url":"https://api.github.com/repos/exercism/xelixir/pulls/5/comments","review_comment_url":"https://api.github.com/repos/exercism/xelixir/pulls/comments/{number}","comments_url":"https://api.github.com/repos/exercism/xelixir/issues/5/comments","statuses_url":"https://api.github.com/repos/exercism/xelixir/statuses/253b345aab1eda88c977e5585fa691497549d0a5","head":{"label":"andrewsardone:assertion-order","ref":"assertion-order","sha":"253b345aab1eda88c977e5585fa691497549d0a5","user":{"login":"andrewsardone","id":14554,"avatar_url":"https://avatars.githubusercontent.com/u/14554?","gravatar_id":"f3c52a0537360c85b46e043711cab0c6","url":"https://api.github.com/users/andrewsardone","html_url":"https://github.com/andrewsardone","followers_url":"https://api.github.com/users/andrewsardone/followers","following_url":"https://api.github.com/users/andrewsardone/following{/other_user}","gists_url":"https://api.github.com/users/andrewsardone/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewsardone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewsardone/subscriptions","organizations_url":"https://api.github.com/users/andrewsardone/orgs","repos_url":"https://api.github.com/users/andrewsardone/repos","events_url":"https://api.github.com/users/andrewsardone/events{/privacy}","received_events_url":"https://api.github.com/users/andrewsardone/received_events","type":"User","site_admin":false},"repo":{"id":19236767,"name":"xelixir","full_name":"andrewsardone/xelixir","owner":{"login":"andrewsardone","id":14554,"avatar_url":"https://avatars.githubusercontent.com/u/14554?","gravatar_id":"f3c52a0537360c85b46e043711cab0c6","url":"https://api.github.com/users/andrewsardone","html_url":"https://github.com/andrewsardone","followers_url":"https://api.github.com/users/andrewsardone/followers","following_url":"https://api.github.com/users/andrewsardone/following{/other_user}","gists_url":"https://api.github.com/users/andrewsardone/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewsardone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewsardone/subscriptions","organizations_url":"https://api.github.com/users/andrewsardone/orgs","repos_url":"https://api.github.com/users/andrewsardone/repos","events_url":"https://api.github.com/users/andrewsardone/events{/privacy}","received_events_url":"https://api.github.com/users/andrewsardone/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andrewsardone/xelixir","description":"Exercism Exercises in Elixir","fork":true,"url":"https://api.github.com/repos/andrewsardone/xelixir","forks_url":"https://api.github.com/repos/andrewsardone/xelixir/forks","keys_url":"https://api.github.com/repos/andrewsardone/xelixir/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andrewsardone/xelixir/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andrewsardone/xelixir/teams","hooks_url":"https://api.github.com/repos/andrewsardone/xelixir/hooks","issue_events_url":"https://api.github.com/repos/andrewsardone/xelixir/issues/events{/number}","events_url":"https://api.github.com/repos/andrewsardone/xelixir/events","assignees_url":"https://api.github.com/repos/andrewsardone/xelixir/assignees{/user}","branches_url":"https://api.github.com/repos/andrewsardone/xelixir/branches{/branch}","tags_url":"https://api.github.com/repos/andrewsardone/xelixir/tags","blobs_url":"https://api.github.com/repos/andrewsardone/xelixir/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andrewsardone/xelixir/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andrewsardone/xelixir/git/refs{/sha}","trees_url":"https://api.github.com/repos/andrewsardone/xelixir/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andrewsardone/xelixir/statuses/{sha}","languages_url":"https://api.github.com/repos/andrewsardone/xelixir/languages","stargazers_url":"https://api.github.com/repos/andrewsardone/xelixir/stargazers","contributors_url":"https://api.github.com/repos/andrewsardone/xelixir/contributors","subscribers_url":"https://api.github.com/repos/andrewsardone/xelixir/subscribers","subscription_url":"https://api.github.com/repos/andrewsardone/xelixir/subscription","commits_url":"https://api.github.com/repos/andrewsardone/xelixir/commits{/sha}","git_commits_url":"https://api.github.com/repos/andrewsardone/xelixir/git/commits{/sha}","comments_url":"https://api.github.com/repos/andrewsardone/xelixir/comments{/number}","issue_comment_url":"https://api.github.com/repos/andrewsardone/xelixir/issues/comments/{number}","contents_url":"https://api.github.com/repos/andrewsardone/xelixir/contents/{+path}","compare_url":"https://api.github.com/repos/andrewsardone/xelixir/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andrewsardone/xelixir/merges","archive_url":"https://api.github.com/repos/andrewsardone/xelixir/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andrewsardone/xelixir/downloads","issues_url":"https://api.github.com/repos/andrewsardone/xelixir/issues{/number}","pulls_url":"https://api.github.com/repos/andrewsardone/xelixir/pulls{/number}","milestones_url":"https://api.github.com/repos/andrewsardone/xelixir/milestones{/number}","notifications_url":"https://api.github.com/repos/andrewsardone/xelixir/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andrewsardone/xelixir/labels{/name}","releases_url":"https://api.github.com/repos/andrewsardone/xelixir/releases{/id}","created_at":"2014-04-28T11:45:22Z","updated_at":"2014-05-04T18:31:54Z","pushed_at":"2014-05-04T17:52:55Z","git_url":"git://github.com/andrewsardone/xelixir.git","ssh_url":"git@github.com:andrewsardone/xelixir.git","clone_url":"https://github.com/andrewsardone/xelixir.git","svn_url":"https://github.com/andrewsardone/xelixir","homepage":null,"size":229,"stargazers_count":0,"watchers_count":0,"language":"Elixir","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"exercism:master","ref":"master","sha":"8584070f5d8436816c9d7b1480b687947b383bc3","user":{"login":"exercism","id":5624255,"avatar_url":"https://avatars.githubusercontent.com/u/5624255?","gravatar_id":"fe98e7e6a96539f47809f36c17ee42ca","url":"https://api.github.com/users/exercism","html_url":"https://github.com/exercism","followers_url":"https://api.github.com/users/exercism/followers","following_url":"https://api.github.com/users/exercism/following{/other_user}","gists_url":"https://api.github.com/users/exercism/gists{/gist_id}","starred_url":"https://api.github.com/users/exercism/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exercism/subscriptions","organizations_url":"https://api.github.com/users/exercism/orgs","repos_url":"https://api.github.com/users/exercism/repos","events_url":"https://api.github.com/users/exercism/events{/privacy}","received_events_url":"https://api.github.com/users/exercism/received_events","type":"Organization","site_admin":false},"repo":{"id":17271271,"name":"xelixir","full_name":"exercism/xelixir","owner":{"login":"exercism","id":5624255,"avatar_url":"https://avatars.githubusercontent.com/u/5624255?","gravatar_id":"fe98e7e6a96539f47809f36c17ee42ca","url":"https://api.github.com/users/exercism","html_url":"https://github.com/exercism","followers_url":"https://api.github.com/users/exercism/followers","following_url":"https://api.github.com/users/exercism/following{/other_user}","gists_url":"https://api.github.com/users/exercism/gists{/gist_id}","starred_url":"https://api.github.com/users/exercism/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exercism/subscriptions","organizations_url":"https://api.github.com/users/exercism/orgs","repos_url":"https://api.github.com/users/exercism/repos","events_url":"https://api.github.com/users/exercism/events{/privacy}","received_events_url":"https://api.github.com/users/exercism/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/exercism/xelixir","description":"Exercism Exercises in Elixir","fork":false,"url":"https://api.github.com/repos/exercism/xelixir","forks_url":"https://api.github.com/repos/exercism/xelixir/forks","keys_url":"https://api.github.com/repos/exercism/xelixir/keys{/key_id}","collaborators_url":"https://api.github.com/repos/exercism/xelixir/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/exercism/xelixir/teams","hooks_url":"https://api.github.com/repos/exercism/xelixir/hooks","issue_events_url":"https://api.github.com/repos/exercism/xelixir/issues/events{/number}","events_url":"https://api.github.com/repos/exercism/xelixir/events","assignees_url":"https://api.github.com/repos/exercism/xelixir/assignees{/user}","branches_url":"https://api.github.com/repos/exercism/xelixir/branches{/branch}","tags_url":"https://api.github.com/repos/exercism/xelixir/tags","blobs_url":"https://api.github.com/repos/exercism/xelixir/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/exercism/xelixir/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/exercism/xelixir/git/refs{/sha}","trees_url":"https://api.github.com/repos/exercism/xelixir/git/trees{/sha}","statuses_url":"https://api.github.com/repos/exercism/xelixir/statuses/{sha}","languages_url":"https://api.github.com/repos/exercism/xelixir/languages","stargazers_url":"https://api.github.com/repos/exercism/xelixir/stargazers","contributors_url":"https://api.github.com/repos/exercism/xelixir/contributors","subscribers_url":"https://api.github.com/repos/exercism/xelixir/subscribers","subscription_url":"https://api.github.com/repos/exercism/xelixir/subscription","commits_url":"https://api.github.com/repos/exercism/xelixir/commits{/sha}","git_commits_url":"https://api.github.com/repos/exercism/xelixir/git/commits{/sha}","comments_url":"https://api.github.com/repos/exercism/xelixir/comments{/number}","issue_comment_url":"https://api.github.com/repos/exercism/xelixir/issues/comments/{number}","contents_url":"https://api.github.com/repos/exercism/xelixir/contents/{+path}","compare_url":"https://api.github.com/repos/exercism/xelixir/compare/{base}...{head}","merges_url":"https://api.github.com/repos/exercism/xelixir/merges","archive_url":"https://api.github.com/repos/exercism/xelixir/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/exercism/xelixir/downloads","issues_url":"https://api.github.com/repos/exercism/xelixir/issues{/number}","pulls_url":"https://api.github.com/repos/exercism/xelixir/pulls{/number}","milestones_url":"https://api.github.com/repos/exercism/xelixir/milestones{/number}","notifications_url":"https://api.github.com/repos/exercism/xelixir/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/exercism/xelixir/labels{/name}","releases_url":"https://api.github.com/repos/exercism/xelixir/releases{/id}","created_at":"2014-02-28T01:19:15Z","updated_at":"2014-04-28T12:03:38Z","pushed_at":"2014-04-28T12:03:42Z","git_url":"git://github.com/exercism/xelixir.git","ssh_url":"git@github.com:exercism/xelixir.git","clone_url":"https://github.com/exercism/xelixir.git","svn_url":"https://github.com/exercism/xelixir","homepage":null,"size":492,"stargazers_count":2,"watchers_count":2,"language":"Elixir","has_issues":true,"has_downloads":true,"has_wiki":false,"forks_count":4,"mirror_url":null,"open_issues_count":2,"forks":4,"open_issues":2,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/exercism/xelixir/pulls/5"},"html":{"href":"https://github.com/exercism/xelixir/pull/5"},"issue":{"href":"https://api.github.com/repos/exercism/xelixir/issues/5"},"comments":{"href":"https://api.github.com/repos/exercism/xelixir/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/exercism/xelixir/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/exercism/xelixir/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/exercism/xelixir/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/exercism/xelixir/statuses/253b345aab1eda88c977e5585fa691497549d0a5"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":329,"deletions":329,"changed_files":26}}