]> git.lizzy.rs Git - rust.git/commitdiff
Move select macro into another file, so it can be including in multiple tests.
authorEric Holk <eric.holk@gmail.com>
Fri, 17 Aug 2012 18:47:01 +0000 (11:47 -0700)
committerEric Holk <eric.holk@gmail.com>
Fri, 17 Aug 2012 19:39:51 +0000 (12:39 -0700)
Fixing long lines.

src/libsyntax/ext/pipes/ast_builder.rs
src/test/run-pass/pipe-select-macro.rs
src/test/run-pass/select-macro.rs [new file with mode: 0644]

index da2f9d433739aa2d1c1808a5d694b04c4ae1c861..39132fd0d5942e1057f48ebd8f5421a9cccd8c62 100644 (file)
@@ -69,7 +69,7 @@ fn item_enum_poly(name: ident,
                       span: span,
                       +enum_definition: ast::enum_def,
                       +ty_params: ~[ast::ty_param]) -> @ast::item;
-    fn item_enum(name: ident, span: span, 
+    fn item_enum(name: ident, span: span,
                  +enum_definition: ast::enum_def) -> @ast::item;
     fn variant(name: ident, span: span, +tys: ~[@ast::ty]) -> ast::variant;
     fn item_mod(name: ident, span: span, +items: ~[@ast::item]) -> @ast::item;
index 421e6306371ed09cff6ef39a5ac565bf821b7d1f..9559d815def5c40b456cfef262e25d9c293bca1d 100644 (file)
     }
 }
 
-
-// select!
-macro_rules! select_if {
-
-    {
-        $index:expr,
-        $count:expr
-    } => {
-        fail
-    };
-
-    {
-        $index:expr,
-        $count:expr,
-        $port:path => [
-            $(type_this $message:path$(($(x $x: ident),+))dont_type_this*
-              -> $next:ident => { $e:expr }),+
-        ]
-        $(, $ports:path => [
-            $(type_this $messages:path$(($(x $xs: ident),+))dont_type_this*
-              -> $nexts:ident => { $es:expr }),+
-        ] )*
-    } => {
-        if $index == $count {
-            match 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 => [
-                    $(type_this $messages$(($(x $xs),+))dont_type_this*
-                      -> $nexts => { $es }),+
-                ])*
-            }
-        }
-    };
-}
-
-macro_rules! select {
-    {
-        $( $port:path => {
-            $($message:path$(($($x: ident),+))dont_type_this*
-              -> $next:ident $e:expr),+
-        } )+
-    } => {
-        let index = pipes::selecti([$(($port).header()),+]/_);
-        select_if!{index, 0 $(, $port => [
-            $(type_this $message$(($(x $x),+))dont_type_this* -> $next => { $e }),+
-        ])+}
-    }
+fn macros() {
+    include!("select-macro.rs");
 }
 
 // Code
@@ -97,7 +42,7 @@ fn test(+foo: foo::client::foo, +bar: bar::client::bar) {
             },
 
             do_baz(b) -> _next {
-                if b { debug!("true") } else { debug!("false") }
+                if *b { debug!("true") } else { debug!("false") }
             }
         }
     }
diff --git a/src/test/run-pass/select-macro.rs b/src/test/run-pass/select-macro.rs
new file mode 100644 (file)
index 0000000..acaac71
--- /dev/null
@@ -0,0 +1,63 @@
+// xfail-test - this isn't really a test.
+
+ {
+
+// select!
+macro_rules! select_if {
+
+    {
+        $index:expr,
+        $count:expr
+    } => {
+        fail
+    };
+
+    {
+        $index:expr,
+        $count:expr,
+        $port:path => [
+            $(type_this $message:path$(($(x $x: ident),+))dont_type_this*
+              -> $next:ident => { $e:expr }),+
+        ]
+        $(, $ports:path => [
+            $(type_this $messages:path$(($(x $xs: ident),+))dont_type_this*
+              -> $nexts:ident => { $es:expr }),+
+        ] )*
+    } => {
+        if $index == $count {
+            match move pipes::try_recv($port) {
+              $(some($message($($(ref $x,)+)* ref 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 => [
+                    $(type_this $messages$(($(x $xs),+))dont_type_this*
+                      -> $nexts => { $es }),+
+                ])*
+            }
+        }
+    };
+}
+
+macro_rules! select {
+    {
+        $( $port:path => {
+            $($message:path$(($($x: ident),+))dont_type_this*
+              -> $next:ident $e:expr),+
+        } )+
+    } => {
+        let index = pipes::selecti([$(($port).header()),+]/_);
+        select_if!{index, 0 $(, $port => [
+            $(type_this $message$(($(x $x),+))dont_type_this* -> $next => { $e }),+
+        ])+}
+    }
+}
+
+}