forked from microsoft/regorus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Special cases of refs to data (microsoft#41)
1. Numeric indices will be converted to strings for refs beginning with `data` if there is not valid numeric key 2. Error out if input document already contains value for a ref Signed-off-by: Anand Krishnamoorthi <[email protected]>
- Loading branch information
Showing
6 changed files
with
164 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
cases: | ||
- note: numbers are converted to string as needed when indexing data | ||
data: | ||
"1": "hello" | ||
"1.2": "world" | ||
test: | ||
"2": 100 | ||
"2.2": 200 | ||
play: | ||
"2": 100 | ||
modules: | ||
- | | ||
package test | ||
p = v { | ||
q = data.play | ||
# 2 is not converted to "2" since refr doesn't being with `data` | ||
v = q[2] | ||
} | ||
a = [ | ||
data[1], | ||
data[1.2], | ||
data.test[2], | ||
data.test[2.2] | ||
] | ||
query: data.test | ||
want_result: | ||
"2": 100 | ||
"2.2": 200 | ||
a: | ||
- "hello" | ||
- "world" | ||
- 100 | ||
- 200 | ||
|
||
- note: overriding refs in data produces error | ||
data: | ||
test: | ||
rule1: 0 | ||
modules: | ||
- | | ||
package test | ||
rule1 = 6 | ||
query: data.test | ||
error: value for rule has already been specified | ||
|
||
- note: rule named data | ||
data: | ||
test: | ||
rule1: 8 | ||
modules: | ||
- | | ||
package test | ||
data.test.rule1 = 9 | ||
data.test.rule1 = 9 | ||
query: data.test | ||
want_result: | ||
rule1: 8 | ||
data: | ||
test: | ||
rule1: 9 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters