Skip to content

Commit 8961a02

Browse files
Nick Desaulniersjihyun
Nick Desaulniers
authored and
jihyun
committed
Fix run-pass/match-borrowed_str.rs Fixes rust-lang#7306
1 parent 77ed3d1 commit 8961a02

File tree

1 file changed

+42
-36
lines changed

1 file changed

+42
-36
lines changed

Diff for: src/test/run-pass/match-borrowed_str.rs

+42-36
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)