{"action":"created","issue":{"url":"https://api.github.com/repos/hadley/testthat/issues/525","repository_url":"https://api.github.com/repos/hadley/testthat","labels_url":"https://api.github.com/repos/hadley/testthat/issues/525/labels{/name}","comments_url":"https://api.github.com/repos/hadley/testthat/issues/525/comments","events_url":"https://api.github.com/repos/hadley/testthat/issues/525/events","html_url":"https://github.com/hadley/testthat/issues/525","id":176455854,"number":525,"title":"How to test own expectation for failure","user":{"login":"schoettl","id":1301843,"avatar_url":"https://avatars.githubusercontent.com/u/1301843?v=3","gravatar_id":"","url":"https://api.github.com/users/schoettl","html_url":"https://github.com/schoettl","followers_url":"https://api.github.com/users/schoettl/followers","following_url":"https://api.github.com/users/schoettl/following{/other_user}","gists_url":"https://api.github.com/users/schoettl/gists{/gist_id}","starred_url":"https://api.github.com/users/schoettl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schoettl/subscriptions","organizations_url":"https://api.github.com/users/schoettl/orgs","repos_url":"https://api.github.com/users/schoettl/repos","events_url":"https://api.github.com/users/schoettl/events{/privacy}","received_events_url":"https://api.github.com/users/schoettl/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-12T18:58:22Z","updated_at":"2016-12-15T03:56:31Z","closed_at":"2016-12-15T03:56:31Z","body":"Hi, I could not find a solution so far for this:\n\nI have written an own expectation, e.g. `is_symmetric`.\n\nI test it like this:\n\n```\na = matrix(c(1, 1, 1, 1), nrow=2)\nexpect_that(a, is_symmetric())\n```\n\nHow can I test failure, i.e. the cases where my expectation is supposed to fail?\n\nI tried these, but they do not work:\n\n```\na = matrix(1:4, nrow=2)\nexpect_fail(expect_that(a, is_symmetric()))\n```\n\n```\na = matrix(1:4, nrow=2)\nexpect_that(is_symmetric()(a), throws_error())\n```\n"},"comment":{"url":"https://api.github.com/repos/hadley/testthat/issues/comments/267232443","html_url":"https://github.com/hadley/testthat/issues/525#issuecomment-267232443","issue_url":"https://api.github.com/repos/hadley/testthat/issues/525","id":267232443,"user":{"login":"hadley","id":4196,"avatar_url":"https://avatars.githubusercontent.com/u/4196?v=3","gravatar_id":"","url":"https://api.github.com/users/hadley","html_url":"https://github.com/hadley","followers_url":"https://api.github.com/users/hadley/followers","following_url":"https://api.github.com/users/hadley/following{/other_user}","gists_url":"https://api.github.com/users/hadley/gists{/gist_id}","starred_url":"https://api.github.com/users/hadley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hadley/subscriptions","organizations_url":"https://api.github.com/users/hadley/orgs","repos_url":"https://api.github.com/users/hadley/repos","events_url":"https://api.github.com/users/hadley/events{/privacy}","received_events_url":"https://api.github.com/users/hadley/received_events","type":"User","site_admin":false},"created_at":"2016-12-15T03:56:31Z","updated_at":"2016-12-15T03:56:31Z","body":"At this point, you'll need to read the source for an expectation (e.g. https://github.com/hadley/testthat/blob/master/R/expect-length.R) and then read the source code for how it's tested in testthat (e.g. https://github.com/hadley/testthat/blob/master/tests/testthat/test-expect-length.R)"}}
{"actor":{"display_login":"hadley"}}