aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/lib.rs
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2019-04-08 08:58:02 +0100
committerEdwin Cheng <[email protected]>2019-04-08 08:58:02 +0100
commit2697ecaa64570841f0ed2a3ca5bc02cf41dccc4a (patch)
tree4d1e37b88e7322abc247cf42915714cee91a5a7e /crates/ra_mbe/src/lib.rs
parenta7254201df07fb929ca689857d7472564d484c3e (diff)
Use SubtreeWalker instread of flatten TtToken
Diffstat (limited to 'crates/ra_mbe/src/lib.rs')
-rw-r--r--crates/ra_mbe/src/lib.rs34
1 files changed, 31 insertions, 3 deletions
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs
index 84ce2b783..a21ea4dbc 100644
--- a/crates/ra_mbe/src/lib.rs
+++ b/crates/ra_mbe/src/lib.rs
@@ -383,8 +383,22 @@ SOURCE_FILE@[0; 40)
383 assert_eq!(to_literal(&stm_tokens[15 + 3]).text, "\"rust1\""); 383 assert_eq!(to_literal(&stm_tokens[15 + 3]).text, "\"rust1\"");
384 } 384 }
385 385
386 /// The following tests are port from intellij-rust directly 386 #[test]
387 /// https://github.com/intellij-rust/intellij-rust/blob/c4e9feee4ad46e7953b1948c112533360b6087bb/src/test/kotlin/org/rust/lang/core/macros/RsMacroExpansionTest.kt 387 fn test_two_idents() {
388 let rules = create_rules(
389 r#"
390 macro_rules! foo {
391 ($ i:ident, $ j:ident) => {
392 fn foo() { let a = $ i; let b = $j; }
393 }
394 }
395"#,
396 );
397 assert_expansion(&rules, "foo! { foo, bar }", "fn foo () {let a = foo ; let b = bar ;}");
398 }
399
400 // The following tests are port from intellij-rust directly
401 // https://github.com/intellij-rust/intellij-rust/blob/c4e9feee4ad46e7953b1948c112533360b6087bb/src/test/kotlin/org/rust/lang/core/macros/RsMacroExpansionTest.kt
388 402
389 #[test] 403 #[test]
390 fn test_path() { 404 fn test_path() {
@@ -401,7 +415,21 @@ SOURCE_FILE@[0; 40)
401 assert_expansion( 415 assert_expansion(
402 &rules, 416 &rules,
403 "foo! { bar::<u8>::baz::<u8> }", 417 "foo! { bar::<u8>::baz::<u8> }",
404 "fn foo () {let a = bar :: < u8 > :: baz :: < u8 > ;}", 418 "fn foo () {let a = bar ::< u8 > ::baz ::< u8 > ;}",
419 );
420 }
421
422 #[test]
423 fn test_two_paths() {
424 let rules = create_rules(
425 r#"
426 macro_rules! foo {
427 ($ i:path, $ j:path) => {
428 fn foo() { let a = $ i; let b = $j; }
429 }
430 }
431"#,
405 ); 432 );
433 assert_expansion(&rules, "foo! { foo, bar }", "fn foo () {let a = foo ; let b = bar ;}");
406 } 434 }
407} 435}