{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/52436","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/52436/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/52436/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/52436/events","html_url":"https://github.com/rust-lang/rust/issues/52436","id":341604168,"node_id":"MDU6SXNzdWUzNDE2MDQxNjg=","number":52436,"title":"tests with Result could have nicer output","user":{"login":"steveklabnik","id":27786,"node_id":"MDQ6VXNlcjI3Nzg2","avatar_url":"https://avatars2.githubusercontent.com/u/27786?v=4","gravatar_id":"","url":"https://api.github.com/users/steveklabnik","html_url":"https://github.com/steveklabnik","followers_url":"https://api.github.com/users/steveklabnik/followers","following_url":"https://api.github.com/users/steveklabnik/following{/other_user}","gists_url":"https://api.github.com/users/steveklabnik/gists{/gist_id}","starred_url":"https://api.github.com/users/steveklabnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steveklabnik/subscriptions","organizations_url":"https://api.github.com/users/steveklabnik/orgs","repos_url":"https://api.github.com/users/steveklabnik/repos","events_url":"https://api.github.com/users/steveklabnik/events{/privacy}","received_events_url":"https://api.github.com/users/steveklabnik/received_events","type":"User","site_admin":false},"labels":[{"id":235791,"node_id":"MDU6TGFiZWwyMzU3OTE=","url":"https://api.github.com/repos/rust-lang/rust/labels/A-diagnostics","name":"A-diagnostics","color":"d7e102","default":false},{"id":630810559,"node_id":"MDU6TGFiZWw2MzA4MTA1NTk=","url":"https://api.github.com/repos/rust-lang/rust/labels/A-libtest","name":"A-libtest","color":"d7e102","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-16T17:16:12Z","updated_at":"2018-07-17T06:17:07Z","closed_at":null,"author_association":"MEMBER","body":"Consider this test:\r\n\r\n```rust\r\n#[cfg(test)]\r\nmod tests {\r\n    #[test]\r\n    fn it_works() -> Result<(), String> {\r\n        if 2 + 2 != 4 {\r\n            Ok(())\r\n        } else {\r\n            Err(String::from(\"two plus two does not equal four\"))\r\n        }\r\n    }\r\n}\r\n```\r\n\r\n(note the `!`) when this fails, you get\r\n\r\n```rust\r\n> cargo test\r\n   Compiling termination v0.1.0 (file:///C:/Users/steve/tmp/termination)\r\n    Finished dev [unoptimized + debuginfo] target(s) in 1.44s\r\n     Running target\\debug\\deps\\termination-4b340b40460d3098.exe\r\n\r\nrunning 1 test\r\ntest tests::it_works ... FAILED\r\n\r\nfailures:\r\n\r\n---- tests::it_works stdout ----\r\nError: \"two plus two does not equal four\"\r\nthread 'tests::it_works' panicked at 'assertion failed: `(left == right)`\r\n  left: `1`,\r\n right: `0`', libtest\\lib.rs:326:5\r\n```\r\n\r\nThis is because it triggers [this assert](https://github.com/rust-lang/rust/blob/50702b28383c15907c29e8f70256cdd439800834/src/libtest/lib.rs#L328-L330).\r\n\r\ncan we make this better somehow? `1 != 0` is not super helpful at learning why this test failed."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/405471997","html_url":"https://github.com/rust-lang/rust/issues/52436#issuecomment-405471997","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/52436","id":405471997,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNTQ3MTk5Nw==","user":{"login":"scottmcm","id":18526288,"node_id":"MDQ6VXNlcjE4NTI2Mjg4","avatar_url":"https://avatars2.githubusercontent.com/u/18526288?v=4","gravatar_id":"","url":"https://api.github.com/users/scottmcm","html_url":"https://github.com/scottmcm","followers_url":"https://api.github.com/users/scottmcm/followers","following_url":"https://api.github.com/users/scottmcm/following{/other_user}","gists_url":"https://api.github.com/users/scottmcm/gists{/gist_id}","starred_url":"https://api.github.com/users/scottmcm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottmcm/subscriptions","organizations_url":"https://api.github.com/users/scottmcm/orgs","repos_url":"https://api.github.com/users/scottmcm/repos","events_url":"https://api.github.com/users/scottmcm/events{/privacy}","received_events_url":"https://api.github.com/users/scottmcm/received_events","type":"User","site_admin":false},"created_at":"2018-07-17T06:17:07Z","updated_at":"2018-07-17T06:17:07Z","author_association":"MEMBER","body":"Hmm, the trait is super-unstable, so maybe it's be worth adding a purpose-built method for this?  Like\r\n\r\n```rust\r\nfn assert_success(self) {\r\n    assert_eq!(self.report(), 0);\r\n}\r\n```\r\n\r\nBut then the `Result` impl could override it to show something better..."}}
{"actor":{"display_login":"scottmcm"}}