diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-05-06 22:27:24 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-05-06 22:27:24 +0800 |
commit | aa884c052ddf7c5e8f673972b34681982de1cd52 (patch) | |
tree | 87d7ad9df9e580854412bb6bc8f72d20559ba556 /jsre/jsre_test.go | |
parent | 2e9ed6f7aa84519a5d209dfc9649a0381e89e8ee (diff) | |
parent | c54d123b31cc66f81de815493ab83f019190f241 (diff) | |
download | dexon-aa884c052ddf7c5e8f673972b34681982de1cd52.tar dexon-aa884c052ddf7c5e8f673972b34681982de1cd52.tar.gz dexon-aa884c052ddf7c5e8f673972b34681982de1cd52.tar.bz2 dexon-aa884c052ddf7c5e8f673972b34681982de1cd52.tar.lz dexon-aa884c052ddf7c5e8f673972b34681982de1cd52.tar.xz dexon-aa884c052ddf7c5e8f673972b34681982de1cd52.tar.zst dexon-aa884c052ddf7c5e8f673972b34681982de1cd52.zip |
Merge pull request #771 from zsfelfoldi/develop
jsre: support for setTimeout, sendAsync
Diffstat (limited to 'jsre/jsre_test.go')
-rw-r--r-- | jsre/jsre_test.go | 28 |
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) } |