Commit 19bb42d6 authored by Alan Donovan's avatar Alan Donovan

math/big: make tests faster by reducing coverage in --test.short mode.

The time to test all of math/big is now:
 default      => ~3min
 --test.short => 150ms

R=rsc
CC=golang-dev
https://golang.org/cl/7223054
parent 1aa56a23
...@@ -500,8 +500,8 @@ func TestIssue3521(t *testing.T) { ...@@ -500,8 +500,8 @@ func TestIssue3521(t *testing.T) {
} }
} }
// Test inputs to Rat.SetString. The optional prefix "slow:" skips // Test inputs to Rat.SetString. The prefix "long:" causes the test
// checks found to be slow for certain large rationals. // to be skipped in --test.short mode. (The threshold is about 500us.)
var float64inputs = []string{ var float64inputs = []string{
// //
// Constants plundered from strconv/testfp.txt. // Constants plundered from strconv/testfp.txt.
...@@ -630,8 +630,8 @@ var float64inputs = []string{ ...@@ -630,8 +630,8 @@ var float64inputs = []string{
"-1e310", "-1e310",
"1e400", "1e400",
"-1e400", "-1e400",
"1e400000", "long:1e400000",
"-1e400000", "long:-1e400000",
// denormalized // denormalized
"1e-305", "1e-305",
...@@ -649,10 +649,10 @@ var float64inputs = []string{ ...@@ -649,10 +649,10 @@ var float64inputs = []string{
"2e-324", "2e-324",
// way too small // way too small
"1e-350", "1e-350",
"slow:1e-400000", "long:1e-400000",
// way too small, negative // way too small, negative
"-1e-350", "-1e-350",
"slow:-1e-400000", "long:-1e-400000",
// try to overflow exponent // try to overflow exponent
// [Disabled: too slow and memory-hungry with rationals.] // [Disabled: too slow and memory-hungry with rationals.]
...@@ -672,7 +672,7 @@ var float64inputs = []string{ ...@@ -672,7 +672,7 @@ var float64inputs = []string{
// A different kind of very large number. // A different kind of very large number.
"22.222222222222222", "22.222222222222222",
"2." + strings.Repeat("2", 4000) + "e+1", "long:2." + strings.Repeat("2", 4000) + "e+1",
// Exactly halfway between 1 and math.Nextafter(1, 2). // Exactly halfway between 1 and math.Nextafter(1, 2).
// Round to even (down). // Round to even (down).
...@@ -682,7 +682,7 @@ var float64inputs = []string{ ...@@ -682,7 +682,7 @@ var float64inputs = []string{
// Slightly higher; round up. // Slightly higher; round up.
"1.00000000000000011102230246251565404236316680908203126", "1.00000000000000011102230246251565404236316680908203126",
// Slightly higher, but you have to read all the way to the end. // Slightly higher, but you have to read all the way to the end.
"slow:1.00000000000000011102230246251565404236316680908203125" + strings.Repeat("0", 10000) + "1", "long:1.00000000000000011102230246251565404236316680908203125" + strings.Repeat("0", 10000) + "1",
// Smallest denormal, 2^(-1022-52) // Smallest denormal, 2^(-1022-52)
"4.940656458412465441765687928682213723651e-324", "4.940656458412465441765687928682213723651e-324",
...@@ -705,9 +705,11 @@ var float64inputs = []string{ ...@@ -705,9 +705,11 @@ var float64inputs = []string{
func TestFloat64SpecialCases(t *testing.T) { func TestFloat64SpecialCases(t *testing.T) {
for _, input := range float64inputs { for _, input := range float64inputs {
slow := strings.HasPrefix(input, "slow:") if strings.HasPrefix(input, "long:") {
if slow { if testing.Short() {
input = input[len("slow:"):] continue
}
input = input[len("long:"):]
} }
r, ok := new(Rat).SetString(input) r, ok := new(Rat).SetString(input)
...@@ -736,7 +738,7 @@ func TestFloat64SpecialCases(t *testing.T) { ...@@ -736,7 +738,7 @@ func TestFloat64SpecialCases(t *testing.T) {
} }
} }
if !isFinite(f) || slow { if !isFinite(f) {
continue continue
} }
...@@ -769,8 +771,11 @@ func TestFloat64Distribution(t *testing.T) { ...@@ -769,8 +771,11 @@ func TestFloat64Distribution(t *testing.T) {
9, 9,
11, 11,
} }
const winc, einc = 5, 100 // quick test (<1s) var winc, einc = uint64(1), int(1) // soak test (~75s on x86-64)
//const winc, einc = 1, 1 // soak test (~75s) if testing.Short() {
winc, einc = 10, 500 // quick test (~12ms on x86-64)
}
for _, sign := range "+-" { for _, sign := range "+-" {
for _, a := range add { for _, a := range add {
for wid := uint64(0); wid < 60; wid += winc { for wid := uint64(0); wid < 60; wid += winc {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment