From a55786ee761f03ca5dd9e555b992c4a15c3188e0 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Sun, 7 Jun 2015 20:08:12 -0700 Subject: [PATCH 1/5] Circle CI: Update Go to latest stable version 1.4.2. --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index ebfa4c58f..c3ccdb64c 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 From 8839012ea4cfc95056e2a9c05d8e95ba67870104 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Sun, 7 Jun 2015 20:10:29 -0700 Subject: [PATCH 2/5] Circle CI: Run gopherjs tests with Go as well. --- circle.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/circle.yml b/circle.yml index c3ccdb64c..f18e5345c 100644 --- a/circle.yml +++ b/circle.yml @@ -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 ./... From cb553f393ba9e6cbab0b47c2d0bbff1ce79e8306 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Sun, 7 Jun 2015 20:29:06 -0700 Subject: [PATCH 3/5] Fix interface equality for undefined (js.Undefined). Catch and handle the case of both values being js.Undefined in $interfaceIsEqual. Place this check underneath the check for (a.constructor !== b.constructor) as an optimization. Related to #237. --- compiler/prelude/prelude.go | 4 ++++ js/js_test.go | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/compiler/prelude/prelude.go b/compiler/prelude/prelude.go index 05b090b40..2092c29cb 100644 --- a/compiler/prelude/prelude.go +++ b/compiler/prelude/prelude.go @@ -413,6 +413,10 @@ var $interfaceIsEqual = function(a, b) { if (a.constructor !== b.constructor) { return false; } + if (a.constructor === $jsObjectPtr && a.object === undefined && + b.constructor === $jsObjectPtr && b.object === undefined) { + return true; + } 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..47f7ac380 100644 --- a/js/js_test.go +++ b/js/js_test.go @@ -302,6 +302,13 @@ func TestEquality(t *testing.T) { } } +func TestUndefinedEquality(t *testing.T) { + var ui interface{} = js.Undefined + if ui != js.Undefined { + t.Fail() + } +} + func TestSameFuncWrapper(t *testing.T) { a := func(_ string) {} // string argument to force wrapping b := func(_ string) {} // string argument to force wrapping From bf81f3863f6c39cdad954f7f31882c7d967a2890 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Sun, 7 Jun 2015 20:30:51 -0700 Subject: [PATCH 4/5] Fix internalize case for undefined value. Fixes #237. --- compiler/prelude/jsmapping.go | 3 +++ js/js_test.go | 10 ++++++++++ 2 files changed, 13 insertions(+) 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/js/js_test.go b/js/js_test.go index 47f7ac380..e46b0e8f1 100644 --- a/js/js_test.go +++ b/js/js_test.go @@ -309,6 +309,16 @@ func TestUndefinedEquality(t *testing.T) { } } +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 From 0bfcd10ef2a81530697eeef64fcc6d5259302ffb Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Tue, 9 Jun 2015 01:07:04 -0700 Subject: [PATCH 5/5] Fix $interfaceIsEqual general handling of two *js.Object. Commit cb553f3 fixes the issue for when both *js.Object were undefined. This change makes that fix general and apply when the value of the two *js.Object is anything. --- compiler/prelude/prelude.go | 5 ++--- js/js_test.go | 8 ++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/compiler/prelude/prelude.go b/compiler/prelude/prelude.go index 2092c29cb..5427c2498 100644 --- a/compiler/prelude/prelude.go +++ b/compiler/prelude/prelude.go @@ -413,9 +413,8 @@ var $interfaceIsEqual = function(a, b) { if (a.constructor !== b.constructor) { return false; } - if (a.constructor === $jsObjectPtr && a.object === undefined && - b.constructor === $jsObjectPtr && b.object === undefined) { - return true; + 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 e46b0e8f1..754fb1a1b 100644 --- a/js/js_test.go +++ b/js/js_test.go @@ -309,6 +309,14 @@ func TestUndefinedEquality(t *testing.T) { } } +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