diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib.rs | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/src/lib.rs b/src/lib.rs index 4a7950a..b806b4c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,7 +82,6 @@ #[cfg(test)] extern crate test; -mod constants; mod engine; pub mod executor; pub mod lexer; @@ -90,7 +89,6 @@ pub mod parser; #[cfg(feature = "utilities")] pub mod utility; -pub use executor::Executor; pub use lexer::{lex, OperatorCode}; use miette::Diagnostic; pub use parser::{parse, Instruction}; @@ -118,33 +116,67 @@ mod tests { use test::Bencher; use super::*; - use crate::constants::TapeInner; #[test] fn hello_world() -> Result<(), Error> { - let mut tape: Vec<TapeInner> = vec![0; 1024]; + let mut tape: Vec<u8> = vec![0; 1024]; - utility::execute_from_file("./test_programs/hello_world.bf", &mut tape)?; + utility::execute_from_file::<executor::U8>("./test_programs/hello_world.bf", &mut tape)?; + + Ok(()) + } + + #[test] + fn hello_world_u16() -> Result<(), Error> { + let mut tape: Vec<u16> = vec![0; 1024]; + + utility::execute_from_file::<executor::U16>("./test_programs/hello_world.bf", &mut tape)?; + + Ok(()) + } + + #[test] + fn hello_world_from_hell() -> Result<(), Error> { + let mut tape: Vec<u16> = vec![0; 1024]; + + utility::execute_from_file::<executor::U16>( + "./test_programs/hello_world_from_hell.bf", + &mut tape, + )?; Ok(()) } #[bench] - fn hello_world_from_hell(b: &mut Bencher) { + fn hello_world_from_hell_bench_u8(b: &mut Bencher) { b.iter(|| { - let mut tape: Vec<TapeInner> = vec![0; 1024]; + let mut tape: Vec<u8> = vec![0; 1024]; #[allow(clippy::expect_used)] - utility::execute_from_file("./test_programs/hello_world.bf", &mut tape) + utility::execute_from_file::<executor::U8>("./test_programs/hello_world.bf", &mut tape) .expect("failed to run"); }); } + #[bench] + fn hello_world_from_hell_bench_u16(b: &mut Bencher) { + b.iter(|| { + let mut tape: Vec<u16> = vec![0; 1024]; + + #[allow(clippy::expect_used)] + utility::execute_from_file::<executor::U16>( + "./test_programs/hello_world.bf", + &mut tape, + ) + .expect("failed to run"); + }); + } + #[test] fn hello_world_short() -> Result<(), Error> { - let mut tape: Vec<TapeInner> = vec![0; 1024]; + let mut tape: Vec<u8> = vec![0; 1024]; - utility::execute_from_str( + utility::execute_from_str::<executor::U8>( "--[+++++++<---->>-->+>+>+<<<<]<.>++++[-<++++>>->--<<]>>-.>--..>+.<<<.<<-.>>+>->>.\ +++[.<]", &mut tape, |