stdlib: Add regression test for fs::connect and a FIXME

This commit is contained in:
Brian Anderson 2011-05-20 20:47:14 -04:00
parent 0755a30051
commit 85bcf75da1
2 changed files with 16 additions and 0 deletions

View file

@ -19,6 +19,7 @@ fn dirname(path p) -> path {
ret str::substr(p, 0u, i as uint);
}
// FIXME: Need some typestate to avoid bounds check when len(pre) == 0
fn connect(path pre, path post) -> path {
auto len = str::byte_len(pre);
if (pre.(len - 1u) == (os_fs::path_sep as u8)) { // Trailing '/'?

View file

@ -0,0 +1,15 @@
use std;
import std::fs;
fn test_connect() {
auto slash = fs::path_sep();
assert (fs::connect("a", "b")
== "a" + slash + "b");
assert (fs::connect("a" + slash, "b")
== "a" + slash + "b");
}
fn main() {
test_connect();
}