mod harness;
use harness::{Compiled, compile};
use std::sync::OnceLock;
fn empty() -> &'static Compiled {
static C: OnceLock<Compiled> = OnceLock::new();
C.get_or_init(|| compile("just_a_fact.\n"))
}
#[test]
fn comparison_operator_as_atom() {
for (q, want) in [("X = (<)", "<"), ("X = (=)", "="), ("X = (>)", ">")] {
let (out, code) = empty().query(q, &[]);
assert_eq!(out, format!("X = {want}\n"), "query: {q}");
assert_eq!(code, 1, "query: {q}");
}
}
#[test]
fn infix_arithmetic_unaffected() {
let (out, _) = empty().query("X is 1 + 2", &[]);
assert_eq!(out, "X = 3\n");
let (out, _) = empty().query("X is -3 + 5", &[]);
assert_eq!(out, "X = 2\n");
}
#[test]
fn operator_atom_and_prefix_surface() {
let (out, code) = empty().query("functor(+ a, N, A)", &[]);
assert_eq!(out, "A = 1\nN = +\n");
assert_eq!(code, 1);
}
#[test]
fn colon_operator() {
let (out, code) = empty().query("functor(pkg : expr, N, A)", &[]);
assert_eq!(out, "A = 2\nN = :\n");
assert_eq!(code, 1);
}