make tests hygienic...

... 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.
This commit is contained in:
John Clements 2014-06-26 17:41:43 -07:00
parent 235ca1801e
commit ee1ee7f463
2 changed files with 18 additions and 8 deletions

View File

@ -10,23 +10,28 @@
#![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));

View 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));