Create more tests yooo 💙
This commit is contained in:
parent
b4ba99f52c
commit
862d785220
4 changed files with 193 additions and 52 deletions
|
@ -8,21 +8,14 @@ pub enum Cell {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Cell {
|
impl Cell {
|
||||||
pub fn set_value_utf8(&mut self, ch: char) {
|
|
||||||
match self {
|
|
||||||
Cell::Byte(_) => {}
|
|
||||||
Cell::Utf8(p) => {
|
|
||||||
*p = ch as u32;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_value(&mut self, ch: char) {
|
pub fn set_value(&mut self, ch: char) {
|
||||||
match self {
|
match self {
|
||||||
Cell::Byte(p) => {
|
Cell::Byte(p) => {
|
||||||
*p = ch as u8;
|
*p = ch as u8;
|
||||||
}
|
}
|
||||||
Cell::Utf8(_) => {}
|
Cell::Utf8(p) => {
|
||||||
|
*p = ch as u32;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +29,8 @@ impl Cell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
/// For testing purposes
|
||||||
pub fn new(value: u32, future: &Vec<Feature>) -> Self {
|
pub fn new(value: u32, future: &Vec<Feature>) -> Self {
|
||||||
if future.contains(&Feature::AllowUtf8) {
|
if future.contains(&Feature::AllowUtf8) {
|
||||||
Cell::Utf8(value)
|
Cell::Utf8(value)
|
||||||
|
@ -107,7 +102,7 @@ impl Cell {
|
||||||
pub fn max_value(&self) -> u32 {
|
pub fn max_value(&self) -> u32 {
|
||||||
match self {
|
match self {
|
||||||
Self::Byte(_) => u8::MAX as u32,
|
Self::Byte(_) => u8::MAX as u32,
|
||||||
Self::Utf8(_) => u32::MAX,
|
Self::Utf8(_) => 1114111,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,4 +127,154 @@ impl std::fmt::Display for Cell {
|
||||||
Self::Utf8(value) => write!(f, "{}", value),
|
Self::Utf8(value) => write!(f, "{}", value),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_increment_u8_no_revers() {
|
||||||
|
let mut cell = Cell::default_cell(&vec![]);
|
||||||
|
cell.increment(true).unwrap();
|
||||||
|
assert_eq!(cell, Cell::Byte(1));
|
||||||
|
|
||||||
|
for _ in 0..254 {
|
||||||
|
cell.increment(true).unwrap();
|
||||||
|
}
|
||||||
|
assert_eq!(cell, Cell::Byte(255));
|
||||||
|
|
||||||
|
assert_eq!(cell.increment(true).unwrap_err(), InterpreterErrorKind::ValueOutOfBounds.to_error());
|
||||||
|
assert_eq!(cell, Cell::Byte(255));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_increment_u32_no_revers() {
|
||||||
|
let mut cell = Cell::default_cell(&vec![Feature::AllowUtf8]);
|
||||||
|
cell.increment(true).unwrap();
|
||||||
|
assert_eq!(cell, Cell::Utf8(1));
|
||||||
|
|
||||||
|
for _ in 0..1114110 {
|
||||||
|
cell.increment(true).unwrap();
|
||||||
|
}
|
||||||
|
assert_eq!(cell, Cell::Utf8(1114111));
|
||||||
|
|
||||||
|
assert_eq!(cell.increment(true).unwrap_err(), InterpreterErrorKind::ValueOutOfBounds.to_error());
|
||||||
|
assert_eq!(cell, Cell::Utf8(1114111));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_increment_u8_revers() {
|
||||||
|
let mut cell = Cell::default_cell(&vec![]);
|
||||||
|
cell.increment(false).unwrap();
|
||||||
|
assert_eq!(cell, Cell::Byte(1));
|
||||||
|
|
||||||
|
for _ in 0..254 {
|
||||||
|
cell.increment(false).unwrap();
|
||||||
|
}
|
||||||
|
assert_eq!(cell, Cell::Byte(255));
|
||||||
|
|
||||||
|
cell.increment(false).unwrap();
|
||||||
|
assert_eq!(cell, Cell::Byte(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_increment_u32_revers() {
|
||||||
|
let mut cell = Cell::default_cell(&vec![Feature::AllowUtf8]);
|
||||||
|
cell.increment(false).unwrap();
|
||||||
|
assert_eq!(cell, Cell::Utf8(1));
|
||||||
|
|
||||||
|
for _ in 0..1114110 {
|
||||||
|
cell.increment(false).unwrap();
|
||||||
|
}
|
||||||
|
assert_eq!(cell, Cell::Utf8(1114111));
|
||||||
|
|
||||||
|
cell.increment(false).unwrap();
|
||||||
|
assert_eq!(cell, Cell::Utf8(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_decrement_u8_no_revers() {
|
||||||
|
let mut cell = Cell::new(255, &vec![]);
|
||||||
|
cell.decrement(true).unwrap();
|
||||||
|
assert_eq!(cell, Cell::Byte(254));
|
||||||
|
|
||||||
|
for _ in 0..254 {
|
||||||
|
cell.decrement(true).unwrap();
|
||||||
|
}
|
||||||
|
assert_eq!(cell, Cell::Byte(0));
|
||||||
|
|
||||||
|
assert_eq!(cell.decrement(true).unwrap_err(), InterpreterErrorKind::ValueOutOfBounds.to_error());
|
||||||
|
assert_eq!(cell, Cell::Byte(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_decrement_u32_no_revers() {
|
||||||
|
let mut cell = Cell::new(1114111, &vec![Feature::AllowUtf8]);
|
||||||
|
cell.decrement(true).unwrap();
|
||||||
|
assert_eq!(cell, Cell::Utf8(1114110));
|
||||||
|
|
||||||
|
for _ in 0..1114110 {
|
||||||
|
cell.decrement(true).unwrap();
|
||||||
|
}
|
||||||
|
assert_eq!(cell, Cell::Utf8(0));
|
||||||
|
|
||||||
|
assert_eq!(cell.decrement(true).unwrap_err(), InterpreterErrorKind::ValueOutOfBounds.to_error());
|
||||||
|
assert_eq!(cell, Cell::Utf8(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_decrement_u8_revers() {
|
||||||
|
let mut cell = Cell::new(0, &vec![]);
|
||||||
|
cell.decrement(false).unwrap();
|
||||||
|
assert_eq!(cell, Cell::Byte(255));
|
||||||
|
|
||||||
|
for _ in 0..254 {
|
||||||
|
cell.decrement(false).unwrap();
|
||||||
|
}
|
||||||
|
assert_eq!(cell, Cell::Byte(1));
|
||||||
|
|
||||||
|
cell.decrement(false).unwrap();
|
||||||
|
assert_eq!(cell, Cell::Byte(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_decrement_u32_revers() {
|
||||||
|
let mut cell = Cell::new(0, &vec![Feature::AllowUtf8]);
|
||||||
|
cell.decrement(false).unwrap();
|
||||||
|
assert_eq!(cell, Cell::Utf8(1114111));
|
||||||
|
|
||||||
|
for _ in 0..1114110 {
|
||||||
|
cell.decrement(false).unwrap();
|
||||||
|
}
|
||||||
|
assert_eq!(cell, Cell::Utf8(1));
|
||||||
|
|
||||||
|
cell.decrement(false).unwrap();
|
||||||
|
assert_eq!(cell, Cell::Utf8(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_to_char() {
|
||||||
|
let cell = Cell::new(65, &vec![]);
|
||||||
|
assert_eq!(cell.to_char().unwrap(), 'A');
|
||||||
|
|
||||||
|
let cell = Cell::new(129408, &vec![Feature::AllowUtf8]);
|
||||||
|
assert_eq!(cell.to_char().unwrap(), '🦀');
|
||||||
|
|
||||||
|
let cell = Cell::new(129392, &vec![Feature::AllowUtf8]);
|
||||||
|
assert_eq!(cell.to_char().unwrap(), '🥰');
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_set_value() {
|
||||||
|
let mut cell = Cell::default_cell(&vec![]);
|
||||||
|
cell.set_value('A');
|
||||||
|
assert_eq!(cell, Cell::Byte(65));
|
||||||
|
|
||||||
|
let mut cell = Cell::default_cell(&vec![Feature::AllowUtf8]);
|
||||||
|
cell.set_value('🦀');
|
||||||
|
assert_eq!(cell, Cell::Utf8(129408));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -10,14 +10,14 @@ pub struct Interpreter {
|
||||||
pub bf_commands: Vec<BfCommand>,
|
pub bf_commands: Vec<BfCommand>,
|
||||||
brackets: Vec<BfCommand>,
|
brackets: Vec<BfCommand>,
|
||||||
pub features: Vec<arguments::Feature>,
|
pub features: Vec<arguments::Feature>,
|
||||||
term: console::Term,
|
pub term: console::Term,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Interpreter {
|
impl Interpreter {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
array_size: usize,
|
array_size: usize,
|
||||||
features: Vec<arguments::Feature>,
|
features: Vec<arguments::Feature>,
|
||||||
term: &console::Term,
|
term: console::Term,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
cells: vec![Cell::default_cell(&features); array_size],
|
cells: vec![Cell::default_cell(&features); array_size],
|
||||||
|
@ -25,7 +25,7 @@ impl Interpreter {
|
||||||
bf_commands: vec![],
|
bf_commands: vec![],
|
||||||
brackets: Vec::new(),
|
brackets: Vec::new(),
|
||||||
features,
|
features,
|
||||||
term: term.clone(),
|
term,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,11 +126,7 @@ impl Interpreter {
|
||||||
trace!("Input value");
|
trace!("Input value");
|
||||||
match self.term.read_char() {
|
match self.term.read_char() {
|
||||||
Ok(ch) => {
|
Ok(ch) => {
|
||||||
if self.features.contains(&arguments::Feature::AllowUtf8) {
|
|
||||||
self.cells[self.pointer].set_value_utf8(ch);
|
|
||||||
} else {
|
|
||||||
self.cells[self.pointer].set_value(ch);
|
self.cells[self.pointer].set_value(ch);
|
||||||
}
|
|
||||||
print!("{}", ch);
|
print!("{}", ch);
|
||||||
match std::io::stdout().flush() {
|
match std::io::stdout().flush() {
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
|
@ -211,14 +207,14 @@ impl BfCommand {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use console::Term;
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::utils;
|
use crate::utils;
|
||||||
use pretty_assertions::assert_eq; // for testing only
|
use pretty_assertions::assert_eq; // for testing only
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn print_h_combine_repl() {
|
fn print_h_combine_repl() {
|
||||||
let mut interpreter = Interpreter::new(30000, vec![],
|
let mut interpreter = Interpreter::new(30000, vec![], Term::stdout());
|
||||||
&console::Term::stdout());
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
interpreter.run(String::from(">+++++++++[<++++ ++++>-]<.")),
|
interpreter.run(String::from(">+++++++++[<++++ ++++>-]<.")),
|
||||||
|
@ -231,7 +227,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn print_h_repl() {
|
fn print_h_repl() {
|
||||||
let mut interpreter = Interpreter::new(30000, vec![],
|
let mut interpreter = Interpreter::new(30000, vec![],
|
||||||
&console::Term::stdout());
|
Term::stdout());
|
||||||
|
|
||||||
assert_eq!(interpreter.run(String::from(">+++++++++")), Ok(0));
|
assert_eq!(interpreter.run(String::from(">+++++++++")), Ok(0));
|
||||||
assert_eq!(interpreter.run(String::from("[<++++ ++++>-]<.")), Ok(0));
|
assert_eq!(interpreter.run(String::from("[<++++ ++++>-]<.")), Ok(0));
|
||||||
|
@ -242,7 +238,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn nested_loop_level_1_combine() {
|
fn nested_loop_level_1_combine() {
|
||||||
let mut interpreter = Interpreter::new(5, vec![],
|
let mut interpreter = Interpreter::new(5, vec![],
|
||||||
&console::Term::stdout());
|
Term::stdout());
|
||||||
|
|
||||||
assert_eq!(interpreter.run(String::from("++[>++[>+<-]<-]")), Ok(0));
|
assert_eq!(interpreter.run(String::from("++[>++[>+<-]<-]")), Ok(0));
|
||||||
assert_eq!(interpreter.cells[2], Cell::new(4, &vec![]));
|
assert_eq!(interpreter.cells[2], Cell::new(4, &vec![]));
|
||||||
|
@ -253,7 +249,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_hello_world_from_file() {
|
fn execute_hello_world_from_file() {
|
||||||
let mut interpreter = Interpreter::new(30000, vec![],
|
let mut interpreter = Interpreter::new(30000, vec![],
|
||||||
&console::Term::stdout());
|
Term::stdout());
|
||||||
|
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
|
@ -268,7 +264,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_print_hi_from_file() {
|
fn execute_print_hi_from_file() {
|
||||||
let mut interpreter = Interpreter::new(30000, vec![],
|
let mut interpreter = Interpreter::new(30000, vec![],
|
||||||
&console::Term::stdout());
|
Term::stdout());
|
||||||
|
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
|
@ -283,7 +279,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_print_hi_yooo_from_file() {
|
fn execute_print_hi_yooo_from_file() {
|
||||||
let mut interpreter = Interpreter::new(30000, vec![],
|
let mut interpreter = Interpreter::new(30000, vec![],
|
||||||
&console::Term::stdout());
|
Term::stdout());
|
||||||
|
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
|
@ -298,7 +294,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_print_my_first_name_from_formatted_file() {
|
fn execute_print_my_first_name_from_formatted_file() {
|
||||||
let mut interpreter = Interpreter::new(30000, vec![],
|
let mut interpreter = Interpreter::new(30000, vec![],
|
||||||
&console::Term::stdout());
|
Term::stdout());
|
||||||
|
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
|
@ -313,7 +309,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_print_my_first_name_from_file() {
|
fn execute_print_my_first_name_from_file() {
|
||||||
let mut interpreter = Interpreter::new(30000, vec![],
|
let mut interpreter = Interpreter::new(30000, vec![],
|
||||||
&console::Term::stdout());
|
Term::stdout());
|
||||||
|
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
|
@ -336,7 +332,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_print_my_first_name_and_last_name_from_formatted_file() {
|
fn execute_print_my_first_name_and_last_name_from_formatted_file() {
|
||||||
let mut interpreter = Interpreter::new(30000, vec![],
|
let mut interpreter = Interpreter::new(30000, vec![],
|
||||||
&console::Term::stdout());
|
Term::stdout());
|
||||||
|
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
|
@ -351,7 +347,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_print_my_first_name_and_last_name_from_file() {
|
fn execute_print_my_first_name_and_last_name_from_file() {
|
||||||
let mut interpreter = Interpreter::new(30000, vec![],
|
let mut interpreter = Interpreter::new(30000, vec![],
|
||||||
&console::Term::stdout());
|
Term::stdout());
|
||||||
|
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
|
@ -366,7 +362,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn reset() {
|
fn reset() {
|
||||||
let mut interpreter = Interpreter::new(30000, vec![],
|
let mut interpreter = Interpreter::new(30000, vec![],
|
||||||
&console::Term::stdout());
|
Term::stdout());
|
||||||
|
|
||||||
assert_eq!(interpreter.run(String::from(">++++")), Ok(0));
|
assert_eq!(interpreter.run(String::from(">++++")), Ok(0));
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ fn main() {
|
||||||
let mut interpreter =
|
let mut interpreter =
|
||||||
Interpreter::new(args.array_size,
|
Interpreter::new(args.array_size,
|
||||||
args.features.unwrap_or_else(|| vec![]),
|
args.features.unwrap_or_else(|| vec![]),
|
||||||
&term);
|
term);
|
||||||
|
|
||||||
match args.source {
|
match args.source {
|
||||||
Some(source) => {
|
Some(source) => {
|
||||||
|
@ -60,6 +60,6 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => repl::start(interpreter, term),
|
None => repl::start(interpreter),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
40
src/repl.rs
40
src/repl.rs
|
@ -5,7 +5,7 @@ use console::{Term, Key};
|
||||||
|
|
||||||
struct Repl {
|
struct Repl {
|
||||||
pub interpreter: Interpreter,
|
pub interpreter: Interpreter,
|
||||||
term: console::Term,
|
term: Term,
|
||||||
history: Vec<String>,
|
history: Vec<String>,
|
||||||
loop_body: String,
|
loop_body: String,
|
||||||
loop_depth: usize,
|
loop_depth: usize,
|
||||||
|
@ -16,10 +16,10 @@ const HISTORY_FILE: &str = "bf-interpreter-history.bfr";
|
||||||
const COMMAND_PREFIX: &str = "!";
|
const COMMAND_PREFIX: &str = "!";
|
||||||
|
|
||||||
impl Repl {
|
impl Repl {
|
||||||
pub fn new(interpreter: Interpreter, term: Term) -> Repl {
|
pub fn new(interpreter: Interpreter) -> Repl {
|
||||||
Repl {
|
Repl {
|
||||||
|
term: interpreter.term.clone(),
|
||||||
interpreter,
|
interpreter,
|
||||||
term,
|
|
||||||
history: Vec::new(),
|
history: Vec::new(),
|
||||||
loop_body: String::new(),
|
loop_body: String::new(),
|
||||||
loop_depth: 0,
|
loop_depth: 0,
|
||||||
|
@ -299,7 +299,7 @@ impl Repl {
|
||||||
/// Run the REPL
|
/// Run the REPL
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
/// * `interpreter` - The interpreter to use
|
/// * `interpreter` - The interpreter to use
|
||||||
pub fn start(interpreter: Interpreter, term: Term) {
|
pub fn start(interpreter: Interpreter) {
|
||||||
info!("Entering REPL mode");
|
info!("Entering REPL mode");
|
||||||
println!(
|
println!(
|
||||||
"{}\n\
|
"{}\n\
|
||||||
|
@ -317,7 +317,7 @@ pub fn start(interpreter: Interpreter, term: Term) {
|
||||||
(COMMAND_PREFIX.to_string() + "help").bold().green(),
|
(COMMAND_PREFIX.to_string() + "help").bold().green(),
|
||||||
);
|
);
|
||||||
|
|
||||||
match Repl::new(interpreter, term).run() {
|
match Repl::new(interpreter).run() {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
info!("Successfully ran REPL");
|
info!("Successfully ran REPL");
|
||||||
}
|
}
|
||||||
|
@ -336,10 +336,10 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn nested_loop_level_1() {
|
fn nested_loop_level_1() {
|
||||||
let mut term = Term::stdout();
|
let term = Term::stdout();
|
||||||
let interpreter = Interpreter::new(4, vec![], &mut term);
|
let interpreter = Interpreter::new(4, vec![], term);
|
||||||
|
|
||||||
let mut repl = Repl::new(interpreter, term);
|
let mut repl = Repl::new(interpreter);
|
||||||
|
|
||||||
repl.process("++".to_string());
|
repl.process("++".to_string());
|
||||||
repl.process("[>++".to_string());
|
repl.process("[>++".to_string());
|
||||||
|
@ -355,10 +355,10 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn nested_loop_level_2() {
|
fn nested_loop_level_2() {
|
||||||
let mut term = console::Term::stdout();
|
let term = Term::stdout();
|
||||||
let interpreter = Interpreter::new(4, vec![], &mut term);
|
let interpreter = Interpreter::new(4, vec![], term);
|
||||||
|
|
||||||
let mut repl = Repl::new(interpreter, term);
|
let mut repl = Repl::new(interpreter);
|
||||||
|
|
||||||
repl.process("++".to_string());
|
repl.process("++".to_string());
|
||||||
repl.process("[>++".to_string());
|
repl.process("[>++".to_string());
|
||||||
|
@ -377,10 +377,10 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn print_my_first_name() {
|
fn print_my_first_name() {
|
||||||
let mut term = console::Term::stdout();
|
let term = Term::stdout();
|
||||||
let interpreter = Interpreter::new(10, vec![], &mut term);
|
let interpreter = Interpreter::new(10, vec![], term);
|
||||||
|
|
||||||
let mut repl = Repl::new(interpreter, term);
|
let mut repl = Repl::new(interpreter);
|
||||||
|
|
||||||
let code = "++++ ++++ 8
|
let code = "++++ ++++ 8
|
||||||
[
|
[
|
||||||
|
@ -449,10 +449,10 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn print_my_first_name_in_one_command() {
|
fn print_my_first_name_in_one_command() {
|
||||||
let mut term = Term::stdout();
|
let term = Term::stdout();
|
||||||
let interpreter = Interpreter::new(10, vec![], &mut term);
|
let interpreter = Interpreter::new(10, vec![], term);
|
||||||
|
|
||||||
let mut repl = Repl::new(interpreter, term);
|
let mut repl = Repl::new(interpreter);
|
||||||
|
|
||||||
let code = "++++++++[>++++[>++>+++>++++>+<<<<-]>>>>>>++[<<<->>>-]<<<<<<<-]>>+.\
|
let code = "++++++++[>++++[>++>+++>++++>+<<<<-]>>>>>>++[<<<->>>-]<<<<<<<-]>>+.\
|
||||||
<<++++[>+++[>+++<-]>++<<-]>>+.<<+++[>+++[>-<-]>-<<-]>>-.<<++++++[>>+++<<-]>>."
|
<<++++[>+++[>+++<-]>++<<-]>>+.<<+++[>+++[>-<-]>-<<-]>>-.<<++++++[>>+++<<-]>>."
|
||||||
|
@ -470,10 +470,10 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn print_hello_world() {
|
fn print_hello_world() {
|
||||||
let mut term = console::Term::stdout();
|
let term = Term::stdout();
|
||||||
let interpreter = Interpreter::new(10, vec![], &mut term);
|
let interpreter = Interpreter::new(10, vec![], term);
|
||||||
|
|
||||||
let mut repl = Repl::new(interpreter, term);
|
let mut repl = Repl::new(interpreter);
|
||||||
|
|
||||||
let _ = "[ This program prints \"Hello World!\" and a newline to the screen, its
|
let _ = "[ This program prints \"Hello World!\" and a newline to the screen, its
|
||||||
length is 106 active command characters. [It is not the shortest.]
|
length is 106 active command characters. [It is not the shortest.]
|
||||||
|
|
Loading…
Reference in a new issue