TestRuntimeAdvancedOptions tests advanced runtime options for coverage
(t *testing.T)
| 856 | |
| 857 | // TestRuntimeAdvancedOptions tests advanced runtime options for coverage |
| 858 | func TestRuntimeAdvancedOptions(t *testing.T) { |
| 859 | // Test WithCanBlock(false) |
| 860 | rt1 := NewRuntime(WithCanBlock(false)) |
| 861 | defer rt1.Close() |
| 862 | |
| 863 | ctx1 := rt1.NewContext() |
| 864 | defer ctx1.Close() |
| 865 | |
| 866 | result1 := ctx1.Eval(`"canBlock disabled"`) |
| 867 | defer result1.Free() |
| 868 | require.False(t, result1.IsException()) // Check for exceptions instead of error |
| 869 | require.Equal(t, "canBlock disabled", result1.ToString()) |
| 870 | |
| 871 | // Test WithModuleImport(true) |
| 872 | rt2 := NewRuntime(WithModuleImport(true)) |
| 873 | defer rt2.Close() |
| 874 | |
| 875 | ctx2 := rt2.NewContext() |
| 876 | defer ctx2.Close() |
| 877 | |
| 878 | result2 := ctx2.Eval(`"module import enabled"`) |
| 879 | defer result2.Free() |
| 880 | require.False(t, result2.IsException()) // Check for exceptions instead of error |
| 881 | require.Equal(t, "module import enabled", result2.ToString()) |
| 882 | |
| 883 | // Test WithStripInfo(0) |
| 884 | rt3 := NewRuntime(WithStripInfo(0)) |
| 885 | defer rt3.Close() |
| 886 | |
| 887 | ctx3 := rt3.NewContext() |
| 888 | defer ctx3.Close() |
| 889 | |
| 890 | result3 := ctx3.Eval(`"strip info test"`) |
| 891 | defer result3.Free() |
| 892 | require.False(t, result3.IsException()) // Check for exceptions instead of error |
| 893 | require.Equal(t, "strip info test", result3.ToString()) |
| 894 | |
| 895 | // Test GC options |
| 896 | rt4 := NewRuntime(WithGCThreshold(1024)) |
| 897 | defer rt4.Close() |
| 898 | |
| 899 | rt5 := NewRuntime(WithGCThreshold(-1)) // Disabled |
| 900 | defer rt5.Close() |
| 901 | |
| 902 | ctx4 := rt4.NewContext() |
| 903 | defer ctx4.Close() |
| 904 | |
| 905 | result4 := ctx4.Eval(`"GC test"`) |
| 906 | defer result4.Free() |
| 907 | require.False(t, result4.IsException()) // Check for exceptions instead of error |
| 908 | require.Equal(t, "GC test", result4.ToString()) |
| 909 | } |
| 910 | |
| 911 | func TestRuntimeWithModuleImportOptionInstallsDefaultLoader(t *testing.T) { |
| 912 | rt := NewRuntime(WithModuleImport(true)) |
nothing calls this directly
no test coverage detected