added test case for tokenization of macro_rules
This commit is contained in:
parent
0322832763
commit
0269850cc2
1 changed files with 45 additions and 0 deletions
|
@ -388,6 +388,51 @@ mod test {
|
||||||
string_to_expr(@"::abc::def::return");
|
string_to_expr(@"::abc::def::return");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check the token-tree-ization of macros
|
||||||
|
#[test] fn string_to_tts_macro () {
|
||||||
|
let tts = string_to_tts(@"macro_rules! zip (($a)=>($a))");
|
||||||
|
match tts {
|
||||||
|
[ast::tt_tok(_,_),
|
||||||
|
ast::tt_tok(_,token::NOT),
|
||||||
|
ast::tt_tok(_,_),
|
||||||
|
ast::tt_delim(delim_elts)] =>
|
||||||
|
match *delim_elts {
|
||||||
|
[ast::tt_tok(_,token::LPAREN),
|
||||||
|
ast::tt_delim(first_set),
|
||||||
|
ast::tt_tok(_,token::FAT_ARROW),
|
||||||
|
ast::tt_delim(second_set),
|
||||||
|
ast::tt_tok(_,token::RPAREN)] =>
|
||||||
|
match *first_set {
|
||||||
|
[ast::tt_tok(_,token::LPAREN),
|
||||||
|
ast::tt_tok(_,token::DOLLAR),
|
||||||
|
ast::tt_tok(_,_),
|
||||||
|
ast::tt_tok(_,token::RPAREN)] =>
|
||||||
|
match *second_set {
|
||||||
|
[ast::tt_tok(_,token::LPAREN),
|
||||||
|
ast::tt_tok(_,token::DOLLAR),
|
||||||
|
ast::tt_tok(_,_),
|
||||||
|
ast::tt_tok(_,token::RPAREN)] =>
|
||||||
|
assert_eq!("correct","correct"),
|
||||||
|
_ => assert_eq!("wrong 4","correct")
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
|
error!("failing value 3: %?",first_set);
|
||||||
|
assert_eq!("wrong 3","correct")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
|
error!("failing value 2: %?",delim_elts);
|
||||||
|
assert_eq!("wrong","correct");
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
|
error!("failing value: %?",tts);
|
||||||
|
assert_eq!("wrong 1","correct");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test] fn string_to_tts_1 () {
|
#[test] fn string_to_tts_1 () {
|
||||||
let tts = string_to_tts(@"fn a (b : int) { b; }");
|
let tts = string_to_tts(@"fn a (b : int) { b; }");
|
||||||
assert_eq!(to_json_str(@tts),
|
assert_eq!(to_json_str(@tts),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue