From: Luqman Aden Date: Fri, 5 Dec 2014 19:41:28 +0000 (-0500) Subject: Add tests. X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=6d91419f27b25810f2cfcd263e0e20b62910f4ff;p=rust.git Add tests. --- diff --git a/src/test/run-pass/enum-null-pointer-opt.rs b/src/test/run-pass/enum-null-pointer-opt.rs index 2d4819231fa..afed658a27b 100644 --- a/src/test/run-pass/enum-null-pointer-opt.rs +++ b/src/test/run-pass/enum-null-pointer-opt.rs @@ -34,9 +34,21 @@ fn main() { // Pointers - Box assert_eq!(size_of::>(), size_of::>>()); - // The optimization can't apply to raw pointers assert!(size_of::>() != size_of::<*const int>()); assert!(Some(0 as *const int).is_some()); // Can't collapse None to null + struct Foo { + _a: Box + } + struct Bar(Box); + + // Should apply through structs + assert_eq!(size_of::(), size_of::>()); + assert_eq!(size_of::(), size_of::>()); + // and tuples + assert_eq!(size_of::<(u8, Box)>(), size_of::)>>()); + // and fixed-size arrays + assert_eq!(size_of::<[Box, ..1]>(), size_of::, ..1]>>()); + }