Skip to content

Commit

Permalink
redo tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ncharlton02 committed Sep 1, 2018
1 parent 59b978f commit d23d4b2
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/test/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@

use super::{Token, scanner};
use std::fs;
use std::io::prelude::*;
use std::fs::File;

#[test]
fn scan_tests(){
verify_token_count(4, "print(\"Hello World!\"");
verify_token_count(17, "name = John\nage = 5\nprint(name)\nprint(age)")
}
fn test(){
let paths = fs::read_dir("assets").unwrap();

for path in paths {
let path = path.unwrap().path();

fn verify_token_count(num: usize, src: &str){
let tokens = scanner::scan(src.to_string());
println!("Testing file: {}", path.display());

super::run(load_file(path.display().to_string()));
}
}

assert_eq!(num, tokens.len());
fn load_file(path: String) -> String{
let mut file = File::open(&path).expect(&format!("Unable to open lua source file: {}", path));
let mut contents = String::new();
file.read_to_string(&mut contents).expect("Unable to read the file");

contents
}

0 comments on commit d23d4b2

Please sign in to comment.