✅ test: measure size of my Value compared to PUC Lua
(mine's bigger sadly, like 40 bytes)main
parent
bc15781457
commit
f29eaac1d0
30
src/tests.rs
30
src/tests.rs
|
@ -191,3 +191,33 @@ fn is_93 () {
|
||||||
assert_eq! (actual, expected);
|
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::<Box <()>> () <= 8);
|
||||||
|
assert! (size_of::<std::rc::Rc <()>> () <= 8);
|
||||||
|
|
||||||
|
pub enum Value {
|
||||||
|
Nil,
|
||||||
|
Boolean (bool),
|
||||||
|
Float (f64),
|
||||||
|
String (Rc <String>),
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_eq! (size_of::<Value> (), 16);
|
||||||
|
assert_eq! (size_of::<crate::state::Value> (), 16);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue