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

Function TestOsDateFormatUTCWithTwoParam

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

Source from the content-addressed store, hash-verified

7)
8
9func TestOsDateFormatUTCWithTwoParam(t *testing.T) {
10 t.Setenv("TZ", "Asia/Tokyo")
11 ls := NewState()
12
13 g := ls.GetGlobal("os")
14 fn := ls.GetField(g, "date")
15
16 int64ptr := func(i int64) *int64 {
17 return &i
18 }
19 cases := []struct {
20 Name string
21 Local time.Time
22 Now time.Time
23 Format string
24 Timestamp *int64
25 }{
26 {
27 "UTCWithTwoParam",
28 time.Now(),
29 time.Now().UTC(),
30 "!*t",
31 int64ptr(time.Now().UTC().Unix()),
32 },
33 {
34 "LocalWithTwoParam",
35 time.Now(),
36 time.Now(),
37 "*t",
38 int64ptr(time.Now().Unix()),
39 },
40 {
41 "UTCWithOnlyFormatParam",
42 time.Now(),
43 time.Now().UTC(),
44 "!*t",
45 nil,
46 },
47 {
48 "LocalWithOnlyFormatParam",
49 time.Now(),
50 time.Now(),
51 "*t",
52 nil,
53 },
54 }
55
56 for _, c := range cases {
57 t.Run(c.Name, func(t *testing.T) {
58 args := make([]LValue, 0)
59 args = append(args, LString(c.Format))
60 if c.Timestamp != nil {
61 args = append(args, LNumber(*c.Timestamp))
62 }
63 err := ls.CallByParam(P{
64 Fn: fn,
65 NRet: 1,
66 Protect: true,

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…