stdlib: Add regression test for fs::connect and a FIXME
This commit is contained in:
parent
0755a30051
commit
85bcf75da1
2 changed files with 16 additions and 0 deletions
|
@ -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 '/'?
|
||||
|
|
15
src/test/run-pass/lib-fs.rs
Normal file
15
src/test/run-pass/lib-fs.rs
Normal 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();
|
||||
}
|
Loading…
Add table
Reference in a new issue