rushcheck 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +515 -0
- data/INSTALL +14 -0
- data/LICENSE +5 -0
- data/README +49 -0
- data/Rakefile +39 -0
- data/copying.txt +23 -0
- data/data/rushcheck/doc/policy.txt +520 -0
- data/data/rushcheck/doc/rushcheck.txt +612 -0
- data/data/rushcheck/examples/printf.rb +22 -0
- data/data/rushcheck/examples/proc.rb +33 -0
- data/data/rushcheck/examples/roguetile.rb +153 -0
- data/data/rushcheck/examples/sample.rb +52 -0
- data/data/rushcheck/rdoc/classes/Arbitrary.html +148 -0
- data/data/rushcheck/rdoc/classes/Arbitrary.src/M000075.html +18 -0
- data/data/rushcheck/rdoc/classes/Assertion.html +183 -0
- data/data/rushcheck/rdoc/classes/Assertion.src/M000015.html +20 -0
- data/data/rushcheck/rdoc/classes/Assertion.src/M000016.html +45 -0
- data/data/rushcheck/rdoc/classes/Coarbitrary.html +135 -0
- data/data/rushcheck/rdoc/classes/Coarbitrary.src/M000095.html +18 -0
- data/data/rushcheck/rdoc/classes/FalseClass.html +177 -0
- data/data/rushcheck/rdoc/classes/FalseClass.src/M000018.html +18 -0
- data/data/rushcheck/rdoc/classes/FalseClass.src/M000019.html +18 -0
- data/data/rushcheck/rdoc/classes/FalseClass.src/M000020.html +18 -0
- data/data/rushcheck/rdoc/classes/Float.html +191 -0
- data/data/rushcheck/rdoc/classes/Float.src/M000047.html +21 -0
- data/data/rushcheck/rdoc/classes/Float.src/M000048.html +18 -0
- data/data/rushcheck/rdoc/classes/Float.src/M000049.html +22 -0
- data/data/rushcheck/rdoc/classes/Float.src/M000050.html +20 -0
- data/data/rushcheck/rdoc/classes/Gen.html +515 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000026.html +18 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000027.html +20 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000028.html +28 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000029.html +24 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000030.html +18 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000031.html +18 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000032.html +18 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000033.html +18 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000034.html +18 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000035.html +24 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000036.html +18 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000037.html +21 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000038.html +18 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000039.html +18 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000040.html +23 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000041.html +19 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000042.html +18 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000043.html +24 -0
- data/data/rushcheck/rdoc/classes/Guard.html +159 -0
- data/data/rushcheck/rdoc/classes/Guard.src/M000024.html +27 -0
- data/data/rushcheck/rdoc/classes/Guard.src/M000025.html +18 -0
- data/data/rushcheck/rdoc/classes/HsRandom.html +201 -0
- data/data/rushcheck/rdoc/classes/HsRandom.src/M000081.html +22 -0
- data/data/rushcheck/rdoc/classes/HsRandom.src/M000082.html +32 -0
- data/data/rushcheck/rdoc/classes/HsRandom.src/M000083.html +18 -0
- data/data/rushcheck/rdoc/classes/Integer.html +212 -0
- data/data/rushcheck/rdoc/classes/Integer.src/M000006.html +18 -0
- data/data/rushcheck/rdoc/classes/Integer.src/M000007.html +18 -0
- data/data/rushcheck/rdoc/classes/Integer.src/M000008.html +21 -0
- data/data/rushcheck/rdoc/classes/Integer.src/M000009.html +19 -0
- data/data/rushcheck/rdoc/classes/NilClass.html +177 -0
- data/data/rushcheck/rdoc/classes/NilClass.src/M000059.html +18 -0
- data/data/rushcheck/rdoc/classes/NilClass.src/M000060.html +18 -0
- data/data/rushcheck/rdoc/classes/NilClass.src/M000061.html +18 -0
- data/data/rushcheck/rdoc/classes/Property.html +174 -0
- data/data/rushcheck/rdoc/classes/Property.src/M000070.html +26 -0
- data/data/rushcheck/rdoc/classes/Property.src/M000071.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomArray.html +184 -0
- data/data/rushcheck/rdoc/classes/RandomArray.src/M000021.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomArray.src/M000022.html +35 -0
- data/data/rushcheck/rdoc/classes/RandomArray.src/M000023.html +22 -0
- data/data/rushcheck/rdoc/classes/RandomBool.html +146 -0
- data/data/rushcheck/rdoc/classes/RandomBool.src/M000079.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomBool.src/M000080.html +19 -0
- data/data/rushcheck/rdoc/classes/RandomGen.html +196 -0
- data/data/rushcheck/rdoc/classes/RandomGen.src/M000076.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomGen.src/M000077.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomGen.src/M000078.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomHash.html +197 -0
- data/data/rushcheck/rdoc/classes/RandomHash.src/M000044.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomHash.src/M000045.html +26 -0
- data/data/rushcheck/rdoc/classes/RandomHash.src/M000046.html +22 -0
- data/data/rushcheck/rdoc/classes/RandomProc.html +192 -0
- data/data/rushcheck/rdoc/classes/RandomProc.src/M000055.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomProc.src/M000056.html +30 -0
- data/data/rushcheck/rdoc/classes/RandomProc.src/M000057.html +26 -0
- data/data/rushcheck/rdoc/classes/RandomProc.src/M000058.html +20 -0
- data/data/rushcheck/rdoc/classes/Result.html +214 -0
- data/data/rushcheck/rdoc/classes/Result.src/M000051.html +18 -0
- data/data/rushcheck/rdoc/classes/Result.src/M000052.html +18 -0
- data/data/rushcheck/rdoc/classes/Result.src/M000053.html +18 -0
- data/data/rushcheck/rdoc/classes/RushCheckConfig.html +240 -0
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000001.html +23 -0
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000002.html +22 -0
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000003.html +18 -0
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000004.html +38 -0
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000005.html +55 -0
- data/data/rushcheck/rdoc/classes/RushCheckGuard.html +118 -0
- data/data/rushcheck/rdoc/classes/SpecialString.html +151 -0
- data/data/rushcheck/rdoc/classes/SpecialString.src/M000017.html +37 -0
- data/data/rushcheck/rdoc/classes/StdGen.html +252 -0
- data/data/rushcheck/rdoc/classes/StdGen.src/M000010.html +23 -0
- data/data/rushcheck/rdoc/classes/StdGen.src/M000011.html +21 -0
- data/data/rushcheck/rdoc/classes/StdGen.src/M000012.html +21 -0
- data/data/rushcheck/rdoc/classes/StdGen.src/M000013.html +18 -0
- data/data/rushcheck/rdoc/classes/StdGen.src/M000014.html +18 -0
- data/data/rushcheck/rdoc/classes/String.html +191 -0
- data/data/rushcheck/rdoc/classes/String.src/M000066.html +24 -0
- data/data/rushcheck/rdoc/classes/String.src/M000067.html +18 -0
- data/data/rushcheck/rdoc/classes/String.src/M000068.html +25 -0
- data/data/rushcheck/rdoc/classes/String.src/M000069.html +22 -0
- data/data/rushcheck/rdoc/classes/Testable.html +281 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000084.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000085.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000088.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000089.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000090.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000092.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000094.html +18 -0
- data/data/rushcheck/rdoc/classes/TheStdGen.html +200 -0
- data/data/rushcheck/rdoc/classes/TheStdGen.src/M000062.html +18 -0
- data/data/rushcheck/rdoc/classes/TheStdGen.src/M000063.html +20 -0
- data/data/rushcheck/rdoc/classes/TheStdGen.src/M000064.html +21 -0
- data/data/rushcheck/rdoc/classes/TheStdGen.src/M000065.html +18 -0
- data/data/rushcheck/rdoc/classes/TrueClass.html +177 -0
- data/data/rushcheck/rdoc/classes/TrueClass.src/M000072.html +18 -0
- data/data/rushcheck/rdoc/classes/TrueClass.src/M000073.html +18 -0
- data/data/rushcheck/rdoc/classes/TrueClass.src/M000074.html +18 -0
- data/data/rushcheck/rdoc/created.rid +1 -0
- data/data/rushcheck/rdoc/files/rushcheck/arbitrary_rb.html +114 -0
- data/data/rushcheck/rdoc/files/rushcheck/array_rb.html +117 -0
- data/data/rushcheck/rdoc/files/rushcheck/assertion_rb.html +120 -0
- data/data/rushcheck/rdoc/files/rushcheck/bool_rb.html +120 -0
- data/data/rushcheck/rdoc/files/rushcheck/config_rb.html +109 -0
- data/data/rushcheck/rdoc/files/rushcheck/float_rb.html +118 -0
- data/data/rushcheck/rdoc/files/rushcheck/gen_rb.html +111 -0
- data/data/rushcheck/rdoc/files/rushcheck/guard_rb.html +108 -0
- data/data/rushcheck/rdoc/files/rushcheck/hash_rb.html +117 -0
- data/data/rushcheck/rdoc/files/rushcheck/integer_rb.html +118 -0
- data/data/rushcheck/rdoc/files/rushcheck/proc_rb.html +118 -0
- data/data/rushcheck/rdoc/files/rushcheck/property_rb.html +119 -0
- data/data/rushcheck/rdoc/files/rushcheck/random_rb.html +126 -0
- data/data/rushcheck/rdoc/files/rushcheck/result_rb.html +118 -0
- data/data/rushcheck/rdoc/files/rushcheck/rushcheck_rb.html +123 -0
- data/data/rushcheck/rdoc/files/rushcheck/string_rb.html +121 -0
- data/data/rushcheck/rdoc/files/rushcheck/testable_rb.html +117 -0
- data/data/rushcheck/rdoc/fr_class_index.html +51 -0
- data/data/rushcheck/rdoc/fr_file_index.html +43 -0
- data/data/rushcheck/rdoc/fr_method_index.html +121 -0
- data/data/rushcheck/rdoc/index.html +24 -0
- data/data/rushcheck/rdoc/rdoc-style.css +208 -0
- data/lib/rushcheck/arbitrary.rb +28 -0
- data/lib/rushcheck/array.rb +49 -0
- data/lib/rushcheck/assertion.rb +67 -0
- data/lib/rushcheck/bool.rb +90 -0
- data/lib/rushcheck/config.rb +98 -0
- data/lib/rushcheck/float.rb +43 -0
- data/lib/rushcheck/gen.rb +189 -0
- data/lib/rushcheck/guard.rb +27 -0
- data/lib/rushcheck/hash.rb +45 -0
- data/lib/rushcheck/integer.rb +43 -0
- data/lib/rushcheck/proc.rb +53 -0
- data/lib/rushcheck/property.rb +29 -0
- data/lib/rushcheck/random.rb +215 -0
- data/lib/rushcheck/result.rb +26 -0
- data/lib/rushcheck/rushcheck.rb +17 -0
- data/lib/rushcheck/string.rb +100 -0
- data/lib/rushcheck/testable.rb +41 -0
- metadata +238 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# roguetile.rb
|
|
2
|
+
# an example of bug patterns
|
|
3
|
+
# appeared in "Bug patterns: an introduction - diagnosing and
|
|
4
|
+
# correcting recurring bug type in your Java programs", written by
|
|
5
|
+
# Eric Allen, 2001.
|
|
6
|
+
# http://www-128.ibm.com/developerworks/library/j-diag1.html
|
|
7
|
+
|
|
8
|
+
# Tree is an abstract class
|
|
9
|
+
class Tree
|
|
10
|
+
def add
|
|
11
|
+
raise(NotImplementedError, "override!")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def multiply
|
|
15
|
+
raise(NotImplementedError, "override!")
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class Leaf < Tree
|
|
20
|
+
|
|
21
|
+
attr_reader :value
|
|
22
|
+
def initialize(v)
|
|
23
|
+
@value = v
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def add
|
|
27
|
+
@value.to_i
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def multiply
|
|
31
|
+
@value.to_i
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class Branch < Tree
|
|
37
|
+
|
|
38
|
+
attr_reader :value, :left, :right
|
|
39
|
+
def initialize(v, l, r)
|
|
40
|
+
@value, @left, @right = v, l, r
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def add
|
|
44
|
+
@value.to_i + @left.add + @right.add
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def multiply
|
|
48
|
+
# Here, there is a bug in multiply because the auther forgot to
|
|
49
|
+
# change after copying the add method. This bug is called Rogue-Tile
|
|
50
|
+
# pattern in the article.
|
|
51
|
+
|
|
52
|
+
@value.to_i * @left.multiply + @right.multiply # bug!
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# To not write a bug such as above, the author of the article
|
|
56
|
+
# recommends to use Command-Pattern. See also the article.
|
|
57
|
+
# Because the aim of this example is to find a bug, I leave
|
|
58
|
+
# a wrong style implementation.
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# ok, then let's test them and find a bug.
|
|
62
|
+
|
|
63
|
+
require 'rushcheck/rushcheck'
|
|
64
|
+
|
|
65
|
+
class Tree
|
|
66
|
+
extend Arbitrary
|
|
67
|
+
include Coarbitrary
|
|
68
|
+
|
|
69
|
+
def self.arbitrary
|
|
70
|
+
Gen.frequency([[3, Leaf.arbitrary], [1, Branch.arbitrary]])
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# In this example, coarbitrary isn't needed, however,
|
|
74
|
+
# I write them to see how to write coarbitrary.
|
|
75
|
+
def coarbitrary
|
|
76
|
+
raise(NotImplementedError, "override!")
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
class Leaf
|
|
81
|
+
extend Arbitrary
|
|
82
|
+
include Coarbitrary
|
|
83
|
+
|
|
84
|
+
def self.arbitrary
|
|
85
|
+
Integer.arbitrary.bind {|x| Gen.unit(new(x)) }
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def coarbitrary(g)
|
|
89
|
+
@value.coarbitrary(g)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
class Branch
|
|
94
|
+
extend Arbitrary
|
|
95
|
+
include Coarbitrary
|
|
96
|
+
|
|
97
|
+
def self.arbitrary
|
|
98
|
+
Gen.new do |n, g|
|
|
99
|
+
g2 = g
|
|
100
|
+
v, l, r = [Integer.arbitrary, Tree.arbitrary, Tree.arbitrary].map do |x|
|
|
101
|
+
g1, g2 = g2.split
|
|
102
|
+
x.value(n, g1)
|
|
103
|
+
end
|
|
104
|
+
new(v, l, r)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def coarbitrary(g)
|
|
109
|
+
@value.coarbitrary(@left.coarbitrary(@right.coarbitrary(g)))
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def prop_leaf_add
|
|
114
|
+
Assertion.new(Leaf) {|x| x.add == x.value }.check
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def prop_leaf_multiply
|
|
118
|
+
Assertion.new(Leaf) {|x| x.multiply == x.value }.check
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def prop_branch_add
|
|
122
|
+
Assertion.new(Branch) do |t|
|
|
123
|
+
t.add == t.value + t.left.add + t.right.add
|
|
124
|
+
end.check
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# a bad example
|
|
128
|
+
def prop_branch_multiply
|
|
129
|
+
# If the tester write a wrong test case by copying the code snippet?
|
|
130
|
+
# Then we will meet the same problem! Even this test is passed, but
|
|
131
|
+
# it is wrong.
|
|
132
|
+
Assertion.new(Branch) do |t|
|
|
133
|
+
t.add == t.value * t.left.add + t.right.add # Oops, a bug in testcase.
|
|
134
|
+
end.check
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# But, we can test another /primitive/ properties about
|
|
138
|
+
# branch_multiply.
|
|
139
|
+
def prop_branch_multiply_zero
|
|
140
|
+
Assertion.new(Leaf) do |x|
|
|
141
|
+
Branch.new(0, x, x).multiply == 0
|
|
142
|
+
end.check
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def prop_branch_multiply_power
|
|
146
|
+
Assertion.new(Leaf) do |x|
|
|
147
|
+
Branch.new(1, x, x).multiply == x.value * x.value
|
|
148
|
+
end.check
|
|
149
|
+
end
|
|
150
|
+
# Yay, then we can find a bug in Branch#multiply.
|
|
151
|
+
# In this example, we gain a practical experience that
|
|
152
|
+
# don't test by copying the definition, but consider /primitive/
|
|
153
|
+
# properties!
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# a simple example
|
|
2
|
+
|
|
3
|
+
require 'rushcheck/rushcheck'
|
|
4
|
+
|
|
5
|
+
# first boring example
|
|
6
|
+
def assert_sort
|
|
7
|
+
Assertion.new { [].sort == [] }.check
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# assert_sort_one should be true
|
|
11
|
+
def assert_sort_one
|
|
12
|
+
Assertion.new(Integer) { |x|
|
|
13
|
+
[x].sort == [x]
|
|
14
|
+
}.check
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# however, assert_sort_two is not true generally,
|
|
18
|
+
# and RushCheck finds a counter example.
|
|
19
|
+
def assert_sort_two
|
|
20
|
+
Assertion.new(Integer, Integer) { |x, y|
|
|
21
|
+
ary = [x, y]
|
|
22
|
+
ary.sort == ary
|
|
23
|
+
}.check
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# if given array is already sorted, then the
|
|
27
|
+
# assertion turns true.
|
|
28
|
+
def assert_sort_two_sorted
|
|
29
|
+
Assertion.new(Integer, Integer) { |x, y, g|
|
|
30
|
+
g.guard {x <= y}
|
|
31
|
+
ary = [x, y]
|
|
32
|
+
ary.sort == ary
|
|
33
|
+
}.check
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# watch statistics
|
|
37
|
+
def assert_sort_two_sorted_trivial
|
|
38
|
+
Assertion.new(Integer, Integer) { |x, y, g|
|
|
39
|
+
g.guard {x <= y}
|
|
40
|
+
ary = [x, y]
|
|
41
|
+
(ary.sort == ary).trivial{x == y}
|
|
42
|
+
}.check
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def assert_sort_two_sorted_classify
|
|
46
|
+
Assertion.new(Integer, Integer) { |x, y, g|
|
|
47
|
+
g.guard {x <= y}
|
|
48
|
+
ary = [x, y]
|
|
49
|
+
(ary.sort == ary).classify('same'){x == y}.
|
|
50
|
+
classify('bit diff') { (x - y).abs == 1 }
|
|
51
|
+
}.check
|
|
52
|
+
end
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
7
|
+
<head>
|
|
8
|
+
<title>Module: Arbitrary</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
|
12
|
+
<script type="text/javascript">
|
|
13
|
+
// <![CDATA[
|
|
14
|
+
|
|
15
|
+
function popupCode( url ) {
|
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function toggleCode( id ) {
|
|
20
|
+
if ( document.getElementById )
|
|
21
|
+
elem = document.getElementById( id );
|
|
22
|
+
else if ( document.all )
|
|
23
|
+
elem = eval( "document.all." + id );
|
|
24
|
+
else
|
|
25
|
+
return false;
|
|
26
|
+
|
|
27
|
+
elemStyle = elem.style;
|
|
28
|
+
|
|
29
|
+
if ( elemStyle.display != "block" ) {
|
|
30
|
+
elemStyle.display = "block"
|
|
31
|
+
} else {
|
|
32
|
+
elemStyle.display = "none"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Make codeblocks hidden by default
|
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
|
40
|
+
|
|
41
|
+
// ]]>
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
<div id="classHeader">
|
|
50
|
+
<table class="header-table">
|
|
51
|
+
<tr class="top-aligned-row">
|
|
52
|
+
<td><strong>Module</strong></td>
|
|
53
|
+
<td class="class-name-in-header">Arbitrary</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr class="top-aligned-row">
|
|
56
|
+
<td><strong>In:</strong></td>
|
|
57
|
+
<td>
|
|
58
|
+
<a href="../files/rushcheck/arbitrary_rb.html">
|
|
59
|
+
rushcheck/arbitrary.rb
|
|
60
|
+
</a>
|
|
61
|
+
<br />
|
|
62
|
+
</td>
|
|
63
|
+
</tr>
|
|
64
|
+
|
|
65
|
+
</table>
|
|
66
|
+
</div>
|
|
67
|
+
<!-- banner header -->
|
|
68
|
+
|
|
69
|
+
<div id="bodyContent">
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
<div id="contextContent">
|
|
74
|
+
|
|
75
|
+
<div id="description">
|
|
76
|
+
<h1>arbitrary.rb</h1>
|
|
77
|
+
<p>
|
|
78
|
+
This file includes two modules <a href="Arbitrary.html">Arbitrary</a> and
|
|
79
|
+
<a href="Coarbitrary.html">Coarbitrary</a>. <a
|
|
80
|
+
href="Arbitrary.html">Arbitrary</a> provides an instance method arbitrary.
|
|
81
|
+
<a href="Coarbitrary.html">Coarbitrary</a> provides a class method
|
|
82
|
+
coarbitrary. However they are abstract methods and should be overrided in
|
|
83
|
+
each class after include/extend them.
|
|
84
|
+
</p>
|
|
85
|
+
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<div id="method-list">
|
|
92
|
+
<h3 class="section-bar">Methods</h3>
|
|
93
|
+
|
|
94
|
+
<div class="name-list">
|
|
95
|
+
<a href="#M000075">arbitrary</a>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
<!-- if includes -->
|
|
103
|
+
|
|
104
|
+
<div id="section">
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
<!-- if method_list -->
|
|
114
|
+
<div id="methods">
|
|
115
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
|
116
|
+
|
|
117
|
+
<div id="method-M000075" class="method-detail">
|
|
118
|
+
<a name="M000075"></a>
|
|
119
|
+
|
|
120
|
+
<div class="method-heading">
|
|
121
|
+
<a href="Arbitrary.src/M000075.html" target="Code" class="method-signature"
|
|
122
|
+
onclick="popupCode('Arbitrary.src/M000075.html');return false;">
|
|
123
|
+
<span class="method-name">arbitrary</span><span class="method-args">()</span>
|
|
124
|
+
</a>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<div class="method-description">
|
|
128
|
+
<p>
|
|
129
|
+
It is assumed that the arbitrary method must be overrided and return a <a
|
|
130
|
+
href="Gen.html">Gen</a> object with the same class of self. See also
|
|
131
|
+
rushcheck/gen.rb.
|
|
132
|
+
</p>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
<div id="validator-badges">
|
|
144
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
</body>
|
|
148
|
+
</html>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html>
|
|
7
|
+
<head>
|
|
8
|
+
<title>arbitrary (Arbitrary)</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
+
</head>
|
|
12
|
+
<body class="standalone-code">
|
|
13
|
+
<pre><span class="ruby-comment cmt"># File rushcheck/arbitrary.rb, line 14</span>
|
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">arbitrary</span>
|
|
15
|
+
<span class="ruby-identifier">raise</span>(<span class="ruby-constant">NotImplementedError</span>, <span class="ruby-value str">"This method should be overrided."</span>)
|
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
7
|
+
<head>
|
|
8
|
+
<title>Class: Assertion</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
|
12
|
+
<script type="text/javascript">
|
|
13
|
+
// <![CDATA[
|
|
14
|
+
|
|
15
|
+
function popupCode( url ) {
|
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function toggleCode( id ) {
|
|
20
|
+
if ( document.getElementById )
|
|
21
|
+
elem = document.getElementById( id );
|
|
22
|
+
else if ( document.all )
|
|
23
|
+
elem = eval( "document.all." + id );
|
|
24
|
+
else
|
|
25
|
+
return false;
|
|
26
|
+
|
|
27
|
+
elemStyle = elem.style;
|
|
28
|
+
|
|
29
|
+
if ( elemStyle.display != "block" ) {
|
|
30
|
+
elemStyle.display = "block"
|
|
31
|
+
} else {
|
|
32
|
+
elemStyle.display = "none"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Make codeblocks hidden by default
|
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
|
40
|
+
|
|
41
|
+
// ]]>
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
<div id="classHeader">
|
|
50
|
+
<table class="header-table">
|
|
51
|
+
<tr class="top-aligned-row">
|
|
52
|
+
<td><strong>Class</strong></td>
|
|
53
|
+
<td class="class-name-in-header">Assertion</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr class="top-aligned-row">
|
|
56
|
+
<td><strong>In:</strong></td>
|
|
57
|
+
<td>
|
|
58
|
+
<a href="../files/rushcheck/assertion_rb.html">
|
|
59
|
+
rushcheck/assertion.rb
|
|
60
|
+
</a>
|
|
61
|
+
<br />
|
|
62
|
+
</td>
|
|
63
|
+
</tr>
|
|
64
|
+
|
|
65
|
+
<tr class="top-aligned-row">
|
|
66
|
+
<td><strong>Parent:</strong></td>
|
|
67
|
+
<td>
|
|
68
|
+
Object
|
|
69
|
+
</td>
|
|
70
|
+
</tr>
|
|
71
|
+
</table>
|
|
72
|
+
</div>
|
|
73
|
+
<!-- banner header -->
|
|
74
|
+
|
|
75
|
+
<div id="bodyContent">
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
<div id="contextContent">
|
|
80
|
+
|
|
81
|
+
<div id="description">
|
|
82
|
+
<p>
|
|
83
|
+
<a href="Assertion.html">Assertion</a> class is one of main features of
|
|
84
|
+
RushCheck. You can write a testcase for random testing as follows:
|
|
85
|
+
</p>
|
|
86
|
+
<p>
|
|
87
|
+
<a href="Assertion.html#M000015">Assertion.new</a>(<a
|
|
88
|
+
href="Integer.html">Integer</a>, <a href="String.html">String</a>) do |x,
|
|
89
|
+
y, g|
|
|
90
|
+
</p>
|
|
91
|
+
<pre>
|
|
92
|
+
g.guard { precondition }
|
|
93
|
+
body
|
|
94
|
+
</pre>
|
|
95
|
+
<p>
|
|
96
|
+
end
|
|
97
|
+
</p>
|
|
98
|
+
<p>
|
|
99
|
+
See also documents and several examples.
|
|
100
|
+
</p>
|
|
101
|
+
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<div id="method-list">
|
|
108
|
+
<h3 class="section-bar">Methods</h3>
|
|
109
|
+
|
|
110
|
+
<div class="name-list">
|
|
111
|
+
<a href="#M000015">new</a>
|
|
112
|
+
<a href="#M000016">property</a>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
<!-- if includes -->
|
|
120
|
+
<div id="includes">
|
|
121
|
+
<h3 class="section-bar">Included Modules</h3>
|
|
122
|
+
|
|
123
|
+
<div id="includes-list">
|
|
124
|
+
<span class="include-name"><a href="Testable.html">Testable</a></span>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
<div id="section">
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
<!-- if method_list -->
|
|
138
|
+
<div id="methods">
|
|
139
|
+
<h3 class="section-bar">Public Class methods</h3>
|
|
140
|
+
|
|
141
|
+
<div id="method-M000015" class="method-detail">
|
|
142
|
+
<a name="M000015"></a>
|
|
143
|
+
|
|
144
|
+
<div class="method-heading">
|
|
145
|
+
<a href="Assertion.src/M000015.html" target="Code" class="method-signature"
|
|
146
|
+
onclick="popupCode('Assertion.src/M000015.html');return false;">
|
|
147
|
+
<span class="method-name">new</span><span class="method-args">(*xs, &f)</span>
|
|
148
|
+
</a>
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
<div class="method-description">
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
|
156
|
+
|
|
157
|
+
<div id="method-M000016" class="method-detail">
|
|
158
|
+
<a name="M000016"></a>
|
|
159
|
+
|
|
160
|
+
<div class="method-heading">
|
|
161
|
+
<a href="Assertion.src/M000016.html" target="Code" class="method-signature"
|
|
162
|
+
onclick="popupCode('Assertion.src/M000016.html');return false;">
|
|
163
|
+
<span class="method-name">property</span><span class="method-args">()</span>
|
|
164
|
+
</a>
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
<div class="method-description">
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
</div>
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
</div>
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
<div id="validator-badges">
|
|
179
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
180
|
+
</div>
|
|
181
|
+
|
|
182
|
+
</body>
|
|
183
|
+
</html>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html>
|
|
7
|
+
<head>
|
|
8
|
+
<title>new (Assertion)</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
+
</head>
|
|
12
|
+
<body class="standalone-code">
|
|
13
|
+
<pre><span class="ruby-comment cmt"># File rushcheck/assertion.rb, line 24</span>
|
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">xs</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">f</span>)
|
|
15
|
+
<span class="ruby-ivar">@inputs</span> = <span class="ruby-identifier">xs</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span>(<span class="ruby-identifier">f</span>.<span class="ruby-identifier">arity</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>)]
|
|
16
|
+
<span class="ruby-ivar">@nguard</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">arity</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">xs</span>.<span class="ruby-identifier">length</span>
|
|
17
|
+
<span class="ruby-ivar">@proc</span> = <span class="ruby-identifier">f</span>
|
|
18
|
+
<span class="ruby-keyword kw">end</span></pre>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html>
|
|
7
|
+
<head>
|
|
8
|
+
<title>property (Assertion)</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
+
</head>
|
|
12
|
+
<body class="standalone-code">
|
|
13
|
+
<pre><span class="ruby-comment cmt"># File rushcheck/assertion.rb, line 30</span>
|
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">property</span>
|
|
15
|
+
<span class="ruby-constant">Property</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Gen</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">n</span>, <span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
|
|
16
|
+
<span class="ruby-identifier">r2</span> = <span class="ruby-identifier">r</span>
|
|
17
|
+
<span class="ruby-ivar">@inputs</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span>
|
|
18
|
+
<span class="ruby-identifier">r1</span>, <span class="ruby-identifier">r2</span> = <span class="ruby-identifier">r2</span>.<span class="ruby-identifier">split</span>
|
|
19
|
+
<span class="ruby-identifier">c</span>.<span class="ruby-identifier">arbitrary</span>.<span class="ruby-identifier">value</span>(<span class="ruby-identifier">n</span>, <span class="ruby-identifier">r1</span>)
|
|
20
|
+
<span class="ruby-keyword kw">end</span>
|
|
21
|
+
<span class="ruby-keyword kw">end</span>.<span class="ruby-identifier">bind</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">args</span><span class="ruby-operator">|</span>
|
|
22
|
+
<span class="ruby-identifier">guards</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@nguard</span>, <span class="ruby-constant">Guard</span>.<span class="ruby-identifier">new</span>)
|
|
23
|
+
<span class="ruby-identifier">test</span> = <span class="ruby-keyword kw">begin</span>
|
|
24
|
+
<span class="ruby-identifier">xs</span> = <span class="ruby-identifier">args</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">guards</span>
|
|
25
|
+
<span class="ruby-ivar">@proc</span>.<span class="ruby-identifier">call</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">xs</span>)
|
|
26
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
|
|
27
|
+
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">ex</span>
|
|
28
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-constant">RushCheckGuard</span>
|
|
29
|
+
<span class="ruby-constant">Result</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">nil</span>)
|
|
30
|
+
<span class="ruby-keyword kw">else</span>
|
|
31
|
+
<span class="ruby-identifier">err</span> = <span class="ruby-node">"Unexpected exception: #{ex.inspect}\n"</span> <span class="ruby-operator">+</span>
|
|
32
|
+
<span class="ruby-identifier">ex</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"\n"</span>)
|
|
33
|
+
<span class="ruby-constant">Result</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">false</span>, [], [<span class="ruby-identifier">err</span>])
|
|
34
|
+
<span class="ruby-keyword kw">end</span>
|
|
35
|
+
<span class="ruby-keyword kw">end</span>
|
|
36
|
+
<span class="ruby-comment cmt"># not use ensure here because ensure clause</span>
|
|
37
|
+
<span class="ruby-comment cmt"># does not return values</span>
|
|
38
|
+
<span class="ruby-identifier">test</span>.<span class="ruby-identifier">property</span>.<span class="ruby-identifier">gen</span>.<span class="ruby-identifier">bind</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">res</span><span class="ruby-operator">|</span>
|
|
39
|
+
<span class="ruby-identifier">res</span>.<span class="ruby-identifier">arguments</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">inspect</span>
|
|
40
|
+
<span class="ruby-constant">Gen</span>.<span class="ruby-identifier">unit</span>(<span class="ruby-identifier">res</span>)
|
|
41
|
+
<span class="ruby-keyword kw">end</span>
|
|
42
|
+
<span class="ruby-keyword kw">end</span>)
|
|
43
|
+
<span class="ruby-keyword kw">end</span></pre>
|
|
44
|
+
</body>
|
|
45
|
+
</html>
|