Skip to content

Commit 964191a

Browse files
committed
Add and update tests
1 parent a8ce669 commit 964191a

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

src/test/compile-fail/issue-6596.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#![feature(macro_rules)]
1212

13-
// error-pattern: unknown macro variable `nonexistent`
13+
// error-pattern: unexpected token
1414

1515
macro_rules! e(
1616
($inp:ident) => (
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(macro_rules)]
12+
13+
macro_rules! test ( ($a, $b) => (()); ) //~ ERROR Cannot transcribe
14+
15+
fn main() {
16+
test!()
17+
}
Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -10,20 +10,14 @@
1010

1111
#![feature(macro_rules)]
1212

13-
macro_rules! print_hd_tl (
14-
($field_hd:ident, $($field_tl:ident),+) => ({
15-
print!("{}", stringify!($field)); //~ ERROR unknown macro variable
16-
print!("::[");
17-
$(
18-
print!("{}", stringify!($field_tl));
19-
print!(", ");
20-
)+
21-
// FIXME: #9970
22-
print!("{}", "]\n");
23-
})
13+
macro_rules! higher_order (
14+
(subst $lhs:tt => $rhs:tt) => ({
15+
macro_rules! anon ( $lhs => $rhs )
16+
anon!(1u, 2u, "foo")
17+
});
2418
)
2519

2620
fn main() {
27-
print_hd_tl!(x, y, z, w)
21+
let val = higher_order!(subst ($x:expr, $y:expr, $foo:expr) => (($x + $y, $foo)));
22+
assert_eq!(val, (3, "foo"));
2823
}
29-

0 commit comments

Comments
 (0)