about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-01-06 15:49:15 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-01-06 15:49:15 -0800
commit26cd8eae48ea99bda183c5224bc423991ccfaf1f (patch)
tree26492380aa79b1b1f70acb2a624e30ca097374df /src/test
parent34a63d336419e80d3afec16c730d1ad5fa11dc73 (diff)
parente9cbdd866d1c9c01e9affaf6875e37e58a073758 (diff)
downloadrust-26cd8eae48ea99bda183c5224bc423991ccfaf1f.tar.gz
rust-26cd8eae48ea99bda183c5224bc423991ccfaf1f.zip
rollup merge of #20563: cmr/macro-input-future-proofing
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/macro-input-future-proofing.rs30
-rw-r--r--src/test/run-pass/const-polymorphic-paths.rs51
-rw-r--r--src/test/run-pass/nullable-pointer-iotareduction.rs22
3 files changed, 66 insertions, 37 deletions
diff --git a/src/test/compile-fail/macro-input-future-proofing.rs b/src/test/compile-fail/macro-input-future-proofing.rs
new file mode 100644
index 00000000000..15f6d88fd89
--- /dev/null
+++ b/src/test/compile-fail/macro-input-future-proofing.rs
@@ -0,0 +1,30 @@
+// Copyright 2015 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.
+
+macro_rules! errors_everywhere {
+    ($ty:ty <) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty`
+    ($ty:ty < foo ,) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty`
+    ($ty:ty , ) => ();
+    ( ( $ty:ty ) ) => ();
+    ( { $ty:ty } ) => ();
+    ( [ $ty:ty ] ) => ();
+    ($bl:block < ) => ();
+    ($pa:pat >) => (); //~ ERROR `$pa:pat` is followed by `>`, which is not allowed for `pat`
+    ($pa:pat , ) => ();
+    ($pa:pat | ) => (); //~ ERROR `$pa:pat` is followed by `|`
+    ($pa:pat $pb:pat $ty:ty ,) => ();
+    //~^ ERROR `$pa:pat` is followed by `$pb:pat`, which is not allowed
+    //~^^ ERROR `$pb:pat` is followed by `$ty:ty`, which is not allowed
+    ($($ty:ty)* -) => (); //~ ERROR `$ty:ty` is followed by `-`
+    ($($a:ty, $b:ty)* -) => (); //~ ERROR `$b:ty` is followed by `-`
+    ($($ty:ty)-+) => (); //~ ERROR `$ty:ty` is followed by `-`, which is not allowed for `ty`
+}
+
+fn main() { }
diff --git a/src/test/run-pass/const-polymorphic-paths.rs b/src/test/run-pass/const-polymorphic-paths.rs
index 25c1464adfa..28b346c9ed4 100644
--- a/src/test/run-pass/const-polymorphic-paths.rs
+++ b/src/test/run-pass/const-polymorphic-paths.rs
@@ -29,7 +29,7 @@ fn odd(x: uint) -> bool { x % 2 == 1 }
 fn dummy_rng() -> DummyRng { DummyRng::new_unseeded() }
 
 macro_rules! tests {
-    ($($expr:expr: $ty:ty /($($test:expr),*);)+) => (pub fn main() {$({
+    ($($expr:expr, $ty:ty, ($($test:expr),*);)+) => (pub fn main() {$({
         const C: $ty = $expr;
         static S: $ty = $expr;
         assert!(eq(C($($test),*), $expr($($test),*)));
@@ -40,45 +40,44 @@ macro_rules! tests {
 
 tests! {
     // Free function.
-    id: fn(int) -> int /(5);
-    id::<int>: fn(int) -> int /(5);
+    id, fn(int) -> int, (5);
+    id::<int>, fn(int) -> int, (5);
 
     // Enum variant constructor.
-    Some: fn(int) -> Option<int> /(5);
-    Some::<int>: fn(int) -> Option<int> /(5);
+    Some, fn(int) -> Option<int>, (5);
+    Some::<int>, fn(int) -> Option<int>, (5);
 
     // Tuple struct constructor.
-    Newt: fn(int) -> Newt<int> /(5);
-    Newt::<int>: fn(int) -> Newt<int> /(5);
+    Newt, fn(int) -> Newt<int>, (5);
+    Newt::<int>, fn(int) -> Newt<int>, (5);
 
     // Inherent static methods.
-    Vec::new: fn() -> Vec<()> /();
-    Vec::<()>::new: fn() -> Vec<()> /();
-    Vec::with_capacity: fn(uint) -> Vec<()> /(5);
-    Vec::<()>::with_capacity: fn(uint) -> Vec<()> /(5);
-    Bitv::from_fn: fn(uint, fn(uint) -> bool) -> Bitv /(5, odd);
-    Bitv::from_fn::<fn(uint) -> bool>: fn(uint, fn(uint) -> bool) -> Bitv /(5, odd);
+    Vec::new, fn() -> Vec<()>, ();
+    Vec::<()>::new, fn() -> Vec<()>, ();
+    Vec::with_capacity, fn(uint) -> Vec<()>, (5);
+    Vec::<()>::with_capacity, fn(uint) -> Vec<()>, (5);
+    Bitv::from_fn, fn(uint, fn(uint) -> bool) -> Bitv, (5, odd);
+    Bitv::from_fn::<fn(uint) -> bool>, fn(uint, fn(uint) -> bool) -> Bitv, (5, odd);
 
     // Inherent non-static method.
-    Vec::map_in_place: fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>
-        /(vec![b'f', b'o', b'o'], u8_as_i8);
-    Vec::map_in_place::<i8, fn(u8) -> i8>: fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>
-        /(vec![b'f', b'o', b'o'], u8_as_i8);
+    Vec::map_in_place, fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>, (vec![b'f', b'o', b'o'], u8_as_i8);
+    Vec::map_in_place::<i8, fn(u8) -> i8>, fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>,
+        (vec![b'f', b'o', b'o'], u8_as_i8);
     // FIXME these break with "type parameter might not appear here pointing at `<u8>`.
     // Vec::<u8>::map_in_place: fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>
-    //     /(vec![b'f', b'o', b'o'], u8_as_i8);
+    //    , (vec![b'f', b'o', b'o'], u8_as_i8);
     // Vec::<u8>::map_in_place::<i8, fn(u8) -> i8>: fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>
-    //     /(vec![b'f', b'o', b'o'], u8_as_i8);
+    //    , (vec![b'f', b'o', b'o'], u8_as_i8);
 
     // Trait static methods.
     // FIXME qualified path expressions aka UFCS i.e. <T as Trait>::method.
-    Default::default: fn() -> int /();
-    Rand::rand: fn(&mut DummyRng) -> int /(&mut dummy_rng());
-    Rand::rand::<DummyRng>: fn(&mut DummyRng) -> int /(&mut dummy_rng());
+    Default::default, fn() -> int, ();
+    Rand::rand, fn(&mut DummyRng) -> int, (&mut dummy_rng());
+    Rand::rand::<DummyRng>, fn(&mut DummyRng) -> int, (&mut dummy_rng());
 
     // Trait non-static methods.
-    Clone::clone: fn(&int) -> int /(&5);
-    FromIterator::from_iter: fn(OptionIter<int>) -> Vec<int> /(Some(5).into_iter());
-    FromIterator::from_iter::<OptionIter<int>>: fn(OptionIter<int>) -> Vec<int>
-        /(Some(5).into_iter());
+    Clone::clone, fn(&int) -> int, (&5);
+    FromIterator::from_iter, fn(OptionIter<int>) -> Vec<int>, (Some(5).into_iter());
+    FromIterator::from_iter::<OptionIter<int>>, fn(OptionIter<int>) -> Vec<int>
+       , (Some(5).into_iter());
 }
diff --git a/src/test/run-pass/nullable-pointer-iotareduction.rs b/src/test/run-pass/nullable-pointer-iotareduction.rs
index 9b9a7f68995..0293c4e36ac 100644
--- a/src/test/run-pass/nullable-pointer-iotareduction.rs
+++ b/src/test/run-pass/nullable-pointer-iotareduction.rs
@@ -35,10 +35,10 @@ impl<T> E<T> {
 }
 
 macro_rules! check_option {
-    ($e:expr: $T:ty) => {{
-        check_option!($e: $T, |ptr| assert!(*ptr == $e));
+    ($e:expr, $T:ty) => {{
+        check_option!($e, $T, |ptr| assert!(*ptr == $e));
     }};
-    ($e:expr: $T:ty, |$v:ident| $chk:expr) => {{
+    ($e:expr, $T:ty, |$v:ident| $chk:expr) => {{
         assert!(option::Option::None::<$T>.is_none());
         let e = $e;
         let s_ = option::Option::Some::<$T>(e);
@@ -48,10 +48,10 @@ macro_rules! check_option {
 }
 
 macro_rules! check_fancy {
-    ($e:expr: $T:ty) => {{
-        check_fancy!($e: $T, |ptr| assert!(*ptr == $e));
+    ($e:expr, $T:ty) => {{
+        check_fancy!($e, $T, |ptr| assert!(*ptr == $e));
     }};
-    ($e:expr: $T:ty, |$v:ident| $chk:expr) => {{
+    ($e:expr, $T:ty, |$v:ident| $chk:expr) => {{
         assert!(E::Nothing::<$T>((), ((), ()), [23i8; 0]).is_none());
         let e = $e;
         let t_ = E::Thing::<$T>(23, e);
@@ -71,12 +71,12 @@ macro_rules! check_type {
 }
 
 pub fn main() {
-    check_type!(&17: &int);
-    check_type!(box 18: Box<int>);
-    check_type!("foo".to_string(): String);
-    check_type!(vec!(20, 22): Vec<int> );
+    check_type!(&17, &int);
+    check_type!(box 18, Box<int>);
+    check_type!("foo".to_string(), String);
+    check_type!(vec!(20, 22), Vec<int> );
     let mint: uint = unsafe { mem::transmute(main) };
-    check_type!(main: fn(), |pthing| {
+    check_type!(main, fn(), |pthing| {
         assert!(mint == unsafe { mem::transmute(*pthing) })
     });
 }