Skip to content

Commit 8b84346

Browse files
committed
Homogenize use and definitions with () paramteres
1 parent 0be1ffe commit 8b84346

File tree

14 files changed

+29
-25
lines changed

14 files changed

+29
-25
lines changed

common-test/src/main/scala/org/scalatest/prop/CommonGenerators.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2403,7 +2403,7 @@ trait CommonGenerators {
24032403
// classify will need to use the same sizing algo as forAll, and same edges approach
24042404
def classify[A](count: PosInt, genOfA: Generator[A])(pf: PartialFunction[A, String]): Classification = {
24052405

2406-
val (initEdges, rnd1) = genOfA.initEdges(100, Randomizer.default())
2406+
val (initEdges, rnd1) = genOfA.initEdges(100, Randomizer.default)
24072407
@tailrec
24082408
def loop(currentCount: Int, edges: List[A], rnd: Randomizer, acc: Map[String, PosZInt]): Map[String, PosZInt] = {
24092409
if (currentCount >= count) acc

common-test/src/main/scala/org/scalatest/prop/Randomizer.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,7 +2204,7 @@ object Randomizer {
22042204
/**
22052205
* This seed is empty under ordinary circumstances. It is here so that the test
22062206
* Runner can poke in a seed value to be used during a test run. If set, it will be used
2207-
* as the seed for all calls to [[Randomizer.default()]].
2207+
* as the seed for all calls to [[Randomizer.default]].
22082208
*/
22092209
private[scalatest] val defaultSeed: AtomicReference[Option[Long]] = new AtomicReference(None)
22102210

@@ -2216,7 +2216,7 @@ object Randomizer {
22162216
*
22172217
* @return A Randomizer, ready to begin producing random values.
22182218
*/
2219-
def default(): Randomizer =
2219+
def default: Randomizer =
22202220
apply(
22212221
defaultSeed.get() match {
22222222
case Some(seed) => seed
@@ -2236,7 +2236,7 @@ object Randomizer {
22362236
* your "random" events.
22372237
*
22382238
* If you want to create an adequate seed to feed into here, the value of [[System.currentTimeMillis()]] is
2239-
* reasonable (and is used in [[Randomizer.default()]]). It's a somewhat weak seed, but decent for most
2239+
* reasonable (and is used in [[Randomizer.default]]). It's a somewhat weak seed, but decent for most
22402240
* purposes.
22412241
*
22422242
* @param seed A number that will be used to initialize a new Randomizer.

project/GenResources.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,16 @@ trait GenResourcesJVM extends GenResources {
158158
if (paramCount > 0)
159159
"def " + kv.key + "(" + (for (i <- 0 until paramCount) yield s"param$i: Any").mkString(", ") + "): String = makeString(\"" + kv.key + "\", Array(" + (for (i <- 0 until paramCount) yield s"param$i").mkString(", ") + "))"
160160
else
161-
"def " + kv.key + "(): String = resourceBundle.getString(\"" + kv.key + "\")"
161+
"def " + kv.key + ": String = resourceBundle.getString(\"" + kv.key + "\")"
162162
) + "\n\n" +
163163
"def raw" + kv.key.capitalize + ": String = resourceBundle.getString(\"" + kv.key + "\")"
164164

165-
def failureMessagesKeyValueTemplate(kv: KeyValue, paramCount: Int): String =
166-
"def " + kv.key + (if (paramCount == 0) "(" else "(prettifier: org.scalactic.Prettifier, ") + (for (i <- 0 until paramCount) yield s"param$i: Any").mkString(", ") + "): String = Resources." + kv.key + "(" + (for (i <- 0 until paramCount) yield s"prettifier.apply(param$i)").mkString(", ") + ")"
165+
def failureMessagesKeyValueTemplate(kv: KeyValue, paramCount: Int): String = {
166+
if (paramCount == 0)
167+
"def " + kv.key + ": String = Resources." + kv.key
168+
else
169+
"def " + kv.key + "(prettifier: org.scalactic.Prettifier, " + (for (i <- 0 until paramCount) yield s"param$i: Any").mkString(", ") + "): String = Resources." + kv.key + "(" + (for (i <- 0 until paramCount) yield s"prettifier.apply(param$i)").mkString(", ") + ")"
170+
}
167171

168172
}
169173

scalactic.dotty/src/main/scala/org/scalactic/source/Position.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ object Position {
7272

7373
val file = refl.rootPosition.sourceFile
7474
val fileName: String = file.jpath.getFileName.toString
75-
val filePath: String = if (showScalacticFillFilePathnames) file.toString else Resources.pleaseDefineScalacticFillFilePathnameEnvVar()
76-
val lineNo: Int = refl.rootPosition.startLine
75+
val filePath: String = if (showScalacticFillFilePathnames) file.toString else Resources.pleaseDefineScalacticFillFilePathnameEnvVar
76+
val lineNo: Int = rootPosition.startLine
7777
'{ Position(${fileName.toExpr}, ${filePath.toExpr}, ${lineNo.toExpr}) }
7878
}
7979

scalatest-test/src/test/scala/org/scalatest/prop/GeneratorSpec.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ class GeneratorSpec extends FunSpec with Matchers {
9898
it("should offer a filter method that throws an exception if too many objects are filtered out") {
9999
val doNotDoThisAtHome = CommonGenerators.ints.filter(i => i == 0) // Only keep zero
100100
a [IllegalStateException] should be thrownBy {
101-
doNotDoThisAtHome.next(SizeParam(PosZInt(0), 100, 100), Nil, Randomizer.default())
101+
doNotDoThisAtHome.next(SizeParam(PosZInt(0), 100, 100), Nil, Randomizer.default)
102102
}
103103
val okToDoThisAtHome = CommonGenerators.ints.filter(i => i != 0) // Only keep non-zeros
104104
noException should be thrownBy {
105-
okToDoThisAtHome.next(SizeParam(PosZInt(0), 100, 100), Nil, Randomizer.default())
105+
okToDoThisAtHome.next(SizeParam(PosZInt(0), 100, 100), Nil, Randomizer.default)
106106
}
107107
}
108108
it("should mix up both i and d when used in a for expression") {
@@ -2808,7 +2808,7 @@ class GeneratorSpec extends FunSpec with Matchers {
28082808
it("should offer a tuple2 generator") {
28092809
val gen = implicitly[Generator[(Int, Int)]]
28102810
val intGen = implicitly[Generator[Int]]
2811-
val (it8, rnd1) = intGen.shrink(8, Randomizer.default())
2811+
val (it8, rnd1) = intGen.shrink(8, Randomizer.default)
28122812
val (it18, rnd2)= intGen.shrink(18, rnd1)
28132813
val list8 = it8.toList
28142814
val list18 = it18.toList
@@ -2823,7 +2823,7 @@ class GeneratorSpec extends FunSpec with Matchers {
28232823
val tupGen: Generator[(String, Int)] = Generator.tuple2Generator[String, Int]
28242824
case class Person(name: String, age: Int)
28252825
val persons = for (tup <- tupGen) yield Person(tup._1, tup._2)
2826-
val (it, _) = persons.shrink(Person("Harry Potter", 32), Randomizer.default())
2826+
val (it, _) = persons.shrink(Person("Harry Potter", 32), Randomizer.default)
28272827
it.toList should not be empty
28282828
}
28292829
}

scalatest/src/main/scala/org/scalatest/ParallelTestExecution.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ trait ParallelTestExecution extends OneInstancePerTest { this: Suite =>
155155
sorter.distributingTest(testName)
156156

157157
// It will be oneInstance, testName, args.copy(reporter = ...)
158-
distribute(new DistributedTestRunnerSuite(newInstance, testName, args), args.copy(tracker = args.tracker.nextTracker))
158+
distribute(new DistributedTestRunnerSuite(newInstance, testName, args), args.copy(tracker = args.tracker.nextTracker()))
159159
}
160160
else {
161161
// In test-specific (distributed) instance, so just run the test. (RTINI was

scalatest/src/main/scala/org/scalatest/Suite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ trait Suite extends Assertions with Serializable { thisSuite =>
12261226
}
12271227
case Some(distribute) =>
12281228
for (nestedSuite <- nestedSuitesArray)
1229-
statusBuffer += distribute(nestedSuite, args.copy(tracker = tracker.nextTracker))
1229+
statusBuffer += distribute(nestedSuite, args.copy(tracker = tracker.nextTracker()))
12301230
}
12311231
}
12321232
new CompositeStatus(Set.empty ++ statusBuffer)

scalatest/src/main/scala/org/scalatest/concurrent/Conductors.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ trait Conductors extends PatienceConfiguration {
571571
testThreadsStartingCounter.decrement()
572572

573573
// wait for the main thread to say its ok to go.
574-
greenLightForTestThreads.await
574+
greenLightForTestThreads.await()
575575

576576
// go
577577
f()

scalatest/src/main/scala/org/scalatest/tools/Durations.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private[scalatest] case class Durations(file: File) {
106106
}
107107

108108
def getTest(): Test = {
109-
val suite = getSuite
109+
val suite = getSuite()
110110
val testOption = suite.tests.find(test => test.name == testName)
111111

112112
if (testOption.isDefined) {

scalatest/src/main/scala/org/scalatest/tools/Framework.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ import java.net.{ServerSocket, InetAddress}
983983
propertiesMap + (Suite.CHOSEN_STYLES -> chosenStyleSet)
984984

985985
if (chosenStyleSet.nonEmpty)
986-
println(Resources.deprecatedChosenStyleWarning())
986+
println(Resources.deprecatedChosenStyleWarning)
987987

988988
val tagsToInclude: Set[String] = parseCompoundArgIntoSet(tagsToIncludeArgs, "-n")
989989
val tagsToExclude: Set[String] = parseCompoundArgIntoSet(tagsToExcludeArgs, "-l")

0 commit comments

Comments
 (0)