aboutsummaryrefslogtreecommitdiffstats
path: root/jsre/jsre_test.go
diff options
context:
space:
mode:
authorzsfelfoldi <zsfelfoldi@gmail.com>2015-04-22 08:31:59 +0800
committerzsfelfoldi <zsfelfoldi@gmail.com>2015-05-06 21:58:27 +0800
commitc54d123b31cc66f81de815493ab83f019190f241 (patch)
tree87d7ad9df9e580854412bb6bc8f72d20559ba556 /jsre/jsre_test.go
parent2e9ed6f7aa84519a5d209dfc9649a0381e89e8ee (diff)
downloaddexon-c54d123b31cc66f81de815493ab83f019190f241.tar
dexon-c54d123b31cc66f81de815493ab83f019190f241.tar.gz
dexon-c54d123b31cc66f81de815493ab83f019190f241.tar.bz2
dexon-c54d123b31cc66f81de815493ab83f019190f241.tar.lz
dexon-c54d123b31cc66f81de815493ab83f019190f241.tar.xz
dexon-c54d123b31cc66f81de815493ab83f019190f241.tar.zst
dexon-c54d123b31cc66f81de815493ab83f019190f241.zip
setTimeout and sendAsync implemented
added and eval queue for serializing JSRE vm execution
Diffstat (limited to 'jsre/jsre_test.go')
-rw-r--r--jsre/jsre_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/jsre/jsre_test.go b/jsre/jsre_test.go
index 667ed4bdc..5eaca2b91 100644
--- a/jsre/jsre_test.go
+++ b/jsre/jsre_test.go
@@ -5,6 +5,7 @@ import (
"io/ioutil"
"os"
"testing"
+ "time"
)
type testNativeObjectBinding struct {
@@ -43,6 +44,31 @@ func TestExec(t *testing.T) {
if exp != got {
t.Errorf("expected '%v', got '%v'", exp, got)
}
+ jsre.Stop(false)
+}
+
+func TestNatto(t *testing.T) {
+ jsre := New("/tmp")
+
+ ioutil.WriteFile("/tmp/test.js", []byte(`setTimeout(function(){msg = "testMsg"}, 1);`), os.ModePerm)
+ err := jsre.Exec("test.js")
+ if err != nil {
+ t.Errorf("expected no error, got %v", err)
+ }
+ time.Sleep(time.Millisecond * 10)
+ val, err := jsre.Run("msg")
+ if err != nil {
+ t.Errorf("expected no error, got %v", err)
+ }
+ if !val.IsString() {
+ t.Errorf("expected string value, got %v", val)
+ }
+ exp := "testMsg"
+ got, _ := val.ToString()
+ if exp != got {
+ t.Errorf("expected '%v', got '%v'", exp, got)
+ }
+ jsre.Stop(false)
}
func TestBind(t *testing.T) {
@@ -59,6 +85,7 @@ func TestBind(t *testing.T) {
t.Errorf("expected no error, got %v", err)
}
t.Logf("no: %v", pp)
+ jsre.Stop(false)
}
func TestLoadScript(t *testing.T) {
@@ -81,4 +108,5 @@ func TestLoadScript(t *testing.T) {
if exp != got {
t.Errorf("expected '%v', got '%v'", exp, got)
}
+ jsre.Stop(false)
}