Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add precision to the frequency based on the number of test #952

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/shared/src/main/scala/org/scalacheck/util/Pretty.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ package org.scalacheck.util
import org.scalacheck.Prop.Arg
import org.scalacheck.Test
import scala.annotation.tailrec
import scala.math.round

sealed trait Pretty extends Serializable {
def apply(prms: Pretty.Params): String
Expand Down Expand Up @@ -143,12 +142,13 @@ object Pretty {
implicit def prettyFreqMap(fm: FreqMap[Set[Any]]): Pretty = Pretty { _ =>
if(fm.total == 0) ""
else {
val precision = if (fm.total <= 100) 0 else if (fm.total <= 1000) 1 else 2
"> Collected test data: " / {
for {
(xs,r) <- fm.getRatios
ys = xs - (())
if !ys.isEmpty
} yield round(r*100).toString + "% " + ys.mkString(", ")
} yield s"%.${precision}f".format(r * 100) + "% " + ys.mkString(", ")
}.mkString("\n")
}
}
Expand Down