Skip to content

Commit

Permalink
Some more coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyco committed Apr 4, 2017
1 parent 6e0db7e commit c542684
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lua_test.go
Expand Up @@ -79,6 +79,11 @@ func TestLua_Module(t *testing.T) {
b := New()

m := b.Module("reverse")

m.String("_STRING", "foobar")
m.Number("_NUMBER", 123)
m.Bool("_BOOL", true)

m.Func("string", func(c *Context) error {
if c.Top() == 0 {
return errors.New("need arguments")
Expand All @@ -95,12 +100,7 @@ func TestLua_Module(t *testing.T) {
return nil
})

if err := b.DoString(`
local r = require('reverse')
assert(r.string('ABCDE') == 'EDCBA', 'ABCDE != EDCBA')
assert(r.string('01234') == '43210', '01234 != 43210')
`); err != nil {
if err := b.DoFile("lua_test.lua"); err != nil {
t.Error("Error execute module", err)
}
}
Expand Down
10 changes: 10 additions & 0 deletions lua_test.lua
@@ -0,0 +1,10 @@
-- see lua_test.go

local r = require('reverse')

assert(r.string('ABCDE') == 'EDCBA', 'ABCDE != EDCBA')
assert(r.string('01234') == '43210', '01234 != 43210')

assert(r._STRING == 'foobar', 'Wrong string field value')
assert(r._NUMBER == 123, 'Wrong number field value')
assert(r._BOOL, 'Wrong bool field value')

0 comments on commit c542684

Please sign in to comment.