Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ThrowException fn to the isolate #221

Merged
merged 10 commits into from
Nov 10, 2021
Prev Previous commit
Add test for disposed isolate check
  • Loading branch information
dylanahsmith committed Nov 10, 2021
commit 8252b3edf45a99797bfb26807b8e9c337116220a
8 changes: 6 additions & 2 deletions isolate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ func TestIsolateGarbageCollection(t *testing.T) {
func TestIsolateThrowException(t *testing.T) {
t.Parallel()
iso := v8.NewIsolate()
defer iso.Dispose()

strErr, _ := v8.NewValue(iso, "some type error")

Expand Down Expand Up @@ -260,7 +259,6 @@ func TestIsolateThrowException(t *testing.T) {
global.Set("foo2", fn2)

ctx := v8.NewContext(iso, global)
defer ctx.Close()

_, e := ctx.RunScript("foo()", "foo.js")

Expand All @@ -273,6 +271,12 @@ func TestIsolateThrowException(t *testing.T) {
if e.Error() != "TypeError: this is a test" {
t.Errorf("expected \"TypeError: this is a test\" error but got: %v", e)
}

ctx.Close()
iso.Dispose()
if recoverPanic(func() { iso.ThrowException(strErr) }) == nil {
t.Error("expected panic")
}
}

func BenchmarkIsolateInitialization(b *testing.B) {
Expand Down