MCPcopy Index your code
hub / github.com/yuin/gopher-lua / TestOsDateFormatLocalWithTwoParam

Function TestOsDateFormatLocalWithTwoParam

baselib_test.go:84–112  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

82}
83
84func TestOsDateFormatLocalWithTwoParam(t *testing.T) {
85 t.Setenv("TZ", "Asia/Tokyo")
86 ls := NewState()
87
88 g := ls.GetGlobal("os")
89 fn := ls.GetField(g, "date")
90
91 nowLocal := time.Now()
92 nowUTC := nowLocal.UTC()
93
94 err := ls.CallByParam(P{
95 Fn: fn,
96 NRet: 1,
97 Protect: true,
98 }, LString("*t"), LNumber(nowLocal.Unix()))
99 if err != nil {
100 t.Fatal(err)
101 }
102
103 result := ls.ToTable(-1)
104
105 resultMap := make(map[string]string)
106 result.ForEach(func(key LValue, value LValue) {
107 t.Logf("key=%v, value=%v", key, value)
108 resultMap[key.String()] = value.String()
109 assertOsDateFields(t, key, value, nowLocal)
110 })
111 t.Logf("resultMap=%+v, nowLocal=%+v, nowUTC=%v", resultMap, nowLocal, nowUTC)
112}
113
114func assertOsDateFields(t *testing.T, key LValue, value LValue, expect time.Time) {
115 switch key.String() {

Callers

nothing calls this directly

Calls 10

LStringTypeAlias · 0.85
LNumberTypeAlias · 0.85
assertOsDateFieldsFunction · 0.85
NewStateFunction · 0.70
StringMethod · 0.65
GetGlobalMethod · 0.45
GetFieldMethod · 0.45
CallByParamMethod · 0.45
ToTableMethod · 0.45
ForEachMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…