Commit 9a8832f1 authored by Russ Cox's avatar Russ Cox

math/big: move exhaustive tests behind -long flag

This way you can still run 'go test' or 'go bench -run Foo'
without wondering why it is taking so very long.

Change-Id: Icfa097a6deb1d6682acb7be9f34729215c29eabb
Reviewed-on: https://go-review.googlesource.com/30707Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
parent 2756d56c
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package big package big
import ( import (
"flag"
"fmt" "fmt"
"math" "math"
"strconv" "strconv"
...@@ -1495,12 +1496,14 @@ func TestFloatQuo(t *testing.T) { ...@@ -1495,12 +1496,14 @@ func TestFloatQuo(t *testing.T) {
} }
} }
var long = flag.Bool("long", false, "run very long tests")
// TestFloatQuoSmoke tests all divisions x/y for values x, y in the range [-n, +n]; // TestFloatQuoSmoke tests all divisions x/y for values x, y in the range [-n, +n];
// it serves as a smoke test for basic correctness of division. // it serves as a smoke test for basic correctness of division.
func TestFloatQuoSmoke(t *testing.T) { func TestFloatQuoSmoke(t *testing.T) {
n := 1000 n := 10
if testing.Short() { if *long {
n = 10 n = 1000
} }
const dprec = 3 // max. precision variation const dprec = 3 // max. precision variation
......
...@@ -382,9 +382,9 @@ func TestFloat32Distribution(t *testing.T) { ...@@ -382,9 +382,9 @@ func TestFloat32Distribution(t *testing.T) {
9, 9,
11, 11,
} }
var winc, einc = uint64(1), 1 // soak test (~1.5s on x86-64) var winc, einc = uint64(5), 15 // quick test (~60ms on x86-64)
if testing.Short() { if testing.Short() {
winc, einc = 5, 15 // quick test (~60ms on x86-64) winc, einc = uint64(1), 1 // soak test (~1.5s on x86-64)
} }
for _, sign := range "+-" { for _, sign := range "+-" {
...@@ -430,9 +430,9 @@ func TestFloat64Distribution(t *testing.T) { ...@@ -430,9 +430,9 @@ func TestFloat64Distribution(t *testing.T) {
9, 9,
11, 11,
} }
var winc, einc = uint64(1), 1 // soak test (~75s on x86-64) var winc, einc = uint64(10), 500 // quick test (~12ms on x86-64)
if testing.Short() { if *long {
winc, einc = 10, 500 // quick test (~12ms on x86-64) winc, einc = uint64(1), 1 // soak test (~75s on x86-64)
} }
for _, sign := range "+-" { for _, sign := range "+-" {
......
...@@ -144,7 +144,7 @@ func TestFloatString(t *testing.T) { ...@@ -144,7 +144,7 @@ func TestFloatString(t *testing.T) {
} }
// Test inputs to Rat.SetString. The prefix "long:" causes the test // Test inputs to Rat.SetString. The prefix "long:" causes the test
// to be skipped in --test.short mode. (The threshold is about 500us.) // to be skipped except in -long mode. (The threshold is about 500us.)
var float64inputs = []string{ var float64inputs = []string{
// Constants plundered from strconv/testfp.txt. // Constants plundered from strconv/testfp.txt.
...@@ -350,7 +350,7 @@ func isFinite(f float64) bool { ...@@ -350,7 +350,7 @@ func isFinite(f float64) bool {
func TestFloat32SpecialCases(t *testing.T) { func TestFloat32SpecialCases(t *testing.T) {
for _, input := range float64inputs { for _, input := range float64inputs {
if strings.HasPrefix(input, "long:") { if strings.HasPrefix(input, "long:") {
if testing.Short() { if !*long {
continue continue
} }
input = input[len("long:"):] input = input[len("long:"):]
...@@ -406,7 +406,7 @@ func TestFloat32SpecialCases(t *testing.T) { ...@@ -406,7 +406,7 @@ func TestFloat32SpecialCases(t *testing.T) {
func TestFloat64SpecialCases(t *testing.T) { func TestFloat64SpecialCases(t *testing.T) {
for _, input := range float64inputs { for _, input := range float64inputs {
if strings.HasPrefix(input, "long:") { if strings.HasPrefix(input, "long:") {
if testing.Short() { if !*long {
continue continue
} }
input = input[len("long:"):] input = input[len("long:"):]
......
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