@@ -9,12 +9,12 @@ import (
9
9
"fmt"
10
10
"testing"
11
11
12
- "rogchap.com/v8go"
12
+ v8 "rogchap.com/v8go"
13
13
)
14
14
15
15
func TestContextExec (t * testing.T ) {
16
16
t .Parallel ()
17
- ctx := v8go .NewContext (nil )
17
+ ctx := v8 .NewContext (nil )
18
18
defer ctx .Isolate ().Dispose ()
19
19
defer ctx .Close ()
20
20
@@ -31,7 +31,7 @@ func TestContextExec(t *testing.T) {
31
31
}
32
32
33
33
iso := ctx .Isolate ()
34
- ctx2 := v8go .NewContext (iso )
34
+ ctx2 := v8 .NewContext (iso )
35
35
_ , err = ctx2 .RunScript (`add` , "ctx2.js" )
36
36
if err == nil {
37
37
t .Error ("error expected but was <nil>" )
@@ -51,7 +51,7 @@ func TestJSExceptions(t *testing.T) {
51
51
{"ReferenceError" , "add()" , "add.js" , "ReferenceError: add is not defined" },
52
52
}
53
53
54
- ctx := v8go .NewContext (nil )
54
+ ctx := v8 .NewContext (nil )
55
55
defer ctx .Isolate ().Dispose ()
56
56
defer ctx .Close ()
57
57
@@ -73,19 +73,19 @@ func TestJSExceptions(t *testing.T) {
73
73
func TestContextRegistry (t * testing.T ) {
74
74
t .Parallel ()
75
75
76
- ctx := v8go .NewContext ()
76
+ ctx := v8 .NewContext ()
77
77
defer ctx .Isolate ().Dispose ()
78
78
defer ctx .Close ()
79
79
80
80
ctxref := ctx .Ref ()
81
81
82
- c1 := v8go .GetContext (ctxref )
82
+ c1 := v8 .GetContext (ctxref )
83
83
if c1 != nil {
84
84
t .Error ("expected context to be <nil>" )
85
85
}
86
86
87
87
ctx .Register ()
88
- c2 := v8go .GetContext (ctxref )
88
+ c2 := v8 .GetContext (ctxref )
89
89
if c2 == nil {
90
90
t .Error ("expected context, but got <nil>" )
91
91
}
@@ -94,7 +94,7 @@ func TestContextRegistry(t *testing.T) {
94
94
}
95
95
ctx .Deregister ()
96
96
97
- c3 := v8go .GetContext (ctxref )
97
+ c3 := v8 .GetContext (ctxref )
98
98
if c3 != nil {
99
99
t .Error ("expected context to be <nil>" )
100
100
}
@@ -103,11 +103,11 @@ func TestContextRegistry(t *testing.T) {
103
103
func TestMemoryLeak (t * testing.T ) {
104
104
t .Parallel ()
105
105
106
- iso := v8go .NewIsolate ()
106
+ iso := v8 .NewIsolate ()
107
107
defer iso .Dispose ()
108
108
109
109
for i := 0 ; i < 6000 ; i ++ {
110
- ctx := v8go .NewContext (iso )
110
+ ctx := v8 .NewContext (iso )
111
111
obj := ctx .Global ()
112
112
_ = obj .String ()
113
113
_ , _ = ctx .RunScript ("2" , "" )
@@ -120,10 +120,10 @@ func TestMemoryLeak(t *testing.T) {
120
120
121
121
func BenchmarkContext (b * testing.B ) {
122
122
b .ReportAllocs ()
123
- iso := v8go .NewIsolate ()
123
+ iso := v8 .NewIsolate ()
124
124
defer iso .Dispose ()
125
125
for n := 0 ; n < b .N ; n ++ {
126
- ctx := v8go .NewContext (iso )
126
+ ctx := v8 .NewContext (iso )
127
127
ctx .RunScript (script , "main.js" )
128
128
str , _ := json .Marshal (makeObject ())
129
129
cmd := fmt .Sprintf ("process(%s)" , str )
@@ -133,7 +133,7 @@ func BenchmarkContext(b *testing.B) {
133
133
}
134
134
135
135
func ExampleContext () {
136
- ctx := v8go .NewContext ()
136
+ ctx := v8 .NewContext ()
137
137
defer ctx .Isolate ().Dispose ()
138
138
defer ctx .Close ()
139
139
ctx .RunScript ("const add = (a, b) => a + b" , "math.js" )
@@ -145,15 +145,15 @@ func ExampleContext() {
145
145
}
146
146
147
147
func ExampleContext_isolate () {
148
- iso := v8go .NewIsolate ()
148
+ iso := v8 .NewIsolate ()
149
149
defer iso .Dispose ()
150
- ctx1 := v8go .NewContext (iso )
150
+ ctx1 := v8 .NewContext (iso )
151
151
defer ctx1 .Close ()
152
152
ctx1 .RunScript ("const foo = 'bar'" , "context_one.js" )
153
153
val , _ := ctx1 .RunScript ("foo" , "foo.js" )
154
154
fmt .Println (val )
155
155
156
- ctx2 := v8go .NewContext (iso )
156
+ ctx2 := v8 .NewContext (iso )
157
157
defer ctx2 .Close ()
158
158
_ , err := ctx2 .RunScript ("foo" , "context_two.js" )
159
159
fmt .Println (err )
@@ -163,11 +163,11 @@ func ExampleContext_isolate() {
163
163
}
164
164
165
165
func ExampleContext_globalTemplate () {
166
- iso := v8go .NewIsolate ()
166
+ iso := v8 .NewIsolate ()
167
167
defer iso .Dispose ()
168
- obj := v8go .NewObjectTemplate (iso )
168
+ obj := v8 .NewObjectTemplate (iso )
169
169
obj .Set ("version" , "v1.0.0" )
170
- ctx := v8go .NewContext (iso , obj )
170
+ ctx := v8 .NewContext (iso , obj )
171
171
defer ctx .Close ()
172
172
val , _ := ctx .RunScript ("version" , "main.js" )
173
173
fmt .Println (val )
0 commit comments