summaryrefslogtreecommitdiffstats
path: root/src/forth
diff options
context:
space:
mode:
Diffstat (limited to 'src/forth')
-rw-r--r--src/forth/mod.rs33
1 files changed, 0 insertions, 33 deletions
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");
- }
-}