diff --git a/src/tests.rs b/src/tests.rs index b053adf..9be3e9b 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -191,3 +191,33 @@ fn is_93 () { assert_eq! (actual, expected); } } + +#[test] +fn value_size () { + // Per https://www.lua.org/doc/jucs05.pdf, + // "The Implementation of Lua 5.0", + // + // Lua's tagged union values are 12-16 bytes on a 32-bit system + // with 64-bit floats + // + // It is very nice if LunarWaveVM is the same or better. + // There is some exploratory things in this test, too + + use std::{ + mem::size_of, + rc::Rc, + }; + + assert! (size_of::> () <= 8); + assert! (size_of::> () <= 8); + + pub enum Value { + Nil, + Boolean (bool), + Float (f64), + String (Rc ), + } + + assert_eq! (size_of:: (), 16); + assert_eq! (size_of:: (), 16); +}