From 2ae00160fccef348a11ff3cf8cd6a133e63c7a79 Mon Sep 17 00:00:00 2001 From: Nilstrieb Date: Sat, 24 Apr 2021 15:31:28 +0200 Subject: [PATCH] fixed underscore --- bfi-rust/src/interpreter/mod.rs | 9 ++++++++- bfi-rust/src/interpreter/o0.rs | 2 +- bfi-rust/src/interpreter/o1.rs | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bfi-rust/src/interpreter/mod.rs b/bfi-rust/src/interpreter/mod.rs index ac97b21..0c6e423 100644 --- a/bfi-rust/src/interpreter/mod.rs +++ b/bfi-rust/src/interpreter/mod.rs @@ -47,9 +47,16 @@ fn parse(chars: Vec) -> Vec { #[cfg(test)] mod tests { - use crate::interpreter::parse; + use crate::interpreter::{parse, minify}; use crate::interpreter::Statement::{Dec, In, Inc, L, Loop, Out, R}; + #[test] + fn minify_test() { + let program = "sdahf+saga-46a[r]r.hr,e"; + let expected = "+-<>[].,"; + assert_eq!(String::from(expected), minify(program)); + } + #[test] fn parse_no_loop() { let program = "+-<>,."; diff --git a/bfi-rust/src/interpreter/o0.rs b/bfi-rust/src/interpreter/o0.rs index da21f82..f9ce80a 100644 --- a/bfi-rust/src/interpreter/o0.rs +++ b/bfi-rust/src/interpreter/o0.rs @@ -5,7 +5,7 @@ use crate::interpreter::{MEM_SIZE, minify}; use std::io::{stdin, Read}; -pub fn _run(program: &str) -> String{ +pub fn run(program: &str) -> String{ let program = minify(program); let out = interpret(program.chars().collect()); out diff --git a/bfi-rust/src/interpreter/o1.rs b/bfi-rust/src/interpreter/o1.rs index 6369eb4..e49bcc2 100644 --- a/bfi-rust/src/interpreter/o1.rs +++ b/bfi-rust/src/interpreter/o1.rs @@ -9,7 +9,7 @@ use std::io::{Read, stdin}; use crate::interpreter::{MEM_SIZE, Memory, minify, parse, Statement}; -pub fn _run(pgm: &str) -> String { +pub fn run(pgm: &str) -> String { let pgm = minify(pgm); let pgm = parse(pgm.chars().collect()); let out = interpret(&pgm);