This moves our floor version to the same we'll release 1.0 with: 1.18. This is congruent with our version policy which is current-2. Fixes #921 Signed-off-by: Adrian Cole <adrian@tetrate.io>
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package gojs_test
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/tetratelabs/wazero"
|
|
"github.com/tetratelabs/wazero/experimental"
|
|
"github.com/tetratelabs/wazero/experimental/logging"
|
|
"github.com/tetratelabs/wazero/internal/testing/require"
|
|
)
|
|
|
|
func Test_time(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
var log bytes.Buffer
|
|
loggingCtx := context.WithValue(testCtx, experimental.FunctionListenerFactoryKey{},
|
|
logging.NewHostLoggingListenerFactory(&log, logging.LogScopeClock))
|
|
|
|
stdout, stderr, err := compileAndRun(loggingCtx, "time", wazero.NewModuleConfig())
|
|
|
|
require.EqualError(t, err, `module "" closed with exit_code(0)`)
|
|
require.Zero(t, stderr)
|
|
require.Equal(t, `Local
|
|
1ms
|
|
`, stdout)
|
|
|
|
// To avoid multiple similar assertions, just check three functions we
|
|
// expect were called.
|
|
require.Contains(t, log.String(), `==> go.runtime.nanotime1()
|
|
<== (nsec=0)`)
|
|
require.Contains(t, log.String(), `==> go.runtime.walltime()
|
|
<== (sec=1640995200,nsec=0)
|
|
`)
|
|
require.Contains(t, log.String(), `==> go.syscall/js.valueCall(Date.getTimezoneOffset())
|
|
<== (tz=0)
|
|
`)
|
|
}
|