Minor test refactoring

This commit is contained in:
greg 2018-11-05 19:17:53 -08:00
parent 5953d9d815
commit 9813609ad7

View File

@ -1090,7 +1090,6 @@ fn parse_hex(digits: String) -> ParseResult<u64> {
#[cfg(test)]
mod parse_tests {
use ::std::rc::Rc;
use super::tokenize;
use super::ParseResult;
use builtin::{PrefixOp, BinOp};
use ast::{AST, Expression, Statement, IfExpressionBody, Discriminator, Pattern, PatternLiteral, TypeBody, Enumerator, ForBody};
@ -1103,7 +1102,9 @@ mod parse_tests {
use super::Variant::*;
use super::ForBody::*;
fn parse(tokens: Vec<::tokenizing::Token>) -> ParseResult<AST> {
fn parse(input: &str) -> ParseResult<AST> {
use super::tokenize;
let tokens: Vec<::tokenizing::Token> = tokenize(input);
let mut parser = super::Parser::new(tokens);
parser.parse()
}
@ -1112,10 +1113,10 @@ mod parse_tests {
($string:tt) => { Rc::new(stringify!($string).to_string()) }
}
macro_rules! parse_test {
($string:expr, $correct:expr) => { assert_eq!(parse(tokenize($string)).unwrap(), $correct) }
($string:expr, $correct:expr) => { assert_eq!(parse($string).unwrap(), $correct) }
}
macro_rules! parse_error {
($string:expr) => { assert!(parse(tokenize($string)).is_err()) }
($string:expr) => { assert!(parse($string).is_err()) }
}
macro_rules! val {
($var:expr) => { Value(Rc::new($var.to_string())) }