summaryrefslogtreecommitdiffstats
path: root/test/fixedbugs/issue13559.go
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:19:13 +0000
commitccd992355df7192993c666236047820244914598 (patch)
treef00fea65147227b7743083c6148396f74cd66935 /test/fixedbugs/issue13559.go
parentInitial commit. (diff)
downloadgolang-1.21-ccd992355df7192993c666236047820244914598.tar.xz
golang-1.21-ccd992355df7192993c666236047820244914598.zip
Adding upstream version 1.21.8.upstream/1.21.8
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/fixedbugs/issue13559.go')
-rw-r--r--test/fixedbugs/issue13559.go89
1 files changed, 89 insertions, 0 deletions
diff --git a/test/fixedbugs/issue13559.go b/test/fixedbugs/issue13559.go
new file mode 100644
index 0000000..cc139d5
--- /dev/null
+++ b/test/fixedbugs/issue13559.go
@@ -0,0 +1,89 @@
+// errorcheck
+
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Verify that error messages print meaningful values
+// for various extreme floating-point constants.
+
+package p
+
+// failure case in issue
+const _ int64 = 1e-10000 // ERROR "1e\-10000 truncated|.* truncated to int64|truncated"
+
+const (
+ _ int64 = 1e10000000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = 1e1000000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = 1e100000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = 1e10000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = 1e1000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = 1e100 // ERROR "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 overflows|truncated to int64|truncated"
+ _ int64 = 1e10
+ _ int64 = 1e1
+ _ int64 = 1e0
+ _ int64 = 1e-1 // ERROR "0\.1 truncated|.* truncated to int64|truncated"
+ _ int64 = 1e-10 // ERROR "1e\-10 truncated|.* truncated to int64|truncated"
+ _ int64 = 1e-100 // ERROR "1e\-100 truncated|.* truncated to int64|truncated"
+ _ int64 = 1e-1000 // ERROR "1e\-1000 truncated|.* truncated to int64|truncated"
+ _ int64 = 1e-10000 // ERROR "1e\-10000 truncated|.* truncated to int64|truncated"
+ _ int64 = 1e-100000 // ERROR "1e\-100000 truncated|.* truncated to int64|truncated"
+ _ int64 = 1e-1000000 // ERROR "1e\-1000000 truncated|.* truncated to int64|truncated"
+)
+
+const (
+ _ int64 = -1e10000000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = -1e1000000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = -1e100000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = -1e10000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = -1e1000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = -1e100 // ERROR "\-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 overflows|truncated to int64|truncated"
+ _ int64 = -1e10
+ _ int64 = -1e1
+ _ int64 = -1e0
+ _ int64 = -1e-1 // ERROR "\-0\.1 truncated|.* truncated to int64|truncated"
+ _ int64 = -1e-10 // ERROR "\-1e\-10 truncated|.* truncated to int64|truncated"
+ _ int64 = -1e-100 // ERROR "\-1e\-100 truncated|.* truncated to int64|truncated"
+ _ int64 = -1e-1000 // ERROR "\-1e\-1000 truncated|.* truncated to int64|truncated"
+ _ int64 = -1e-10000 // ERROR "\-1e\-10000 truncated|.* truncated to int64|truncated"
+ _ int64 = -1e-100000 // ERROR "\-1e\-100000 truncated|.* truncated to int64|truncated"
+ _ int64 = -1e-1000000 // ERROR "\-1e\-1000000 truncated|.* truncated to int64|truncated"
+)
+
+const (
+ _ int64 = 1.23456789e10000000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = 1.23456789e1000000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = 1.23456789e100000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = 1.23456789e10000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = 1.23456789e1000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = 1.23456789e100 // ERROR "12345678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 overflows|truncated to int64|truncated"
+ _ int64 = 1.23456789e10
+ _ int64 = 1.23456789e1 // ERROR "12\.3457 truncated|.* truncated to int64|truncated"
+ _ int64 = 1.23456789e0 // ERROR "1\.23457 truncated|.* truncated to int64|truncated"
+ _ int64 = 1.23456789e-1 // ERROR "0\.123457 truncated|.* truncated to int64|truncated"
+ _ int64 = 1.23456789e-10 // ERROR "1\.23457e\-10 truncated|.* truncated to int64|truncated"
+ _ int64 = 1.23456789e-100 // ERROR "1\.23457e\-100 truncated|.* truncated to int64|truncated"
+ _ int64 = 1.23456789e-1000 // ERROR "1\.23457e\-1000 truncated|.* truncated to int64|truncated"
+ _ int64 = 1.23456789e-10000 // ERROR "1\.23457e\-10000 truncated|.* truncated to int64|truncated"
+ _ int64 = 1.23456789e-100000 // ERROR "1\.23457e\-100000 truncated|.* truncated to int64|truncated"
+ _ int64 = 1.23456789e-1000000 // ERROR "1\.23457e\-1000000 truncated|.* truncated to int64|truncated"
+)
+
+const (
+ _ int64 = -1.23456789e10000000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = -1.23456789e1000000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = -1.23456789e100000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = -1.23456789e10000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = -1.23456789e1000 // ERROR "integer too large|truncated to int64|truncated"
+ _ int64 = -1.23456789e100 // ERROR "\-12345678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 overflows|truncated to int64|truncated"
+ _ int64 = -1.23456789e10
+ _ int64 = -1.23456789e1 // ERROR "\-12\.3457 truncated|.* truncated to int64|truncated"
+ _ int64 = -1.23456789e0 // ERROR "\-1\.23457 truncated|.* truncated to int64|truncated"
+ _ int64 = -1.23456789e-1 // ERROR "\-0\.123457 truncated|.* truncated to int64|truncated"
+ _ int64 = -1.23456789e-10 // ERROR "\-1\.23457e\-10 truncated|.* truncated to int64|truncated"
+ _ int64 = -1.23456789e-100 // ERROR "\-1\.23457e\-100 truncated|.* truncated to int64|truncated"
+ _ int64 = -1.23456789e-1000 // ERROR "\-1\.23457e\-1000 truncated|.* truncated to int64|truncated"
+ _ int64 = -1.23456789e-10000 // ERROR "\-1\.23457e\-10000 truncated|.* truncated to int64|truncated"
+ _ int64 = -1.23456789e-100000 // ERROR "\-1\.23457e\-100000 truncated|.* truncated to int64|truncated"
+ _ int64 = -1.23456789e-1000000 // ERROR "\-1\.23457e\-1000000 truncated|.* truncated to int64|truncated"
+)