]> git.lizzy.rs Git - rust.git/blobdiff - src/test/run-pass/pipe-select-macro.rs
Move select macro into another file, so it can be including in multiple tests.
[rust.git] / src / test / run-pass / pipe-select-macro.rs
index 0a50e9ef89913befa18ce58d02fc110284d439c1..9559d815def5c40b456cfef262e25d9c293bca1d 100644 (file)
@@ -1,4 +1,4 @@
-// xfail-test
+// xfail-pretty
 
 // Protocols
 proto! foo {
     }
 }
 
-
-// select!
-macro_rules! select_if {
-    {
-        $index:expr,
-        $count:expr,
-        $port:path => [
-            $($message:path$(($($x: ident),+))dont_type_this*
-              -> $next:ident $e:expr),+
-        ],
-        $( $ports:path => [
-            $($messages:path$(($($xs: ident),+))dont_type_this*
-              -> $nexts:ident $es:expr),+
-        ], )*
-    } => {
-        log_syntax!{select_if1};
-        if $index == $count {
-            alt move pipes::try_recv($port) {
-              $(some($message($($($x,)+)* next)) => {
-                // FIXME (#2329) we really want move out of enum here.
-                let $next = unsafe { let x <- *ptr::addr_of(next); x };
-                $e
-              })+
-              _ => fail
-            }
-        } else {
-            select_if!{
-                $index,
-                $count + 1,
-                $( $ports => [
-                    $($messages$(($($xs),+))dont_type_this*
-                      -> $nexts $es),+
-                ], )*
-            }
-        }
-    };
-
-    {
-        $index:expr,
-        $count:expr,
-    } => {
-        log_syntax!{select_if2};
-        fail
-    }
-}
-
-macro_rules! select {
-    {
-        $( $port:path => {
-            $($message:path$(($($x: ident),+))dont_type_this*
-              -> $next:ident $e:expr),+
-        } )+
-    } => {
-        let index = pipes::selecti([$(($port).header()),+]/_);
-        log_syntax!{select};
-        log_syntax!{
-        select_if!{index, 0, $( $port => [
-            $($message$(($($x),+))dont_type_this* -> $next $e),+
-        ], )+}
-        };
-        select_if!{index, 0, $( $port => [
-            $($message$(($($x),+))dont_type_this* -> $next $e),+
-        ], )+}
-    }
+fn macros() {
+    include!("select-macro.rs");
 }
 
 // Code
 fn test(+foo: foo::client::foo, +bar: bar::client::bar) {
+    import bar::do_baz;
+
     select! {
         foo => {
             foo::do_foo -> _next {
@@ -98,11 +38,11 @@ fn test(+foo: foo::client::foo, +bar: bar::client::bar) {
 
         bar => {
             bar::do_bar(x) -> _next {
-                //debug!("%?", x)
+                debug!("%?", x)
             },
 
             do_baz(b) -> _next {
-                //if b { debug!("true") } else { debug!("false") }
+                if *b { debug!("true") } else { debug!("false") }
             }
         }
     }