]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-13304.rs
test: Remove all uses of `~str` from the test suite.
[rust.git] / src / test / run-pass / issue-13304.rs
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 // ignore-fast
12
13 extern crate green;
14 extern crate rustuv;
15 extern crate native;
16
17 use std::os;
18 use std::io;
19 use std::str;
20
21 #[start]
22 fn start(argc: int, argv: **u8) -> int {
23     green::start(argc, argv, rustuv::event_loop, main)
24 }
25
26 fn main() {
27     let args = os::args();
28     let args = args.as_slice();
29     if args.len() > 1 && args[1].as_slice() == "child" {
30         if args[2].as_slice() == "green" {
31             child();
32         } else {
33             let (tx, rx) = channel();
34             native::task::spawn(proc() { tx.send(child()); });
35             rx.recv();
36         }
37     } else {
38         parent("green".to_strbuf());
39         parent("native".to_strbuf());
40         let (tx, rx) = channel();
41         native::task::spawn(proc() {
42             parent("green".to_strbuf());
43             parent("native".to_strbuf());
44             tx.send(());
45         });
46         rx.recv();
47     }
48 }
49
50 fn parent(flavor: StrBuf) {
51     let args = os::args();
52     let args = args.as_slice();
53     let mut p = io::Process::new(args[0].as_slice(), [
54         "child".to_owned(),
55         flavor.to_owned()
56     ]).unwrap();
57     p.stdin.get_mut_ref().write_str("test1\ntest2\ntest3").unwrap();
58     let out = p.wait_with_output().unwrap();
59     assert!(out.status.success());
60     let s = str::from_utf8(out.output.as_slice()).unwrap();
61     assert_eq!(s, "test1\n\ntest2\n\ntest3\n");
62 }
63
64 fn child() {
65     for line in io::stdin().lines() {
66         println!("{}", line.unwrap());
67     }
68 }