From 1d813b0f44b89047a65eb52fd99455817fe9799b Mon Sep 17 00:00:00 2001 From: _ <_@_> Date: Tue, 26 Sep 2023 20:41:47 -0500 Subject: [PATCH] :white_check_mark: test: add tables test --- src/tests.rs | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/tests.rs b/src/tests.rs index 6b19036..1ad7ba3 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -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::> () <= 8); assert! (size_of::> () <= 8);