Skip to content

Commit

Permalink
Add and fix more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Mar 17, 2015
1 parent 1e9bef9 commit b98255c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/libcore/result.rs
Expand Up @@ -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;
///
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/old_path/mod.rs
Expand Up @@ -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]>;
Expand Down Expand Up @@ -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]> {
Expand Down Expand Up @@ -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]> {
Expand Down
25 changes: 25 additions & 0 deletions src/test/run-pass/issue-17233.rs
@@ -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);
}

0 comments on commit b98255c

Please sign in to comment.