Beispiel #1
0
func Open(l *lua.State) {
	regexp.Open(l)
	strings.Open(l)
	json.Open(l)
	time.Open(l)
	fmt.Open(l)
	url.Open(l)
	util.Open(l)
	hmac.Open(l)
	base64.Open(l)
	env.Open(l)
	uuid.Open(l)
}
Beispiel #2
0
func TestPullTableWithArraysFromLua(t *testing.T) {
	require := func(l *lua.State) {
		util.Open(l)
		l.Register("validateTable", func(l *lua.State) int {
			actual, err := util.PullTable(l, -1)
			if err != nil {
				t.Fatalf("failed to pull table: %s", err.Error())
			}

			expected := map[string]interface{}{
				"foo": []interface{}{
					"I",
					"love",
					map[string]interface{}{
						"lua": []interface{}{"LuaJIT", "go-lua"},
						"go":  []interface{}{"6g", "gcc-go"},
					},
				},
			}
			if !reflect.DeepEqual(expected, actual) {
				t.Fatalf("expected %v, actual %v", expected, actual)
			}

			return 0
		})
	}
	luatesting.RunLuaTestString(t, require, `
		validateTable({
			foo = array({
			  "I",
				"love",
				{
					lua = array({"LuaJIT", "go-lua"}),
					go = array({"6g", "gcc-go"}),
				},
			})
		})
	`)
}