mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Config stores the RNG instead of a seed
This commit is contained in:
parent
21a0f78219
commit
d0ba2c5400
3 changed files with 10 additions and 7 deletions
|
@ -78,7 +78,6 @@ module Spectator
|
|||
|
||||
@@config_builder = ConfigBuilder.new
|
||||
@@config : Config?
|
||||
@@random : Random?
|
||||
|
||||
# Provides a means to configure how Spectator will run and report tests.
|
||||
# A `ConfigBuilder` is yielded to allow changing the configuration.
|
||||
|
@ -93,7 +92,7 @@ module Spectator
|
|||
# This provides reproducable results even though random values are used.
|
||||
# The seed for this random generator is controlled by `ConfigBuilder.seed=`.
|
||||
def random
|
||||
@@random ||= Random.new(config.seed)
|
||||
config.random
|
||||
end
|
||||
|
||||
# Builds the tests and runs the framework.
|
||||
|
|
|
@ -13,8 +13,8 @@ module Spectator
|
|||
# Examples won't run, but the output will show that they did.
|
||||
getter? dry_run : Bool
|
||||
|
||||
# Seed for the random number generator.
|
||||
getter seed : Int32
|
||||
# Random number generator to use for everything.
|
||||
getter random : Random
|
||||
|
||||
# Creates a new configuration.
|
||||
def initialize(builder)
|
||||
|
@ -22,7 +22,7 @@ module Spectator
|
|||
@fail_fast = builder.fail_fast?
|
||||
@fail_blank = builder.fail_blank?
|
||||
@dry_run = builder.dry_run?
|
||||
@seed = builder.seed
|
||||
@random = builder.random
|
||||
end
|
||||
|
||||
# Yields each formatter that should be reported to.
|
||||
|
|
|
@ -8,8 +8,8 @@ module Spectator
|
|||
new.build
|
||||
end
|
||||
|
||||
# Seed for the random number generator.
|
||||
property seed = 0
|
||||
# Random number generator to use.
|
||||
getter random = Random::DEFAULT
|
||||
|
||||
@primary_formatter : Formatting::Formatter?
|
||||
@additional_formatters = [] of Formatting::Formatter
|
||||
|
@ -87,6 +87,10 @@ module Spectator
|
|||
@dry_run
|
||||
end
|
||||
|
||||
# Sets the seed for the random number generator.
|
||||
def seed=(seed)
|
||||
@random = Random.new(seed)
|
||||
end
|
||||
# Creates a configuration.
|
||||
def build : Config
|
||||
Config.new(self)
|
||||
|
|
Loading…
Reference in a new issue