From 2788f66ab079e76ee5c73ba1651103c557be7a61 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Sun, 20 May 2018 20:25:28 +0200 Subject: [PATCH] Add some runtime sanity checks --- src/test/ui/const-eval/strlen.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/test/ui/const-eval/strlen.rs b/src/test/ui/const-eval/strlen.rs index bdadf5dd5e14a..dfa41c491fa89 100644 --- a/src/test/ui/const-eval/strlen.rs +++ b/src/test/ui/const-eval/strlen.rs @@ -8,12 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// compile-pass +// run-pass #![feature(const_str_len, const_str_as_bytes)] -#![crate_type = "lib"] - const S: &str = "foo"; pub const B: &[u8] = S.as_bytes(); @@ -24,3 +22,12 @@ pub fn foo() -> [u8; S.len()] { } buf } + +fn main() { + assert_eq!(&foo()[..], b"foo"); + assert_eq!(foo().len(), S.len()); + const LEN: usize = S.len(); + assert_eq!(LEN, S.len()); + assert_eq!(B, foo()); + assert_eq!(B, b"foo"); +}