Add and fix more tests
This commit is contained in:
parent
1e9bef916f
commit
b98255cbd2
@ -448,7 +448,8 @@ impl<T, E> Result<T, E> {
|
||||
/// ```
|
||||
/// use std::old_io::IoResult;
|
||||
///
|
||||
/// let mut buffer = &mut b"1\n2\n3\n4\n";
|
||||
/// let mut buffer: &[u8] = b"1\n2\n3\n4\n";
|
||||
/// let mut buffer = &mut buffer;
|
||||
///
|
||||
/// let mut sum = 0;
|
||||
///
|
||||
|
@ -311,7 +311,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
|
||||
/// # #[cfg(windows)] fn foo() {}
|
||||
/// # #[cfg(unix)] fn foo() {
|
||||
/// let p = Path::new("abc/def/ghi");
|
||||
/// assert_eq!(p.filename(), Some(b"ghi"));
|
||||
/// assert_eq!(p.filename(), Some(&b"ghi"[..]));
|
||||
/// # }
|
||||
/// ```
|
||||
fn filename<'a>(&'a self) -> Option<&'a [u8]>;
|
||||
@ -345,7 +345,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
|
||||
/// # #[cfg(windows)] fn foo() {}
|
||||
/// # #[cfg(unix)] fn foo() {
|
||||
/// let p = Path::new("/abc/def.txt");
|
||||
/// assert_eq!(p.filestem(), Some(b"def"));
|
||||
/// assert_eq!(p.filestem(), Some(&b"def"[..]));
|
||||
/// # }
|
||||
/// ```
|
||||
fn filestem<'a>(&'a self) -> Option<&'a [u8]> {
|
||||
@ -392,7 +392,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
|
||||
/// # #[cfg(windows)] fn foo() {}
|
||||
/// # #[cfg(unix)] fn foo() {
|
||||
/// let p = Path::new("abc/def.txt");
|
||||
/// assert_eq!(p.extension(), Some(b"txt"));
|
||||
/// assert_eq!(p.extension(), Some(&b"txt"[..]));
|
||||
/// # }
|
||||
/// ```
|
||||
fn extension<'a>(&'a self) -> Option<&'a [u8]> {
|
||||
|
25
src/test/run-pass/issue-17233.rs
Normal file
25
src/test/run-pass/issue-17233.rs
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
const X1: &'static [u8] = &[b'1'];
|
||||
const X2: &'static [u8] = b"1";
|
||||
const X3: &'static [u8; 1] = &[b'1'];
|
||||
const X4: &'static [u8; 1] = b"1";
|
||||
|
||||
static Y1: u8 = X1[0];
|
||||
static Y2: u8 = X2[0];
|
||||
static Y3: u8 = X3[0];
|
||||
static Y4: u8 = X4[0];
|
||||
|
||||
fn main() {
|
||||
assert_eq!(Y1, Y2);
|
||||
assert_eq!(Y1, Y3);
|
||||
assert_eq!(Y1, Y4);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user