about summary refs log tree commit diff
path: root/src/liballoc/tests
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-07-28 16:25:04 +0800
committerGitHub <noreply@github.com>2018-07-28 16:25:04 +0800
commit2c088cb03ed3da331e9c4535027be74feb5fb581 (patch)
tree136f5cae21e63601b6834e7de27e13da7a7fbc33 /src/liballoc/tests
parentc9347f7f4980552c4c7611d4d400219dd24411f5 (diff)
parentb326e71b7967f5c67d7bd3d07b690bc1c17d055c (diff)
downloadrust-2c088cb03ed3da331e9c4535027be74feb5fb581.tar.gz
rust-2c088cb03ed3da331e9c4535027be74feb5fb581.zip
Rollup merge of #52769 - sinkuu:stray_test, r=alexcrichton
Incorporate a stray test

`liballoc/repeat-generic-slice.rs` doesn't seem to be tested (I think it was intended to be placed in `run-pass`). This PR incorporates the test into `liballoc/tests`.
Diffstat (limited to 'src/liballoc/tests')
-rw-r--r--src/liballoc/tests/lib.rs1
-rw-r--r--src/liballoc/tests/slice.rs11
2 files changed, 12 insertions, 0 deletions
diff --git a/src/liballoc/tests/lib.rs b/src/liballoc/tests/lib.rs
index 91bc778ad4c..618aff963f2 100644
--- a/src/liballoc/tests/lib.rs
+++ b/src/liballoc/tests/lib.rs
@@ -24,6 +24,7 @@
 #![feature(try_reserve)]
 #![feature(unboxed_closures)]
 #![feature(exact_chunks)]
+#![feature(repeat_generic_slice)]
 
 extern crate alloc_system;
 extern crate core;
diff --git a/src/liballoc/tests/slice.rs b/src/liballoc/tests/slice.rs
index 3b7eec38609..df5e18a9a18 100644
--- a/src/liballoc/tests/slice.rs
+++ b/src/liballoc/tests/slice.rs
@@ -1529,3 +1529,14 @@ fn panic_safe() {
         }
     }
 }
+
+#[test]
+fn repeat_generic_slice() {
+    assert_eq!([1, 2].repeat(2), vec![1, 2, 1, 2]);
+    assert_eq!([1, 2, 3, 4].repeat(0), vec![]);
+    assert_eq!([1, 2, 3, 4].repeat(1), vec![1, 2, 3, 4]);
+    assert_eq!(
+        [1, 2, 3, 4].repeat(3),
+        vec![1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
+    );
+}