summaryrefslogtreecommitdiffstats
path: root/tests/ui/consts/const-vecs-and-slices.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/consts/const-vecs-and-slices.rs')
-rw-r--r--tests/ui/consts/const-vecs-and-slices.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/ui/consts/const-vecs-and-slices.rs b/tests/ui/consts/const-vecs-and-slices.rs
new file mode 100644
index 000000000..1cdc33b7a
--- /dev/null
+++ b/tests/ui/consts/const-vecs-and-slices.rs
@@ -0,0 +1,23 @@
+// run-pass
+#![allow(non_upper_case_globals)]
+
+static x : [isize; 4] = [1,2,3,4];
+static y : &'static [isize] = &[1,2,3,4];
+static z : &'static [isize; 4] = &[1,2,3,4];
+static zz : &'static [isize] = &[1,2,3,4];
+
+pub fn main() {
+ println!("{}", x[1]);
+ println!("{}", y[1]);
+ println!("{}", z[1]);
+ println!("{}", zz[1]);
+ assert_eq!(x[1], 2);
+ assert_eq!(x[3], 4);
+ assert_eq!(x[3], y[3]);
+ assert_eq!(z[1], 2);
+ assert_eq!(z[3], 4);
+ assert_eq!(z[3], y[3]);
+ assert_eq!(zz[1], 2);
+ assert_eq!(zz[3], 4);
+ assert_eq!(zz[3], y[3]);
+}