Files
regorus/tests/rvm/rego/cases/sets.yaml
Anand Krishnamoorthi a514e8da83 fix: Implement RVM set ops correctly
- treat set subtraction in RVM the same as the interpreter by supporting
  Value::Set operands in sub_values
- emit internal-only builtin names for set union/intersection and register
  handlers so compiled bytecode resolves without exposing new Rego builtins
- add regression coverage for literal set difference/intersection
  (x/y from failure.rego) in tests/rvm/rego/cases/sets.yaml

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2025-12-16 12:03:02 -06:00

90 lines
1.7 KiB
YAML

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Sets Test Suite
# Tests set creation, deduplication, membership testing, and nested sets
cases:
- note: set_creation
data: {}
modules:
- |
package test
main := result if {
result := {1, 2, 3, "hello", true}
}
query: data.test.main
want_result:
set!: [1, 2, 3, "hello", true]
- note: set_with_duplicates
data: {}
modules:
- |
package test
main := result if {
result := {1, 2, 2, 3, 1}
}
query: data.test.main
want_result:
set!: [1, 2, 3]
- note: set_membership
data: {}
modules:
- |
package test
my_set := {1, 2, 3, 4, 5}
main := result if {
result := 3 in my_set
}
query: data.test.main
want_result: true
- note: set_non_membership
data: {}
modules:
- |
package test
my_set := {"a", "b", "c"}
main := result if {
result := "d" in my_set
}
query: data.test.main
want_result: false
- note: nested_sets
data: {}
modules:
- |
package test
main := result if {
result := {{1, 2}, {3, 4}, {"a", "b"}}
}
query: data.test.main
want_result:
set!:
- set!: [1, 2]
- set!: [3, 4]
- set!: ["a", "b"]
- note: set_difference_literals
data: {}
modules:
- |
package test
x := {2, 3} - {4, 2}
query: data.test.x
want_result:
set!: [3]
- note: set_intersection_literals
data: {}
modules:
- |
package test
y := {2, 3} & {4, 2}
query: data.test.y
want_result:
set!: [2]