Lines
100 %
Functions
Branches
use nomiscript::{
Reader, eval_program,
runtime::{SymbolTable, Value},
};
fn eval_expr(code: &str) -> Result<Value, nomiscript::Error> {
let program = Reader::parse(code)?;
let mut symbols = SymbolTable::with_builtins();
eval_program(&mut symbols, &program)
}
#[test]
fn test_transaction_struct_definition() {
let code = r"
(defstruct transaction
post-date
enter-date
split-count
tag-count
is-multi-currency)
T
";
let result = eval_expr(code);
assert!(
result.is_ok(),
"Transaction struct should be defined successfully"
);
fn test_split_struct_definition() {
(defstruct split
account-id
commodity-id
value-num
value-denom
reconcile-state
reconcile-date)
"Split struct should be defined successfully"
fn test_account_struct_definition() {
(defstruct account
parent-account-id
name
path
tag-count)
"Account struct should be defined successfully"
fn test_commodity_struct_definition() {
(defstruct commodity
symbol
"Commodity struct should be defined successfully"
fn test_tag_struct_definition() {
(defstruct tag
value)
assert!(result.is_ok(), "Tag struct should be defined successfully");
fn test_all_financial_structs() {
"All financial structs should be defined successfully"