diff options
| author | Luqman Aden <me@luqman.ca> | 2014-07-04 14:54:23 -0700 |
|---|---|---|
| committer | Luqman Aden <me@luqman.ca> | 2014-07-04 16:06:21 -0700 |
| commit | f48cc740017bac1214030300435dfa95dbaa220b (patch) | |
| tree | cfa852966c056f387aa4d8d839ddf2ac197c16db | |
| parent | 31570cb22e8ab60233956368bad710f987a64b06 (diff) | |
| download | rust-f48cc740017bac1214030300435dfa95dbaa220b.tar.gz rust-f48cc740017bac1214030300435dfa95dbaa220b.zip | |
Add tests for null pointer opt.
| -rw-r--r-- | src/test/run-pass/enum-null-pointer-opt.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/test/run-pass/enum-null-pointer-opt.rs b/src/test/run-pass/enum-null-pointer-opt.rs new file mode 100644 index 00000000000..bd9dfc1e449 --- /dev/null +++ b/src/test/run-pass/enum-null-pointer-opt.rs @@ -0,0 +1,40 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +use std::gc::Gc; +use std::mem::size_of; + +trait Trait {} + +fn main() { + // Closures - || / proc() + assert_eq!(size_of::<proc()>(), size_of::<Option<proc()>>()); + assert_eq!(size_of::<||>(), size_of::<Option<||>>()); + + // Functions + assert_eq!(size_of::<fn(int)>(), size_of::<Option<fn(int)>>()); + assert_eq!(size_of::<extern "C" fn(int)>(), size_of::<Option<extern "C" fn(int)>>()); + + // Slices - &str / &[T] / &mut [T] + assert_eq!(size_of::<&str>(), size_of::<Option<&str>>()); + assert_eq!(size_of::<&[int]>(), size_of::<Option<&[int]>>()); + assert_eq!(size_of::<&mut [int]>(), size_of::<Option<&mut [int]>>()); + + // Traits - Box<Trait> / &Trait / &mut Trait + assert_eq!(size_of::<Box<Trait>>(), size_of::<Option<Box<Trait>>>()); + assert_eq!(size_of::<&Trait>(), size_of::<Option<&Trait>>()); + assert_eq!(size_of::<&mut Trait>(), size_of::<Option<&mut Trait>>()); + + // Pointers - Box<T> / Gc<T> + assert_eq!(size_of::<Box<int>>(), size_of::<Option<Box<int>>>()); + assert_eq!(size_of::<Gc<int>>(), size_of::<Option<Gc<int>>>()); + +} |
