package onthefly import ( "strings" "testing" lua "github.com/xyproto/gopher-lua" ) // runLua loads onthefly into a fresh Lua state and executes the given script. // Returns the last printed string (via a captured `out` global) if the script // stored one in the `out` global, otherwise the error. func runLua(t *testing.T, script string) string { t.Helper() L := lua.NewState() defer L.Close() Load(L) if err := L.DoString(script); err != nil { t.Fatalf("lua error: %v", err) } return L.GetGlobal("out").String() } func TestHTML5Basic(t *testing.T) { html := runLua(t, ` local page = HTML5("Hi") out = tostring(page) `) for _, want := range []string{"", "", "