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.
Make unary
-
operator OPA compatible. (microsoft#175)
OPA supports unary - operator only in the following cases: -\s+numeric literal We match OPAs behavior for now. This can be revisited later.
- Loading branch information
Showing
2 changed files
with
62 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
cases: | ||
- note: unary expr on non literals produces an error | ||
modules: | ||
- | | ||
package test | ||
x = - y | ||
y = 1 | ||
query: data.test | ||
error: "unary - can only be used with numeric literals" | ||
|
||
- note: unary expr on literals work | ||
modules: | ||
- | | ||
package test | ||
x = - 1 # With space | ||
y = -1 | ||
z = - # With newlines and comment | ||
1 | ||
query: data.test | ||
want_result: | ||
x: -1 | ||
y: -1 | ||
z: -1 | ||
|
||
- note: double unary expr | ||
modules: | ||
- | | ||
package test | ||
x = - -1 | ||
query: data.test | ||
error: "unary - can only be used with numeric literals" | ||
|
||
- note: double unary expr double space | ||
modules: | ||
- | | ||
package test | ||
x = - - 1 | ||
query: data.test | ||
error: "unary - can only be used with numeric literals" |