]> git.lizzy.rs Git - rust.git/commitdiff
Tests
authorNick Cameron <ncameron@mozilla.com>
Sat, 3 Jan 2015 00:34:13 +0000 (13:34 +1300)
committerNick Cameron <ncameron@mozilla.com>
Tue, 6 Jan 2015 21:49:00 +0000 (10:49 +1300)
17 files changed:
src/test/bench/shootout-fasta-redux.rs
src/test/bench/shootout-k-nucleotide.rs
src/test/compile-fail/borrowck-array-double-move.rs
src/test/compile-fail/borrowck-vec-pattern-move-tail.rs
src/test/compile-fail/packed-struct-generic-transmute.rs
src/test/compile-fail/slice-1.rs
src/test/compile-fail/slice-2.rs
src/test/compile-fail/slice-borrow.rs
src/test/compile-fail/slice-mut-2.rs
src/test/compile-fail/slice-mut.rs
src/test/debuginfo/vec-slices.rs
src/test/run-pass/auto-encode.rs
src/test/run-pass/deriving-encodable-decodable.rs
src/test/run-pass/issue-8898.rs
src/test/run-pass/repeated-vector-syntax.rs
src/test/run-pass/slice-2.rs
src/test/run-pass/slice.rs

index 7109dc7948ed5ca9635646163201a0ac9bb3805a..9a6152dc13c9d4429ef36f97fd12ac65b02be735 100644 (file)
@@ -130,7 +130,7 @@ fn make(&mut self, n: uint) -> IoResult<()> {
         copy_memory(buf.as_mut_slice(), alu);
         let buf_len = buf.len();
         copy_memory(buf.slice_mut(alu_len, buf_len),
-                    alu.index(&(0..LINE_LEN)));
+                    &alu[0..LINE_LEN]);
 
         let mut pos = 0;
         let mut bytes;
@@ -206,7 +206,7 @@ fn make(&mut self, n: uint) -> IoResult<()> {
         for i in range(0u, chars_left) {
             buf[i] = self.nextc();
         }
-        self.out.write(buf.index(&(0..chars_left)))
+        self.out.write(&buf[0..chars_left])
     }
 }
 
index 65127868b8788f3fd5f4f66121b0772fd76234de..4f71ea8cbe997d0ae8dbb1631d16660cc7fedff2 100644 (file)
@@ -247,14 +247,14 @@ fn generate_frequencies(mut input: &[u8], frame: uint) -> Table {
     // Pull first frame.
     for _ in range(0, frame) {
         code = code.push_char(input[0]);
-        input = input.index(&(1..));
+        input = &input[1..];
     }
     frequencies.lookup(code, BumpCallback);
 
     while input.len() != 0 && input[0] != ('>' as u8) {
         code = code.rotate(input[0], frame);
         frequencies.lookup(code, BumpCallback);
-        input = input.index(&(1..));
+        input = &input[1..];
     }
     frequencies
 }
index 79a6dd005a7acca3493a11a845df5f758a7872ec..c872d0dc4b9c4aa5e0ada23002d18b5231a506d4 100644 (file)
@@ -12,7 +12,7 @@ fn f() {
     let mut a = [box 0i, box 1i];
     drop(a[0]);
     a[1] = box 2i;
-    drop(a[0]); //~ ERROR use of moved value: `a.index(&(..))`
+    drop(a[0]); //~ ERROR use of moved value: `a[..]`
 }
 
 fn main() {
index b328ea722a09a8741ffb5fb1d737a16ce4ce5e05..cb8762f44fb7932ceef6283b1648635788e741cf 100644 (file)
@@ -14,6 +14,6 @@ fn main() {
         [1, 2, tail..] => tail,
         _ => unreachable!()
     };
-    a[0] = 0; //~ ERROR cannot assign to `a.index(&(..))` because it is borrowed
+    a[0] = 0; //~ ERROR cannot assign to `a[..]` because it is borrowed
     t[0];
 }
index 0d8631788a9e1855ed207e352a257bc058121135..38177d076455d5bae99415e117762b32f291e42c 100644 (file)
@@ -34,6 +34,6 @@ fn main() {
     let foo = Foo { bar: [1u8, 2, 3, 4, 5], baz: 10i32 };
     unsafe {
         let oof: Oof<[u8; 5], i32> = mem::transmute(foo);
-        println!("{} {}", oof.rab.index(&FullRange), oof.zab);
+        println!("{} {}", &oof.rab[], oof.zab);
     }
 }
index 26281c2e90754e6738352d1d99c06da0ff116944..903760caf1a1eb64bf73184e490c8ed8e24e1d72 100644 (file)
@@ -8,12 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// Test slicing expr.index(&(..)) is an error and gives a helpful error message.
+// Test slicing expr[..] is an error and gives a helpful error message.
 
 struct Foo;
 
 fn main() {
     let x = Foo;
-    x.index(&(..)); //~ ERROR incorrect slicing expression: `[..]`
-    //~^ NOTE use `expr.index(&FullRange)` to construct a slice of the whole of expr
+    &x[..]; //~ ERROR incorrect slicing expression: `[..]`
+    //~^ NOTE use `&expr[]` to construct a slice of the whole of expr
 }
index 1e850d6307eb4e972581e390bf9e6a01d6b1eb1d..9ee700225456bfca4525a44fd3f88351deb84d72 100644 (file)
@@ -16,8 +16,8 @@
 
 fn main() {
     let x = Foo;
-    x.index(&FullRange); //~ ERROR cannot take a slice of a value with type `Foo`
-    x.index(&(Foo..)); //~ ERROR cannot take a slice of a value with type `Foo`
-    x.index(&(0..Foo)); //~ ERROR cannot take a slice of a value with type `Foo`
-    x.index(&(Foo..Foo)); //~ ERROR cannot take a slice of a value with type `Foo`
+    &x[]; //~ ERROR cannot take a slice of a value with type `Foo`
+    &x[Foo..]; //~ ERROR cannot take a slice of a value with type `Foo`
+    &x[0..Foo]; //~ ERROR cannot take a slice of a value with type `Foo`
+    &x[Foo..Foo]; //~ ERROR cannot take a slice of a value with type `Foo`
 }
index 7839013ee2224f9fdb95316ffc61215d8a302b5b..aab187f97515a0c693e88b55891a5374963b366d 100644 (file)
@@ -16,6 +16,6 @@ fn main() {
     let y;
     {
         let x: &[int] = &[1, 2, 3, 4, 5]; //~ ERROR borrowed value does not live long enough
-        y = x.index(&(1..));
+        y = &x[1..];
     }
 }
index b7d7ea67f067c975b8421dd5682c54c91a5b9ff0..b34c9a49268b58428fb7384ddf32b91a98266461 100644 (file)
@@ -16,5 +16,5 @@ fn main() {
     let x: &[int] = &[1, 2, 3, 4, 5];
     // Can't mutably slice an immutable slice
     let slice: &mut [int] = &mut [0, 1];
-    x.index(&(2..4)) = slice; //~ ERROR cannot borrow
+    &mut x[2..4] = slice; //~ ERROR cannot borrow
 }
index 3d621580f5d4ae1d43dab3479e8324d22634ab18..e7353dfbcd0e4a761731999d2b179ce99ae17a70 100644 (file)
@@ -15,5 +15,5 @@
 fn main() {
     let x: &[int] = &[1, 2, 3, 4, 5];
     // Immutable slices are not mutable.
-    let y: &mut[_] = x.index(&(2..4)); //~ ERROR cannot borrow immutable dereference of `&`-pointer as mutabl
+    let y: &mut[_] = &x[2..4]; //~ ERROR cannot borrow immutable dereference of `&`-pointer as mutabl
 }
index f2cb5f82a6c4c93ee67b382dc0e99f86a81c2d1a..14f1dbb9d651cb88fbffce15e5e7b8b4f269735e 100644 (file)
@@ -93,7 +93,7 @@ fn main() {
     let empty: &[i64] = &[];
     let singleton: &[i64] = &[1];
     let multiple: &[i64] = &[2, 3, 4, 5];
-    let slice_of_slice = multiple.index(&(1..3));
+    let slice_of_slice = &multiple[1..3];
 
     let padded_tuple: &[(i32, i16)] = &[(6, 7), (8, 9)];
 
index 6eb4bc352d1944c82dddb8820cc3019fb29363d4..9b030de998373be9b62b6b9542d8de7fbb5c4a11 100644 (file)
@@ -35,7 +35,7 @@ fn test_rbml<'a, 'b, A:
     let mut rbml_w = EBwriter::Encoder::new(&mut wr);
     a1.encode(&mut rbml_w);
 
-    let d: serialize::rbml::Doc<'a> = EBDoc::new(wr.index(&FullRange));
+    let d: serialize::rbml::Doc<'a> = EBDoc::new(&wr[]);
     let mut decoder: EBReader::Decoder<'a> = EBreader::Decoder::new(d);
     let a2: A = Decodable::decode(&mut decoder);
     assert!(*a1 == a2);
index 459060d349ce4935e17f54d4282ee9888cbdf8e0..01814e8eab7909cd948c87b8935472f67d1fff35 100644 (file)
@@ -59,7 +59,7 @@ fn roundtrip<'a, T: Rand + Eq + Encodable<Encoder<'a>> +
     let mut w = Vec::new();
     let mut e = Encoder::new(&mut w);
     obj.encode(&mut e);
-    let doc = rbml::Doc::new(@w.index(&FullRange));
+    let doc = rbml::Doc::new(&w[]);
     let mut dec = Decoder::new(doc);
     let obj2 = Decodable::decode(&mut dec);
     assert!(obj == obj2);
index 706f640c18d951852beb74f01c1f9ef283357ef3..5b90878aa285419570c37bfbe6f59ed80becfcf9 100644 (file)
@@ -20,9 +20,9 @@ pub fn main() {
     let x  = [(), ()];
     let slice = x.index(&(0..1));
 
-    assert_repr_eq(abc.index(&FullRange), "[1, 2, 3]".to_string());
-    assert_repr_eq(tf.index(&FullRange), "[true, false]".to_string());
-    assert_repr_eq(x.index(&FullRange), "[(), ()]".to_string());
+    assert_repr_eq(&abc[], "[1, 2, 3]".to_string());
+    assert_repr_eq(&tf[], "[true, false]".to_string());
+    assert_repr_eq(&x[], "[(), ()]".to_string());
     assert_repr_eq(slice, "[()]".to_string());
-    assert_repr_eq(x.index(&FullRange), "[(), ()]".to_string());
+    assert_repr_eq(&x[], "[(), ()]".to_string());
 }
index e5a617634632f911963a2a9c8f4e22dabd602858..e854a7326329c8d6d0e977230224b3dc9285f578 100644 (file)
@@ -16,8 +16,8 @@ pub fn main() {
 
     print!("[");
     for xi in x.iter() {
-        print!("{}, ", (*xi)[]);
+        print!("{}, ", &xi[]);
     }
     println!("]");
-    println!("{}", y.index(&FullRange));
+    println!("{}", &y[]);
 }
index 7be05b9d71e538ca4fa709fed0424269e05d7dbd..05f318b53c2e543404988c2c536e40751601d4ed 100644 (file)
 fn main() {
     let x: &[int] = &[1, 2, 3, 4, 5];
     let cmp: &[int] = &[1, 2, 3, 4, 5];
-    assert!(x.index(&FullRange) == cmp);
+    assert!(&x[] == cmp);
     let cmp: &[int] = &[3, 4, 5];
-    assert!(x.index(&(2..)) == cmp);
+    assert!(&x[2..] == cmp);
     let cmp: &[int] = &[1, 2, 3];
-    assert!(x.index(&(0..3)) == cmp);
+    assert!(&x[0..3] == cmp);
     let cmp: &[int] = &[2, 3, 4];
-    assert!(x.index(&(1..4)) == cmp);
+    assert!(&x[1..4] == cmp);
 
     let x: Vec<int> = vec![1, 2, 3, 4, 5];
     let cmp: &[int] = &[1, 2, 3, 4, 5];
-    assert!(x.index(&FullRange) == cmp);
+    assert!(&x[] == cmp);
     let cmp: &[int] = &[3, 4, 5];
-    assert!(x.index(&(2..)) == cmp);
+    assert!(&x[2..] == cmp);
     let cmp: &[int] = &[1, 2, 3];
-    assert!(x.index(&(0..3)) == cmp);
+    assert!(&x[0..3] == cmp);
     let cmp: &[int] = &[2, 3, 4];
-    assert!(x.index(&(1..4)) == cmp);
+    assert!(&x[1..4] == cmp);
 
     let x: &mut [int] = &mut [1, 2, 3, 4, 5];
     {
         let cmp: &mut [int] = &mut [1, 2, 3, 4, 5];
-        assert!(x[mut] == cmp);
+        assert!(&mut x[] == cmp);
     }
     {
         let cmp: &mut [int] = &mut [3, 4, 5];
-        assert!(x[mut 2..] == cmp);
+        assert!(&mut x[2..] == cmp);
     }
     {
         let cmp: &mut [int] = &mut [1, 2, 3];
-        assert!(x[mut ..3] == cmp);
+        assert!(&mut x[..3] == cmp);
     }
     {
         let cmp: &mut [int] = &mut [2, 3, 4];
-        assert!(x[mut 1..4] == cmp);
+        assert!(&mut x[1..4] == cmp);
     }
 
     let mut x: Vec<int> = vec![1, 2, 3, 4, 5];
     {
         let cmp: &mut [int] = &mut [1, 2, 3, 4, 5];
-        assert!(x[mut] == cmp);
+        assert!(&mut x[] == cmp);
     }
     {
         let cmp: &mut [int] = &mut [3, 4, 5];
-        assert!(x[mut 2..] == cmp);
+        assert!(&mut x[2..] == cmp);
     }
     {
         let cmp: &mut [int] = &mut [1, 2, 3];
-        assert!(x[mut ..3] == cmp);
+        assert!(&mut x[..3] == cmp);
     }
     {
         let cmp: &mut [int] = &mut [2, 3, 4];
-        assert!(x[mut 1..4] == cmp);
+        assert!(&mut x[1..4] == cmp);
     }
 }
index c6dfc8dfd23a3dfcf0ea5dad93bedb16f992caba..e039886022c27d3ed94f8b92d4f505ba20be7360 100644 (file)
@@ -13,7 +13,7 @@
 #![feature(slicing_syntax)]
 
 extern crate core;
-use core::ops::{Slice,SliceMut};
+use core::ops::{Index, Range, RangeTo, RangeFrom, FullRange};
 
 static mut COUNT: uint = 0;
 
@@ -56,16 +56,17 @@ fn slice_or_fail_mut<'a>(&'a mut self, _from: &Foo, _to: &Foo) -> &'a mut Foo {
         self
     }
 }
+
 fn main() {
     let mut x = Foo;
-    x.index(&FullRange);
-    x.index(&(Foo..));
-    x.index(&(0..Foo));
-    x.index(&(Foo..Foo));
-    x[mut];
-    x[mut Foo..];
-    x[mut ..Foo];
-    x[mut Foo..Foo];
+    &x[];
+    &x[Foo..];
+    &x[0..Foo];
+    &x[Foo..Foo];
+    &mut x[];
+    &mut x[Foo..];
+    &mut x[..Foo];
+    &mut x[Foo..Foo];
     unsafe {
         assert!(COUNT == 8);
     }