From 0d5e1098bc084f21046ef4f68c37935585cd0ba5 Mon Sep 17 00:00:00 2001 From: _ <_@_> Date: Tue, 26 Sep 2023 20:47:47 -0500 Subject: [PATCH] :white_check_mark: test: found a bug in my tables impl --- src/tests.rs | 15 +++++++++++++++ test_vectors/hello.lua | 19 +++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/tests.rs b/src/tests.rs index 1ad7ba3..6d5202e 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -275,6 +275,21 @@ fn tables_1 () { run_source (&[], src); } +#[test] +fn tables_2 () { + let src = r#" + print " 3" + + local c = {} + local a = { c } + print (a [1]) + c [2] = "eee" + print (a [2]) + "#; + + run_source (&[], src); +} + #[test] fn value_size () { // Per https://www.lua.org/doc/jucs05.pdf, diff --git a/test_vectors/hello.lua b/test_vectors/hello.lua index fb08d11..4d882e8 100644 --- a/test_vectors/hello.lua +++ b/test_vectors/hello.lua @@ -1,4 +1,4 @@ -print "# 1" +print " 1" print (nil) print (false) @@ -7,7 +7,7 @@ print (1993) print (1993.00) print "Hello." -print "# 2" +print " 2" local t = {} print (t) @@ -20,3 +20,18 @@ print (t.x) t.t = { 3.14159 } print (t ["t"][1]) +print " 3" + +local c = {} +c [1] = "ddd" + +local a = { c } +local b = { c } + +print (a [1]) +print (b [1]) + +c [2] = "eee" + +print (a [2]) +print (b [2])