MCPcopy Create free account
hub / github.com/Shopify/goluago / TestPullTableWithArraysFromLua

Function TestPullTableWithArraysFromLua

util/deep_pull_test.go:227–265  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

225}
226
227func TestPullTableWithArraysFromLua(t *testing.T) {
228 require := func(l *lua.State) {
229 util.Open(l)
230 l.Register("validateTable", func(l *lua.State) int {
231 actual, err := util.PullTable(l, -1)
232 if err != nil {
233 t.Fatalf("failed to pull table: %s", err.Error())
234 }
235
236 expected := map[string]interface{}{
237 "foo": []interface{}{
238 "I",
239 "love",
240 map[string]interface{}{
241 "lua": []interface{}{"LuaJIT", "go-lua"},
242 "go": []interface{}{"6g", "gcc-go"},
243 },
244 },
245 }
246 if !reflect.DeepEqual(expected, actual) {
247 t.Fatalf("expected %v, actual %v", expected, actual)
248 }
249
250 return 0
251 })
252 }
253 luatesting.RunLuaTestString(t, require, `
254 validateTable({
255 foo = array({
256 "I",
257 "love",
258 {
259 lua = array({"LuaJIT", "go-lua"}),
260 go = array({"6g", "gcc-go"}),
261 },
262 })
263 })
264 `)
265}
266
267func TestPullTableFailsWhenNotATable(t *testing.T) {
268 l := lua.NewState()

Callers

nothing calls this directly

Calls 2

OpenFunction · 0.92
PullTableFunction · 0.92

Tested by

no test coverage detected