aboutsummaryrefslogtreecommitdiff
path: root/test/switch5.go
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo@golang.org>2018-10-16 13:01:07 -0400
committerFilippo Valsorda <filippo@golang.org>2018-10-16 21:54:35 +0000
commita52289ef2bf7e9b7a619caecc14d6c95eff9eeae (patch)
tree5baa3e49cc86a1e4bbebefe1e344d9d442d8025b /test/switch5.go
parent965fa3b191270bbc23a040a520ce43406ba29343 (diff)
downloadgo-a52289ef2bf7e9b7a619caecc14d6c95eff9eeae.tar.gz
go-a52289ef2bf7e9b7a619caecc14d6c95eff9eeae.zip
Revert "fmt: fix incorrect format of whole-number floats when using %#v"
Numbers without decimals are valid Go representations of whole-number floats. That is, "var x float64 = 5" is valid Go. Avoid breakage in tests that expect a certain output from %#v by reverting to it. To guarantee the right type is generated by a print use %T(%#v) instead. Added a test to lock in this behavior. This reverts commit 7c7cecc1846aaaa0ce73931644fe1df2b4559e09. Fixes #27634 Updates #26363 Change-Id: I544c400a0903777dd216452a7e86dfe60b0b0283 Reviewed-on: https://go-review.googlesource.com/c/142597 Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'test/switch5.go')
-rw-r--r--test/switch5.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/test/switch5.go b/test/switch5.go
index 6641d582bc..ce95bf8d7b 100644
--- a/test/switch5.go
+++ b/test/switch5.go
@@ -24,8 +24,8 @@ func f0(x int) {
func f1(x float32) {
switch x {
case 5:
- case 5: // ERROR "duplicate case 5 .value 5\.0. in switch"
- case 5.0: // ERROR "duplicate case 5 .value 5\.0. in switch"
+ case 5: // ERROR "duplicate case 5 in switch"
+ case 5.0: // ERROR "duplicate case 5 in switch"
}
}
@@ -44,9 +44,9 @@ func f3(e interface{}) {
case 0: // ERROR "duplicate case 0 in switch"
case int64(0):
case float32(10):
- case float32(10): // ERROR "duplicate case float32\(10\) .value 10\.0. in switch"
+ case float32(10): // ERROR "duplicate case float32\(10\) .value 10. in switch"
case float64(10):
- case float64(10): // ERROR "duplicate case float64\(10\) .value 10\.0. in switch"
+ case float64(10): // ERROR "duplicate case float64\(10\) .value 10. in switch"
}
}