(t *testing.T)
| 82 | } |
| 83 | |
| 84 | func 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 | |
| 114 | func assertOsDateFields(t *testing.T, key LValue, value LValue, expect time.Time) { |
| 115 | switch key.String() { |
nothing calls this directly
no test coverage detected
searching dependent graphs…