2025-08-16 21:52:36 +02:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// Testing
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
use super::dsl::*;
|
|
|
|
|
use super::super::{translator, structure};
|
|
|
|
|
|
2025-08-16 21:52:36 +02:00
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_true() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {tree: Tree::Return(Box::new(Expression::True))};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Boolean(true))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_concat_1() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::True))),
|
|
|
|
|
Box::new(Tree::Return(Box::new(Expression::True))),
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Boolean(true))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_concat_2() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Return(Box::new(Expression::True))),
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Integer(10)))),
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Boolean(true))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_return_1() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Return(Box::new(Expression::True))),
|
|
|
|
|
Box::new(Tree::Return(Box::new(Expression::False))),
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Boolean(true))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_return_incompatible_1() {
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Return(Box::new(Expression::True))),
|
|
|
|
|
Box::new(Tree::Return(Box::new(Expression::Integer(10)))),
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_err());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_return_incompatible_2() {
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Return(Box::new(Expression::True))),
|
|
|
|
|
Box::new(
|
|
|
|
|
Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Integer(10)))),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(Variable::Id("a".into())))
|
|
|
|
|
))),
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_err());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_return_2() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Return(Box::new(Expression::True))),
|
|
|
|
|
Box::new(
|
|
|
|
|
Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::False))),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(Variable::Id("a".into())))
|
|
|
|
|
))),
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Boolean(true))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_return_3() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(
|
|
|
|
|
Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::False))),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(Variable::Id("a".into())))
|
|
|
|
|
))),
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(Box::new(Expression::True))),
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Boolean(false))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_if_1() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Return(Box::new(Expression::True))),
|
|
|
|
|
Box::new(
|
|
|
|
|
Tree::If(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::True
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::True)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Boolean(true))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_if_2() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(
|
|
|
|
|
Tree::If(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::True
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::False)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(Box::new(Expression::True))),
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Boolean(false))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_if_3() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(
|
|
|
|
|
Tree::If(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::False
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::False)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(Box::new(Expression::True))),
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Boolean(true))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_if_4() {
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(
|
|
|
|
|
Tree::If(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::Integer(10)
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::True)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(Box::new(Expression::True))),
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_err());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_if_else_1() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Return(Box::new(Expression::True))),
|
|
|
|
|
Box::new(
|
|
|
|
|
Tree::IfElse(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::True
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::True)
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::False)
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Boolean(true))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_if_else_2() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(
|
|
|
|
|
Tree::IfElse(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::False
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::True)
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::False)
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(Box::new(Expression::True))),
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Boolean(false))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_if_else_3() {
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(
|
|
|
|
|
Tree::IfElse(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::Integer(10)
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::True)
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::False)
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(Box::new(Expression::True))),
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_err());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_if_else_4() {
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(
|
|
|
|
|
Tree::IfElse(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::True
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::True)
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::Integer(10))
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(Box::new(Expression::True))),
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_err());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_assignment_1() {
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::True)
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_err());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_assignment_2() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(
|
|
|
|
|
Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::True)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
Box::new(
|
|
|
|
|
Tree::Return(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::True
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Boolean(true))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_assignment_3() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(
|
|
|
|
|
Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::False)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
Box::new(
|
|
|
|
|
Tree::Return(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::Var(
|
|
|
|
|
Variable::Id("a".into())
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Boolean(false))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_assignment_4() {
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(
|
|
|
|
|
Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::True)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
Box::new(
|
|
|
|
|
Tree::Return(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::Var(
|
|
|
|
|
Variable::Id("b".into())
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_err());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_assignment_5() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Integer(10))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("a".into())
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("a".into())
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Integer(10))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_assignment_6() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Integer(10))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("b".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Integer(200))
|
|
|
|
|
)),
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("a".into())
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("b".into())
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Integer(10))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_assignment_7() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Integer(10))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::True)
|
|
|
|
|
)),
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("a".into())
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::False)
|
|
|
|
|
)),
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Boolean(true))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_assignment_8() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Integer(10))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("b".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("a".into())
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("a".into())
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("b".into())
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Integer(10))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_assignment_9() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Integer(10))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("b".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("a".into())
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("b".into())
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Integer(200))
|
|
|
|
|
)),
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Integer(10))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_assignment_10() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Integer(10))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("b".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("a".into())
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Integer(200))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("b".into())
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Integer(10))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_for_1() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel, RSset};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Set(RSset::new()))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("b".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Set(RSset::new()))
|
|
|
|
|
)),
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::For(
|
|
|
|
|
Variable::Id("c".into()),
|
|
|
|
|
Range::IterateOverSet(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::Var(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Integer(200))
|
|
|
|
|
)),
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(tree.execute(&graph, &edge, &mut tr).is_err());
|
2025-08-16 21:52:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_for_2() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel, RSset};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Set(RSset::from([1, 2])))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("b".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Set(RSset::new()))
|
|
|
|
|
)),
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::For(
|
|
|
|
|
Variable::Id("c".into()),
|
|
|
|
|
Range::IterateOverSet(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::Var(
|
|
|
|
|
Variable::Id("a".into())
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("b".into())
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
|
|
|
|
tr.encode("one");
|
|
|
|
|
tr.encode("two");
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Set(_))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_for_3() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel, RSset};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Label(
|
|
|
|
|
Box::new(RSlabel::from(RSset::from([1, 2]),
|
|
|
|
|
RSset::new(),
|
|
|
|
|
RSset::from([1, 2]),
|
|
|
|
|
RSset::new(),
|
|
|
|
|
RSset::new(),
|
|
|
|
|
RSset::new(),
|
|
|
|
|
RSset::new(),
|
|
|
|
|
RSset::new()))
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("b".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Set(RSset::new()))
|
|
|
|
|
)),
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::For(
|
|
|
|
|
Variable::Id("c".into()),
|
|
|
|
|
Range::IterateOverSet(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::Unary(
|
|
|
|
|
Unary::Qualifier(Qualifier::Restricted(
|
|
|
|
|
QualifierRestricted::Entities
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("a".into())
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("b".into())
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
|
|
|
|
tr.encode("one");
|
|
|
|
|
tr.encode("two");
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Set(_))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_for_4() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel, RSset};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Label(
|
|
|
|
|
Box::new(RSlabel::from(RSset::from([1, 2]),
|
|
|
|
|
RSset::from([3]),
|
|
|
|
|
RSset::from([1, 2, 3]),
|
|
|
|
|
RSset::new(),
|
|
|
|
|
RSset::new(),
|
|
|
|
|
RSset::new(),
|
|
|
|
|
RSset::new(),
|
|
|
|
|
RSset::new()))
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("b".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Set(RSset::new()))
|
|
|
|
|
)),
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::For(
|
|
|
|
|
Variable::Id("c".into()),
|
|
|
|
|
Range::IterateOverSet(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::Unary(
|
|
|
|
|
Unary::Qualifier(Qualifier::Label(
|
|
|
|
|
QualifierLabel::AvailableEntities
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("a".into())
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("c".into())
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
|
|
|
|
tr.encode("one");
|
|
|
|
|
tr.encode("two");
|
|
|
|
|
tr.encode("three");
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Element(_))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_for_5() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel, RSset};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Label(
|
|
|
|
|
Box::new(RSlabel::from(RSset::from([1, 2]),
|
|
|
|
|
RSset::from([3]),
|
|
|
|
|
RSset::from([1, 2, 3]),
|
|
|
|
|
RSset::new(),
|
|
|
|
|
RSset::new(),
|
|
|
|
|
RSset::new(),
|
|
|
|
|
RSset::new(),
|
|
|
|
|
RSset::new()))
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("b".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Integer(0))
|
|
|
|
|
)),
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::For(
|
|
|
|
|
Variable::Id("c".into()),
|
|
|
|
|
Range::IterateOverSet(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::Unary(
|
|
|
|
|
Unary::Qualifier(Qualifier::Label(
|
|
|
|
|
QualifierLabel::AvailableEntities
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("a".into())
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("b".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Binary(
|
|
|
|
|
Binary::Plus,
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("b".into())
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Expression::Integer(1))
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("b".into())
|
|
|
|
|
))
|
|
|
|
|
))
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
|
|
|
|
tr.encode("one");
|
|
|
|
|
tr.encode("two");
|
|
|
|
|
tr.encode("three");
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Integer(3))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_for_6() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel, RSset};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Label(
|
|
|
|
|
Box::new(RSlabel::from(RSset::from([1, 2]),
|
|
|
|
|
RSset::from([3]),
|
|
|
|
|
RSset::from([1, 2, 3]),
|
|
|
|
|
RSset::new(),
|
|
|
|
|
RSset::new(),
|
|
|
|
|
RSset::new(),
|
|
|
|
|
RSset::new(),
|
|
|
|
|
RSset::new()))
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("b".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Set(RSset::from([2])))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("c".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Integer(0))
|
|
|
|
|
)),
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::For(
|
|
|
|
|
Variable::Id("d".into()),
|
|
|
|
|
Range::IterateOverSet(
|
|
|
|
|
Box::new(
|
|
|
|
|
Expression::Binary(
|
|
|
|
|
Binary::Plus,
|
|
|
|
|
Box::new(Expression::Unary(
|
|
|
|
|
Unary::Qualifier(Qualifier::Restricted(
|
|
|
|
|
QualifierRestricted::Context
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("a".into())
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("b".into())
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("c".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Binary(
|
|
|
|
|
Binary::Plus,
|
|
|
|
|
Box::new(Expression::Var(Variable::Id("c".into()))),
|
|
|
|
|
Box::new(Expression::Integer(1))
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(Variable::Id("c".into())))
|
|
|
|
|
))
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
|
|
|
|
tr.encode("one");
|
|
|
|
|
tr.encode("two");
|
|
|
|
|
tr.encode("three");
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Integer(2))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_for_7() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Integer(0))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("b".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Integer(10))
|
|
|
|
|
)),
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::For(
|
|
|
|
|
Variable::Id("c".into()),
|
|
|
|
|
Range::IterateInRange(
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("a".into())
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("b".into()),
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("c".into())
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Integer(0))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_for_8() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel};
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Unary(
|
|
|
|
|
Unary::Neighbours,
|
|
|
|
|
Box::new(Expression::Unary(
|
|
|
|
|
Unary::Source,
|
2025-08-17 01:01:56 +02:00
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Special(EdgeRelablerInput::Edge)
|
|
|
|
|
))
|
2025-08-16 21:52:36 +02:00
|
|
|
))
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("b".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Integer(0))
|
|
|
|
|
)),
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Concat(
|
|
|
|
|
Box::new(Tree::For(
|
|
|
|
|
Variable::Id("c".into()),
|
|
|
|
|
Range::IterateOverSet(
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("a".into())
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("b".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Binary(
|
|
|
|
|
Binary::Plus,
|
|
|
|
|
Box::new(Expression::Var(Variable::Id("b".into()))),
|
|
|
|
|
Box::new(Expression::Integer(1))
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Var(Variable::Id("b".into())))
|
|
|
|
|
))
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Integer(1))));
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(RSsystem::new());
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
let node_3 = graph.add_node(RSsystem::new());
|
|
|
|
|
graph.add_edge(node_1, node_3, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Integer(2))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_tycheck_system() {
|
2025-08-17 01:25:35 +02:00
|
|
|
use translator::Translator;
|
|
|
|
|
use structure::{RSsystem, RSlabel, RSset, RSenvironment, RSprocess};
|
2025-08-16 21:52:36 +02:00
|
|
|
use std::rc::Rc;
|
|
|
|
|
|
|
|
|
|
let tree = RSassert {
|
|
|
|
|
tree: Tree::Concat(
|
|
|
|
|
Box::new(Tree::Assignment(
|
|
|
|
|
Variable::Id("a".into()),
|
|
|
|
|
None,
|
|
|
|
|
Box::new(Expression::Unary(
|
|
|
|
|
Unary::Qualifier(
|
|
|
|
|
Qualifier::System(QualifierSystem::Entities)
|
|
|
|
|
),
|
|
|
|
|
Box::new(Expression::Unary(
|
|
|
|
|
Unary::System,
|
|
|
|
|
Box::new(Expression::Unary(
|
|
|
|
|
Unary::Target,
|
2025-08-17 01:01:56 +02:00
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Special(EdgeRelablerInput::Edge)
|
|
|
|
|
))
|
2025-08-16 21:52:36 +02:00
|
|
|
))
|
|
|
|
|
))
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Tree::Return(
|
|
|
|
|
Box::new(Expression::Binary(
|
|
|
|
|
Binary::Less,
|
|
|
|
|
Box::new(Expression::Var(
|
|
|
|
|
Variable::Id("a".into())
|
|
|
|
|
)),
|
|
|
|
|
Box::new(Expression::Set(RSset::from([1, 2])))
|
|
|
|
|
))
|
|
|
|
|
)),
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
assert!(tree.typecheck().is_ok());
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
let mut tr = Translator::new();
|
2025-08-16 21:52:36 +02:00
|
|
|
|
|
|
|
|
let mut graph = petgraph::Graph::new();
|
|
|
|
|
let node_1 = graph.add_node(RSsystem::new());
|
|
|
|
|
let node_2 = graph.add_node(
|
|
|
|
|
RSsystem::from(
|
|
|
|
|
Rc::new(RSenvironment::new()),
|
|
|
|
|
RSset::from([2]),
|
|
|
|
|
RSprocess::Nill,
|
|
|
|
|
Rc::new(vec![])
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
let edge = graph.add_edge(node_1, node_2, RSlabel::new());
|
|
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
println!("{:?}", tree.execute(&graph, &edge, &mut tr));
|
2025-08-16 21:52:36 +02:00
|
|
|
|
2025-08-17 01:25:35 +02:00
|
|
|
assert!(matches!(tree.execute(&graph, &edge, &mut tr),
|
2025-08-16 21:52:36 +02:00
|
|
|
Ok(AssertReturnValue::Boolean(true))));
|
|
|
|
|
}
|