Uh oh!
There was an error while loading. Please reload this page.
[WIP] Add support for arbitrary predicates - #57
Conversation
epage
commented
Oct 18, 2017
So we don't forget, there is also the question of whether we should use a
Some options
|
I think I want to implement not only #[macro_use]externcrate assert_cli;fnchecklen(expect_len:usize){assert_cmd!(echo "-n""forty-two").stdout().satisfies(|x| x.len() == expect_len).unwrap();}(Or could this also be achieved using |
epage
commented
Oct 20, 2017
Thanks for listing out a use case!
You'd have to hard code an fn for each length: #[macro_use]externcrate assert_cli;fntest_length(){assert_cmd!(echo "-n""forty-two").stdout().satisfies(|x| x.len() == 9).unwrap();}(I'm assuming this closure will resolve to be just a I was mostly considering direct calls to assert_cli where hard coded functions are more reasonable. My reason being that reusing test boiler plate is probably a smell because it is probably incidental code sharing (shared implementation details that will diverge as requirements change) rather than abstraction sharing (requirements are the same). I did not consider the idea of people building larger abstractions on top of assert_cli in which case they might need to take a specialized value from the user and create a closure out of it, requiring an |
epage
commented
Oct 28, 2017
dsprenkels
commented
Oct 29, 2017
Thanks for the heads-up. I haven't had the mood to write the code myself. In my project I ended up using just duct. I am looking forward to seeing your solution. |
epage
commented
Feb 4, 2018
Just merged #87 which adds a limited form of predicates. Closing this for now. |
Fixes#55.
I currently use, as
OutputAssertionstruct which has a closure containing the actual information of the assertion. In #55@epage suggest using an enum to differentiate between different types of enum. Although it will probably be a little bit more verbose than what I have not, I think I agree to using this approach (instead of what I have now). I.e. This PR still needs some work.Planned enum type:
Could also merge
SatisfiesPredintoSatisfiesTest, by making a new closure every time, but I think this kinda misses the point, so I probably won't do this. :P