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,67 @@
|
||||
# Copyright (c) Rego-Rs Authors.
|
||||
# Licensed under the Apache 2.0 license.
|
||||
|
||||
cases:
|
||||
- note: simple
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
|
||||
x = { k:1 | k = ["Hello", "world", 1][_] }
|
||||
query: data.test
|
||||
want_result:
|
||||
x:
|
||||
object!:
|
||||
- key: "Hello"
|
||||
value: 1
|
||||
- key: "world"
|
||||
value: 1
|
||||
- key: 1
|
||||
value: 1
|
||||
|
||||
|
||||
- note: key-loop
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
|
||||
x = { ["Hello", "world", 1][_]:1 | true }
|
||||
query: data.test
|
||||
want_result:
|
||||
x:
|
||||
object!:
|
||||
- key: "Hello"
|
||||
value: 1
|
||||
- key: "world"
|
||||
value: 1
|
||||
- key: 1
|
||||
value: 1
|
||||
|
||||
- note: multiple-occurance-of-same-key-value-pair
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
x = { k:v | k = ["Hello", "world", 1][_]; v = [1, 1][_] }
|
||||
query: data.test
|
||||
want_result:
|
||||
x:
|
||||
object!:
|
||||
- key: "Hello"
|
||||
value: 1
|
||||
- key: "world"
|
||||
value: 1
|
||||
- key: 1
|
||||
value: 1
|
||||
|
||||
- note: different-values-for-same-key
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
x = { k:v | k = ["Hello", "world", 1][_]; v = [1, 2][_] }
|
||||
query: data.test
|
||||
error: "value for key `\"Hello\"` generated multiple times: `1` and `2`"
|
||||
want_result:
|
||||
Reference in New Issue
Block a user