-
Notifications
You must be signed in to change notification settings - Fork 20
Align heterogeneous equality with CEL spec #903
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -176,10 +176,7 @@ void uintDivide() { | |
|
|
||
| @Test | ||
| void uintEqual() { | ||
| assertThat(uintOf(0).equal(False)) | ||
| .isInstanceOf(Err.class) | ||
| .extracting(Object::toString) | ||
| .isEqualTo("no such overload: uint.equal(bool)"); | ||
| assertThat(uintOf(0).equal(False)).isSameAs(False); | ||
| assertThat(uintOf(0).equal(NullValue)).isSameAs(False); | ||
| assertThat(uintOf(0).equal(intOf(0))).isSameAs(True); | ||
| assertThat(uintOf(0).equal(intOf(1))).isSameAs(False); | ||
|
|
@@ -189,7 +186,7 @@ void uintEqual() { | |
| assertThat(uintOf(0).equal(uintOf(1))).isSameAs(False); | ||
| assertThat(uintOf(0).equal(doubleOf(0))).isSameAs(True); | ||
| assertThat(uintOf(0).equal(doubleOf(1))).isSameAs(False); | ||
| assertThat(uintOf(0).equal(stringOf("0"))).isSameAs(True); | ||
| assertThat(uintOf(0).equal(stringOf("0"))).isSameAs(False); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isnt it surprising that conformance tests did not cover cases like this?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really. I suspect, the conformance tests still use the "old" CEL-spec, where this was allowed. |
||
| assertThat(uintOf(0).equal(stringOf("1"))).isSameAs(False); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -248,6 +248,14 @@ static TestCase[] testCases() { | |
| new TestCase(InterpreterTestCase.map_key_mixed_numbers_lossy_double_key) | ||
| .expr("{1u: 1.0, 2: 2.0, 3u: 3.0}[3.1]") | ||
| .err("no such key: double{3.1}"), | ||
| new TestCase(InterpreterTestCase.map_key_string_and_int_are_distinct) | ||
| .expr("{1: 'int', '1': 'string'}['1']") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we have a test that covers trying to use two equal keys in the same map literal?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, for equal heterogeneous numeric keys (somewhere below
Honestly, I don't know. |
||
| .out(stringOf("string")), | ||
| new TestCase(InterpreterTestCase.eq_dyn_string_int).expr("dyn('1') == dyn(1)").out(False), | ||
| new TestCase(InterpreterTestCase.eq_dyn_int_string).expr("dyn(1) == dyn('1')").out(False), | ||
| new TestCase(InterpreterTestCase.eq_dyn_string_bool) | ||
| .expr("dyn('true') == dyn(true)") | ||
| .out(False), | ||
| new TestCase(InterpreterTestCase.zero_based_double_error) | ||
| .expr("[7, 8, 9][dyn(0.1)]") | ||
| .err("invalid_argument"), | ||
|
|
||
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 am no expert on the CEL spec, so just wondering what you think about:
https://github.com/cel-expr/cel-spec/blob/master/doc/langdef.md#equality
would it be preferable to throw an error for equal on incompatible types?
or is this the "dynamically typed" scenario?
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.
The CEL-spec just say "those are not equal". Mean, that's the same as Java
"foo".equals(1) == false