Skip to content

Commit

Permalink
Remove useless print statement in a test (rogchap#232)
Browse files Browse the repository at this point in the history
* Remove useless print statement in a test

* Move/rename test that is actually for object template garbage collection

Isolates aren't garbaged collected at the moment. I think they may have
been in the past though.
  • Loading branch information
dylanahsmith authored Nov 17, 2021
1 parent 11de938 commit 64149e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
20 changes: 0 additions & 20 deletions isolate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"encoding/json"
"fmt"
"math/rand"
"runtime"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -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()
Expand Down
15 changes: 15 additions & 0 deletions object_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package v8go_test

import (
"math/big"
"runtime"
"testing"

v8 "rogchap.com/v8go"
Expand Down Expand Up @@ -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()
}

0 comments on commit 64149e7

Please sign in to comment.