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,45 @@
|
||||
// Copyright (c) Rego-Rs Authors.
|
||||
// Licensed under the Apache 2.0 license.
|
||||
#![cfg(test)]
|
||||
|
||||
use crate::interpreter::*;
|
||||
use anyhow::Result;
|
||||
|
||||
#[test]
|
||||
fn basic() -> Result<()> {
|
||||
let rego = r#"
|
||||
package test
|
||||
|
||||
add {
|
||||
1 + 2 == 3
|
||||
}
|
||||
|
||||
sub {
|
||||
5 - 1 == 4
|
||||
}
|
||||
|
||||
mul {
|
||||
3 * 4 == 12
|
||||
}
|
||||
|
||||
# Lock down float operation.
|
||||
div {
|
||||
21 / 5 == 4.2
|
||||
}
|
||||
"#;
|
||||
|
||||
let expected = Value::from_json_str(
|
||||
r#" {
|
||||
"add" : true,
|
||||
"sub" : true,
|
||||
"mul" : true,
|
||||
"div" : true
|
||||
}"#,
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
eval_file(&[rego.to_owned()], None, None, "data.test")?,
|
||||
expected
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user