diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2013-12-03 09:43:15 +0100 |
---|---|---|
committer | Michael Stapelberg <stapelberg@debian.org> | 2013-12-03 09:43:15 +0100 |
commit | 64d2a7c8945ba05af859901f5e248f1befdd8621 (patch) | |
tree | 013fcb7e9e3296ecdda876012252c36bd6bcb063 /test/shift1.go | |
parent | b901efe83e212f0c34c769c079e41373da12d723 (diff) | |
download | golang-64d2a7c8945ba05af859901f5e248f1befdd8621.tar.gz |
Imported Upstream version 1.2upstream/1.2
Diffstat (limited to 'test/shift1.go')
-rw-r--r-- | test/shift1.go | 185 |
1 files changed, 93 insertions, 92 deletions
diff --git a/test/shift1.go b/test/shift1.go index 71f7861c6..44a3792c4 100644 --- a/test/shift1.go +++ b/test/shift1.go @@ -23,7 +23,7 @@ var ( // non-constant shift expressions var ( - e1 = g(2.0 << s) // ERROR "invalid" "as type interface" + e1 = g(2.0 << s) // ERROR "invalid|shift of non-integer operand" "as type interface" f1 = h(2 << s) // ERROR "invalid" "as type float64" g1 int64 = 1.1 << s // ERROR "truncated" ) @@ -39,12 +39,12 @@ var ( var ( // issues 4882, 4936. - a3 = 1.0<<s + 0 // ERROR "invalid operation|shift of non-integer operand" + a3 = 1.0<<s + 0 // ERROR "invalid|shift of non-integer operand" // issue 4937 - b3 = 1<<s + 1 + 1.0 // ERROR "invalid operation|shift of non-integer operand" + b3 = 1<<s + 1 + 1.0 // ERROR "invalid|shift of non-integer operand" // issue 5014 - c3 = complex(1<<s, 0) // ERROR "shift of type float64" - d3 int = complex(1<<s, 3) // ERROR "cannot use.*as type int" "shift of type float64" + c3 = complex(1<<s, 0) // ERROR "invalid|shift of type float64" + d3 int = complex(1<<s, 3) // ERROR "non-integer|cannot use.*as type int" "shift of type float64" e3 = real(1 << s) // ERROR "invalid" f3 = imag(1 << s) // ERROR "invalid" ) @@ -61,60 +61,61 @@ func _() { o = 1<<s == 2<<s // 1 and 2 have type int; o == true if ints are 32bits in size // next test only fails on 32bit systems // p = 1<<s == 1<<33 // illegal if ints are 32bits in size: 1 has type int, but 1<<33 overflows int - u = 1.0 << s // ERROR "float64" - u1 = 1.0<<s != 0 // ERROR "float64" - u2 = 1<<s != 1.0 // ERROR "float64" - v float32 = 1 << s // ERROR "float32" + u = 1.0 << s // ERROR "non-integer|float64" + u1 = 1.0<<s != 0 // ERROR "non-integer|float64" + u2 = 1<<s != 1.0 // ERROR "non-integer|float64" + v float32 = 1 << s // ERROR "non-integer|float32" w int64 = 1.0 << 33 // 1.0<<33 is a constant shift expression + _, _, _, _, _, _, _, _, _, _ = j, k, m, n, o, u, u1, u2, v, w ) } // shifts in comparisons w/ untyped operands var ( _ = 1<<s == 1 - _ = 1<<s == 1. // ERROR "shift of type float64" - _ = 1.<<s == 1 // ERROR "shift of type float64" - _ = 1.<<s == 1. // ERROR "shift of type float64" + _ = 1<<s == 1. // ERROR "invalid|shift of type float64" + _ = 1.<<s == 1 // ERROR "invalid|shift of type float64" + _ = 1.<<s == 1. // ERROR "invalid|non-integer|shift of type float64" _ = 1<<s+1 == 1 - _ = 1<<s+1 == 1. // ERROR "shift of type float64" - _ = 1<<s+1. == 1 // ERROR "shift of type float64" - _ = 1<<s+1. == 1. // ERROR "shift of type float64" - _ = 1.<<s+1 == 1 // ERROR "shift of type float64" - _ = 1.<<s+1 == 1. // ERROR "shift of type float64" - _ = 1.<<s+1. == 1 // ERROR "shift of type float64" - _ = 1.<<s+1. == 1. // ERROR "shift of type float64" + _ = 1<<s+1 == 1. // ERROR "invalid|shift of type float64" + _ = 1<<s+1. == 1 // ERROR "invalid|shift of type float64" + _ = 1<<s+1. == 1. // ERROR "invalid|shift of type float64" + _ = 1.<<s+1 == 1 // ERROR "invalid|shift of type float64" + _ = 1.<<s+1 == 1. // ERROR "invalid|shift of type float64" + _ = 1.<<s+1. == 1 // ERROR "invalid|shift of type float64" + _ = 1.<<s+1. == 1. // ERROR "invalid|non-integer|shift of type float64" _ = 1<<s == 1<<s - _ = 1<<s == 1.<<s // ERROR "shift of type float64" - _ = 1.<<s == 1<<s // ERROR "shift of type float64" - _ = 1.<<s == 1.<<s // ERROR "shift of type float64" + _ = 1<<s == 1.<<s // ERROR "invalid|shift of type float64" + _ = 1.<<s == 1<<s // ERROR "invalid|shift of type float64" + _ = 1.<<s == 1.<<s // ERROR "invalid|non-integer|shift of type float64" _ = 1<<s+1<<s == 1 - _ = 1<<s+1<<s == 1. // ERROR "shift of type float64" - _ = 1<<s+1.<<s == 1 // ERROR "shift of type float64" - _ = 1<<s+1.<<s == 1. // ERROR "shift of type float64" - _ = 1.<<s+1<<s == 1 // ERROR "shift of type float64" - _ = 1.<<s+1<<s == 1. // ERROR "shift of type float64" - _ = 1.<<s+1.<<s == 1 // ERROR "shift of type float64" - _ = 1.<<s+1.<<s == 1. // ERROR "shift of type float64" + _ = 1<<s+1<<s == 1. // ERROR "invalid|shift of type float64" + _ = 1<<s+1.<<s == 1 // ERROR "invalid|shift of type float64" + _ = 1<<s+1.<<s == 1. // ERROR "invalid|shift of type float64" + _ = 1.<<s+1<<s == 1 // ERROR "invalid|shift of type float64" + _ = 1.<<s+1<<s == 1. // ERROR "invalid|shift of type float64" + _ = 1.<<s+1.<<s == 1 // ERROR "invalid|shift of type float64" + _ = 1.<<s+1.<<s == 1. // ERROR "invalid|non-integer|shift of type float64" _ = 1<<s+1<<s == 1<<s+1<<s - _ = 1<<s+1<<s == 1<<s+1.<<s // ERROR "shift of type float64" - _ = 1<<s+1<<s == 1.<<s+1<<s // ERROR "shift of type float64" - _ = 1<<s+1<<s == 1.<<s+1.<<s // ERROR "shift of type float64" - _ = 1<<s+1.<<s == 1<<s+1<<s // ERROR "shift of type float64" - _ = 1<<s+1.<<s == 1<<s+1.<<s // ERROR "shift of type float64" - _ = 1<<s+1.<<s == 1.<<s+1<<s // ERROR "shift of type float64" - _ = 1<<s+1.<<s == 1.<<s+1.<<s // ERROR "shift of type float64" - _ = 1.<<s+1<<s == 1<<s+1<<s // ERROR "shift of type float64" - _ = 1.<<s+1<<s == 1<<s+1.<<s // ERROR "shift of type float64" - _ = 1.<<s+1<<s == 1.<<s+1<<s // ERROR "shift of type float64" - _ = 1.<<s+1<<s == 1.<<s+1.<<s // ERROR "shift of type float64" - _ = 1.<<s+1.<<s == 1<<s+1<<s // ERROR "shift of type float64" - _ = 1.<<s+1.<<s == 1<<s+1.<<s // ERROR "shift of type float64" - _ = 1.<<s+1.<<s == 1.<<s+1<<s // ERROR "shift of type float64" - _ = 1.<<s+1.<<s == 1.<<s+1.<<s // ERROR "shift of type float64" + _ = 1<<s+1<<s == 1<<s+1.<<s // ERROR "invalid|shift of type float64" + _ = 1<<s+1<<s == 1.<<s+1<<s // ERROR "invalid|shift of type float64" + _ = 1<<s+1<<s == 1.<<s+1.<<s // ERROR "invalid|shift of type float64" + _ = 1<<s+1.<<s == 1<<s+1<<s // ERROR "invalid|shift of type float64" + _ = 1<<s+1.<<s == 1<<s+1.<<s // ERROR "invalid|shift of type float64" + _ = 1<<s+1.<<s == 1.<<s+1<<s // ERROR "invalid|shift of type float64" + _ = 1<<s+1.<<s == 1.<<s+1.<<s // ERROR "invalid|non-integer|shift of type float64" + _ = 1.<<s+1<<s == 1<<s+1<<s // ERROR "invalid|shift of type float64" + _ = 1.<<s+1<<s == 1<<s+1.<<s // ERROR "invalid|shift of type float64" + _ = 1.<<s+1<<s == 1.<<s+1<<s // ERROR "invalid|shift of type float64" + _ = 1.<<s+1<<s == 1.<<s+1.<<s // ERROR "invalid|non-integer|shift of type float64" + _ = 1.<<s+1.<<s == 1<<s+1<<s // ERROR "invalid|shift of type float64" + _ = 1.<<s+1.<<s == 1<<s+1.<<s // ERROR "invalid|non-integer|shift of type float64" + _ = 1.<<s+1.<<s == 1.<<s+1<<s // ERROR "invalid|non-integer|shift of type float64" + _ = 1.<<s+1.<<s == 1.<<s+1.<<s // ERROR "invalid|non-integer|shift of type float64" ) // shifts in comparisons w/ typed operands @@ -122,21 +123,21 @@ var ( x int _ = 1<<s == x _ = 1.<<s == x - _ = 1.1<<s == x // ERROR "1.1 truncated" + _ = 1.1<<s == x // ERROR "truncated" _ = 1<<s+x == 1 _ = 1<<s+x == 1. - _ = 1<<s+x == 1.1 // ERROR "1.1 truncated" + _ = 1<<s+x == 1.1 // ERROR "truncated" _ = 1.<<s+x == 1 _ = 1.<<s+x == 1. - _ = 1.<<s+x == 1.1 // ERROR "1.1 truncated" - _ = 1.1<<s+x == 1 // ERROR "1.1 truncated" - _ = 1.1<<s+x == 1. // ERROR "1.1 truncated" - _ = 1.1<<s+x == 1.1 // ERROR "1.1 truncated" + _ = 1.<<s+x == 1.1 // ERROR "truncated" + _ = 1.1<<s+x == 1 // ERROR "truncated" + _ = 1.1<<s+x == 1. // ERROR "truncated" + _ = 1.1<<s+x == 1.1 // ERROR "truncated" _ = 1<<s == x<<s _ = 1.<<s == x<<s - _ = 1.1<<s == x<<s // ERROR "1.1 truncated" + _ = 1.1<<s == x<<s // ERROR "truncated" ) // shifts as operands in non-arithmetic operations and as arguments @@ -146,43 +147,43 @@ func _() { _ = a[1<<s] _ = a[1.] // For now, the spec disallows these. We may revisit past Go 1.1. - _ = a[1.<<s] // ERROR "shift of type float64" - _ = a[1.1<<s] // ERROR "shift of type float64" + _ = a[1.<<s] // ERROR "integer|shift of type float64" + _ = a[1.1<<s] // ERROR "integer|shift of type float64" _ = make([]int, 1) _ = make([]int, 1.) _ = make([]int, 1.<<s) - _ = make([]int, 1.1<<s) // ERROR "1.1 truncated" + _ = make([]int, 1.1<<s) // ERROR "non-integer|truncated" _ = float32(1) - _ = float32(1 << s) // ERROR "shift of type float32" + _ = float32(1 << s) // ERROR "non-integer|shift of type float32" _ = float32(1.) - _ = float32(1. << s) // ERROR "shift of type float32" - _ = float32(1.1 << s) // ERROR "shift of type float32" + _ = float32(1. << s) // ERROR "non-integer|shift of type float32" + _ = float32(1.1 << s) // ERROR "non-integer|shift of type float32" _ = append(a, 1<<s) _ = append(a, 1.<<s) - _ = append(a, 1.1<<s) // ERROR "1.1 truncated" + _ = append(a, 1.1<<s) // ERROR "truncated" var b []float32 - _ = append(b, 1<<s) // ERROR "type float32" - _ = append(b, 1.<<s) // ERROR "type float32" - _ = append(b, 1.1<<s) // ERROR "type float32" + _ = append(b, 1<<s) // ERROR "non-integer|type float32" + _ = append(b, 1.<<s) // ERROR "non-integer|type float32" + _ = append(b, 1.1<<s) // ERROR "non-integer|type float32" - _ = complex(1.<<s, 0) // ERROR "shift of type float64" - _ = complex(1.1<<s, 0) // ERROR "shift of type float64" - _ = complex(0, 1.<<s) // ERROR "shift of type float64" - _ = complex(0, 1.1<<s) // ERROR "shift of type float64" + _ = complex(1.<<s, 0) // ERROR "non-integer|shift of type float64" + _ = complex(1.1<<s, 0) // ERROR "non-integer|shift of type float64" + _ = complex(0, 1.<<s) // ERROR "non-integer|shift of type float64" + _ = complex(0, 1.1<<s) // ERROR "non-integer|shift of type float64" var a4 float64 var b4 int - _ = complex(1<<s, a4) // ERROR "shift of type float64" - _ = complex(1<<s, b4) // ERROR "invalid" + _ = complex(1<<s, a4) // ERROR "non-integer|shift of type float64" + _ = complex(1<<s, b4) // ERROR "invalid|non-integer|" var m1 map[int]string delete(m1, 1<<s) delete(m1, 1.<<s) - delete(m1, 1.1<<s) // ERROR "1.1 truncated|shift of type float64" + delete(m1, 1.1<<s) // ERROR "truncated|shift of type float64" var m2 map[float32]string delete(m2, 1<<s) // ERROR "invalid|cannot use 1 << s as type float32" @@ -195,46 +196,46 @@ func _() { var s uint _ = 1 << (1 << s) _ = 1 << (1. << s) - _ = 1 << (1.1 << s) // ERROR "1.1 truncated" - _ = 1. << (1 << s) // ERROR "shift of type float64" - _ = 1. << (1. << s) // ERROR "shift of type float64" - _ = 1.1 << (1.1 << s) // ERROR "invalid|1.1 truncated" + _ = 1 << (1.1 << s) // ERROR "non-integer|truncated" + _ = 1. << (1 << s) // ERROR "non-integer|shift of type float64" + _ = 1. << (1. << s) // ERROR "non-integer|shift of type float64" + _ = 1.1 << (1.1 << s) // ERROR "invalid|non-integer|truncated" _ = (1 << s) << (1 << s) _ = (1 << s) << (1. << s) - _ = (1 << s) << (1.1 << s) // ERROR "1.1 truncated" - _ = (1. << s) << (1 << s) // ERROR "shift of type float64" - _ = (1. << s) << (1. << s) // ERROR "shift of type float64" - _ = (1.1 << s) << (1.1 << s) // ERROR "invalid|1.1 truncated" + _ = (1 << s) << (1.1 << s) // ERROR "truncated" + _ = (1. << s) << (1 << s) // ERROR "non-integer|shift of type float64" + _ = (1. << s) << (1. << s) // ERROR "non-integer|shift of type float64" + _ = (1.1 << s) << (1.1 << s) // ERROR "invalid|non-integer|truncated" var x int x = 1 << (1 << s) x = 1 << (1. << s) - x = 1 << (1.1 << s) // ERROR "1.1 truncated" + x = 1 << (1.1 << s) // ERROR "truncated" x = 1. << (1 << s) x = 1. << (1. << s) - x = 1.1 << (1.1 << s) // ERROR "1.1 truncated" + x = 1.1 << (1.1 << s) // ERROR "truncated" x = (1 << s) << (1 << s) x = (1 << s) << (1. << s) - x = (1 << s) << (1.1 << s) // ERROR "1.1 truncated" + x = (1 << s) << (1.1 << s) // ERROR "truncated" x = (1. << s) << (1 << s) x = (1. << s) << (1. << s) - x = (1.1 << s) << (1.1 << s) // ERROR "1.1 truncated" + x = (1.1 << s) << (1.1 << s) // ERROR "truncated" var y float32 - y = 1 << (1 << s) // ERROR "type float32" - y = 1 << (1. << s) // ERROR "type float32" - y = 1 << (1.1 << s) // ERROR "invalid|1.1 truncated|float32" - y = 1. << (1 << s) // ERROR "type float32" - y = 1. << (1. << s) // ERROR "type float32" - y = 1.1 << (1.1 << s) // ERROR "invalid|1.1 truncated|float32" + y = 1 << (1 << s) // ERROR "non-integer|type float32" + y = 1 << (1. << s) // ERROR "non-integer|type float32" + y = 1 << (1.1 << s) // ERROR "invalid|truncated|float32" + y = 1. << (1 << s) // ERROR "non-integer|type float32" + y = 1. << (1. << s) // ERROR "non-integer|type float32" + y = 1.1 << (1.1 << s) // ERROR "invalid|truncated|float32" var z complex128 - z = (1 << s) << (1 << s) // ERROR "type complex128" - z = (1 << s) << (1. << s) // ERROR "type complex128" - z = (1 << s) << (1.1 << s) // ERROR "invalid|1.1 truncated|complex128" - z = (1. << s) << (1 << s) // ERROR "type complex128" - z = (1. << s) << (1. << s) // ERROR "type complex128" - z = (1.1 << s) << (1.1 << s) // ERROR "invalid|1.1 truncated|complex128" + z = (1 << s) << (1 << s) // ERROR "non-integer|type complex128" + z = (1 << s) << (1. << s) // ERROR "non-integer|type complex128" + z = (1 << s) << (1.1 << s) // ERROR "invalid|truncated|complex128" + z = (1. << s) << (1 << s) // ERROR "non-integer|type complex128" + z = (1. << s) << (1. << s) // ERROR "non-integer|type complex128" + z = (1.1 << s) << (1.1 << s) // ERROR "invalid|truncated|complex128" } |