MCPcopy Index your code
hub / github.com/Shopify/go-lua / TestLua

Function TestLua

vm_test.go:54–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

52}
53
54func 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 }

Callers

nothing calls this directly

Calls 10

PushBooleanMethod · 0.95
SetGlobalMethod · 0.95
GlobalMethod · 0.95
FieldMethod · 0.95
TopMethod · 0.95
ProtectedCallMethod · 0.95
NewStateFunction · 0.85
OpenLibrariesFunction · 0.85
LoadFileFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected