about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2021-10-10 14:23:52 +0300
committerAleksey Kladov <aleksey.kladov@gmail.com>2021-10-10 14:23:52 +0300
commit6253213a6e4c9a1d0059d5ed9834e1eb2808d927 (patch)
tree00ae7d64052854df9f42fba047c5adf1e3168304
parente55797f59d47153651661588e9ff09ffb75c6e67 (diff)
downloadrust-6253213a6e4c9a1d0059d5ed9834e1eb2808d927.tar.gz
rust-6253213a6e4c9a1d0059d5ed9834e1eb2808d927.zip
move test
-rw-r--r--crates/hir_def/src/macro_expansion_tests/mbe/regression.rs56
-rw-r--r--crates/mbe/src/tests/expand.rs28
2 files changed, 56 insertions, 28 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 ac09c23cd3e..9762570412c 100644
--- a/crates/hir_def/src/macro_expansion_tests/mbe/regression.rs
+++ b/crates/hir_def/src/macro_expansion_tests/mbe/regression.rs
@@ -477,3 +477,59 @@ __cfg_if_items! {
 "##]],
     );
 }
+
+#[test]
+fn test_proptest_arbitrary() {
+    // From <https://github.com/AltSysrq/proptest/blob/d1c4b049337d2f75dd6f49a095115f7c532e5129/proptest/src/arbitrary/macros.rs#L16>.
+    check(
+        r#"
+macro_rules! arbitrary {
+    ([$($bounds : tt)*] $typ: ty, $strat: ty, $params: ty;
+        $args: ident => $logic: expr) => {
+        impl<$($bounds)*> $crate::arbitrary::Arbitrary for $typ {
+            type Parameters = $params;
+            type Strategy = $strat;
+            fn arbitrary_with($args: Self::Parameters) -> Self::Strategy {
+                $logic
+            }
+        }
+    };
+}
+
+arbitrary!(
+    [A:Arbitrary]
+    Vec<A> ,
+    VecStrategy<A::Strategy>,
+    RangedParams1<A::Parameters>;
+    args =>   {
+        let product_unpack![range, a] = args;
+        vec(any_with::<A>(a), range)
+    }
+);
+"#,
+        expect![[r#"
+macro_rules! arbitrary {
+    ([$($bounds : tt)*] $typ: ty, $strat: ty, $params: ty;
+        $args: ident => $logic: expr) => {
+        impl<$($bounds)*> $crate::arbitrary::Arbitrary for $typ {
+            type Parameters = $params;
+            type Strategy = $strat;
+            fn arbitrary_with($args: Self::Parameters) -> Self::Strategy {
+                $logic
+            }
+        }
+    };
+}
+
+impl <A: Arbitrary> $crate::arbitrary::Arbitrary for Vec<A> {
+    type Parameters = RangedParams1<A::Parameters>;
+    type Strategy = VecStrategy<A::Strategy>;
+    fn arbitrary_with(args: Self::Parameters) -> Self::Strategy { {
+            let product_unpack![range, a] = args;
+            vec(any_with::<A>(a), range)
+        }
+    }
+}
+"#]],
+    );
+}
diff --git a/crates/mbe/src/tests/expand.rs b/crates/mbe/src/tests/expand.rs
index 1287b3ea9b9..300467306d6 100644
--- a/crates/mbe/src/tests/expand.rs
+++ b/crates/mbe/src/tests/expand.rs
@@ -99,34 +99,6 @@ fn test_attr_to_token_tree() {
 }
 
 #[test]
-fn test_proptest_arbitrary() {
-    // from https://github.com/AltSysrq/proptest/blob/d1c4b049337d2f75dd6f49a095115f7c532e5129/proptest/src/arbitrary/macros.rs#L16
-    parse_macro(
-        r#"
-macro_rules! arbitrary {
-    ([$($bounds : tt)*] $typ: ty, $strat: ty, $params: ty;
-        $args: ident => $logic: expr) => {
-        impl<$($bounds)*> $crate::arbitrary::Arbitrary for $typ {
-            type Parameters = $params;
-            type Strategy = $strat;
-            fn arbitrary_with($args: Self::Parameters) -> Self::Strategy {
-                $logic
-            }
-        }
-    };
-
-}"#,
-    ).assert_expand_items(r#"arbitrary !   ( [ A : Arbitrary ]
-        Vec < A > ,
-        VecStrategy < A :: Strategy > ,
-        RangedParams1 < A :: Parameters > ;
-        args =>   { let product_unpack !   [ range , a ] = args ; vec ( any_with :: < A >   ( a ) , range ) }
-    ) ;"#,
-    "impl <A : Arbitrary > $crate :: arbitrary :: Arbitrary for Vec < A > {type Parameters = RangedParams1 < A :: Parameters > ; type Strategy = VecStrategy < A :: Strategy > ; fn arbitrary_with (args : Self :: Parameters) -> Self :: Strategy {{let product_unpack ! [range , a] = args ; vec (any_with :: < A > (a) , range)}}}"
-    );
-}
-
-#[test]
 fn test_old_ridl() {
     // This is from winapi 2.8, which do not have a link from github
     //