diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-02-03 16:39:27 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-02-03 21:30:32 -0800 |
| commit | 70ecd8ed38d5bedbeb281d78c3da44477764236a (patch) | |
| tree | a9e08bd10dc4cb6cb0d489e120001c3445e89b00 /src/libstd | |
| parent | d0029a47c274a2ce97641b80ba34cf6fbfa2d73e (diff) | |
| download | rust-70ecd8ed38d5bedbeb281d78c3da44477764236a.tar.gz rust-70ecd8ed38d5bedbeb281d78c3da44477764236a.zip | |
Test fixes and rebase conflicts
Diffstat (limited to 'src/libstd')
| -rwxr-xr-x | src/libstd/path.rs | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 3fd45ea6a7b..3f4f1ec4c0d 100755 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -156,7 +156,7 @@ mod platform { None } - #[derive(Copy, Clone, Show, Hash, PartialEq, Eq)] + #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] pub struct Prefix<'a>; impl<'a> Prefix<'a> { @@ -177,9 +177,10 @@ mod platform { mod platform { use core::prelude::*; - use super::{Path, os_str_as_u8_slice, u8_slice_as_os_str}; - use ffi::OsStr; + use char::CharExt as UnicodeCharExt; + use super::{os_str_as_u8_slice, u8_slice_as_os_str}; use ascii::*; + use ffi::OsStr; #[inline] pub fn is_sep(b: u8) -> bool { @@ -299,7 +300,7 @@ mod platform { pub fn len(&self) -> usize { use self::Prefix::*; fn os_str_len(s: &OsStr) -> usize { - unsafe { os_str_as_u8_slice(s).len() } + os_str_as_u8_slice(s).len() } match *self { Verbatim(x) => 4 + os_str_len(x), @@ -339,12 +340,12 @@ mod platform { } } - impl<'a> ops::PartialEq for Prefix<'a> { + impl<'a> PartialEq for Prefix<'a> { fn eq(&self, other: &Prefix<'a>) -> bool { use self::Prefix::*; match (*self, *other) { (Verbatim(x), Verbatim(y)) => x == y, - (VerbatimUNC(x1, x2), Verbatim(y1, y2)) => x1 == y1 && x2 == y2, + (VerbatimUNC(x1, x2), VerbatimUNC(y1, y2)) => x1 == y1 && x2 == y2, (VerbatimDisk(x), VerbatimDisk(y)) => os_str_as_u8_slice(x).eq_ignore_ascii_case(os_str_as_u8_slice(y)), (DeviceNS(x), DeviceNS(y)) => x == y, @@ -457,7 +458,7 @@ fn split_file_at_dot(file: &OsStr) -> (Option<&OsStr>, Option<&OsStr>) { /// Going front to back, a path is made up of a prefix, a root component, a body /// (of normal components), and a suffix/emptycomponent (normalized `.` or `` /// for a path ending with the separator) -#[derive(Copy, Clone, PartialEq, PartialOrd, Show)] +#[derive(Copy, Clone, PartialEq, PartialOrd, Debug)] enum State { Prefix = 0, // c: Root = 1, // / @@ -470,7 +471,7 @@ enum State { /// /// See the module documentation for an in-depth explanation of components and /// their role in the API. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Show)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] pub enum Component<'a> { /// A Windows path prefix, e.g. `C:` or `\server\share` Prefix(&'a OsStr), @@ -2434,12 +2435,21 @@ mod tests { tfn!("foo", "bar", "bar"); tfn!("foo", "", ""); tfn!("", "foo", "foo"); - tfn!(".", "foo", "./foo"); - tfn!("foo/", "bar", "foo/bar"); - tfn!("foo/.", "bar", "foo/./bar"); - tfn!("..", "foo", "../foo"); - tfn!("foo/..", "bar", "foo/../bar"); - tfn!("/", "foo", "/foo"); + if cfg!(unix) { + tfn!(".", "foo", "./foo"); + tfn!("foo/", "bar", "foo/bar"); + tfn!("foo/.", "bar", "foo/./bar"); + tfn!("..", "foo", "../foo"); + tfn!("foo/..", "bar", "foo/../bar"); + tfn!("/", "foo", "/foo"); + } else { + tfn!(".", "foo", r".\foo"); + tfn!(r"foo\", "bar", r"foo\bar"); + tfn!(r"foo\.", "bar", r"foo\.\bar"); + tfn!("..", "foo", r"..\foo"); + tfn!(r"foo\..", "bar", r"foo\..\bar"); + tfn!(r"\", "foo", r"\foo"); + } } #[test] |
