From 15ee18083ac60bd8b673f57a227cca48a67db316 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Wed, 16 Nov 2022 19:57:06 -0800 Subject: [PATCH] mu --- Gemfile.lock | 6 ++++++ lib/minitest/thesis.rb | 2 +- lib/minitest/thesis/possibility.rb | 8 ++++---- minitest-thesis.gemspec | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3509d0a..7449551 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,7 +6,12 @@ PATH GEM remote: https://rubygems.org/ specs: + coderay (1.1.3) + method_source (1.0.0) minitest (5.16.3) + pry (0.14.1) + coderay (~> 1.1) + method_source (~> 1.0) rake (13.0.6) PLATFORMS @@ -16,6 +21,7 @@ DEPENDENCIES bundler (~> 2.3) minitest (~> 5.16) minitest-thesis! + pry (~> 0.14) rake (~> 13.0) BUNDLED WITH diff --git a/lib/minitest/thesis.rb b/lib/minitest/thesis.rb index 08583db..5c59633 100644 --- a/lib/minitest/thesis.rb +++ b/lib/minitest/thesis.rb @@ -104,7 +104,7 @@ module Minitest def just(value) = Possibility.new("just(#{value})") { value } # No possible values. i.e. Any call to `any` will reject the test case. - def nothing = Possibility.new {|tc| tc.reject } + def nothing = Possibility.new("nothing") {|tc| tc.reject } # Possible values can be any value possible for one of `possibilities`. def mix_of(*possibilities) diff --git a/lib/minitest/thesis/possibility.rb b/lib/minitest/thesis/possibility.rb index 8f24e81..37b54bc 100644 --- a/lib/minitest/thesis/possibility.rb +++ b/lib/minitest/thesis/possibility.rb @@ -5,7 +5,7 @@ module Minitest::Thesis class Possibility attr_reader :produce, :name - def initialize(name = "TODO", &produce) + def initialize(name, &produce) @name = name @produce = produce end @@ -15,20 +15,20 @@ module Minitest::Thesis # "Returns a `Possibility` where values come from applying `f` to some possible value for `self`." def map(&f) - self.class.new("#{name}.map(TODO)") {|tc| f.call(tc.any(self)) } + self.class.new("#{name}.map(#{f.class})") {|tc| f.call(tc.any(self)) } end # Returns a `Possibility` where values come from applying `f` (which # should return a new `Possibility` to some possible value for `self` # then returning a possible value from that. def bind(&f) - self.class.new("#{name}.bind(TODO)") {|tc| tc.any(f.(tc.any(self))) } + self.class.new("#{name}.bind(#{f.class})") {|tc| tc.any(f.(tc.any(self))) } end # Returns a `Possibility` whose values are any possible value of `self` # for which `f` returns True. def satisfying(&f) - self.class.new("#{name}.select(TODO)") {|test_case| + self.class.new("#{name}.select(#{f.class})") {|test_case| 3.times.first { candidate = test_case.any(self) candidate if f.(candidate) diff --git a/minitest-thesis.gemspec b/minitest-thesis.gemspec index da221cc..b2fd088 100644 --- a/minitest-thesis.gemspec +++ b/minitest-thesis.gemspec @@ -38,4 +38,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "bundler", "~> 2.3" spec.add_development_dependency "rake", "~> 13.0" spec.add_development_dependency "minitest", "~> 5.16" + spec.add_development_dependency "pry", "~> 0.14" end