-
Notifications
You must be signed in to change notification settings - Fork 34
Extend the set of comparison operations permitted #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Previously FiveAM used a home-brewed matching construct to process `is` forms in tests. Replaced this home-brew matcher (which was only used in one place in the code) by a dependency on the "trivia" pattern-matching library.
The new matcher allows us to have comparisons with modifier arguments, such as (set-equal X Y :test 'equalp) which could not be handled by previous versions of FiveAM.
The change in this branch is backwards compatible, but tests that are constructed using some newly-available comparison operations will not be usable in the previous version of FiveAM.
@@ -146,6 +147,34 @@ ELSE will be executed." | |||
,@progn) | |||
(list-match-case ,tgt ,@others)))))) | |||
nil)) | |||
|# | |||
|
|||
(defun list-match-pattern->trivia (pattern) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this make a dependency on trivia?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it does. I looked at list-match-case
and it was too much trouble to figure it out to fix a single case statement.
If one doesn't like the dependency on trivia, it would probably be better to rewrite the case statement in the is
macro into a hand-coded multi-way branch: that would be easier than trying to understand the hand-written matcher well enough to fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I'm not the maintainer of fiveam.
But there are Cl implementations that don't work well with trivia, like ABCL.
fiveam should work with the largest set of CL implementations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a workaround to not using Trivia but make your set-equa
usecase work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I'm not the maintainer of fiveam. But there are Cl implementations that don't work well with trivia, like ABCL. fiveam should work with the largest set of CL implementations.
I did not know about that. Do you have any pointers to information about trivia's (in)compatibility with various lisp implementations?
I agree with you that 5AM should aim to be as portable as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mdbergmann I believe that the best work-around -- although it is not good -- would be simply to rip out the use of pattern-matching and have a hand-written cond
expression with destructuring-bind
.
As I implied earlier, there's a lot more code to make list-match-case
work than there is actual use of this macro!
Another possibility is that the uses of trivia here are so limited that maybe they will work on any lisp implementation even ABCL. Again, it would help to know what breaks on ABCL.
It would be nice if 5AM had some github-actions to run the tests on multiple lisp implementations (like we have for ASDF and ITERATE on common-lisp.net).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried on ABCL. Trivia can be compiled and basic pattern matching works.
But running the whole test suite for some reason fails, though for some other reason than trivia.
I wanted to be able to use
alexandria:set-equal
as a comparison operation in FiveAM tests. This turned out to be impossible (except by usingtest-true
), because theis
macro did not accept extra, modifier arguments such asThe reason for this limitation was that FiveAM used a home-brewed matching construct to process
is
forms in tests.In this PR I have replaced FiveAM's home-brew matcher (which was only used in one place in the code) by a dependency on the "trivia" pattern-matching library. This was a judgment call, but figuring out the undocumented list matcher seemed more trouble than it was worth.