(t *testing.T)
| 52 | } |
| 53 | |
| 54 | func TestLua(t *testing.T) { |
| 55 | tests := []struct { |
| 56 | name string |
| 57 | nonPort bool |
| 58 | }{ |
| 59 | {name: "attrib", nonPort: true}, |
| 60 | // {name: "big"}, |
| 61 | {name: "bitwise"}, |
| 62 | // {name: "calls"}, |
| 63 | // {name: "checktable"}, |
| 64 | {name: "closure"}, |
| 65 | // {name: "code"}, |
| 66 | // {name: "constructs"}, |
| 67 | // {name: "db"}, |
| 68 | // {name: "errors"}, |
| 69 | {name: "events"}, |
| 70 | // {name: "files"}, |
| 71 | // {name: "gc"}, |
| 72 | {name: "goto"}, |
| 73 | // {name: "literals"}, |
| 74 | {name: "locals"}, |
| 75 | // {name: "main"}, |
| 76 | {name: "math"}, |
| 77 | // {name: "nextvar"}, |
| 78 | // {name: "pm"}, |
| 79 | {name: "sort", nonPort: true}, // sort.lua depends on os.clock(), which is not yet implemented on Windows. |
| 80 | {name: "strings"}, |
| 81 | // {name: "vararg"}, |
| 82 | // {name: "verybig"}, |
| 83 | } |
| 84 | for _, v := range tests { |
| 85 | if v.nonPort && runtime.GOOS == "windows" { |
| 86 | t.Skipf("'%s' skipped because it's non-portable & we're running Windows", v.name) |
| 87 | } |
| 88 | t.Log(v) |
| 89 | l := NewState() |
| 90 | OpenLibraries(l) |
| 91 | for _, s := range []string{"_port", "_no32", "_noformatA"} { |
| 92 | l.PushBoolean(true) |
| 93 | l.SetGlobal(s) |
| 94 | } |
| 95 | if v.nonPort { |
| 96 | l.PushBoolean(false) |
| 97 | l.SetGlobal("_port") |
| 98 | } |
| 99 | // l.SetDebugHook(func(state *State, ar Debug) { |
| 100 | // ci := state.callInfo.(*luaCallInfo) |
| 101 | // p := state.prototype(ci) |
| 102 | // println(stack(state.stack[ci.base():state.top])) |
| 103 | // println(ci.code[ci.savedPC].String(), p.source, p.lineInfo[ci.savedPC]) |
| 104 | // }, MaskCount, 1) |
| 105 | l.Global("debug") |
| 106 | l.Field(-1, "traceback") |
| 107 | traceback := l.Top() |
| 108 | // t.Logf("%#v", l.ToValue(traceback)) |
| 109 | if err := LoadFile(l, filepath.Join("lua-tests", v.name+".lua"), "text"); err != nil { |
| 110 | t.Errorf("'%s' failed: %s", v.name, err.Error()) |
| 111 | } |
nothing calls this directly
no test coverage detected