diff --git a/.travis.yml b/.travis.yml index 7e6e53fa..7f0c7112 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,10 @@ language: go os: - linux - osx +before_script: + - rvm get head || true # https://github.com/travis-ci/travis-ci/issues/6307 + - set -e # Run gofmt and lint serially to avoid confusing output. Run tests in parallel # for speed. script: make gofmt lint && make -j2 test +after_script: set +e diff --git a/Makefile b/Makefile index c320a98a..9398f9e7 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ endif PYTHON_BIN := $(shell which $(PYTHON)) PYTHON_VER := $(word 2,$(shell $(PYTHON) -V 2>&1)) GO_REQ_MAJ := 1 -GO_REQ_MIN := 6 +GO_REQ_MIN := 9 GO_MAJ_MIN := $(subst go,, $(word 3,$(shell go version 2>&1)) ) GO_MAJ := $(word 1,$(subst ., ,$(GO_MAJ_MIN) )) GO_MIN := $(word 2,$(subst ., ,$(GO_MAJ_MIN) )) diff --git a/runtime/complex.go b/runtime/complex.go index c5ca7c92..752ca4c5 100644 --- a/runtime/complex.go +++ b/runtime/complex.go @@ -457,7 +457,7 @@ func complexModOp(v, w complex128) complex128 { } const ( - _ = iota + blank = iota real1 imag1 real2 diff --git a/runtime/complex_test.go b/runtime/complex_test.go index 2001e48f..61b68722 100644 --- a/runtime/complex_test.go +++ b/runtime/complex_test.go @@ -75,6 +75,10 @@ func TestComplexEq(t *testing.T) { } } +// FIXME(corona10): Since Go 1.9 moved to C99 float division and what CPython uses as well. +// Some tests can be failed with version < Go 1.9. We need to detect Go version. +// And changed expected values. + func TestComplexBinaryOps(t *testing.T) { cases := []struct { fun func(f *Frame, v, w *Object) (*Object, *BaseException) @@ -107,8 +111,8 @@ func TestComplexBinaryOps(t *testing.T) { {Div, NewComplex(3 - 4i).ToObject(), NewLong(big.NewInt(-34)).ToObject(), NewComplex(-0.08823529411764706 + 0.11764705882352941i).ToObject(), nil}, {Div, NewComplex(3 + 4i).ToObject(), NewComplex(complex(math.Inf(1), math.Inf(-1))).ToObject(), NewComplex(0i).ToObject(), nil}, {Div, NewComplex(3 + 4i).ToObject(), NewComplex(complex(math.Inf(1), 2)).ToObject(), NewComplex(0i).ToObject(), nil}, - {Div, NewComplex(complex(math.Inf(1), math.Inf(1))).ToObject(), NewComplex(1 + 2i).ToObject(), NewComplex(complex(math.Inf(1), math.Inf(1))).ToObject(), nil}, - {Div, NewComplex(complex(math.Inf(1), 4)).ToObject(), NewComplex(1 + 2i).ToObject(), NewComplex(complex(math.Inf(1), math.Inf(1))).ToObject(), nil}, + {Div, NewComplex(complex(math.Inf(1), math.Inf(1))).ToObject(), NewComplex(1 + 2i).ToObject(), NewComplex(complex(math.Inf(1), math.NaN())).ToObject(), nil}, + {Div, NewComplex(complex(math.Inf(1), 4)).ToObject(), NewComplex(1 + 2i).ToObject(), NewComplex(complex(math.Inf(1), math.Inf(-1))).ToObject(), nil}, {Div, NewComplex(complex(3, math.Inf(1))).ToObject(), NewComplex(1 + 2i).ToObject(), NewComplex(complex(math.Inf(1), math.Inf(1))).ToObject(), nil}, {Div, NewComplex(complex(3, math.NaN())).ToObject(), NewComplex(1 + 2i).ToObject(), NewComplex(complex(math.NaN(), math.NaN())).ToObject(), nil}, {Div, NewStr("foo").ToObject(), NewComplex(1 + 2i).ToObject(), nil, mustCreateException(TypeErrorType, "unsupported operand type(s) for /: 'str' and 'complex'")}, @@ -189,8 +193,8 @@ func TestComplexBinaryOps(t *testing.T) { {Pow, NewComplex(complex(math.Inf(-1), 2)).ToObject(), NewComplex(1 + 2i).ToObject(), NewComplex(complex(math.NaN(), math.NaN())).ToObject(), nil}, {Pow, NewComplex(1 + 2i).ToObject(), NewComplex(complex(1, math.Inf(1))).ToObject(), NewComplex(complex(math.NaN(), math.NaN())).ToObject(), nil}, {Pow, NewComplex(complex(math.NaN(), 1)).ToObject(), NewComplex(3 + 4i).ToObject(), NewComplex(complex(math.NaN(), math.NaN())).ToObject(), nil}, - {Pow, NewComplex(3 + 4i).ToObject(), NewInt(3).ToObject(), NewComplex(-117 + 44.000000000000036i).ToObject(), nil}, - {Pow, NewComplex(3 + 4i).ToObject(), NewFloat(3.1415).ToObject(), NewComplex(-152.8892667678244 + 35.55533513049651i).ToObject(), nil}, + {Pow, NewComplex(3 + 4i).ToObject(), NewInt(3).ToObject(), NewComplex(-117 + 44.00000000000003i).ToObject(), nil}, + {Pow, NewComplex(3 + 4i).ToObject(), NewFloat(3.1415).ToObject(), NewComplex(-152.8892667678244 + 35.555335130496516i).ToObject(), nil}, {Pow, NewComplex(3 + 4i).ToObject(), NewLong(big.NewInt(123)).ToObject(), NewComplex(5.393538720276193e+85 + 7.703512580443326e+85i).ToObject(), nil}, {Pow, NewComplex(1 + 2i).ToObject(), NewStr("foo").ToObject(), nil, mustCreateException(TypeErrorType, "unsupported operand type(s) for **: 'complex' and 'str'")}, {Pow, NewStr("foo").ToObject(), NewComplex(1 + 2i).ToObject(), nil, mustCreateException(TypeErrorType, "unsupported operand type(s) for **: 'str' and 'complex'")}, diff --git a/runtime/dict.go b/runtime/dict.go index 66a07e67..32eeca43 100644 --- a/runtime/dict.go +++ b/runtime/dict.go @@ -230,7 +230,7 @@ func (iter *dictEntryIterator) next() *dictEntry { // 64bit atomic ops need to be 8 byte aligned. This compile time check // verifies alignment by creating a negative constant for an unsigned type. // See sync/atomic docs for details. - const _ = -(unsafe.Offsetof(iter.index) % 8) + const blank = -(unsafe.Offsetof(iter.index) % 8) index := int(atomic.AddInt64(&iter.index, 1)) - 1 if index >= numEntries { break @@ -310,7 +310,7 @@ func (d *Dict) loadVersion() int64 { // 64bit atomic ops need to be 8 byte aligned. This compile time check // verifies alignment by creating a negative constant for an unsigned type. // See sync/atomic docs for details. - const _ = -(unsafe.Offsetof(d.version) % 8) + const blank = -(unsafe.Offsetof(d.version) % 8) return atomic.LoadInt64(&d.version) } @@ -319,7 +319,7 @@ func (d *Dict) incVersion() { // 64bit atomic ops need to be 8 byte aligned. This compile time check // verifies alignment by creating a negative constant for an unsigned type. // See sync/atomic docs for details. - const _ = -(unsafe.Offsetof(d.version) % 8) + const blank = -(unsafe.Offsetof(d.version) % 8) atomic.AddInt64(&d.version, 1) } diff --git a/runtime/file_test.go b/runtime/file_test.go index 2e04ea7c..d292408d 100644 --- a/runtime/file_test.go +++ b/runtime/file_test.go @@ -73,7 +73,7 @@ func TestFileCloseExit(t *testing.T) { cases := []invokeTestCase{ {args: wrapArgs(newObject(FileType)), want: None}, {args: wrapArgs(f.open("r")), want: None}, - {args: wrapArgs(closedFile), wantExc: mustCreateException(IOErrorType, "invalid argument")}, + {args: wrapArgs(closedFile), wantExc: mustCreateException(IOErrorType, closedFile.file.Close().Error())}, } for _, cas := range cases { if err := runInvokeMethodTestCase(FileType, method, &cas); err != "" { diff --git a/runtime/set.go b/runtime/set.go index a19897a7..54aa2914 100644 --- a/runtime/set.go +++ b/runtime/set.go @@ -106,10 +106,7 @@ func (s *Set) ToObject() *Object { // Update inserts all elements in the iterable o into s. func (s *Set) Update(f *Frame, o *Object) *BaseException { raised := seqForEach(f, o, func(key *Object) *BaseException { - if raised := s.dict.SetItem(f, key, None); raised != nil { - return raised - } - return nil + return s.dict.SetItem(f, key, None) }) return raised }