Skip to content

Commit

Permalink
added test case for tokenization of macro_rules
Browse files Browse the repository at this point in the history
  • Loading branch information
jbclements committed Sep 24, 2013
1 parent 0322832 commit 0269850
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/libsyntax/parse/mod.rs
Expand Up @@ -388,6 +388,51 @@ mod test {
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 () {
let tts = string_to_tts(@"fn a (b : int) { b; }");
assert_eq!(to_json_str(@tts),
Expand Down

5 comments on commit 0269850

@bors
Copy link
Contributor

@bors bors commented on 0269850 Sep 25, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from cmr
at jbclements@0269850

@bors
Copy link
Contributor

@bors bors commented on 0269850 Sep 25, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging jbclements/rust/minor-cleanup = 0269850 into auto

@bors
Copy link
Contributor

@bors bors commented on 0269850 Sep 25, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jbclements/rust/minor-cleanup = 0269850 merged ok, testing candidate = f6c9ff3

@bors
Copy link
Contributor

@bors bors commented on 0269850 Sep 25, 2013

@bors
Copy link
Contributor

@bors bors commented on 0269850 Sep 25, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = f6c9ff3

Please sign in to comment.