mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
Code from github.com/anakrish/rego-rs
Authored by anakrish and mingweishih Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
# Copyright (c) Rego-Rs Authors.
|
||||
# Licensed under the Apache 2.0 license.
|
||||
|
||||
cases:
|
||||
- note: basic
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
|
||||
array = [1, 2, 3]
|
||||
|
||||
nested_array = [1, [2, 3, 4], 5, 6]
|
||||
|
||||
object = { "key0": "value0" }
|
||||
|
||||
key = "key"
|
||||
|
||||
object_var = { key: array }
|
||||
|
||||
local_0 = x {
|
||||
x = 10
|
||||
}
|
||||
|
||||
local_1 = x {
|
||||
x = "test_local"
|
||||
}
|
||||
|
||||
# Set with nested object, array and set.
|
||||
set = { 1, 2,
|
||||
{"a": 3, "b" : 4}, [5, 6], {7, 8}}
|
||||
|
||||
# Object with non-string as keys
|
||||
complex_object = {
|
||||
{1, 2, 3} : [4, 5, 6],
|
||||
true: false,
|
||||
[1, 3] : {"hello", "world"}
|
||||
}
|
||||
|
||||
query: data.test
|
||||
want_result:
|
||||
array: [1, 2, 3]
|
||||
nested_array: [1, [2, 3, 4], 5, 6]
|
||||
object:
|
||||
key0: value0
|
||||
key: key
|
||||
object_var:
|
||||
key: [1, 2, 3]
|
||||
local_0: 10
|
||||
local_1: test_local
|
||||
set:
|
||||
# Specify set using special encoding.
|
||||
# Order of elements shouldn't matter for set.
|
||||
set!:
|
||||
- 2
|
||||
- 1
|
||||
- a : 3
|
||||
b : 4
|
||||
- [5, 6]
|
||||
- set!: [8, 7]
|
||||
complex_object:
|
||||
# Specify object using special encoding.
|
||||
object!:
|
||||
- key:
|
||||
set!: [3, 2, 1]
|
||||
value: [4, 5, 6]
|
||||
- key: true
|
||||
value: false
|
||||
- key: [1, 3]
|
||||
value:
|
||||
set!:
|
||||
- "hello"
|
||||
- "world"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user