From 03d9415399bbfc5afbb35521391cd6d05fec6c0d Mon Sep 17 00:00:00 2001 From: Gordon Hecker Date: Mon, 4 Jan 2010 15:27:25 +0100 Subject: [PATCH] env: implement get_dict() Signed-off-by: Gordon Hecker --- local/environment.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/local/environment.lua b/local/environment.lua index 5642b41..d3a20b4 100644 --- a/local/environment.lua +++ b/local/environment.lua @@ -51,6 +51,15 @@ function iter(env) return _iter, env.sorted end +--- return a (copy of the) dictionary +function get_dict(env) + local dict = {} + for k,v in env:iter() do + dict[k] = v + end + return dict +end + function unittest(env) local function p(...) --print(...) @@ -103,4 +112,7 @@ function unittest(env) p(var, val) end assert(e5:id() == "404AA226CF94A483FD61878682F8E2759998B197") + + local dict = e5:get_dict() + assert(dict['var'] == "val4") end -- 2.39.5