From a7f64ba5171564e307de89f5b130528897887592 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 12 Mar 2017 03:02:14 +0300 Subject: unittests: Move filtering cdefs to main process --- test/unit/set.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/unit/set.lua') diff --git a/test/unit/set.lua b/test/unit/set.lua index 4e66546f32..f3d68c3042 100644 --- a/test/unit/set.lua +++ b/test/unit/set.lua @@ -26,6 +26,22 @@ function Set:new(items) return obj end +function Set:copy() + local obj = {} + obj.nelem = self.nelem + obj.tbl = {} + obj.items = {} + for k, v in pairs(self.tbl) do + obj.tbl[k] = v + end + for k, v in pairs(self.items) do + obj.items[k] = v + end + setmetatable(obj, Set) + obj.__index = Set + return obj +end + -- adds the argument Set to this Set function Set:union(other) for e in other:iterator() do -- cgit