diff options
Diffstat (limited to 'src/syscall/js/js_test.go')
-rw-r--r-- | src/syscall/js/js_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/syscall/js/js_test.go b/src/syscall/js/js_test.go index 9cc931a31d..ed39fe3714 100644 --- a/src/syscall/js/js_test.go +++ b/src/syscall/js/js_test.go @@ -22,6 +22,7 @@ var dummys = js.Global().Call("eval", `({ add: function(a, b) { return a + b; }, + zero: 0, NaN: NaN, })`) @@ -74,6 +75,9 @@ func TestInt(t *testing.T) { if dummys.Get("someInt") != dummys.Get("someInt") { t.Errorf("same value not equal") } + if got := dummys.Get("zero").Int(); got != 0 { + t.Errorf("got %#v, want %#v", got, 0) + } } func TestIntConversion(t *testing.T) { @@ -237,6 +241,9 @@ func TestType(t *testing.T) { if got, want := js.ValueOf(true).Type(), js.TypeBoolean; got != want { t.Errorf("got %s, want %s", got, want) } + if got, want := js.ValueOf(0).Type(), js.TypeNumber; got != want { + t.Errorf("got %s, want %s", got, want) + } if got, want := js.ValueOf(42).Type(), js.TypeNumber; got != want { t.Errorf("got %s, want %s", got, want) } @@ -269,6 +276,13 @@ func TestValueOf(t *testing.T) { } } +func TestZeroValue(t *testing.T) { + var v js.Value + if v != js.Undefined() { + t.Error("zero js.Value is not js.Undefined()") + } +} + func TestCallback(t *testing.T) { c := make(chan struct{}) cb := js.NewCallback(func(args []js.Value) { |