Sha256: 050e5f63ec838fc7be9a393c15469c20b4281b71bfe16a7c6c4af783096e5b17
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
require 'rantly' require 'test/unit' require 'pp' class Rantly::Property def initialize(property) @property = property end def check(n=100,limit=10,&assertion) i = 0 test_data = nil begin Rantly.singleton.generate(n,limit,@property) do |val| test_data = val assertion.call(val) if assertion puts "" if i % 100 == 0 print "." if i % 10 == 0 i += 1 end puts puts "success: #{i} tests" rescue Rantly::TooManyTries => e puts puts "too many tries: #{e.tries}" raise e rescue => boom puts puts "failure: #{i} tests, on:" pp test_data raise boom end end def report distribs = self.classifiers.sort { |a,b| b[1] <=> a[1] } total = distribs.inject(0) { |sum,pair| sum + pair[1]} distribs.each do |(classifier,count)| format "%10.5f%% of => %s", count, classifier end end end module Test::Unit::Assertions def property_of(&block) Rantly::Property.new(block) end end begin require 'rspec' class RSpec::Core::ExampleGroup def property_of(&block) Rantly::Property.new(block) end end rescue LoadError "No RSpec loaded. Oh, well." end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rantly-0.3.1 | lib/rantly/property.rb |