Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/mbe/src/expander.rs')
-rw-r--r--crates/mbe/src/expander.rs61
1 files changed, 0 insertions, 61 deletions
diff --git a/crates/mbe/src/expander.rs b/crates/mbe/src/expander.rs
index 230d33e538..7244d21161 100644
--- a/crates/mbe/src/expander.rs
+++ b/crates/mbe/src/expander.rs
@@ -114,64 +114,3 @@ enum Fragment {
/// like `$i * 2` where `$i = 1 + 1` work as expectd.
Ast(tt::TokenTree),
}
-
-#[cfg(test)]
-mod tests {
- use syntax::{ast, AstNode};
-
- use super::*;
- use crate::syntax_node_to_token_tree;
-
- #[test]
- fn test_expand_rule() {
- assert_err(
- "($($i:ident);*) => ($i)",
- "foo!{a}",
- ExpandError::BindingError(String::from(
- "expected simple binding, found nested binding `i`",
- )),
- );
-
- // FIXME:
- // Add an err test case for ($($i:ident)) => ($())
- }
-
- fn assert_err(macro_body: &str, invocation: &str, err: ExpandError) {
- assert_eq!(
- expand_first(&create_rules(&format_macro(macro_body)), invocation).err,
- Some(err)
- );
- }
-
- fn format_macro(macro_body: &str) -> String {
- format!(
- "
- macro_rules! foo {{
- {}
- }}
-",
- macro_body
- )
- }
-
- fn create_rules(macro_definition: &str) -> crate::MacroRules {
- let source_file = ast::SourceFile::parse(macro_definition).ok().unwrap();
- let macro_definition =
- source_file.syntax().descendants().find_map(ast::MacroRules::cast).unwrap();
-
- let (definition_tt, _) =
- syntax_node_to_token_tree(macro_definition.token_tree().unwrap().syntax());
- crate::MacroRules::parse(&definition_tt).unwrap()
- }
-
- fn expand_first(rules: &crate::MacroRules, invocation: &str) -> ExpandResult<tt::Subtree> {
- let source_file = ast::SourceFile::parse(invocation).ok().unwrap();
- let macro_invocation =
- source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap();
-
- let (invocation_tt, _) =
- syntax_node_to_token_tree(macro_invocation.token_tree().unwrap().syntax());
-
- expand_rules(&rules.rules, &invocation_tt)
- }
-}