Skip to content

Commit 85bcf75

Browse files
committed
stdlib: Add regression test for fs::connect and a FIXME
1 parent 0755a30 commit 85bcf75

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/lib/fs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ fn dirname(path p) -> path {
1919
ret str::substr(p, 0u, i as uint);
2020
}
2121

22+
// FIXME: Need some typestate to avoid bounds check when len(pre) == 0
2223
fn connect(path pre, path post) -> path {
2324
auto len = str::byte_len(pre);
2425
if (pre.(len - 1u) == (os_fs::path_sep as u8)) { // Trailing '/'?

src/test/run-pass/lib-fs.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use std;
2+
3+
import std::fs;
4+
5+
fn test_connect() {
6+
auto slash = fs::path_sep();
7+
assert (fs::connect("a", "b")
8+
== "a" + slash + "b");
9+
assert (fs::connect("a" + slash, "b")
10+
== "a" + slash + "b");
11+
}
12+
13+
fn main() {
14+
test_connect();
15+
}

0 commit comments

Comments
 (0)