-
Notifications
You must be signed in to change notification settings - Fork 23
test mapcat
(#354)
#762
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: main
Are you sure you want to change the base?
test mapcat
(#354)
#762
Conversation
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.
Thanks for the PR! I have one suggestion and I've looped in Emma for a review as well.
(testing "function sometimes returns []" | ||
(is (= [1 3 5] (mapcat #(if (odd? %) [%] []) (range 1 6))))) | ||
(testing "function sometimes returns nil" | ||
(is (= [2 4] (mapcat #(if (even? %) [%] nil) (range 1 5))))) |
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.
mapcat
has a variadic arity, which we should test by passing many sequences. The most we're doing, in these tests, is two sequences.
Thanks for both of y'all's work! I'll take a look tonight |
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.
Great work! Just some small suggestions
|
||
|
||
(when-var-exists mapcat | ||
(deftest common-cases |
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.
nitpick but why isn't the test name based on the var it's testing?
(mapcat identity 5)))) | ||
(testing "non-function first arg" | ||
(is (thrown? #?(:cljs :default :clj Exception :cljr Exception) | ||
(mapcat 42 [1 2])))))) |
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'd add one more negative test for when the result of map
ping isn't a concat
able data structure, e.g.
(mapcat identity (range 2))
;; => Exception
@gavlooth if you're busy I don't mind making the changes, just would need write access to push to your fork |
No description provided.