| 1 |
package spectest |
| 2 |
|
| 3 |
import ( |
| 4 |
"context" |
| 5 |
"embed" |
| 6 |
"math" |
| 7 |
"testing" |
| 8 |
|
| 9 |
"github.com/tetratelabs/wazero" |
| 10 |
"github.com/tetratelabs/wazero/api" |
| 11 |
"github.com/tetratelabs/wazero/experimental" |
| 12 |
"github.com/tetratelabs/wazero/internal/integration_test/spectest" |
| 13 |
"github.com/tetratelabs/wazero/internal/platform" |
| 14 |
) |
| 15 |
|
| 16 |
//go:embed testdata |
| 17 |
var testcases embed.FS |
| 18 |
|
| 19 |
const enabledFeatures = api.CoreFeaturesV2 | experimental.CoreFeaturesExceptionHandling | experimental.CoreFeaturesTailCall | experimental.CoreFeaturesTypedFunctionReferences |
| 20 |
|
| 21 |
func TestCompiler(t *testing.T) { |
| 22 |
if !platform.CompilerSupported() { |
| 23 |
t.Skip() |
| 24 |
} |
| 25 |
ctx := context.Background() |
| 26 |
config := wazero.NewRuntimeConfigCompiler().WithCoreFeatures(enabledFeatures) |
| 27 |
runCases(t, ctx, config) |
| 28 |
} |
| 29 |
|
| 30 |
func TestInterpreter(t *testing.T) { |
| 31 |
ctx := context.Background() |
| 32 |
config := wazero.NewRuntimeConfigInterpreter().WithCoreFeatures(enabledFeatures) |
| 33 |
runCases(t, ctx, config) |
| 34 |
} |
| 35 |
|
| 36 |
func runCases(t *testing.T, ctx context.Context, config wazero.RuntimeConfig) { |
| 37 |
spectest.RunCase(t, testcases, "throw", ctx, config, -1, 0, math.MaxInt) |
| 38 |
spectest.RunCase(t, testcases, "throw_ref", ctx, config, -1, 0, math.MaxInt) |
| 39 |
spectest.RunCase(t, testcases, "tag", ctx, config, -1, 0, math.MaxInt) |
| 40 |
spectest.RunCase(t, testcases, "try_table", ctx, config, -1, 0, math.MaxInt) |
| 41 |
} |