diff --git a/circle.yml b/circle.yml index ebfa4c58f..f18e5345c 100644 --- a/circle.yml +++ b/circle.yml @@ -4,7 +4,7 @@ machine: dependencies: pre: - - cd /usr/local && sudo rm -rf go && curl https://storage.googleapis.com/golang/go1.4.1.linux-amd64.tar.gz | sudo tar -xz && sudo chmod a+w go/src/path/filepath + - cd /usr/local && sudo rm -rf go && curl https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz | sudo tar -xz && sudo chmod a+w go/src/path/filepath post: - npm install --global node-gyp - cd node-syscall && node-gyp rebuild && mkdir -p ~/.node_libraries/ && cp build/Release/syscall.node ~/.node_libraries/syscall.node @@ -12,3 +12,4 @@ dependencies: test: override: - ./gopherjs test --short --minify github.com/gopherjs/gopherjs/tests github.com/gopherjs/gopherjs/js archive/tar archive/zip bufio bytes compress/bzip2 compress/flate compress/gzip compress/lzw compress/zlib container/heap container/list container/ring crypto/aes crypto/cipher crypto/des crypto/dsa crypto/ecdsa crypto/elliptic crypto/hmac crypto/md5 crypto/rand crypto/rc4 crypto/rsa crypto/sha1 crypto/sha256 crypto/sha512 crypto/subtle crypto/x509 database/sql database/sql/driver debug/dwarf debug/elf debug/gosym debug/macho debug/pe encoding/ascii85 encoding/asn1 encoding/base32 encoding/base64 encoding/binary encoding/csv encoding/gob encoding/hex encoding/json encoding/pem encoding/xml errors expvar flag fmt go/ast go/doc go/format go/parser go/printer go/scanner go/token hash/adler32 hash/crc32 hash/crc64 hash/fnv html html/template image image/color image/draw image/gif image/jpeg image/png index/suffixarray io io/ioutil math math/big math/cmplx math/rand mime mime/multipart net/http/cookiejar net/http/fcgi net/mail net/rpc/jsonrpc net/textproto net/url path path/filepath reflect regexp regexp/syntax sort strconv strings sync sync/atomic testing/quick text/scanner text/tabwriter text/template text/template/parse time unicode unicode/utf16 unicode/utf8 + - go test -v -race ./... diff --git a/compiler/prelude/jsmapping.go b/compiler/prelude/jsmapping.go index 7c60b7d08..38874daec 100644 --- a/compiler/prelude/jsmapping.go +++ b/compiler/prelude/jsmapping.go @@ -245,6 +245,9 @@ var $internalize = function(v, t, recv) { if (v === null) { return $ifaceNil; } + if (v === undefined) { + return new $jsObjectPtr(undefined); + } switch (v.constructor) { case Int8Array: return new ($sliceType($Int8))(v); diff --git a/compiler/prelude/prelude.go b/compiler/prelude/prelude.go index 05b090b40..5427c2498 100644 --- a/compiler/prelude/prelude.go +++ b/compiler/prelude/prelude.go @@ -413,6 +413,9 @@ var $interfaceIsEqual = function(a, b) { if (a.constructor !== b.constructor) { return false; } + if (a.constructor === $jsObjectPtr) { + return a.object === b.object; + } if (!a.constructor.comparable) { $throwRuntimeError("comparing uncomparable type " + a.constructor.string); } diff --git a/js/js_test.go b/js/js_test.go index 71fdad905..754fb1a1b 100644 --- a/js/js_test.go +++ b/js/js_test.go @@ -302,6 +302,31 @@ func TestEquality(t *testing.T) { } } +func TestUndefinedEquality(t *testing.T) { + var ui interface{} = js.Undefined + if ui != js.Undefined { + t.Fail() + } +} + +func TestInterfaceEquality(t *testing.T) { + o := js.Global.Get("Object").New() + var i interface{} = o + if i != o { + t.Fail() + } +} + +func TestUndefinedInternalization(t *testing.T) { + undefinedEqualsJsUndefined := func(i interface{}) bool { + return i == js.Undefined + } + js.Global.Set("undefinedEqualsJsUndefined", undefinedEqualsJsUndefined) + if !js.Global.Call("eval", "(undefinedEqualsJsUndefined(undefined))").Bool() { + t.Fail() + } +} + func TestSameFuncWrapper(t *testing.T) { a := func(_ string) {} // string argument to force wrapping b := func(_ string) {} // string argument to force wrapping