Skip to content

Commit 95c5d79

Browse files
Nick Desaulniersemberian
authored andcommitted
---
yaml --- r: 66317 b: refs/heads/master c: 82fa5b6 h: refs/heads/master i: 66315: 5b0807c v: v3
1 parent 3466cf8 commit 95c5d79

File tree

2 files changed

+43
-37
lines changed

2 files changed

+43
-37
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 394d28cac54b936bf5c3d1420229b52156744e7f
2+
refs/heads/master: 82fa5b615ec65501abccb470fe71c1aff1f29fc8
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,61 @@
1-
// FIXME #7306
2-
// xfail-fast
1+
// Copyright 2013 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.
310

4-
use std::io;
5-
6-
fn f1(ref_string: &str) {
11+
fn f1(ref_string: &str) -> ~str {
712
match ref_string {
8-
"a" => io::println("found a"),
9-
"b" => io::println("found b"),
10-
_ => io::println("not found")
13+
"a" => ~"found a",
14+
"b" => ~"found b",
15+
_ => ~"not found"
1116
}
1217
}
1318

14-
fn f2(ref_string: &str) {
19+
fn f2(ref_string: &str) -> ~str {
1520
match ref_string {
16-
"a" => io::println("found a"),
17-
"b" => io::println("found b"),
18-
s => io::println(fmt!("not found (%s)", s))
21+
"a" => ~"found a",
22+
"b" => ~"found b",
23+
s => fmt!("not found (%s)", s)
1924
}
2025
}
2126

22-
fn g1(ref_1: &str, ref_2: &str) {
27+
fn g1(ref_1: &str, ref_2: &str) -> ~str {
2328
match (ref_1, ref_2) {
24-
("a", "b") => io::println("found a,b"),
25-
("b", "c") => io::println("found b,c"),
26-
_ => io::println("not found")
29+
("a", "b") => ~"found a,b",
30+
("b", "c") => ~"found b,c",
31+
_ => ~"not found"
2732
}
2833
}
2934

30-
fn g2(ref_1: &str, ref_2: &str) {
35+
fn g2(ref_1: &str, ref_2: &str) -> ~str {
3136
match (ref_1, ref_2) {
32-
("a", "b") => io::println("found a,b"),
33-
("b", "c") => io::println("found b,c"),
34-
(s1, s2) => io::println(fmt!("not found (%s, %s)", s1, s2))
37+
("a", "b") => ~"found a,b",
38+
("b", "c") => ~"found b,c",
39+
(s1, s2) => fmt!("not found (%s, %s)", s1, s2)
3540
}
3641
}
3742

3843
pub fn main() {
39-
f1(@"a");
40-
f1(~"b");
41-
f1(&"c");
42-
f1("d");
43-
f2(@"a");
44-
f2(~"b");
45-
f2(&"c");
46-
f2("d");
47-
g1(@"a", @"b");
48-
g1(~"b", ~"c");
49-
g1(&"c", &"d");
50-
g1("d", "e");
51-
g2(@"a", @"b");
52-
g2(~"b", ~"c");
53-
g2(&"c", &"d");
54-
g2("d", "e");
44+
assert_eq!(f1(@"a"), ~"found a");
45+
assert_eq!(f1(~"b"), ~"found b");
46+
assert_eq!(f1(&"c"), ~"not found");
47+
assert_eq!(f1("d"), ~"not found");
48+
assert_eq!(f2(@"a"), ~"found a");
49+
assert_eq!(f2(~"b"), ~"found b");
50+
assert_eq!(f2(&"c"), ~"not found (c)");
51+
assert_eq!(f2("d"), ~"not found (d)");
52+
assert_eq!(g1(@"a", @"b"), ~"found a,b");
53+
assert_eq!(g1(~"b", ~"c"), ~"found b,c");
54+
assert_eq!(g1(&"c", &"d"), ~"not found");
55+
assert_eq!(g1("d", "e"), ~"not found");
56+
assert_eq!(g2(@"a", @"b"), ~"found a,b");
57+
assert_eq!(g2(~"b", ~"c"), ~"found b,c");
58+
assert_eq!(g2(&"c", &"d"), ~"not found (c, d)");
59+
assert_eq!(g2("d", "e"), ~"not found (d, e)");
5560
}
61+

0 commit comments

Comments
 (0)