rushcheck 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/data/rushcheck/doc/policy.txt +107 -0
- data/data/rushcheck/doc/rushcheck.thtml +832 -0
- data/data/rushcheck/examples/candy.rb +6 -8
- data/data/rushcheck/examples/printf.rb +3 -3
- data/data/rushcheck/examples/proc.rb +4 -4
- data/data/rushcheck/examples/roguetile.rb +16 -16
- data/data/rushcheck/examples/sample.rb +10 -10
- data/data/rushcheck/rdoc/classes/Arbitrary.html +5 -5
- data/data/rushcheck/rdoc/classes/Arbitrary.src/M000082.html +18 -0
- data/data/rushcheck/rdoc/classes/Assertion.html +11 -11
- data/data/rushcheck/rdoc/classes/Assertion.src/M000019.html +20 -0
- data/data/rushcheck/rdoc/classes/Assertion.src/M000020.html +50 -0
- data/data/rushcheck/rdoc/classes/Coarbitrary.html +5 -5
- data/data/rushcheck/rdoc/classes/Coarbitrary.src/M000105.html +18 -0
- data/data/rushcheck/rdoc/classes/FalseClass.html +15 -15
- data/data/rushcheck/rdoc/classes/FalseClass.src/M000022.html +18 -0
- data/data/rushcheck/rdoc/classes/FalseClass.src/M000023.html +18 -0
- data/data/rushcheck/rdoc/classes/FalseClass.src/M000024.html +18 -0
- data/data/rushcheck/rdoc/classes/Float.html +20 -20
- data/data/rushcheck/rdoc/classes/Float.src/M000052.html +21 -0
- data/data/rushcheck/rdoc/classes/Float.src/M000053.html +18 -0
- data/data/rushcheck/rdoc/classes/Float.src/M000054.html +22 -0
- data/data/rushcheck/rdoc/classes/Float.src/M000055.html +20 -0
- data/data/rushcheck/rdoc/classes/Gen.html +102 -102
- data/data/rushcheck/rdoc/classes/Gen.src/M000030.html +4 -10
- data/data/rushcheck/rdoc/classes/Gen.src/M000031.html +29 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000032.html +6 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000033.html +14 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000034.html +10 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000035.html +4 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000036.html +4 -10
- data/data/rushcheck/rdoc/classes/Gen.src/M000037.html +4 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000038.html +4 -7
- data/data/rushcheck/rdoc/classes/Gen.src/M000039.html +4 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000040.html +10 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000041.html +4 -9
- data/data/rushcheck/rdoc/classes/Gen.src/M000042.html +7 -5
- data/data/rushcheck/rdoc/classes/Gen.src/M000043.html +4 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000044.html +4 -10
- data/data/rushcheck/rdoc/classes/Gen.src/M000045.html +23 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000046.html +19 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000047.html +18 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000048.html +24 -0
- data/data/rushcheck/rdoc/classes/Guard.html +10 -10
- data/data/rushcheck/rdoc/classes/Guard.src/M000028.html +27 -0
- data/data/rushcheck/rdoc/classes/Guard.src/M000029.html +18 -0
- data/data/rushcheck/rdoc/classes/HsRandom.html +20 -20
- data/data/rushcheck/rdoc/classes/HsRandom.src/M000088.html +22 -0
- data/data/rushcheck/rdoc/classes/HsRandom.src/M000089.html +32 -0
- data/data/rushcheck/rdoc/classes/HsRandom.src/M000090.html +18 -0
- data/data/rushcheck/rdoc/classes/Integer.html +20 -20
- data/data/rushcheck/rdoc/classes/Integer.src/M000010.html +18 -0
- data/data/rushcheck/rdoc/classes/Integer.src/M000011.html +18 -0
- data/data/rushcheck/rdoc/classes/Integer.src/M000012.html +21 -0
- data/data/rushcheck/rdoc/classes/Integer.src/M000013.html +19 -0
- data/data/rushcheck/rdoc/classes/NilClass.html +15 -15
- data/data/rushcheck/rdoc/classes/NilClass.src/M000064.html +18 -0
- data/data/rushcheck/rdoc/classes/NilClass.src/M000065.html +18 -0
- data/data/rushcheck/rdoc/classes/NilClass.src/M000066.html +18 -0
- data/data/rushcheck/rdoc/classes/Property.html +10 -10
- data/data/rushcheck/rdoc/classes/Property.src/M000077.html +26 -0
- data/data/rushcheck/rdoc/classes/Property.src/M000078.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomArray.html +15 -15
- data/data/rushcheck/rdoc/classes/RandomArray.src/M000025.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomArray.src/M000026.html +35 -0
- data/data/rushcheck/rdoc/classes/RandomArray.src/M000027.html +22 -0
- data/data/rushcheck/rdoc/classes/RandomBool.html +10 -10
- data/data/rushcheck/rdoc/classes/RandomBool.src/M000086.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomBool.src/M000087.html +19 -0
- data/data/rushcheck/rdoc/classes/RandomGen.html +20 -20
- data/data/rushcheck/rdoc/classes/RandomGen.src/M000083.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomGen.src/M000084.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomGen.src/M000085.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomHash.html +16 -16
- data/data/rushcheck/rdoc/classes/RandomHash.src/M000049.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomHash.src/M000050.html +26 -0
- data/data/rushcheck/rdoc/classes/RandomHash.src/M000051.html +22 -0
- data/data/rushcheck/rdoc/classes/RandomProc.html +20 -20
- data/data/rushcheck/rdoc/classes/RandomProc.src/M000060.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomProc.src/M000061.html +30 -0
- data/data/rushcheck/rdoc/classes/RandomProc.src/M000062.html +26 -0
- data/data/rushcheck/rdoc/classes/RandomProc.src/M000063.html +20 -0
- data/data/rushcheck/rdoc/classes/Result.html +19 -19
- data/data/rushcheck/rdoc/classes/Result.src/M000056.html +18 -0
- data/data/rushcheck/rdoc/classes/Result.src/M000057.html +18 -0
- data/data/rushcheck/rdoc/classes/Result.src/M000058.html +18 -0
- data/data/rushcheck/rdoc/classes/RushCheckConfig.html +41 -11
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000001.html +1 -1
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000002.html +1 -1
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000003.html +8 -4
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000004.html +4 -24
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000005.html +22 -39
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000006.html +55 -0
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000007.html +50 -0
- data/data/rushcheck/rdoc/classes/SpecialString.html +5 -5
- data/data/rushcheck/rdoc/classes/SpecialString.src/M000021.html +37 -0
- data/data/rushcheck/rdoc/classes/StdGen.html +27 -27
- data/data/rushcheck/rdoc/classes/StdGen.src/M000014.html +9 -4
- data/data/rushcheck/rdoc/classes/StdGen.src/M000015.html +21 -0
- data/data/rushcheck/rdoc/classes/StdGen.src/M000016.html +21 -0
- data/data/rushcheck/rdoc/classes/StdGen.src/M000017.html +18 -0
- data/data/rushcheck/rdoc/classes/StdGen.src/M000018.html +18 -0
- data/data/rushcheck/rdoc/classes/String.html +20 -20
- data/data/rushcheck/rdoc/classes/String.src/M000073.html +24 -0
- data/data/rushcheck/rdoc/classes/String.src/M000074.html +18 -0
- data/data/rushcheck/rdoc/classes/String.src/M000075.html +25 -0
- data/data/rushcheck/rdoc/classes/String.src/M000076.html +22 -0
- data/data/rushcheck/rdoc/classes/TestExausted.html +113 -0
- data/data/rushcheck/rdoc/classes/TestFailed.html +155 -0
- data/data/rushcheck/rdoc/classes/TestFailed.src/M000067.html +18 -0
- data/data/rushcheck/rdoc/classes/TestOk.html +113 -0
- data/data/rushcheck/rdoc/classes/TestOptions.html +180 -0
- data/data/rushcheck/rdoc/classes/TestOptions.src/M000008.html +18 -0
- data/data/rushcheck/rdoc/classes/TestOptions.src/M000009.html +18 -0
- data/data/rushcheck/rdoc/classes/TestResult.html +164 -0
- data/data/rushcheck/rdoc/classes/TestResult.src/M000068.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.html +96 -51
- data/data/rushcheck/rdoc/classes/Testable.src/M000091.html +4 -4
- data/data/rushcheck/rdoc/classes/Testable.src/M000092.html +4 -4
- data/data/rushcheck/rdoc/classes/Testable.src/M000095.html +4 -4
- data/data/rushcheck/rdoc/classes/Testable.src/M000096.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000097.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000099.html +19 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000100.html +21 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000101.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000103.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000104.html +18 -0
- data/data/rushcheck/rdoc/classes/TheStdGen.html +20 -20
- data/data/rushcheck/rdoc/classes/TheStdGen.src/M000069.html +18 -0
- data/data/rushcheck/rdoc/classes/TheStdGen.src/M000070.html +20 -0
- data/data/rushcheck/rdoc/classes/TheStdGen.src/M000071.html +21 -0
- data/data/rushcheck/rdoc/classes/TheStdGen.src/M000072.html +18 -0
- data/data/rushcheck/rdoc/classes/TrueClass.html +15 -15
- data/data/rushcheck/rdoc/classes/TrueClass.src/M000079.html +18 -0
- data/data/rushcheck/rdoc/classes/TrueClass.src/M000080.html +18 -0
- data/data/rushcheck/rdoc/classes/TrueClass.src/M000081.html +18 -0
- data/data/rushcheck/rdoc/created.rid +1 -1
- data/data/rushcheck/rdoc/files/rushcheck/config_rb.html +8 -1
- data/data/rushcheck/rdoc/files/rushcheck/testable_rb.html +3 -1
- data/data/rushcheck/rdoc/files/rushcheck/testoptions_rb.html +109 -0
- data/data/rushcheck/rdoc/files/rushcheck/testresult_rb.html +105 -0
- data/data/rushcheck/rdoc/files/rushcheck_rb.html +127 -0
- data/data/rushcheck/rdoc/fr_class_index.html +5 -0
- data/data/rushcheck/rdoc/fr_file_index.html +3 -1
- data/data/rushcheck/rdoc/fr_method_index.html +103 -94
- data/lib/rushcheck/arbitrary.rb +16 -12
- data/lib/rushcheck/array.rb +7 -6
- data/lib/rushcheck/assertion.rb +53 -50
- data/lib/rushcheck/bool.rb +26 -24
- data/lib/rushcheck/config.rb +131 -81
- data/lib/rushcheck/float.rb +4 -4
- data/lib/rushcheck/gen.rb +194 -182
- data/lib/rushcheck/guard.rb +9 -10
- data/lib/rushcheck/hash.rb +4 -3
- data/lib/rushcheck/integer.rb +11 -6
- data/lib/rushcheck/proc.rb +7 -7
- data/lib/rushcheck/property.rb +19 -15
- data/lib/rushcheck/random.rb +162 -159
- data/lib/rushcheck/result.rb +16 -12
- data/lib/rushcheck/string.rb +12 -12
- data/lib/rushcheck/testable.rb +99 -25
- data/lib/rushcheck/testoptions.rb +20 -0
- data/lib/rushcheck/testresult.rb +25 -0
- data/lib/{rushcheck/rushcheck.rb → rushcheck.rb} +2 -1
- metadata +93 -4
- data/data/rushcheck/doc/rushcheck.txt +0 -670
data/lib/rushcheck/bool.rb
CHANGED
@@ -7,25 +7,27 @@ require 'rushcheck/random'
|
|
7
7
|
require 'rushcheck/result'
|
8
8
|
require 'rushcheck/testable'
|
9
9
|
|
10
|
-
module
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
module RushCheck
|
11
|
+
module RandomBool
|
12
|
+
def arbitrary
|
13
|
+
RushCheck::Gen.elements([true, false])
|
14
|
+
end
|
15
|
+
|
16
|
+
def random_range(gen, lo=@@min_bound, hi=@@max_bound)
|
17
|
+
v, g = Integer.random_range(gen, 0, 1)
|
18
|
+
[v==0, g]
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
23
|
class TrueClass
|
22
24
|
|
23
|
-
extend Arbitrary
|
24
|
-
extend HsRandom
|
25
|
-
extend RandomBool
|
25
|
+
extend RushCheck::Arbitrary
|
26
|
+
extend RushCheck::HsRandom
|
27
|
+
extend RushCheck::RandomBool
|
26
28
|
|
27
|
-
include Testable
|
28
|
-
include Coarbitrary
|
29
|
+
include RushCheck::Testable
|
30
|
+
include RushCheck::Coarbitrary
|
29
31
|
|
30
32
|
@@min_bound = 0
|
31
33
|
@@max_bound = 1
|
@@ -39,19 +41,19 @@ class TrueClass
|
|
39
41
|
end
|
40
42
|
|
41
43
|
def property
|
42
|
-
Result.new(self).result
|
44
|
+
RushCheck::Result.new(self).result
|
43
45
|
end
|
44
46
|
|
45
47
|
end
|
46
48
|
|
47
49
|
class FalseClass
|
48
50
|
|
49
|
-
extend Arbitrary
|
50
|
-
extend HsRandom
|
51
|
-
extend RandomBool
|
51
|
+
extend RushCheck::Arbitrary
|
52
|
+
extend RushCheck::HsRandom
|
53
|
+
extend RushCheck::RandomBool
|
52
54
|
|
53
|
-
include Coarbitrary
|
54
|
-
include Testable
|
55
|
+
include RushCheck::Coarbitrary
|
56
|
+
include RushCheck::Testable
|
55
57
|
|
56
58
|
@@min_bound = 0
|
57
59
|
@@max_bound = 1
|
@@ -65,15 +67,15 @@ class FalseClass
|
|
65
67
|
end
|
66
68
|
|
67
69
|
def property
|
68
|
-
Result.new(self).result
|
70
|
+
RushCheck::Result.new(self).result
|
69
71
|
end
|
70
72
|
end
|
71
73
|
|
72
74
|
class NilClass
|
73
|
-
extend Arbitrary
|
75
|
+
extend RushCheck::Arbitrary
|
74
76
|
|
75
|
-
include Coarbitrary
|
76
|
-
include Testable
|
77
|
+
include RushCheck::Coarbitrary
|
78
|
+
include RushCheck::Testable
|
77
79
|
|
78
80
|
def self.arbitrary
|
79
81
|
Gen.unit(nil)
|
@@ -84,7 +86,7 @@ class NilClass
|
|
84
86
|
end
|
85
87
|
|
86
88
|
def property
|
87
|
-
Result.nothing
|
89
|
+
RushCheck::Result.nothing
|
88
90
|
end
|
89
91
|
|
90
92
|
end
|
data/lib/rushcheck/config.rb
CHANGED
@@ -1,98 +1,148 @@
|
|
1
1
|
# = Config.rb
|
2
|
-
# This file is implemented for the class
|
2
|
+
# This file is implemented for the class Config.
|
3
3
|
|
4
|
-
|
5
|
-
# This class is needed for several test functions.
|
6
|
-
class RushCheckConfig
|
4
|
+
require 'rushcheck/testresult'
|
7
5
|
|
8
|
-
|
6
|
+
module RushCheck
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
Proc.new do |n, args|
|
14
|
-
s = n.to_s
|
15
|
-
s + ("\b" * s.length)
|
16
|
-
end)
|
17
|
-
end
|
8
|
+
# Config is a class which has configurations of tests.
|
9
|
+
# This class is needed for several test functions.
|
10
|
+
class Config
|
18
11
|
|
19
|
-
|
20
|
-
new(100, 1000,
|
21
|
-
Proc.new{|x| x / 2 + 3},
|
22
|
-
Proc.new do |n, args|
|
23
|
-
n.to_s + ":\n" + args.join("\n") + "\n"
|
24
|
-
end)
|
25
|
-
end
|
12
|
+
attr_reader :max_test, :max_fail, :size, :every
|
26
13
|
|
27
|
-
|
28
|
-
|
29
|
-
|
14
|
+
def self.quick
|
15
|
+
new(100, 1000,
|
16
|
+
Proc.new{|x| x / 2 + 3},
|
17
|
+
Proc.new do |n, args|
|
18
|
+
s = n.to_s
|
19
|
+
s + ("\b" * s.length)
|
20
|
+
end)
|
21
|
+
end
|
30
22
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
r
|
39
|
-
end.sort_by {|k, v| v}.reverse.map do |pair|
|
40
|
-
percentage = ((100 * pair[1]) / ntest).to_s + '%'
|
41
|
-
([percentage] + pair[0]).join(', ')
|
42
|
-
end
|
23
|
+
def self.verbose
|
24
|
+
new(100, 1000,
|
25
|
+
Proc.new{|x| x / 2 + 3},
|
26
|
+
Proc.new do |n, args|
|
27
|
+
n.to_s + ":\n" + args.join("\n") + "\n"
|
28
|
+
end)
|
29
|
+
end
|
43
30
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
31
|
+
def self.batch(n, v)
|
32
|
+
new(n, n * 10,
|
33
|
+
Proc.new{|x| (x / 2 + 3).to_i},
|
34
|
+
Proc.new do |n, args|
|
35
|
+
v ? n.to_s + ":\n" + args.join("\n") + "\n" : ""
|
36
|
+
end)
|
37
|
+
end
|
52
38
|
|
53
|
-
|
54
|
-
|
39
|
+
def initialize(max_test, max_fail, size, every)
|
40
|
+
@max_test, @max_fail, @size, @every = max_test, max_fail, size, every
|
41
|
+
end
|
55
42
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
|
-
tests_result = nil
|
68
|
-
break
|
43
|
+
# print results of tests.
|
44
|
+
def done(mesg, ntest, stamps)
|
45
|
+
print mesg + ' ' + ntest.to_s + ' tests'
|
46
|
+
|
47
|
+
bag = stamps.compact.find_all {|x| ! x.empty?}.sort.
|
48
|
+
inject(Hash.new) do |r, m|
|
49
|
+
r[m] = r[m].nil? ? 1 : r[m] + 1
|
50
|
+
r
|
51
|
+
end.sort_by {|k, v| v}.reverse.map do |pair|
|
52
|
+
percentage = ((100 * pair[1]) / ntest).to_s + '%'
|
53
|
+
([percentage] + pair[0]).join(', ')
|
69
54
|
end
|
70
55
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
56
|
+
mes = case bag.length
|
57
|
+
when 0
|
58
|
+
".\n"
|
59
|
+
when 1
|
60
|
+
'(' + bag[0] + ").\n"
|
61
|
+
else
|
62
|
+
".\n" + bag.join(".\n") + ".\n"
|
63
|
+
end
|
64
|
+
|
65
|
+
print mes
|
66
|
+
end
|
67
|
+
|
68
|
+
# execute tests
|
69
|
+
def tests(gen, rnd, nt=1, nf=0, stamps=[])
|
70
|
+
ntest, nfail = nt, nf
|
71
|
+
while true
|
72
|
+
if ntest > max_test
|
73
|
+
done('OK, passed', max_test, stamps)
|
74
|
+
tests_result = true
|
75
|
+
break
|
76
|
+
end
|
77
|
+
if nfail > max_fail
|
78
|
+
done('Arguments exhausted after ', ntest, stamps)
|
79
|
+
tests_result = nil
|
80
|
+
break
|
81
|
+
end
|
82
|
+
|
83
|
+
rnd_l, rnd_r = rnd.split
|
84
|
+
result = gen.generate(size.call(ntest), rnd_r)
|
85
|
+
message = every.call(ntest, result.arguments)
|
86
|
+
print message # don't puts
|
87
|
+
|
88
|
+
case result.ok
|
89
|
+
when nil
|
90
|
+
nfail += 1
|
91
|
+
redo
|
92
|
+
when true
|
93
|
+
stamps.push(result.stamp)
|
94
|
+
ntest += 1
|
95
|
+
redo
|
96
|
+
when false
|
97
|
+
error = "Falsifiable, after " + ntest.to_s + " tests:\n" +
|
98
|
+
result.arguments.join("\n")
|
99
|
+
puts error
|
100
|
+
tests_result = false
|
101
|
+
break
|
102
|
+
else
|
103
|
+
raise(RuntimeError, "RushCheck: illegal result")
|
104
|
+
end
|
92
105
|
end
|
106
|
+
|
107
|
+
tests_result
|
93
108
|
end
|
94
|
-
|
95
|
-
|
109
|
+
|
110
|
+
def test_batch(gen, rnd, nt=1, nf=0, stamps=[])
|
111
|
+
ntest, nfail = nt, nf
|
112
|
+
while true
|
113
|
+
if ntest > max_test
|
114
|
+
tests_result = RushCheck::TestOk.new("OK, passed", ntest, stamps)
|
115
|
+
break
|
116
|
+
end
|
117
|
+
if nfail > max_fail
|
118
|
+
test_result = RushCheck::TestExausted.new('Arguments exhausted after ', ntest, stamps)
|
119
|
+
break
|
120
|
+
end
|
121
|
+
|
122
|
+
rnd_l, rnd_r = rnd.split
|
123
|
+
result = gen.generate(size.call(ntest), rnd_r)
|
124
|
+
message = every.call(ntest, result.arguments)
|
125
|
+
print message # don't puts
|
126
|
+
|
127
|
+
case result.ok
|
128
|
+
when nil
|
129
|
+
nfail += 1
|
130
|
+
redo
|
131
|
+
when true
|
132
|
+
stamps.push(result.stamp)
|
133
|
+
ntest += 1
|
134
|
+
redo
|
135
|
+
when false
|
136
|
+
tests_result = RushCheck::TestFailed.new(result.arguments, ntest)
|
137
|
+
break
|
138
|
+
else
|
139
|
+
raise(RuntimeError, "RushCheck: illegal result")
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
test_result
|
144
|
+
end
|
145
|
+
|
96
146
|
end
|
97
147
|
|
98
148
|
end
|
data/lib/rushcheck/float.rb
CHANGED
@@ -7,16 +7,16 @@ require 'rushcheck/random'
|
|
7
7
|
|
8
8
|
class Float
|
9
9
|
|
10
|
-
extend Arbitrary
|
11
|
-
extend HsRandom
|
10
|
+
extend RushCheck::Arbitrary
|
11
|
+
extend RushCheck::HsRandom
|
12
12
|
|
13
|
-
include Coarbitrary
|
13
|
+
include RushCheck::Coarbitrary
|
14
14
|
|
15
15
|
@@min_bound = 0.0
|
16
16
|
@@max_bound = 1.0
|
17
17
|
|
18
18
|
def self.arbitrary
|
19
|
-
Gen.new do |n, r|
|
19
|
+
RushCheck::Gen.new do |n, r|
|
20
20
|
a, b, c = (1..3).map { Integer.arbitrary.value(n, r) }
|
21
21
|
a + (b / (c.abs + 1))
|
22
22
|
end
|