aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_mbe/src/tests.rs')
-rw-r--r--crates/ra_mbe/src/tests.rs408
1 files changed, 204 insertions, 204 deletions
diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs
index 76f571502..7ceec7752 100644
--- a/crates/ra_mbe/src/tests.rs
+++ b/crates/ra_mbe/src/tests.rs
@@ -257,30 +257,30 @@ fn test_expr_order() {
257 let dump = format!("{:#?}", expanded); 257 let dump = format!("{:#?}", expanded);
258 assert_eq_text!( 258 assert_eq_text!(
259 dump.trim(), 259 dump.trim(),
260 r#"MACRO_ITEMS@[0; 15) 260 r#"MACRO_ITEMS@0..15
261 FN_DEF@[0; 15) 261 FN_DEF@0..15
262 FN_KW@[0; 2) "fn" 262 FN_KW@0..2 "fn"
263 NAME@[2; 5) 263 NAME@2..5
264 IDENT@[2; 5) "bar" 264 IDENT@2..5 "bar"
265 PARAM_LIST@[5; 7) 265 PARAM_LIST@5..7
266 L_PAREN@[5; 6) "(" 266 L_PAREN@5..6 "("
267 R_PAREN@[6; 7) ")" 267 R_PAREN@6..7 ")"
268 BLOCK_EXPR@[7; 15) 268 BLOCK_EXPR@7..15
269 BLOCK@[7; 15) 269 BLOCK@7..15
270 L_CURLY@[7; 8) "{" 270 L_CURLY@7..8 "{"
271 EXPR_STMT@[8; 14) 271 EXPR_STMT@8..14
272 BIN_EXPR@[8; 13) 272 BIN_EXPR@8..13
273 BIN_EXPR@[8; 11) 273 BIN_EXPR@8..11
274 LITERAL@[8; 9) 274 LITERAL@8..9
275 INT_NUMBER@[8; 9) "1" 275 INT_NUMBER@8..9 "1"
276 PLUS@[9; 10) "+" 276 PLUS@9..10 "+"
277 LITERAL@[10; 11) 277 LITERAL@10..11
278 INT_NUMBER@[10; 11) "1" 278 INT_NUMBER@10..11 "1"
279 STAR@[11; 12) "*" 279 STAR@11..12 "*"
280 LITERAL@[12; 13) 280 LITERAL@12..13
281 INT_NUMBER@[12; 13) "2" 281 INT_NUMBER@12..13 "2"
282 SEMICOLON@[13; 14) ";" 282 SEMICOLON@13..14 ";"
283 R_CURLY@[14; 15) "}""#, 283 R_CURLY@14..15 "}""#,
284 ); 284 );
285} 285}
286 286
@@ -490,39 +490,39 @@ fn test_expand_to_item_list() {
490 assert_eq!( 490 assert_eq!(
491 format!("{:#?}", tree).trim(), 491 format!("{:#?}", tree).trim(),
492 r#" 492 r#"
493MACRO_ITEMS@[0; 40) 493MACRO_ITEMS@0..40
494 STRUCT_DEF@[0; 20) 494 STRUCT_DEF@0..20
495 STRUCT_KW@[0; 6) "struct" 495 STRUCT_KW@0..6 "struct"
496 NAME@[6; 9) 496 NAME@6..9
497 IDENT@[6; 9) "Foo" 497 IDENT@6..9 "Foo"
498 RECORD_FIELD_DEF_LIST@[9; 20) 498 RECORD_FIELD_DEF_LIST@9..20
499 L_CURLY@[9; 10) "{" 499 L_CURLY@9..10 "{"
500 RECORD_FIELD_DEF@[10; 19) 500 RECORD_FIELD_DEF@10..19
501 NAME@[10; 15) 501 NAME@10..15
502 IDENT@[10; 15) "field" 502 IDENT@10..15 "field"
503 COLON@[15; 16) ":" 503 COLON@15..16 ":"
504 PATH_TYPE@[16; 19) 504 PATH_TYPE@16..19
505 PATH@[16; 19) 505 PATH@16..19
506 PATH_SEGMENT@[16; 19) 506 PATH_SEGMENT@16..19
507 NAME_REF@[16; 19) 507 NAME_REF@16..19
508 IDENT@[16; 19) "u32" 508 IDENT@16..19 "u32"
509 R_CURLY@[19; 20) "}" 509 R_CURLY@19..20 "}"
510 STRUCT_DEF@[20; 40) 510 STRUCT_DEF@20..40
511 STRUCT_KW@[20; 26) "struct" 511 STRUCT_KW@20..26 "struct"
512 NAME@[26; 29) 512 NAME@26..29
513 IDENT@[26; 29) "Bar" 513 IDENT@26..29 "Bar"
514 RECORD_FIELD_DEF_LIST@[29; 40) 514 RECORD_FIELD_DEF_LIST@29..40
515 L_CURLY@[29; 30) "{" 515 L_CURLY@29..30 "{"
516 RECORD_FIELD_DEF@[30; 39) 516 RECORD_FIELD_DEF@30..39
517 NAME@[30; 35) 517 NAME@30..35
518 IDENT@[30; 35) "field" 518 IDENT@30..35 "field"
519 COLON@[35; 36) ":" 519 COLON@35..36 ":"
520 PATH_TYPE@[36; 39) 520 PATH_TYPE@36..39
521 PATH@[36; 39) 521 PATH@36..39
522 PATH_SEGMENT@[36; 39) 522 PATH_SEGMENT@36..39
523 NAME_REF@[36; 39) 523 NAME_REF@36..39
524 IDENT@[36; 39) "u32" 524 IDENT@36..39 "u32"
525 R_CURLY@[39; 40) "}""# 525 R_CURLY@39..40 "}""#
526 .trim() 526 .trim()
527 ); 527 );
528} 528}
@@ -623,37 +623,37 @@ fn test_tt_to_stmts() {
623 623
624 assert_eq!( 624 assert_eq!(
625 format!("{:#?}", stmts).trim(), 625 format!("{:#?}", stmts).trim(),
626 r#"MACRO_STMTS@[0; 15) 626 r#"MACRO_STMTS@0..15
627 LET_STMT@[0; 7) 627 LET_STMT@0..7
628 LET_KW@[0; 3) "let" 628 LET_KW@0..3 "let"
629 BIND_PAT@[3; 4) 629 BIND_PAT@3..4
630 NAME@[3; 4) 630 NAME@3..4
631 IDENT@[3; 4) "a" 631 IDENT@3..4 "a"
632 EQ@[4; 5) "=" 632 EQ@4..5 "="
633 LITERAL@[5; 6) 633 LITERAL@5..6
634 INT_NUMBER@[5; 6) "0" 634 INT_NUMBER@5..6 "0"
635 SEMICOLON@[6; 7) ";" 635 SEMICOLON@6..7 ";"
636 EXPR_STMT@[7; 14) 636 EXPR_STMT@7..14
637 BIN_EXPR@[7; 13) 637 BIN_EXPR@7..13
638 PATH_EXPR@[7; 8) 638 PATH_EXPR@7..8
639 PATH@[7; 8) 639 PATH@7..8
640 PATH_SEGMENT@[7; 8) 640 PATH_SEGMENT@7..8
641 NAME_REF@[7; 8) 641 NAME_REF@7..8
642 IDENT@[7; 8) "a" 642 IDENT@7..8 "a"
643 EQ@[8; 9) "=" 643 EQ@8..9 "="
644 BIN_EXPR@[9; 13) 644 BIN_EXPR@9..13
645 LITERAL@[9; 11) 645 LITERAL@9..11
646 INT_NUMBER@[9; 11) "10" 646 INT_NUMBER@9..11 "10"
647 PLUS@[11; 12) "+" 647 PLUS@11..12 "+"
648 LITERAL@[12; 13) 648 LITERAL@12..13
649 INT_NUMBER@[12; 13) "1" 649 INT_NUMBER@12..13 "1"
650 SEMICOLON@[13; 14) ";" 650 SEMICOLON@13..14 ";"
651 EXPR_STMT@[14; 15) 651 EXPR_STMT@14..15
652 PATH_EXPR@[14; 15) 652 PATH_EXPR@14..15
653 PATH@[14; 15) 653 PATH@14..15
654 PATH_SEGMENT@[14; 15) 654 PATH_SEGMENT@14..15
655 NAME_REF@[14; 15) 655 NAME_REF@14..15
656 IDENT@[14; 15) "a""#, 656 IDENT@14..15 "a""#,
657 ); 657 );
658} 658}
659 659
@@ -974,20 +974,20 @@ fn test_tt_composite2() {
974 let res = format!("{:#?}", &node); 974 let res = format!("{:#?}", &node);
975 assert_eq_text!( 975 assert_eq_text!(
976 res.trim(), 976 res.trim(),
977 r###"MACRO_ITEMS@[0; 10) 977 r###"MACRO_ITEMS@0..10
978 MACRO_CALL@[0; 10) 978 MACRO_CALL@0..10
979 PATH@[0; 3) 979 PATH@0..3
980 PATH_SEGMENT@[0; 3) 980 PATH_SEGMENT@0..3
981 NAME_REF@[0; 3) 981 NAME_REF@0..3
982 IDENT@[0; 3) "abs" 982 IDENT@0..3 "abs"
983 BANG@[3; 4) "!" 983 BANG@3..4 "!"
984 TOKEN_TREE@[4; 10) 984 TOKEN_TREE@4..10
985 L_PAREN@[4; 5) "(" 985 L_PAREN@4..5 "("
986 EQ@[5; 6) "=" 986 EQ@5..6 "="
987 R_ANGLE@[6; 7) ">" 987 R_ANGLE@6..7 ">"
988 WHITESPACE@[7; 8) " " 988 WHITESPACE@7..8 " "
989 POUND@[8; 9) "#" 989 POUND@8..9 "#"
990 R_PAREN@[9; 10) ")""### 990 R_PAREN@9..10 ")""###
991 ); 991 );
992} 992}
993 993
@@ -1113,69 +1113,69 @@ fn test_vec() {
1113 1113
1114 assert_eq!( 1114 assert_eq!(
1115 format!("{:#?}", tree).trim(), 1115 format!("{:#?}", tree).trim(),
1116 r#"BLOCK_EXPR@[0; 45) 1116 r#"BLOCK_EXPR@0..45
1117 BLOCK@[0; 45) 1117 BLOCK@0..45
1118 L_CURLY@[0; 1) "{" 1118 L_CURLY@0..1 "{"
1119 LET_STMT@[1; 20) 1119 LET_STMT@1..20
1120 LET_KW@[1; 4) "let" 1120 LET_KW@1..4 "let"
1121 BIND_PAT@[4; 8) 1121 BIND_PAT@4..8
1122 MUT_KW@[4; 7) "mut" 1122 MUT_KW@4..7 "mut"
1123 NAME@[7; 8) 1123 NAME@7..8
1124 IDENT@[7; 8) "v" 1124 IDENT@7..8 "v"
1125 EQ@[8; 9) "=" 1125 EQ@8..9 "="
1126 CALL_EXPR@[9; 19) 1126 CALL_EXPR@9..19
1127 PATH_EXPR@[9; 17) 1127 PATH_EXPR@9..17
1128 PATH@[9; 17) 1128 PATH@9..17
1129 PATH@[9; 12) 1129 PATH@9..12
1130 PATH_SEGMENT@[9; 12) 1130 PATH_SEGMENT@9..12
1131 NAME_REF@[9; 12) 1131 NAME_REF@9..12
1132 IDENT@[9; 12) "Vec" 1132 IDENT@9..12 "Vec"
1133 COLON2@[12; 14) "::" 1133 COLON2@12..14 "::"
1134 PATH_SEGMENT@[14; 17) 1134 PATH_SEGMENT@14..17
1135 NAME_REF@[14; 17) 1135 NAME_REF@14..17
1136 IDENT@[14; 17) "new" 1136 IDENT@14..17 "new"
1137 ARG_LIST@[17; 19) 1137 ARG_LIST@17..19
1138 L_PAREN@[17; 18) "(" 1138 L_PAREN@17..18 "("
1139 R_PAREN@[18; 19) ")" 1139 R_PAREN@18..19 ")"
1140 SEMICOLON@[19; 20) ";" 1140 SEMICOLON@19..20 ";"
1141 EXPR_STMT@[20; 33) 1141 EXPR_STMT@20..33
1142 METHOD_CALL_EXPR@[20; 32) 1142 METHOD_CALL_EXPR@20..32
1143 PATH_EXPR@[20; 21) 1143 PATH_EXPR@20..21
1144 PATH@[20; 21) 1144 PATH@20..21
1145 PATH_SEGMENT@[20; 21) 1145 PATH_SEGMENT@20..21
1146 NAME_REF@[20; 21) 1146 NAME_REF@20..21
1147 IDENT@[20; 21) "v" 1147 IDENT@20..21 "v"
1148 DOT@[21; 22) "." 1148 DOT@21..22 "."
1149 NAME_REF@[22; 26) 1149 NAME_REF@22..26
1150 IDENT@[22; 26) "push" 1150 IDENT@22..26 "push"
1151 ARG_LIST@[26; 32) 1151 ARG_LIST@26..32
1152 L_PAREN@[26; 27) "(" 1152 L_PAREN@26..27 "("
1153 LITERAL@[27; 31) 1153 LITERAL@27..31
1154 INT_NUMBER@[27; 31) "1u32" 1154 INT_NUMBER@27..31 "1u32"
1155 R_PAREN@[31; 32) ")" 1155 R_PAREN@31..32 ")"
1156 SEMICOLON@[32; 33) ";" 1156 SEMICOLON@32..33 ";"
1157 EXPR_STMT@[33; 43) 1157 EXPR_STMT@33..43
1158 METHOD_CALL_EXPR@[33; 42) 1158 METHOD_CALL_EXPR@33..42
1159 PATH_EXPR@[33; 34) 1159 PATH_EXPR@33..34
1160 PATH@[33; 34) 1160 PATH@33..34
1161 PATH_SEGMENT@[33; 34) 1161 PATH_SEGMENT@33..34
1162 NAME_REF@[33; 34) 1162 NAME_REF@33..34
1163 IDENT@[33; 34) "v" 1163 IDENT@33..34 "v"
1164 DOT@[34; 35) "." 1164 DOT@34..35 "."
1165 NAME_REF@[35; 39) 1165 NAME_REF@35..39
1166 IDENT@[35; 39) "push" 1166 IDENT@35..39 "push"
1167 ARG_LIST@[39; 42) 1167 ARG_LIST@39..42
1168 L_PAREN@[39; 40) "(" 1168 L_PAREN@39..40 "("
1169 LITERAL@[40; 41) 1169 LITERAL@40..41
1170 INT_NUMBER@[40; 41) "2" 1170 INT_NUMBER@40..41 "2"
1171 R_PAREN@[41; 42) ")" 1171 R_PAREN@41..42 ")"
1172 SEMICOLON@[42; 43) ";" 1172 SEMICOLON@42..43 ";"
1173 PATH_EXPR@[43; 44) 1173 PATH_EXPR@43..44
1174 PATH@[43; 44) 1174 PATH@43..44
1175 PATH_SEGMENT@[43; 44) 1175 PATH_SEGMENT@43..44
1176 NAME_REF@[43; 44) 1176 NAME_REF@43..44
1177 IDENT@[43; 44) "v" 1177 IDENT@43..44 "v"
1178 R_CURLY@[44; 45) "}""# 1178 R_CURLY@44..45 "}""#
1179 ); 1179 );
1180} 1180}
1181 1181
@@ -1798,45 +1798,45 @@ fn test_no_space_after_semi_colon() {
1798 let dump = format!("{:#?}", expanded); 1798 let dump = format!("{:#?}", expanded);
1799 assert_eq_text!( 1799 assert_eq_text!(
1800 dump.trim(), 1800 dump.trim(),
1801 r###"MACRO_ITEMS@[0; 52) 1801 r###"MACRO_ITEMS@0..52
1802 MODULE@[0; 26) 1802 MODULE@0..26
1803 ATTR@[0; 21) 1803 ATTR@0..21
1804 POUND@[0; 1) "#" 1804 POUND@0..1 "#"
1805 L_BRACK@[1; 2) "[" 1805 L_BRACK@1..2 "["
1806 PATH@[2; 5) 1806 PATH@2..5
1807 PATH_SEGMENT@[2; 5) 1807 PATH_SEGMENT@2..5
1808 NAME_REF@[2; 5) 1808 NAME_REF@2..5
1809 IDENT@[2; 5) "cfg" 1809 IDENT@2..5 "cfg"
1810 TOKEN_TREE@[5; 20) 1810 TOKEN_TREE@5..20
1811 L_PAREN@[5; 6) "(" 1811 L_PAREN@5..6 "("
1812 IDENT@[6; 13) "feature" 1812 IDENT@6..13 "feature"
1813 EQ@[13; 14) "=" 1813 EQ@13..14 "="
1814 STRING@[14; 19) "\"std\"" 1814 STRING@14..19 "\"std\""
1815 R_PAREN@[19; 20) ")" 1815 R_PAREN@19..20 ")"
1816 R_BRACK@[20; 21) "]" 1816 R_BRACK@20..21 "]"
1817 MOD_KW@[21; 24) "mod" 1817 MOD_KW@21..24 "mod"
1818 NAME@[24; 25) 1818 NAME@24..25
1819 IDENT@[24; 25) "m" 1819 IDENT@24..25 "m"
1820 SEMICOLON@[25; 26) ";" 1820 SEMICOLON@25..26 ";"
1821 MODULE@[26; 52) 1821 MODULE@26..52
1822 ATTR@[26; 47) 1822 ATTR@26..47
1823 POUND@[26; 27) "#" 1823 POUND@26..27 "#"
1824 L_BRACK@[27; 28) "[" 1824 L_BRACK@27..28 "["
1825 PATH@[28; 31) 1825 PATH@28..31
1826 PATH_SEGMENT@[28; 31) 1826 PATH_SEGMENT@28..31
1827 NAME_REF@[28; 31) 1827 NAME_REF@28..31
1828 IDENT@[28; 31) "cfg" 1828 IDENT@28..31 "cfg"
1829 TOKEN_TREE@[31; 46) 1829 TOKEN_TREE@31..46
1830 L_PAREN@[31; 32) "(" 1830 L_PAREN@31..32 "("
1831 IDENT@[32; 39) "feature" 1831 IDENT@32..39 "feature"
1832 EQ@[39; 40) "=" 1832 EQ@39..40 "="
1833 STRING@[40; 45) "\"std\"" 1833 STRING@40..45 "\"std\""
1834 R_PAREN@[45; 46) ")" 1834 R_PAREN@45..46 ")"
1835 R_BRACK@[46; 47) "]" 1835 R_BRACK@46..47 "]"
1836 MOD_KW@[47; 50) "mod" 1836 MOD_KW@47..50 "mod"
1837 NAME@[50; 51) 1837 NAME@50..51
1838 IDENT@[50; 51) "f" 1838 IDENT@50..51 "f"
1839 SEMICOLON@[51; 52) ";""###, 1839 SEMICOLON@51..52 ";""###,
1840 ); 1840 );
1841} 1841}
1842 1842