mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-28 03:05:04 -06:00
Add a few int/float comparison tests (#4798)
Signed-off-by: Anders Eknert <anders@eknert.com>
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user