Add a few int/float comparison tests (#4798)

Signed-off-by: Anders Eknert <anders@eknert.com>
This commit is contained in:
Anders Eknert
2022-06-21 12:23:08 +02:00
committed by GitHub
parent e98d47829a
commit aacb7fc276
2 changed files with 49 additions and 85 deletions
@@ -1,93 +1,10 @@
cases:
- data:
a:
- 1
- 2
- 3
- 4
b:
v1: hello
v2: goodbye
c:
- x:
- true
- false
- foo
"y":
- null
- 3.14159
z:
p: true
q: false
d:
e:
- bar
- baz
f:
- xs:
- 1
ys:
- 2
- xs:
- 2
ys:
- 3
g:
a:
- 1
- 0
- 0
- 0
b:
- 0
- 2
- 0
- 0
c:
- 0
- 0
- 0
- 4
h:
- - 1
- 2
- 3
- - 2
- 3
- 4
l:
- a: bob
b: -1
c:
- 1
- 2
- 3
- 4
- a: alice
b: 1
c:
- 2
- 3
- 4
- 5
d: null
m: []
numbers:
- "1"
- "2"
- "3"
- "4"
strings:
bar: 2
baz: 3
foo: 1
three: 3
modules:
- modules:
- |
package generated
p {
1 < -1
1 <= -1
}
note: 'comparisonexpr/undefined: lteq'
query: data.generated.p = x
@@ -0,0 +1,47 @@
cases:
# Leaving out floats as map keys until this is resolved:
# https://github.com/open-policy-agent/opa/issues/4797
- modules:
- |
package comparison
p {
1 == 1.0
}
note: 'comparisonexpr/numbers: int and float comparison'
query: data.comparison.p = x
want_result:
- x: true
- modules:
- |
package comparison
p {
[1] == [1.0]
}
note: 'comparisonexpr/numbers: int and float array comparison'
query: data.comparison.p = x
want_result:
- x: true
- modules:
- |
package comparison
p {
{1: 1} == {1: 1.0}
}
note: 'comparisonexpr/numbers: int and float object comparison'
query: data.comparison.p = x
want_result:
- x: true
- modules:
- |
package comparison
p {
{"x": [1, 2, {"b": 3.0}]} == {"x": [1, 2, {"b": 3}]}
}
note: 'comparisonexpr/numbers: int and float nested object comparison'
query: data.comparison.p = x
want_result:
- x: true