mirror of
https://github.com/Noratrieb/brainfuck.git
synced 2026-01-14 13:35:00 +01:00
fixed underscore
This commit is contained in:
parent
0d29e477ce
commit
2ae00160fc
3 changed files with 10 additions and 3 deletions
|
|
@ -47,9 +47,16 @@ fn parse(chars: Vec<char>) -> Vec<Statement> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::interpreter::parse;
|
use crate::interpreter::{parse, minify};
|
||||||
use crate::interpreter::Statement::{Dec, In, Inc, L, Loop, Out, R};
|
use crate::interpreter::Statement::{Dec, In, Inc, L, Loop, Out, R};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn minify_test() {
|
||||||
|
let program = "sdahf+saga-46<sgbv>a[r]r.hr,e";
|
||||||
|
let expected = "+-<>[].,";
|
||||||
|
assert_eq!(String::from(expected), minify(program));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_no_loop() {
|
fn parse_no_loop() {
|
||||||
let program = "+-<>,.";
|
let program = "+-<>,.";
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
use crate::interpreter::{MEM_SIZE, minify};
|
use crate::interpreter::{MEM_SIZE, minify};
|
||||||
use std::io::{stdin, Read};
|
use std::io::{stdin, Read};
|
||||||
|
|
||||||
pub fn _run(program: &str) -> String{
|
pub fn run(program: &str) -> String{
|
||||||
let program = minify(program);
|
let program = minify(program);
|
||||||
let out = interpret(program.chars().collect());
|
let out = interpret(program.chars().collect());
|
||||||
out
|
out
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use std::io::{Read, stdin};
|
||||||
|
|
||||||
use crate::interpreter::{MEM_SIZE, Memory, minify, parse, Statement};
|
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 = minify(pgm);
|
||||||
let pgm = parse(pgm.chars().collect());
|
let pgm = parse(pgm.chars().collect());
|
||||||
let out = interpret(&pgm);
|
let out = interpret(&pgm);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue