Sha256: d29764a2d8133bd8f22e3b29b7f511bb50ddf7aee50511afbce1f28b298e9342
Contents?: true
Size: 1.01 KB
Versions: 2
Compression:
Stored size: 1.01 KB
Contents
require 'rant' require 'test/unit' require 'pp' class Rant::Property def initialize(property) @property = property end def check(n=100,limit=10,&assertion) i = 0 test_data = nil begin Rant.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 Rant::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) Rant::Property.new(block) end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
hayeah-Rant-0.0.0 | lib/rant/check.rb |
rantly-0.1.0 | lib/rant/property.rb |