{"action":"opened","issue":{"url":"https://api.github.com/repos/lpil/check/issues/2","labels_url":"https://api.github.com/repos/lpil/check/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/lpil/check/issues/2/comments","events_url":"https://api.github.com/repos/lpil/check/issues/2/events","html_url":"https://github.com/lpil/check/issues/2","id":105586632,"number":2,"title":"Syntax proposal","user":{"login":"jonnyarnold","id":3803030,"avatar_url":"https://avatars.githubusercontent.com/u/3803030?v=3","gravatar_id":"","url":"https://api.github.com/users/jonnyarnold","html_url":"https://github.com/jonnyarnold","followers_url":"https://api.github.com/users/jonnyarnold/followers","following_url":"https://api.github.com/users/jonnyarnold/following{/other_user}","gists_url":"https://api.github.com/users/jonnyarnold/gists{/gist_id}","starred_url":"https://api.github.com/users/jonnyarnold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonnyarnold/subscriptions","organizations_url":"https://api.github.com/users/jonnyarnold/orgs","repos_url":"https://api.github.com/users/jonnyarnold/repos","events_url":"https://api.github.com/users/jonnyarnold/events{/privacy}","received_events_url":"https://api.github.com/users/jonnyarnold/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-09T12:30:37Z","updated_at":"2015-09-09T12:30:37Z","closed_at":null,"body":"As @lpil challenged me yesterday, here's a first draft at a test syntax that I think could be achieved.\r\n\r\n```elixir\r\n# Makes the syntax look more sugary.\r\n# Note that given's arguments are lists,\r\n# hence the double-list.\r\ndef empty_list do\r\n  [[]]\r\nend\r\n\r\n# A value of any type.\r\n# Elixir has more, but you get the point.\r\n# This would probably be provided as part of the test framework.\r\n#\r\n# This has the benefit that users could be more selective:\r\n#   def enumerable\r\n#     Enum.filter(value, fn(x) -> x.is_enum?)\r\n#   end\r\n#\r\n# (I know no Elixir. Be lenient.)\r\ndef value do\r\n  [nil, 0, 1.5, \"Hello\", {}]\r\nend\r\n\r\n# Proposal: Given yields to its block once\r\n# for each value in the `given` lists.\r\ndescribe \"lists\" do\r\n  given [l: empty_list] do\r\n    assert l.length = 0\r\n  \r\n    given [v: value] do\r\n      when \"I append a value\" do\r\n        l = l.append(v)\r\n        \r\n        assert l.last == v\r\n        assert l.length == 1\r\n      end\r\n    end\r\n  end\r\n  \r\n  given [v1: value, v2: value] do\r\n    l = [v1, v2]\r\n    \r\n    assert l.first == v1\r\n    assert l.last == v2\r\n    \r\n    when \"I reverse the list\" do\r\n      l = l.reverse\r\n      \r\n      assert l.first == v2\r\n      assert l.last == v1\r\n    end\r\n  end\r\nend\r\n```"}}