Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/argcheck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRonan Collobert <ronan@collobert.com>2015-02-28 06:40:18 +0300
committerRonan Collobert <ronan@collobert.com>2015-02-28 06:40:18 +0300
commit8f3b28864473ba58d55beea36bc5d28cdb4c570c (patch)
tree87e97d8610696680c531ec09c478fb98db65551c /test
parentb72ffeb038427f00f285b6e722bb560346d318cb (diff)
fix handling of multiple default values in method mode and added corresponding test case
Diffstat (limited to 'test')
-rw-r--r--test/test.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test.lua b/test/test.lua
index f703ed9..503e464 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -258,6 +258,26 @@ assert(foobar:addfive{x=5, msg='paf'} == '5.000000 + 5 = 10.000000 [msg = paf] [
assert(foobar:addfive(5) == '5.000000 + 5 = 10.000000 [msg = i know what i am doing] [self.checksum=1234567]')
assert(foobar:addfive{x=5} == '5.000000 + 5 = 10.000000 [msg = i know what i am doing] [self.checksum=1234567]')
+foobar.addfive = argcheck{
+ {name="self", type="table"},
+ {name="x", type="number", default=5},
+ {name="msg", type="string", default="wassup"},
+ call =
+ function(self, x, msg) -- called in case of success
+ return string.format('%f + 5 = %f [msg = %s] [self.checksum=%s]', x, x+5, msg, self.checksum)
+ end
+}
+
+assert(foobar:addfive() == '5.000000 + 5 = 10.000000 [msg = wassup] [self.checksum=1234567]')
+assert(foobar:addfive('paf') == '5.000000 + 5 = 10.000000 [msg = paf] [self.checksum=1234567]')
+assert(foobar:addfive(6, 'paf') == '6.000000 + 5 = 11.000000 [msg = paf] [self.checksum=1234567]')
+assert(foobar:addfive(6) == '6.000000 + 5 = 11.000000 [msg = wassup] [self.checksum=1234567]')
+
+assert(foobar:addfive{} == '5.000000 + 5 = 10.000000 [msg = wassup] [self.checksum=1234567]')
+assert(foobar:addfive{msg='paf'} == '5.000000 + 5 = 10.000000 [msg = paf] [self.checksum=1234567]')
+assert(foobar:addfive{x=6, msg='paf'} == '6.000000 + 5 = 11.000000 [msg = paf] [self.checksum=1234567]')
+assert(foobar:addfive{x=6} == '6.000000 + 5 = 11.000000 [msg = wassup] [self.checksum=1234567]')
+
addstuff = argcheck{
{name="x", type="number"},
{name="y", type="number", default=7},