From ae3cfa9f1a1b4b357ba6736b6deda865c27358ef Mon Sep 17 00:00:00 2001 From: Mark Canlas Date: Thu, 18 Jul 2024 15:06:50 -0400 Subject: [PATCH] symbol to string --- .../com/htmlism/spawningpool/PackageSpec.scala | 16 ++++++++-------- .../com/htmlism/spawningpool/SolverSpec.scala | 2 +- .../DiscreteAlleleGeneratorSpec.scala | 10 +++++----- .../FixedLengthCombinatorSpec.scala | 12 ++++++------ .../VariableLengthCombinatorSpec.scala | 16 ++++++++-------- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/PackageSpec.scala b/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/PackageSpec.scala index 99de2be..c9254a5 100644 --- a/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/PackageSpec.scala +++ b/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/PackageSpec.scala @@ -7,21 +7,21 @@ class PackageSpec extends Specification { "prevent side-effects on subsequent applications" in { val scratch = collection.mutable.Map[Symbol, Int]().withDefaultValue(0) - val originalFunction = { key: Symbol => + val originalFunction = { key: String => scratch(key) = scratch(key) + 1 } val memoizedFunction = memoize(originalFunction) - memoizedFunction('pauper) - scratch === Map('pauper -> 1) + memoizedFunction("pauper") + scratch === Map("pauper" -> 1) - memoizedFunction('pauper) - scratch === Map('pauper -> 1) + memoizedFunction("pauper") + scratch === Map("pauper" -> 1) - originalFunction('prince) - originalFunction('prince) - scratch == Map('pauper -> 1, 'prince -> 2) // smart equality operator not so smart on disparate constructions? + originalFunction("prince") + originalFunction("prince") + scratch == Map("pauper" -> 1, "prince" -> 2) // smart equality operator not so smart on disparate constructions? } } } diff --git a/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/SolverSpec.scala b/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/SolverSpec.scala index 3064bf9..6a41b81 100644 --- a/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/SolverSpec.scala +++ b/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/SolverSpec.scala @@ -13,7 +13,7 @@ class SolverSpec extends Specification { def randomIndex(size: Int) = iterator.next() } - randomIndividual(Seq('arthas))(rig) === 'arthas + randomIndividual(Seq("arthas"))(rig) === "arthas" } } } diff --git a/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/combinatorics/DiscreteAlleleGeneratorSpec.scala b/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/combinatorics/DiscreteAlleleGeneratorSpec.scala index 5a3b8d2..2ab8337 100644 --- a/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/combinatorics/DiscreteAlleleGeneratorSpec.scala +++ b/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/combinatorics/DiscreteAlleleGeneratorSpec.scala @@ -6,17 +6,17 @@ class DiscreteAlleleGeneratorSpec extends Specification { "A discrete allele generator" should { "return the expected values" in { - val generator = new DiscreteAlleleGenerator[Symbol] with AlleleIndexProvider { + val generator = new DiscreteAlleleGenerator[String] with AlleleIndexProvider { private val rng = Iterable(2, 0, 1).iterator - val alleles = Seq('alpha, 'beta, 'gamma) + val alleles = Seq("alpha", "beta", "gamma") def nextAlleleIndex(size: Int) = rng.next() } - generator.generateAllele === 'gamma - generator.generateAllele === 'alpha - generator.generateAllele === 'beta + generator.generateAllele === "gamma" + generator.generateAllele === "alpha" + generator.generateAllele === "beta" } } } diff --git a/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/combinatorics/FixedLengthCombinatorSpec.scala b/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/combinatorics/FixedLengthCombinatorSpec.scala index 9ec524d..ecaa28f 100644 --- a/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/combinatorics/FixedLengthCombinatorSpec.scala +++ b/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/combinatorics/FixedLengthCombinatorSpec.scala @@ -19,25 +19,25 @@ class FixedLengthCombinatorSpec extends Specification { } "generate the expected values" in { - firstChromosome === Seq('luigi, 'bowser, 'peach) - secondChromosome === Seq('mario, 'luigi, 'bowser) + firstChromosome === Seq("luigi", "bowser", "peach") + secondChromosome === Seq("mario", "luigi", "bowser") } "support spot mutation" in { - mutatedChromosome === Seq('luigi, 'mario, 'peach) + mutatedChromosome === Seq("luigi", "mario", "peach") } "support crossover" in { - combinator.crossover(firstChromosome, secondChromosome) === Seq('mario, 'luigi, 'peach) + combinator.crossover(firstChromosome, secondChromosome) === Seq("mario", "luigi", "peach") } } } -class FixedTestCombinator(val size: Int) extends FixedLengthCombinator[Symbol] with DiscreteAlleleGenerator[Symbol] { +class FixedTestCombinator(val size: Int) extends FixedLengthCombinator[String] with DiscreteAlleleGenerator[String] { private val alleleIndexes = Iterable(1, 3, 2, 0, 1, 3, 0).iterator private val parents = Iterable(false, false, true).iterator - def alleles: Seq[Symbol] = Seq('mario, 'luigi, 'peach, 'bowser) + def alleles: Seq[String] = Seq("mario", "luigi", "peach", "bowser") def nextAlleleIndex(size: Int) = alleleIndexes.next() diff --git a/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/combinatorics/VariableLengthCombinatorSpec.scala b/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/combinatorics/VariableLengthCombinatorSpec.scala index e6288b5..7e367c3 100644 --- a/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/combinatorics/VariableLengthCombinatorSpec.scala +++ b/spawning-pool-core/src/test/scala/com/htmlism/spawningpool/combinatorics/VariableLengthCombinatorSpec.scala @@ -23,17 +23,17 @@ class VariableLengthCombinatorSpec extends Specification { } "generate chromosomes of the provided alleles" in { - firstChromosome === Seq('GoGo) - secondChromosome === Seq('HoneyLemon, 'Baymax, 'Fred) - thirdChromosome === Seq('Hiro, 'Wasabi, 'GoGo, 'Baymax, 'HoneyLemon) + firstChromosome === Seq("GoGo") + secondChromosome === Seq("HoneyLemon", "Baymax", "Fred") + thirdChromosome === Seq("Hiro", "Wasabi", "GoGo", "Baymax", "HoneyLemon") } "support spot mutation" in { - secondMutation === Seq('HoneyLemon, 'Hiro, 'Fred) + secondMutation === Seq("HoneyLemon", "Hiro", "Fred") } "support insertion mutation" in { - thirdMutation === Seq('Wasabi, 'Hiro, 'Wasabi, 'GoGo, 'Baymax, 'HoneyLemon) + thirdMutation === Seq("Wasabi", "Hiro", "Wasabi", "GoGo", "Baymax", "HoneyLemon") } "support removal mutation" in { @@ -41,14 +41,14 @@ class VariableLengthCombinatorSpec extends Specification { } "support crossover" in { - child === Seq('GoGo, 'Fred) + child === Seq("GoGo", "Fred") } } } -class VariableTestCombinator extends VariableLengthCombinator[Symbol] with DiscreteAlleleGenerator[Symbol] { +class VariableTestCombinator extends VariableLengthCombinator[String] with DiscreteAlleleGenerator[String] { val initialSize = 11 - val alleles = Seq('Hiro, 'Baymax, 'Fred, 'GoGo, 'Wasabi, 'HoneyLemon) + val alleles = Seq("Hiro", "Baymax", "Fred", "GoGo", "Wasabi", "HoneyLemon") private val mutationMethods = Iterable(RemoveGene, MutateGene, AddGene).iterator