Minor test refactoring
This commit is contained in:
parent
5953d9d815
commit
9813609ad7
@ -1090,7 +1090,6 @@ fn parse_hex(digits: String) -> ParseResult<u64> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod parse_tests {
|
mod parse_tests {
|
||||||
use ::std::rc::Rc;
|
use ::std::rc::Rc;
|
||||||
use super::tokenize;
|
|
||||||
use super::ParseResult;
|
use super::ParseResult;
|
||||||
use builtin::{PrefixOp, BinOp};
|
use builtin::{PrefixOp, BinOp};
|
||||||
use ast::{AST, Expression, Statement, IfExpressionBody, Discriminator, Pattern, PatternLiteral, TypeBody, Enumerator, ForBody};
|
use ast::{AST, Expression, Statement, IfExpressionBody, Discriminator, Pattern, PatternLiteral, TypeBody, Enumerator, ForBody};
|
||||||
@ -1103,7 +1102,9 @@ mod parse_tests {
|
|||||||
use super::Variant::*;
|
use super::Variant::*;
|
||||||
use super::ForBody::*;
|
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);
|
let mut parser = super::Parser::new(tokens);
|
||||||
parser.parse()
|
parser.parse()
|
||||||
}
|
}
|
||||||
@ -1112,10 +1113,10 @@ mod parse_tests {
|
|||||||
($string:tt) => { Rc::new(stringify!($string).to_string()) }
|
($string:tt) => { Rc::new(stringify!($string).to_string()) }
|
||||||
}
|
}
|
||||||
macro_rules! parse_test {
|
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 {
|
macro_rules! parse_error {
|
||||||
($string:expr) => { assert!(parse(tokenize($string)).is_err()) }
|
($string:expr) => { assert!(parse($string).is_err()) }
|
||||||
}
|
}
|
||||||
macro_rules! val {
|
macro_rules! val {
|
||||||
($var:expr) => { Value(Rc::new($var.to_string())) }
|
($var:expr) => { Value(Rc::new($var.to_string())) }
|
||||||
|
Loading…
Reference in New Issue
Block a user