From d36a31e6739bcd39c84f637344227af87cfd0ee5 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 18 Jul 2019 14:58:15 -0300 Subject: Reviving HARDMEMTESTS This commit brings a new implementation for HARDMEMTESTS, which forces an emergency GC whenever possible. It also fixes some issues detected with this option: - A small bug in lvm.c: a closure could be collected by an emergency GC while being initialized. - Some tests: a memory address can be immediatly reused after a GC; for instance, two consecutive '{}' expressions can return exactly the same address, if the first one is not anchored. --- testes/api.lua | 7 +++++-- testes/strings.lua | 11 ++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'testes') diff --git a/testes/api.lua b/testes/api.lua index 8f4e89ac..5da03641 100644 --- a/testes/api.lua +++ b/testes/api.lua @@ -354,8 +354,11 @@ assert(to("topointer", nil) == null) assert(to("topointer", "abc") ~= null) assert(to("topointer", string.rep("x", 10)) == to("topointer", string.rep("x", 10))) -- short strings -assert(to("topointer", string.rep("x", 300)) ~= - to("topointer", string.rep("x", 300))) -- long strings +do -- long strings + local s1 = string.rep("x", 300) + local s2 = string.rep("x", 300) + assert(to("topointer", s1) ~= to("topointer", s2)) +end assert(to("topointer", T.pushuserdata(20)) ~= null) assert(to("topointer", io.read) ~= null) -- light C function assert(to("topointer", hfunc) ~= null) -- "heavy" C function diff --git a/testes/strings.lua b/testes/strings.lua index 1b2b570e..2540fdef 100644 --- a/testes/strings.lua +++ b/testes/strings.lua @@ -163,11 +163,16 @@ do -- tests for '%p' format assert(string.format("%p", 4) == null) assert(string.format("%p", print) ~= null) assert(string.format("%p", coroutine.running()) ~= null) - assert(string.format("%p", {}) ~= string.format("%p", {})) + do + local t1 = {}; local t2 = {} + assert(string.format("%p", t1) ~= string.format("%p", t2)) + end assert(string.format("%p", string.rep("a", 10)) == string.format("%p", string.rep("a", 10))) -- short strings - assert(string.format("%p", string.rep("a", 300)) ~= - string.format("%p", string.rep("a", 300))) -- long strings + do -- long strings + local s1 = string.rep("a", 300); local s2 = string.rep("a", 300) + assert(string.format("%p", s1) ~= string.format("%p", s2)) + end assert(#string.format("%90p", {}) == 90) end -- cgit v1.2.3-55-g6feb