From 0f9a9158b7135a3162522cf473a7bad80f141109 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Sun, 24 Aug 2025 18:25:10 -0400 Subject: move factorial test to integration test --- src/forth/mod.rs | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'src/forth') diff --git a/src/forth/mod.rs b/src/forth/mod.rs index f61bbda..aea8bda 100644 --- a/src/forth/mod.rs +++ b/src/forth/mod.rs @@ -1,35 +1,2 @@ pub mod compiler; pub mod vm; - -#[cfg(test)] -mod tests { - use super::{ - vm::{VM, WordList}, - compiler::Compiler, - }; - - fn compiler_for(text: &str) -> Compiler { - let mut p = Compiler::new(text); - p.compile().expect("badparse"); - p - } - - fn eprintwordlist(wordlist: &WordList) { - for i in 0..wordlist.0.len() { - eprintln!("wordlist[{}]: {:?}", i, wordlist.0[i]); - } - } - - // recursive! - #[test] - fn fac() { - let prog = ": fac dup 1 > if dup 1 - fac * then ; 5 fac\n"; - let p = compiler_for(prog); - eprintwordlist(&p.wordlist); - let mut vm = VM::new(p.wordlist); - vm.run().expect("should run to completion"); - eprintln!("stack: {:?}", vm.stack); - assert_eq!(vm.stack.0.len(), 1, "factorial result stack len"); - assert_eq!(vm.stack.0[0], 120, "factorial result value"); - } -} -- cgit v1.3