Update and fix a few tests
This commit is contained in:
parent
302935ff2a
commit
d316874c87
4 changed files with 8 additions and 8 deletions
|
@ -687,7 +687,7 @@ mod tests {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
node: ast::ExprKind::Path(None, ast::Path {
|
node: ast::ExprKind::Path(None, ast::Path {
|
||||||
span: sp(0, 6),
|
span: sp(0, 6),
|
||||||
segments: vec![ast::PathSegment::crate_root(),
|
segments: vec![ast::PathSegment::crate_root(sp(0, 2)),
|
||||||
str2seg("a", 2, 3),
|
str2seg("a", 2, 3),
|
||||||
str2seg("b", 5, 6)]
|
str2seg("b", 5, 6)]
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -20,7 +20,7 @@ use std::iter::Peekable;
|
||||||
/// Map a string to tts, using a made-up filename:
|
/// Map a string to tts, using a made-up filename:
|
||||||
pub fn string_to_stream(source_str: String) -> TokenStream {
|
pub fn string_to_stream(source_str: String) -> TokenStream {
|
||||||
let ps = ParseSess::new(FilePathMapping::empty());
|
let ps = ParseSess::new(FilePathMapping::empty());
|
||||||
filemap_to_stream(&ps, ps.codemap().new_filemap("bogofile".to_string(), source_str))
|
filemap_to_stream(&ps, ps.codemap().new_filemap("bogofile".to_string(), source_str), None)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Map string to parser (via tts)
|
/// Map string to parser (via tts)
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
// no-prefer-dynamic
|
// no-prefer-dynamic
|
||||||
|
|
||||||
#![crate_type = "proc-macro"]
|
#![crate_type = "proc-macro"]
|
||||||
#![feature(proc_macro, proc_macro_lib)]
|
#![feature(proc_macro)]
|
||||||
|
|
||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ pub fn cond(input: TokenStream) -> TokenStream {
|
||||||
let mut input = input.into_iter().peekable();
|
let mut input = input.into_iter().peekable();
|
||||||
while let Some(tree) = input.next() {
|
while let Some(tree) = input.next() {
|
||||||
let cond = match tree.kind {
|
let cond = match tree.kind {
|
||||||
TokenNode::Sequence(_, cond) => cond,
|
TokenNode::Group(_, cond) => cond,
|
||||||
_ => panic!("Invalid input"),
|
_ => panic!("Invalid input"),
|
||||||
};
|
};
|
||||||
let mut cond_trees = cond.clone().into_iter();
|
let mut cond_trees = cond.clone().into_iter();
|
||||||
|
@ -33,7 +33,7 @@ pub fn cond(input: TokenStream) -> TokenStream {
|
||||||
panic!("Invalid macro usage in cond: {}", cond);
|
panic!("Invalid macro usage in cond: {}", cond);
|
||||||
}
|
}
|
||||||
let is_else = match test.kind {
|
let is_else = match test.kind {
|
||||||
TokenNode::Word(word) => word.as_str() == "else",
|
TokenNode::Term(word) => word.as_str() == "else",
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
conds.push(if is_else || input.peek().is_none() {
|
conds.push(if is_else || input.peek().is_none() {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
|
|
||||||
use proc_macro::{TokenStream, TokenNode, OpKind, Literal, quote};
|
use proc_macro::{TokenStream, TokenNode, Spacing, Literal, quote};
|
||||||
|
|
||||||
#[proc_macro]
|
#[proc_macro]
|
||||||
pub fn count_compound_ops(input: TokenStream) -> TokenStream {
|
pub fn count_compound_ops(input: TokenStream) -> TokenStream {
|
||||||
|
@ -27,8 +27,8 @@ fn count_compound_ops_helper(input: TokenStream) -> u32 {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
for token in input {
|
for token in input {
|
||||||
match token.kind {
|
match token.kind {
|
||||||
TokenNode::Op(c, OpKind::Alone) => count += 1,
|
TokenNode::Op(c, Spacing::Alone) => count += 1,
|
||||||
TokenNode::Sequence(_, tokens) => count += count_compound_ops_helper(tokens),
|
TokenNode::Group(_, tokens) => count += count_compound_ops_helper(tokens),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue