}
#[test]
-fn tries_all_branches_matching_token_literally() {
+fn tries_all_branches_matching_first_token_literally() {
check(
r#"
macro_rules! m {
fn bar() {}
struct Baz;
"#]],
- )
+ );
+}
+
+#[test]
+fn tries_all_branches_matching_last_token_literally() {
+ check(
+ r#"
+macro_rules! m {
+ ($ i:ident) => ( mod $ i {} );
+ ($ i:ident =) => ( fn $ i() {} );
+ ($ i:ident +) => ( struct $ i; )
+}
+m! { foo }
+m! { bar = }
+m! { Baz + }
+"#,
+ expect![[r#"
+macro_rules! m {
+ ($ i:ident) => ( mod $ i {} );
+ ($ i:ident =) => ( fn $ i() {} );
+ ($ i:ident +) => ( struct $ i; )
+}
+mod foo {}
+fn bar() {}
+struct Baz;
+"#]],
+ );
}
);
}
-#[test]
-fn test_fail_match_pattern_by_last_token() {
- parse_macro(
- r#"
- macro_rules! foo {
- ($ i:ident) => (
- mod $ i {}
- );
- ($ i:ident =) => (
- fn $ i() {}
- );
- ($ i:ident +) => (
- struct $ i;
- )
- }
-"#,
- )
- .assert_expand_items("foo! { foo }", "mod foo {}")
- .assert_expand_items("foo! { bar = }", "fn bar () {}")
- .assert_expand_items("foo! { Baz + }", "struct Baz ;");
-}
-
#[test]
fn test_fail_match_pattern_by_word_token() {
parse_macro(