Skip to content

Commit 2788f66

Browse files
committed
Add some runtime sanity checks
1 parent d6fc3e1 commit 2788f66

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/test/ui/const-eval/strlen.rs

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

11-
// compile-pass
11+
// run-pass
1212

1313
#![feature(const_str_len, const_str_as_bytes)]
1414

15-
#![crate_type = "lib"]
16-
1715
const S: &str = "foo";
1816
pub const B: &[u8] = S.as_bytes();
1917

@@ -24,3 +22,12 @@ pub fn foo() -> [u8; S.len()] {
2422
}
2523
buf
2624
}
25+
26+
fn main() {
27+
assert_eq!(&foo()[..], b"foo");
28+
assert_eq!(foo().len(), S.len());
29+
const LEN: usize = S.len();
30+
assert_eq!(LEN, S.len());
31+
assert_eq!(B, foo());
32+
assert_eq!(B, b"foo");
33+
}

0 commit comments

Comments
 (0)