]> git.lizzy.rs Git - rust.git/commitdiff
Add and update tests
authorPiotr Czarnecki <pioczarn@gmail.com>
Sun, 12 Oct 2014 11:42:41 +0000 (12:42 +0100)
committerPiotr Czarnecki <pioczarn@gmail.com>
Fri, 7 Nov 2014 09:21:50 +0000 (10:21 +0100)
src/test/compile-fail/issue-5060-fail.rs [deleted file]
src/test/compile-fail/issue-6596.rs
src/test/compile-fail/macro-match-nonterminal.rs [new file with mode: 0644]
src/test/run-pass/macro-of-higher-order.rs [new file with mode: 0644]

diff --git a/src/test/compile-fail/issue-5060-fail.rs b/src/test/compile-fail/issue-5060-fail.rs
deleted file mode 100644 (file)
index fedb064..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![feature(macro_rules)]
-
-macro_rules! print_hd_tl (
-    ($field_hd:ident, $($field_tl:ident),+) => ({
-        print!("{}", stringify!($field)); //~ ERROR unknown macro variable
-        print!("::[");
-        $(
-            print!("{}", stringify!($field_tl));
-            print!(", ");
-        )+
-        // FIXME: #9970
-        print!("{}", "]\n");
-    })
-)
-
-fn main() {
-    print_hd_tl!(x, y, z, w)
-}
-
index 54bcf415d2eadbc6d72cd1cf10dc440c3c36a080..267b30677a18f13f7343880be19b9598f2d21ebc 100644 (file)
@@ -10,7 +10,7 @@
 
 #![feature(macro_rules)]
 
-// error-pattern: unknown macro variable `nonexistent`
+// error-pattern: unexpected token
 
 macro_rules! e(
     ($inp:ident) => (
diff --git a/src/test/compile-fail/macro-match-nonterminal.rs b/src/test/compile-fail/macro-match-nonterminal.rs
new file mode 100644 (file)
index 0000000..d6d32d9
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(macro_rules)]
+
+macro_rules! test ( ($a, $b) => (()); ) //~ ERROR Cannot transcribe
+
+fn main() {
+    test!()
+}
diff --git a/src/test/run-pass/macro-of-higher-order.rs b/src/test/run-pass/macro-of-higher-order.rs
new file mode 100644 (file)
index 0000000..561933d
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(macro_rules)]
+
+macro_rules! higher_order (
+    (subst $lhs:tt => $rhs:tt) => ({
+            macro_rules! anon ( $lhs => $rhs )
+            anon!(1u, 2u, "foo")
+    });
+)
+
+fn main() {
+    let val = higher_order!(subst ($x:expr, $y:expr, $foo:expr) => (($x + $y, $foo)));
+    assert_eq!(val, (3, "foo"));
+}