diff options
Diffstat (limited to 'src/syscall/js/js_test.go')
-rw-r--r-- | src/syscall/js/js_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/syscall/js/js_test.go b/src/syscall/js/js_test.go index e5e950f3a3..c96ad82850 100644 --- a/src/syscall/js/js_test.go +++ b/src/syscall/js/js_test.go @@ -8,6 +8,7 @@ package js_test import ( "fmt" + "math" "syscall/js" "testing" ) @@ -21,6 +22,7 @@ var dummys = js.Global().Call("eval", `({ add: function(a, b) { return a + b; }, + NaN: NaN, })`) func TestBool(t *testing.T) { @@ -33,6 +35,9 @@ func TestBool(t *testing.T) { if got := dummys.Get("otherBool").Bool(); got != want { t.Errorf("got %#v, want %#v", got, want) } + if dummys.Get("someBool") != dummys.Get("someBool") { + t.Errorf("same value not equal") + } } func TestString(t *testing.T) { @@ -45,6 +50,9 @@ func TestString(t *testing.T) { if got := dummys.Get("otherString").String(); got != want { t.Errorf("got %#v, want %#v", got, want) } + if dummys.Get("someString") != dummys.Get("someString") { + t.Errorf("same value not equal") + } } func TestInt(t *testing.T) { @@ -57,6 +65,9 @@ func TestInt(t *testing.T) { if got := dummys.Get("otherInt").Int(); got != want { t.Errorf("got %#v, want %#v", got, want) } + if dummys.Get("someInt") != dummys.Get("someInt") { + t.Errorf("same value not equal") + } } func TestIntConversion(t *testing.T) { @@ -87,6 +98,23 @@ func TestFloat(t *testing.T) { if got := dummys.Get("otherFloat").Float(); got != want { t.Errorf("got %#v, want %#v", got, want) } + if dummys.Get("someFloat") != dummys.Get("someFloat") { + t.Errorf("same value not equal") + } +} + +func TestObject(t *testing.T) { + if dummys.Get("someArray") != dummys.Get("someArray") { + t.Errorf("same value not equal") + } +} + +func TestNaN(t *testing.T) { + want := js.ValueOf(math.NaN()) + got := dummys.Get("NaN") + if got != want { + t.Errorf("got %#v, want %#v", got, want) + } } func TestUndefined(t *testing.T) { |