Skip to content

Commit 5357d7f

Browse files
committed
Tests
1 parent aab9c95 commit 5357d7f

17 files changed

+52
-51
lines changed

src/test/bench/shootout-fasta-redux.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl<'a, W: Writer> RepeatFasta<'a, W> {
130130
copy_memory(buf.as_mut_slice(), alu);
131131
let buf_len = buf.len();
132132
copy_memory(buf.slice_mut(alu_len, buf_len),
133-
alu.index(&(0..LINE_LEN)));
133+
&alu[0..LINE_LEN]);
134134

135135
let mut pos = 0;
136136
let mut bytes;
@@ -206,7 +206,7 @@ impl<'a, W: Writer> RandomFasta<'a, W> {
206206
for i in range(0u, chars_left) {
207207
buf[i] = self.nextc();
208208
}
209-
self.out.write(buf.index(&(0..chars_left)))
209+
self.out.write(&buf[0..chars_left])
210210
}
211211
}
212212

src/test/bench/shootout-k-nucleotide.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,14 @@ fn generate_frequencies(mut input: &[u8], frame: uint) -> Table {
247247
// Pull first frame.
248248
for _ in range(0, frame) {
249249
code = code.push_char(input[0]);
250-
input = input.index(&(1..));
250+
input = &input[1..];
251251
}
252252
frequencies.lookup(code, BumpCallback);
253253

254254
while input.len() != 0 && input[0] != ('>' as u8) {
255255
code = code.rotate(input[0], frame);
256256
frequencies.lookup(code, BumpCallback);
257-
input = input.index(&(1..));
257+
input = &input[1..];
258258
}
259259
frequencies
260260
}

src/test/compile-fail/borrowck-array-double-move.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn f() {
1212
let mut a = [box 0i, box 1i];
1313
drop(a[0]);
1414
a[1] = box 2i;
15-
drop(a[0]); //~ ERROR use of moved value: `a.index(&(..))`
15+
drop(a[0]); //~ ERROR use of moved value: `a[..]`
1616
}
1717

1818
fn main() {

src/test/compile-fail/borrowck-vec-pattern-move-tail.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ fn main() {
1414
[1, 2, tail..] => tail,
1515
_ => unreachable!()
1616
};
17-
a[0] = 0; //~ ERROR cannot assign to `a.index(&(..))` because it is borrowed
17+
a[0] = 0; //~ ERROR cannot assign to `a[..]` because it is borrowed
1818
t[0];
1919
}

src/test/compile-fail/packed-struct-generic-transmute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ fn main() {
3434
let foo = Foo { bar: [1u8, 2, 3, 4, 5], baz: 10i32 };
3535
unsafe {
3636
let oof: Oof<[u8; 5], i32> = mem::transmute(foo);
37-
println!("{} {}", oof.rab.index(&FullRange), oof.zab);
37+
println!("{} {}", &oof.rab[], oof.zab);
3838
}
3939
}

src/test/compile-fail/slice-1.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// Test slicing expr.index(&(..)) is an error and gives a helpful error message.
11+
// Test slicing expr[..] is an error and gives a helpful error message.
1212

1313
struct Foo;
1414

1515
fn main() {
1616
let x = Foo;
17-
x.index(&(..)); //~ ERROR incorrect slicing expression: `[..]`
18-
//~^ NOTE use `expr.index(&FullRange)` to construct a slice of the whole of expr
17+
&x[..]; //~ ERROR incorrect slicing expression: `[..]`
18+
//~^ NOTE use `&expr[]` to construct a slice of the whole of expr
1919
}

src/test/compile-fail/slice-2.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ struct Foo;
1616

1717
fn main() {
1818
let x = Foo;
19-
x.index(&FullRange); //~ ERROR cannot take a slice of a value with type `Foo`
20-
x.index(&(Foo..)); //~ ERROR cannot take a slice of a value with type `Foo`
21-
x.index(&(0..Foo)); //~ ERROR cannot take a slice of a value with type `Foo`
22-
x.index(&(Foo..Foo)); //~ ERROR cannot take a slice of a value with type `Foo`
19+
&x[]; //~ ERROR cannot take a slice of a value with type `Foo`
20+
&x[Foo..]; //~ ERROR cannot take a slice of a value with type `Foo`
21+
&x[0..Foo]; //~ ERROR cannot take a slice of a value with type `Foo`
22+
&x[Foo..Foo]; //~ ERROR cannot take a slice of a value with type `Foo`
2323
}

src/test/compile-fail/slice-borrow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ fn main() {
1616
let y;
1717
{
1818
let x: &[int] = &[1, 2, 3, 4, 5]; //~ ERROR borrowed value does not live long enough
19-
y = x.index(&(1..));
19+
y = &x[1..];
2020
}
2121
}

src/test/compile-fail/slice-mut-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ fn main() {
1616
let x: &[int] = &[1, 2, 3, 4, 5];
1717
// Can't mutably slice an immutable slice
1818
let slice: &mut [int] = &mut [0, 1];
19-
x.index(&(2..4)) = slice; //~ ERROR cannot borrow
19+
&mut x[2..4] = slice; //~ ERROR cannot borrow
2020
}

src/test/compile-fail/slice-mut.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
fn main() {
1616
let x: &[int] = &[1, 2, 3, 4, 5];
1717
// Immutable slices are not mutable.
18-
let y: &mut[_] = x.index(&(2..4)); //~ ERROR cannot borrow immutable dereference of `&`-pointer as mutabl
18+
let y: &mut[_] = &x[2..4]; //~ ERROR cannot borrow immutable dereference of `&`-pointer as mutabl
1919
}

src/test/debuginfo/vec-slices.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fn main() {
9393
let empty: &[i64] = &[];
9494
let singleton: &[i64] = &[1];
9595
let multiple: &[i64] = &[2, 3, 4, 5];
96-
let slice_of_slice = multiple.index(&(1..3));
96+
let slice_of_slice = &multiple[1..3];
9797

9898
let padded_tuple: &[(i32, i16)] = &[(6, 7), (8, 9)];
9999

src/test/run-pass/auto-encode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn test_rbml<'a, 'b, A:
3535
let mut rbml_w = EBwriter::Encoder::new(&mut wr);
3636
a1.encode(&mut rbml_w);
3737

38-
let d: serialize::rbml::Doc<'a> = EBDoc::new(wr.index(&FullRange));
38+
let d: serialize::rbml::Doc<'a> = EBDoc::new(&wr[]);
3939
let mut decoder: EBReader::Decoder<'a> = EBreader::Decoder::new(d);
4040
let a2: A = Decodable::decode(&mut decoder);
4141
assert!(*a1 == a2);

src/test/run-pass/deriving-encodable-decodable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn roundtrip<'a, T: Rand + Eq + Encodable<Encoder<'a>> +
5959
let mut w = Vec::new();
6060
let mut e = Encoder::new(&mut w);
6161
obj.encode(&mut e);
62-
let doc = rbml::Doc::new(@w.index(&FullRange));
62+
let doc = rbml::Doc::new(&w[]);
6363
let mut dec = Decoder::new(doc);
6464
let obj2 = Decodable::decode(&mut dec);
6565
assert!(obj == obj2);

src/test/run-pass/issue-8898.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ pub fn main() {
2020
let x = [(), ()];
2121
let slice = x.index(&(0..1));
2222

23-
assert_repr_eq(abc.index(&FullRange), "[1, 2, 3]".to_string());
24-
assert_repr_eq(tf.index(&FullRange), "[true, false]".to_string());
25-
assert_repr_eq(x.index(&FullRange), "[(), ()]".to_string());
23+
assert_repr_eq(&abc[], "[1, 2, 3]".to_string());
24+
assert_repr_eq(&tf[], "[true, false]".to_string());
25+
assert_repr_eq(&x[], "[(), ()]".to_string());
2626
assert_repr_eq(slice, "[()]".to_string());
27-
assert_repr_eq(x.index(&FullRange), "[(), ()]".to_string());
27+
assert_repr_eq(&x[], "[(), ()]".to_string());
2828
}

src/test/run-pass/repeated-vector-syntax.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ pub fn main() {
1616

1717
print!("[");
1818
for xi in x.iter() {
19-
print!("{}, ", (*xi)[]);
19+
print!("{}, ", &xi[]);
2020
}
2121
println!("]");
22-
println!("{}", y.index(&FullRange));
22+
println!("{}", &y[]);
2323
}

src/test/run-pass/slice-2.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,57 +15,57 @@
1515
fn main() {
1616
let x: &[int] = &[1, 2, 3, 4, 5];
1717
let cmp: &[int] = &[1, 2, 3, 4, 5];
18-
assert!(x.index(&FullRange) == cmp);
18+
assert!(&x[] == cmp);
1919
let cmp: &[int] = &[3, 4, 5];
20-
assert!(x.index(&(2..)) == cmp);
20+
assert!(&x[2..] == cmp);
2121
let cmp: &[int] = &[1, 2, 3];
22-
assert!(x.index(&(0..3)) == cmp);
22+
assert!(&x[0..3] == cmp);
2323
let cmp: &[int] = &[2, 3, 4];
24-
assert!(x.index(&(1..4)) == cmp);
24+
assert!(&x[1..4] == cmp);
2525

2626
let x: Vec<int> = vec![1, 2, 3, 4, 5];
2727
let cmp: &[int] = &[1, 2, 3, 4, 5];
28-
assert!(x.index(&FullRange) == cmp);
28+
assert!(&x[] == cmp);
2929
let cmp: &[int] = &[3, 4, 5];
30-
assert!(x.index(&(2..)) == cmp);
30+
assert!(&x[2..] == cmp);
3131
let cmp: &[int] = &[1, 2, 3];
32-
assert!(x.index(&(0..3)) == cmp);
32+
assert!(&x[0..3] == cmp);
3333
let cmp: &[int] = &[2, 3, 4];
34-
assert!(x.index(&(1..4)) == cmp);
34+
assert!(&x[1..4] == cmp);
3535

3636
let x: &mut [int] = &mut [1, 2, 3, 4, 5];
3737
{
3838
let cmp: &mut [int] = &mut [1, 2, 3, 4, 5];
39-
assert!(x[mut] == cmp);
39+
assert!(&mut x[] == cmp);
4040
}
4141
{
4242
let cmp: &mut [int] = &mut [3, 4, 5];
43-
assert!(x[mut 2..] == cmp);
43+
assert!(&mut x[2..] == cmp);
4444
}
4545
{
4646
let cmp: &mut [int] = &mut [1, 2, 3];
47-
assert!(x[mut ..3] == cmp);
47+
assert!(&mut x[..3] == cmp);
4848
}
4949
{
5050
let cmp: &mut [int] = &mut [2, 3, 4];
51-
assert!(x[mut 1..4] == cmp);
51+
assert!(&mut x[1..4] == cmp);
5252
}
5353

5454
let mut x: Vec<int> = vec![1, 2, 3, 4, 5];
5555
{
5656
let cmp: &mut [int] = &mut [1, 2, 3, 4, 5];
57-
assert!(x[mut] == cmp);
57+
assert!(&mut x[] == cmp);
5858
}
5959
{
6060
let cmp: &mut [int] = &mut [3, 4, 5];
61-
assert!(x[mut 2..] == cmp);
61+
assert!(&mut x[2..] == cmp);
6262
}
6363
{
6464
let cmp: &mut [int] = &mut [1, 2, 3];
65-
assert!(x[mut ..3] == cmp);
65+
assert!(&mut x[..3] == cmp);
6666
}
6767
{
6868
let cmp: &mut [int] = &mut [2, 3, 4];
69-
assert!(x[mut 1..4] == cmp);
69+
assert!(&mut x[1..4] == cmp);
7070
}
7171
}

src/test/run-pass/slice.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#![feature(slicing_syntax)]
1414

1515
extern crate core;
16-
use core::ops::{Slice,SliceMut};
16+
use core::ops::{Index, Range, RangeTo, RangeFrom, FullRange};
1717

1818
static mut COUNT: uint = 0;
1919

@@ -56,16 +56,17 @@ impl SliceMut<Foo, Foo> for Foo {
5656
self
5757
}
5858
}
59+
5960
fn main() {
6061
let mut x = Foo;
61-
x.index(&FullRange);
62-
x.index(&(Foo..));
63-
x.index(&(0..Foo));
64-
x.index(&(Foo..Foo));
65-
x[mut];
66-
x[mut Foo..];
67-
x[mut ..Foo];
68-
x[mut Foo..Foo];
62+
&x[];
63+
&x[Foo..];
64+
&x[0..Foo];
65+
&x[Foo..Foo];
66+
&mut x[];
67+
&mut x[Foo..];
68+
&mut x[..Foo];
69+
&mut x[Foo..Foo];
6970
unsafe {
7071
assert!(COUNT == 8);
7172
}

0 commit comments

Comments
 (0)