Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Commit 3ec8795

Browse files
corona10trotterdylan
authored andcommitted
runtime: Fix complain about linting and Go 1.9 compiler error. (#384)
1 parent 2c8ff4b commit 3ec8795

File tree

7 files changed

+19
-14
lines changed

7 files changed

+19
-14
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ language: go
22
os:
33
- linux
44
- osx
5+
before_script:
6+
- rvm get head || true # https://github.com/travis-ci/travis-ci/issues/6307
7+
- set -e
58
# Run gofmt and lint serially to avoid confusing output. Run tests in parallel
69
# for speed.
710
script: make gofmt lint && make -j2 test
11+
after_script: set +e

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ endif
3333
PYTHON_BIN := $(shell which $(PYTHON))
3434
PYTHON_VER := $(word 2,$(shell $(PYTHON) -V 2>&1))
3535
GO_REQ_MAJ := 1
36-
GO_REQ_MIN := 6
36+
GO_REQ_MIN := 9
3737
GO_MAJ_MIN := $(subst go,, $(word 3,$(shell go version 2>&1)) )
3838
GO_MAJ := $(word 1,$(subst ., ,$(GO_MAJ_MIN) ))
3939
GO_MIN := $(word 2,$(subst ., ,$(GO_MAJ_MIN) ))

runtime/complex.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ func complexModOp(v, w complex128) complex128 {
457457
}
458458

459459
const (
460-
_ = iota
460+
blank = iota
461461
real1
462462
imag1
463463
real2

runtime/complex_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ func TestComplexEq(t *testing.T) {
7575
}
7676
}
7777

78+
// FIXME(corona10): Since Go 1.9 moved to C99 float division and what CPython uses as well.
79+
// Some tests can be failed with version < Go 1.9. We need to detect Go version.
80+
// And changed expected values.
81+
7882
func TestComplexBinaryOps(t *testing.T) {
7983
cases := []struct {
8084
fun func(f *Frame, v, w *Object) (*Object, *BaseException)
@@ -107,8 +111,8 @@ func TestComplexBinaryOps(t *testing.T) {
107111
{Div, NewComplex(3 - 4i).ToObject(), NewLong(big.NewInt(-34)).ToObject(), NewComplex(-0.08823529411764706 + 0.11764705882352941i).ToObject(), nil},
108112
{Div, NewComplex(3 + 4i).ToObject(), NewComplex(complex(math.Inf(1), math.Inf(-1))).ToObject(), NewComplex(0i).ToObject(), nil},
109113
{Div, NewComplex(3 + 4i).ToObject(), NewComplex(complex(math.Inf(1), 2)).ToObject(), NewComplex(0i).ToObject(), nil},
110-
{Div, NewComplex(complex(math.Inf(1), math.Inf(1))).ToObject(), NewComplex(1 + 2i).ToObject(), NewComplex(complex(math.Inf(1), math.Inf(1))).ToObject(), nil},
111-
{Div, NewComplex(complex(math.Inf(1), 4)).ToObject(), NewComplex(1 + 2i).ToObject(), NewComplex(complex(math.Inf(1), math.Inf(1))).ToObject(), nil},
114+
{Div, NewComplex(complex(math.Inf(1), math.Inf(1))).ToObject(), NewComplex(1 + 2i).ToObject(), NewComplex(complex(math.Inf(1), math.NaN())).ToObject(), nil},
115+
{Div, NewComplex(complex(math.Inf(1), 4)).ToObject(), NewComplex(1 + 2i).ToObject(), NewComplex(complex(math.Inf(1), math.Inf(-1))).ToObject(), nil},
112116
{Div, NewComplex(complex(3, math.Inf(1))).ToObject(), NewComplex(1 + 2i).ToObject(), NewComplex(complex(math.Inf(1), math.Inf(1))).ToObject(), nil},
113117
{Div, NewComplex(complex(3, math.NaN())).ToObject(), NewComplex(1 + 2i).ToObject(), NewComplex(complex(math.NaN(), math.NaN())).ToObject(), nil},
114118
{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) {
189193
{Pow, NewComplex(complex(math.Inf(-1), 2)).ToObject(), NewComplex(1 + 2i).ToObject(), NewComplex(complex(math.NaN(), math.NaN())).ToObject(), nil},
190194
{Pow, NewComplex(1 + 2i).ToObject(), NewComplex(complex(1, math.Inf(1))).ToObject(), NewComplex(complex(math.NaN(), math.NaN())).ToObject(), nil},
191195
{Pow, NewComplex(complex(math.NaN(), 1)).ToObject(), NewComplex(3 + 4i).ToObject(), NewComplex(complex(math.NaN(), math.NaN())).ToObject(), nil},
192-
{Pow, NewComplex(3 + 4i).ToObject(), NewInt(3).ToObject(), NewComplex(-117 + 44.000000000000036i).ToObject(), nil},
193-
{Pow, NewComplex(3 + 4i).ToObject(), NewFloat(3.1415).ToObject(), NewComplex(-152.8892667678244 + 35.55533513049651i).ToObject(), nil},
196+
{Pow, NewComplex(3 + 4i).ToObject(), NewInt(3).ToObject(), NewComplex(-117 + 44.00000000000003i).ToObject(), nil},
197+
{Pow, NewComplex(3 + 4i).ToObject(), NewFloat(3.1415).ToObject(), NewComplex(-152.8892667678244 + 35.555335130496516i).ToObject(), nil},
194198
{Pow, NewComplex(3 + 4i).ToObject(), NewLong(big.NewInt(123)).ToObject(), NewComplex(5.393538720276193e+85 + 7.703512580443326e+85i).ToObject(), nil},
195199
{Pow, NewComplex(1 + 2i).ToObject(), NewStr("foo").ToObject(), nil, mustCreateException(TypeErrorType, "unsupported operand type(s) for **: 'complex' and 'str'")},
196200
{Pow, NewStr("foo").ToObject(), NewComplex(1 + 2i).ToObject(), nil, mustCreateException(TypeErrorType, "unsupported operand type(s) for **: 'str' and 'complex'")},

runtime/dict.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func (iter *dictEntryIterator) next() *dictEntry {
230230
// 64bit atomic ops need to be 8 byte aligned. This compile time check
231231
// verifies alignment by creating a negative constant for an unsigned type.
232232
// See sync/atomic docs for details.
233-
const _ = -(unsafe.Offsetof(iter.index) % 8)
233+
const blank = -(unsafe.Offsetof(iter.index) % 8)
234234
index := int(atomic.AddInt64(&iter.index, 1)) - 1
235235
if index >= numEntries {
236236
break
@@ -310,7 +310,7 @@ func (d *Dict) loadVersion() int64 {
310310
// 64bit atomic ops need to be 8 byte aligned. This compile time check
311311
// verifies alignment by creating a negative constant for an unsigned type.
312312
// See sync/atomic docs for details.
313-
const _ = -(unsafe.Offsetof(d.version) % 8)
313+
const blank = -(unsafe.Offsetof(d.version) % 8)
314314
return atomic.LoadInt64(&d.version)
315315
}
316316

@@ -319,7 +319,7 @@ func (d *Dict) incVersion() {
319319
// 64bit atomic ops need to be 8 byte aligned. This compile time check
320320
// verifies alignment by creating a negative constant for an unsigned type.
321321
// See sync/atomic docs for details.
322-
const _ = -(unsafe.Offsetof(d.version) % 8)
322+
const blank = -(unsafe.Offsetof(d.version) % 8)
323323
atomic.AddInt64(&d.version, 1)
324324
}
325325

runtime/file_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func TestFileCloseExit(t *testing.T) {
7373
cases := []invokeTestCase{
7474
{args: wrapArgs(newObject(FileType)), want: None},
7575
{args: wrapArgs(f.open("r")), want: None},
76-
{args: wrapArgs(closedFile), wantExc: mustCreateException(IOErrorType, "invalid argument")},
76+
{args: wrapArgs(closedFile), wantExc: mustCreateException(IOErrorType, closedFile.file.Close().Error())},
7777
}
7878
for _, cas := range cases {
7979
if err := runInvokeMethodTestCase(FileType, method, &cas); err != "" {

runtime/set.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,7 @@ func (s *Set) ToObject() *Object {
106106
// Update inserts all elements in the iterable o into s.
107107
func (s *Set) Update(f *Frame, o *Object) *BaseException {
108108
raised := seqForEach(f, o, func(key *Object) *BaseException {
109-
if raised := s.dict.SetItem(f, key, None); raised != nil {
110-
return raised
111-
}
112-
return nil
109+
return s.dict.SetItem(f, key, None)
113110
})
114111
return raised
115112
}

0 commit comments

Comments
 (0)