Split eval.rs out of ast.rs, and rename ast.rs to basic.rs. Copy it over to opt.rs, and hook up a From<> impl and a congruent(x)->bool function, and add to main.rs and test.rs. Now we actually have to make opt.rs optimize...

This commit is contained in:
2023-07-06 01:11:56 -04:00
parent f4ae4db92d
commit b077daf12e
6 changed files with 479 additions and 195 deletions

View File

@@ -1,7 +1,9 @@
use std::rc::Rc;
use crate::grammar;
use crate::ast::{eval,root_env,Form};
use crate::basic::{root_env,Form};
use crate::opt::{OptForm};
use crate::eval::{eval};
#[test]
fn parse_test() {
@@ -23,8 +25,15 @@ fn eval_test<T: Into<Form>>(also_pe: bool, gram: &grammar::TermParser, e: &Rc<Fo
let parsed = gram.parse(code).unwrap();
let basic_result = eval(Rc::clone(e), Rc::clone(&parsed));
assert_eq!(*basic_result, expected.into());
if also_pe {
}
let opt_root: Rc<OptForm> = (&**e).into();
let opt_input: Rc<OptForm> = (&*parsed).into();
let opt_result = eval(opt_root, opt_input);
assert!(opt_result.congruent(&*basic_result));
//if also_pe {
//}
}
#[test]