test: add tables test

main
_ 2023-09-26 20:41:47 -05:00
parent 9d29aeb43b
commit 1d813b0f44
1 changed files with 33 additions and 3 deletions

View File

@ -243,6 +243,38 @@ fn is_93 () {
assert_eq! (run (&["", "94"], &chunk), vec! [Value::from (1)]);
}
#[test]
fn tables_1 () {
// I don't capture stdout yet, but I can at least make sure basic table
// operations don't crash
let src = r#"
print " 1"
print (nil)
print (false)
print (true)
print (1993)
print (1993.00)
print "Hello."
print " 2"
local t = {}
print (t)
print (t [1])
t [1] = "asdf"
print (t [1])
t.x = 1993
print (t.x)
t.t = { 3.14159 }
print (t ["t"][1])
"#;
run_source (&[], src);
}
#[test]
fn value_size () {
// Per https://www.lua.org/doc/jucs05.pdf,
@ -254,9 +286,7 @@ fn value_size () {
// It would be nice if LunarWaveVM is the same or better.
// There are some exploratory things in this test, too
use std::{
mem::size_of,
};
use std::mem::size_of;
assert! (size_of::<Box <()>> () <= 8);
assert! (size_of::<std::rc::Rc <()>> () <= 8);