Skip to content

Commit

Permalink
Add test for semicolon_in_proc_parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyberboss committed Apr 7, 2020
1 parent 5f5cba0 commit 4d43874
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/dreammaker/tests/ast_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
extern crate dreammaker as dm;

use dm::*;
use dm::preprocessor::Preprocessor;
use dm::objtree::ObjectTree;

fn with_code<F: FnOnce(Context, ObjectTree)>(code: &'static str, f: F) {
let context = Context::default();
let path = std::path::PathBuf::from(r"test.dm");
let pp = Preprocessor::from_buffer(&context, path, code.trim());
let indents = indents::IndentProcessor::new(&context, pp);
let mut parser = parser::Parser::new(&context, indents);
parser.enable_procs();
let _tree = parser.parse_object_tree();

f(context, _tree)
}

#[test]
fn check_semicolon_in_proc_parameters() {
with_code("
#define SOMESHIT 0x01;
#define SUMFUCK \"asdf\" as text;
/proc/fuck(foo = SOMESHIT, bar = SUMFUCK, anotherarg = 1)
", |context, _| {
let errors = context.errors();
assert_eq!(errors.len(), 2);

for error in errors.into_iter() {
assert_eq!(error.errortype().expect("No errortype set!"), "semicolon_in_proc_parameter");
}
});
}

0 comments on commit 4d43874

Please sign in to comment.