aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr/GuiLua/test.lua
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-03-29 23:42:54 +1000
committerDavid Walter Seikel2014-03-29 23:42:54 +1000
commit075d853a95e07530a9f5437dbbec36a3afe1621f (patch)
tree18072d511beefc5227261ad0a360834501ba71d9 /ClientHamr/GuiLua/test.lua
parentAdd my usual table printer. (diff)
downloadSledjHamr-075d853a95e07530a9f5437dbbec36a3afe1621f.zip
SledjHamr-075d853a95e07530a9f5437dbbec36a3afe1621f.tar.gz
SledjHamr-075d853a95e07530a9f5437dbbec36a3afe1621f.tar.bz2
SledjHamr-075d853a95e07530a9f5437dbbec36a3afe1621f.tar.xz
Rewrite skang.lua to put all the Thing stuff in metatables, plus get(), reset(), and set().
Diffstat (limited to 'ClientHamr/GuiLua/test.lua')
-rw-r--r--ClientHamr/GuiLua/test.lua36
1 files changed, 22 insertions, 14 deletions
diff --git a/ClientHamr/GuiLua/test.lua b/ClientHamr/GuiLua/test.lua
index 2f93c94..c983943 100644
--- a/ClientHamr/GuiLua/test.lua
+++ b/ClientHamr/GuiLua/test.lua
@@ -48,22 +48,21 @@ end
48local skang = require 'skang' 48local skang = require 'skang'
49local test = require 'test' 49local test = require 'test'
50local test_c = require 'test_c' 50local test_c = require 'test_c'
51local copy_test = skang.new(test, 'copy') 51local copy = skang.copy(test, 'copy')
52 52
53print('End ' .. test.bar .. ' ' .. test.VERSION .. ' ' .. skang.things.ffunc.help .. ' ->> ' .. skang.things.f.action) 53print('End ' .. test.bar .. ' ' .. test.VERSION .. ' ' .. skang.get(test, 'ffunc', 'help') .. ' ->> ' .. skang.get(test, 'f', 'action'))
54print('foo = ' .. test.foo .. ' ->> ' .. skang.things.foo.help) 54print('foo = ' .. test.foo .. ' ->> ' .. skang.get(test, 'foo', 'help'))
55print('cfunc ->> ' .. skang.things.cfunc.help) 55print('cfunc ->> ' .. skang.get(test_c, 'cfunc', 'help'))
56test.ffunc('one', 2) 56test.ffunc('one', 2)
57test_c.cfunc(0, 'zero') 57test_c.cfunc(0, 'zero')
58--skang.things.ffunc('seven', 'aight')
59print('') 58print('')
60 59
61test.f = 42 60test.f = 42
62print('f is now ' .. test.fooble .. ' ' .. test.f .. ' ' .. skang.things.f.help .. ' ' .. skang.things.fooble.help) 61print('f is now ' .. test.fooble .. ' ' .. test.f)
63print('copy_f is now ' .. copy_test.fooble .. ' ' .. copy_test.f) 62print('copy_f is now ' .. copy.fooble .. ' ' .. copy.f)
64copy_test.f = 24 63copy.f = 24
65print('f is now ' .. test.fooble .. ' ' .. test.f .. ' ' .. skang.things.f.help .. ' ' .. skang.things.fooble.help) 64print('f is now ' .. test.fooble .. ' ' .. test.f)
66print('copy_f is now ' .. copy_test.fooble .. ' ' .. copy_test.f) 65print('copy_f is now ' .. copy.fooble .. ' ' .. copy.f)
67test.f = nil 66test.f = nil
68print('f is now ' .. test.fooble .. ' ' .. test.f) 67print('f is now ' .. test.fooble .. ' ' .. test.f)
69test.fooble = 42 68test.fooble = 42
@@ -92,10 +91,9 @@ print(skang.isBoolean(function (a) return false end))
92print('') 91print('')
93 92
94-- Make it required, even though it was anyway. 93-- Make it required, even though it was anyway.
95skang.thing{'f', required = true} 94skang.set(test, 'f', 'required', true)
96-- First, disable the default value, so we see "is required" errors. 95-- Disable the default value, so we see "is required" errors.
97-- Coz using the above syntax means that default is never passed to skang.thing, since it's nil. 96skang.reset(test, 'f', 'default')
98skang.things.f.default = nil
99test.fooble = 42 97test.fooble = 42
100test.fooble = 'Should fail.' 98test.fooble = 'Should fail.'
101test.fooble = 42 99test.fooble = 42
@@ -105,3 +103,13 @@ test.fooble = 42
105test.fooble = true 103test.fooble = true
106test.f = 42 104test.f = 42
107test.f = nil 105test.f = nil
106print('')
107
108skang.set(test, 'f', 'required', false)
109test.f = 42
110test.f = nil
111skang.set(test, 'f', 'default', 999)
112test.f = 42
113test.f = nil
114print(test.fooble .. ' ' .. test.f)
115print(skang.get(test, 'f', 'default'))