pull out libm. pow and sqrt to be implemented in userlib maybe?

Signed-off-by: Ava Affine <ava@sunnypup.io>
This commit is contained in:
Ava Apples Affine 2024-07-29 11:14:34 -07:00
parent a93fb512aa
commit 48178b5a48
3 changed files with 2 additions and 126 deletions

View file

@ -1,7 +1,6 @@
mod math_lib_tests {
use flesh::ast::{eval, lex, Ctr, SymTable};
use flesh::stdlib::static_stdlib;
use libm::pow;
#[test]
fn test_add_chain() {
@ -138,66 +137,6 @@ mod math_lib_tests {
);
}
#[test]
fn test_ii_exp() {
let document = "(exp 7 20)";
let result = pow(7 as f64, 20 as f64);
let mut syms = SymTable::new();
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
#[test]
fn test_if_exp() {
let document = "(exp 1 10.2)";
let result = f64::powf(1f64, 10.2);
let mut syms = SymTable::new();
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
#[test]
fn test_fi_exp() {
let document = "(exp 10.2 1)";
let result = pow(10.2 as f64, 1 as f64);
let mut syms = SymTable::new();
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
#[test]
fn test_ff_exp() {
let document = "(exp 1.4 1.5)";
let result = pow(1.4, 1.5);
let mut syms = SymTable::new();
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
#[test]
fn test_ii_mod() {
let document = "(def test \"\" (mod 7 3))";