aboutsummaryrefslogtreecommitdiff
path: root/deep_test/deeptest.lua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--deep_test/deeptest.lua34
1 files changed, 29 insertions, 5 deletions
diff --git a/deep_test/deeptest.lua b/deep_test/deeptest.lua
index 89e6f0d..99cf1e4 100644
--- a/deep_test/deeptest.lua
+++ b/deep_test/deeptest.lua
@@ -4,8 +4,11 @@ local l = lanes.linda "my linda"
4-- we will transfer userdata created by this module, so we need to make Lanes aware of it 4-- we will transfer userdata created by this module, so we need to make Lanes aware of it
5local dt = lanes.require "deep_test" 5local dt = lanes.require "deep_test"
6 6
7local test_deep = true 7-- set DEEP to any non-false value to run the Deep Userdata tests. "gc" selects a special test for debug purposes
8local test_clonable = true 8DEEP = DEEP or true
9-- set CLONABLE to any non-false value to run the Clonable Userdata tests
10CLONABLE = CLONABLE or true
11
9-- lua 5.1->5.2 support a single table uservalue 12-- lua 5.1->5.2 support a single table uservalue
10-- lua 5.3->5.4 supports an arbitrary type uservalue 13-- lua 5.3->5.4 supports an arbitrary type uservalue
11local test_uvtype = (_VERSION == "Lua 5.4") and "function" or (_VERSION == "Lua 5.3") and "string" or "table" 14local test_uvtype = (_VERSION == "Lua 5.4") and "function" or (_VERSION == "Lua 5.3") and "string" or "table"
@@ -86,13 +89,34 @@ local performTest = function( obj_)
86 printDeep( "from lane:", h[1], h[2]) 89 printDeep( "from lane:", h[1], h[2])
87end 90end
88 91
89if test_deep then 92if DEEP then
90 print "================================================================" 93 print "================================================================"
91 print "DEEP" 94 print "DEEP"
92 performTest( dt.new_deep(nupvals)) 95 local d = dt.new_deep(nupvals)
96 if DEEP == "gc" then
97 local thrasher = function(repeat_, size_)
98 print "in thrasher"
99 -- result is a table of repeat_ tables, each containing size_ entries
100 local result = {}
101 for i = 1, repeat_ do
102 local batch_values = {}
103 for j = 1, size_ do
104 table.insert(batch_values, j)
105 end
106 table.insert(result, batch_values)
107 end
108 print "thrasher done"
109 return result
110 end
111 -- have the object call the function from inside one of its functions, to detect if it gets collected from there (while in use!)
112 local r = d:invoke(thrasher, REPEAT or 10, SIZE or 10)
113 print("invoke -> ", tostring(r))
114 else
115 performTest(d)
116 end
93end 117end
94 118
95if test_clonable then 119if CLONABLE then
96 print "================================================================" 120 print "================================================================"
97 print "CLONABLE" 121 print "CLONABLE"
98 performTest( dt.new_clonable(nupvals)) 122 performTest( dt.new_clonable(nupvals))