diff --git a/isolate_test.go b/isolate_test.go index 3e389bdc..a912276f 100644 --- a/isolate_test.go +++ b/isolate_test.go @@ -8,7 +8,6 @@ import ( "encoding/json" "fmt" "math/rand" - "runtime" "strings" "testing" "time" @@ -204,25 +203,6 @@ func TestIsolateDispose(t *testing.T) { } } -func TestIsolateGarbageCollection(t *testing.T) { - t.Parallel() - - iso := v8.NewIsolate() - val, _ := v8.NewValue(iso, "some string") - fmt.Println(val.String()) - - tmpl := v8.NewObjectTemplate(iso) - tmpl.Set("foo", "bar") - ctx := v8.NewContext(iso, tmpl) - - ctx.Close() - iso.Dispose() - - runtime.GC() - - time.Sleep(time.Second) -} - func TestIsolateThrowException(t *testing.T) { t.Parallel() iso := v8.NewIsolate() diff --git a/object_template_test.go b/object_template_test.go index 46189afa..76ca2f01 100644 --- a/object_template_test.go +++ b/object_template_test.go @@ -6,6 +6,7 @@ package v8go_test import ( "math/big" + "runtime" "testing" v8 "rogchap.com/v8go" @@ -139,5 +140,19 @@ func TestObjectTemplateNewInstance(t *testing.T) { if foo, _ := obj.Get("foo"); foo.String() != "bar" { t.Errorf("unexpected value for object property: %v", foo) } +} + +func TestObjectTemplate_garbageCollection(t *testing.T) { + t.Parallel() + + iso := v8.NewIsolate() + + tmpl := v8.NewObjectTemplate(iso) + tmpl.Set("foo", "bar") + ctx := v8.NewContext(iso, tmpl) + + ctx.Close() + iso.Dispose() + runtime.GC() }