-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
GROOVY-9848: in
operator: key set membership for isCase(Map,Object)
#1904
base: master
Are you sure you want to change the base?
Conversation
I added tests for GROOVY-2456 as well. This is probably a good time to revisit that item and decide if |
* <pre class="groovyTestCase">switch( 'foo' ) { | ||
* case [foo:true, bar:false]: | ||
* case [foo:true]: |
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.
To make it really clear I would go one step further and change [foo:true] to [foo:false]
assert 'foo' in [foo:true] | ||
assert 'foo' in [foo:null] | ||
assert 'bar' !in [foo:true] | ||
assert 'bar' !in [:].withDefault{ true } |
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.
Again here I would use false as default to be more clear about the keys being used
// GROOVY-7919 | ||
void testInForIterables() { | ||
Iterable iter = { -> ['a','b','c'].iterator() } | ||
assert 'a' in iter |
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.
actually it would be nice to do assert 'a' in iter twice to show that the second time it fails
I think your idea about leaving isCase alone and changing "in" to use "contains" has merit and is worth exploring as an alternative to this change. |
https://issues.apache.org/jira/browse/GROOVY-9848