about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2021-10-10 14:26:47 +0300
committerAleksey Kladov <aleksey.kladov@gmail.com>2021-10-10 14:26:47 +0300
commitaf76db3c3663e517a3e8e2c05bee494453bf9877 (patch)
treefb5a71369171506668aacd884c59b858867c7a78
parent6253213a6e4c9a1d0059d5ed9834e1eb2808d927 (diff)
downloadrust-af76db3c3663e517a3e8e2c05bee494453bf9877.tar.gz
rust-af76db3c3663e517a3e8e2c05bee494453bf9877.zip
move tests
-rw-r--r--crates/hir_def/src/macro_expansion_tests/mbe/regression.rs107
-rw-r--r--crates/mbe/src/tests/expand.rs66
2 files changed, 107 insertions, 66 deletions
diff --git a/crates/hir_def/src/macro_expansion_tests/mbe/regression.rs b/crates/hir_def/src/macro_expansion_tests/mbe/regression.rs
index 9762570412c..527395992b1 100644
--- a/crates/hir_def/src/macro_expansion_tests/mbe/regression.rs
+++ b/crates/hir_def/src/macro_expansion_tests/mbe/regression.rs
@@ -533,3 +533,110 @@ impl <A: Arbitrary> $crate::arbitrary::Arbitrary for Vec<A> {
 "#]],
     );
 }
+
+#[test]
+fn test_old_ridl() {
+    // This is from winapi 2.8, which do not have a link from github.
+    check(
+        r#"
+#[macro_export]
+macro_rules! RIDL {
+    (interface $interface:ident ($vtbl:ident) : $pinterface:ident ($pvtbl:ident)
+        {$(
+            fn $method:ident(&mut self $(,$p:ident : $t:ty)*) -> $rtr:ty
+        ),+}
+    ) => {
+        impl $interface {
+            $(pub unsafe fn $method(&mut self) -> $rtr {
+                ((*self.lpVtbl).$method)(self $(,$p)*)
+            })+
+        }
+    };
+}
+
+RIDL!{interface ID3D11Asynchronous(ID3D11AsynchronousVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) {
+    fn GetDataSize(&mut self) -> UINT
+}}
+"#,
+        expect![[r##"
+#[macro_export]
+macro_rules! RIDL {
+    (interface $interface:ident ($vtbl:ident) : $pinterface:ident ($pvtbl:ident)
+        {$(
+            fn $method:ident(&mut self $(,$p:ident : $t:ty)*) -> $rtr:ty
+        ),+}
+    ) => {
+        impl $interface {
+            $(pub unsafe fn $method(&mut self) -> $rtr {
+                ((*self.lpVtbl).$method)(self $(,$p)*)
+            })+
+        }
+    };
+}
+
+impl ID3D11Asynchronous {
+    pub unsafe fn GetDataSize(&mut self ) -> UINT {
+        ((*self .lpVtbl).GetDataSize)(self )
+    }
+}
+"##]],
+    );
+}
+
+#[test]
+fn test_quick_error() {
+    check(
+        r#"
+macro_rules! quick_error {
+    (SORT [enum $name:ident $( #[$meta:meta] )*]
+        items [$($( #[$imeta:meta] )*
+                  => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*]
+                                {$( $ifuncs:tt )*} )* ]
+        buf [ ]
+        queue [ ]
+    ) => {
+        quick_error!(ENUMINITION [enum $name $( #[$meta] )*]
+            body []
+            queue [$(
+                $( #[$imeta] )*
+                =>
+                $iitem: $imode [$( $ivar: $ityp ),*]
+            )*]
+        );
+    };
+}
+quick_error ! (
+    SORT
+    [enum Wrapped #[derive(Debug)]]
+    items [
+        => One: UNIT [] {}
+        => Two: TUPLE [s :String] {display ("two: {}" , s) from ()} ]
+    buf [ ]
+    queue [ ]
+);
+
+"#,
+        expect![[r##"
+macro_rules! quick_error {
+    (SORT [enum $name:ident $( #[$meta:meta] )*]
+        items [$($( #[$imeta:meta] )*
+                  => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*]
+                                {$( $ifuncs:tt )*} )* ]
+        buf [ ]
+        queue [ ]
+    ) => {
+        quick_error!(ENUMINITION [enum $name $( #[$meta] )*]
+            body []
+            queue [$(
+                $( #[$imeta] )*
+                =>
+                $iitem: $imode [$( $ivar: $ityp ),*]
+            )*]
+        );
+    };
+}
+quick_error!(ENUMINITION[enum Wrapped#[derive(Debug)]]body[]queue[ = > One: UNIT[] = > Two: TUPLE[s: String]]);
+
+"##]],
+    )
+}
diff --git a/crates/mbe/src/tests/expand.rs b/crates/mbe/src/tests/expand.rs
index 300467306d6..c3c753cf558 100644
--- a/crates/mbe/src/tests/expand.rs
+++ b/crates/mbe/src/tests/expand.rs
@@ -99,72 +99,6 @@ fn test_attr_to_token_tree() {
 }
 
 #[test]
-fn test_old_ridl() {
-    // This is from winapi 2.8, which do not have a link from github
-    //
-    let expanded = parse_macro(
-        r#"
-#[macro_export]
-macro_rules! RIDL {
-    (interface $interface:ident ($vtbl:ident) : $pinterface:ident ($pvtbl:ident)
-        {$(
-            fn $method:ident(&mut self $(,$p:ident : $t:ty)*) -> $rtr:ty
-        ),+}
-    ) => {
-        impl $interface {
-            $(pub unsafe fn $method(&mut self) -> $rtr {
-                ((*self.lpVtbl).$method)(self $(,$p)*)
-            })+
-        }
-    };
-}"#,
-    ).expand_tt(r#"
-    RIDL!{interface ID3D11Asynchronous(ID3D11AsynchronousVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) {
-        fn GetDataSize(&mut self) -> UINT
-    }}"#);
-
-    assert_eq!(expanded.to_string(), "impl ID3D11Asynchronous {pub unsafe fn GetDataSize (& mut self) -> UINT {((* self . lpVtbl) .GetDataSize) (self)}}");
-}
-
-#[test]
-fn test_quick_error() {
-    let expanded = parse_macro(
-        r#"
-macro_rules! quick_error {
-
- (SORT [enum $name:ident $( #[$meta:meta] )*]
-        items [$($( #[$imeta:meta] )*
-                  => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*]
-                                {$( $ifuncs:tt )*} )* ]
-        buf [ ]
-        queue [ ]
-    ) => {
-        quick_error!(ENUMINITION [enum $name $( #[$meta] )*]
-            body []
-            queue [$(
-                $( #[$imeta] )*
-                =>
-                $iitem: $imode [$( $ivar: $ityp ),*]
-            )*]
-        );
-};
-
-}
-"#,
-    )
-    .expand_tt(
-        r#"
-quick_error ! (SORT [enum Wrapped # [derive (Debug)]] items [
-        => One : UNIT [] {}
-        => Two : TUPLE [s :String] {display ("two: {}" , s) from ()}
-    ] buf [] queue []) ;
-"#,
-    );
-
-    assert_eq!(expanded.to_string(), "quick_error ! (ENUMINITION [enum Wrapped # [derive (Debug)]] body [] queue [=> One : UNIT [] => Two : TUPLE [s : String]]) ;");
-}
-
-#[test]
 fn test_empty_repeat_vars_in_empty_repeat_vars() {
     parse_macro(
         r#"