Files
wazero/examples/import-go/age-calculator_test.go
Crypt Keeper c4caa1ea9b Changes how examples are tested, and fixes ExitError bug (#468)
Before, we tested the examples/ directory using "ExampleXX", but this is
not ideal because it literally embeds the call to `main` into example
godoc output. This stops doing that for a different infrastructure.

This also makes sure there's a godoc example for both the main package
and wasi, so that people looking at https://pkg.go.dev see something and
also a link to our real examples directory.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-04-15 15:51:27 +08:00

22 lines
513 B
Go

package age_calculator
import (
"testing"
"github.com/tetratelabs/wazero/internal/testing/maintester"
"github.com/tetratelabs/wazero/internal/testing/require"
)
// Test_main ensures the following will work:
//
// go run age-calculator.go 2000
func Test_main(t *testing.T) {
// Set ENV to ensure this test doesn't need maintenance every year.
t.Setenv("CURRENT_YEAR", "2021")
stdout, _ := maintester.TestMain(t, main, "age-calculator", "2000")
require.Equal(t, `println >> 21
log_i32 >> 21
`, stdout)
}