]> git.lizzy.rs Git - rust.git/commitdiff
make tests hygienic...
authorJohn Clements <clements@racket-lang.org>
Fri, 27 Jun 2014 00:41:43 +0000 (17:41 -0700)
committerJohn Clements <clements@racket-lang.org>
Sat, 28 Jun 2014 05:08:57 +0000 (22:08 -0700)
... and possibly totally pointless. Specifically, fixing
these to make their macros hygienic may mean that they no
longer test the thing that they were supposed to test.

src/test/run-pass/issue-8851.rs
src/test/run-pass/typeck-macro-interaction-issue-8852.rs

index 62970369579a762a4f7063738e56d64f0bed9f75..210371205696a91d6c6b9789b92c3b9769e2bf23 100644 (file)
 
 #![feature(macro_rules)]
 
+// after fixing #9384 and implementing hygiene for match bindings,
+// this now fails because the insertion of the 'y' into the match
+// doesn't cause capture. Making this macro hygienic (as I've done)
+// could very well make this test case completely pointless....
+
 enum T {
     A(int),
     B(uint)
 }
 
 macro_rules! test(
-    ($e:expr) => (
+    ($id:ident, $e:expr) => (
         fn foo(t: T) -> int {
             match t {
-                A(y) => $e,
-                B(y) => $e
+                A($id) => $e,
+                B($id) => $e
             }
         }
     )
 )
 
-test!(10 + (y as int))
+test!(y, 10 + (y as int))
 
 pub fn main() {
     foo(A(20));
index 50ef1922c8fb8d612a2c9ac12216e7b56e3cb2d3..6be79cb62dd7f09ccf6c1f32ffc1c14cd1b0d1a4 100644 (file)
@@ -15,19 +15,24 @@ enum T {
     B(f64)
 }
 
+// after fixing #9384 and implementing hygiene for match bindings,
+// this now fails because the insertion of the 'y' into the match
+// doesn't cause capture. Making this macro hygienic (as I've done)
+// could very well make this test case completely pointless....
+
 macro_rules! test(
-    ($e:expr) => (
+    ($id1:ident, $id2:ident, $e:expr) => (
         fn foo(a:T, b:T) -> T {
             match (a, b) {
-                (A(x), A(y)) => A($e),
-                (B(x), B(y)) => B($e),
+                (A($id1), A($id2)) => A($e),
+                (B($id1), B($id2)) => B($e),
                 _ => fail!()
             }
         }
     )
 )
 
-test!(x + y)
+test!(x,y,x + y)
 
 pub fn main() {
     foo(A(1), A(2));