rushcheck 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. data/COPYING +515 -0
  2. data/INSTALL +14 -0
  3. data/LICENSE +5 -0
  4. data/README +49 -0
  5. data/Rakefile +39 -0
  6. data/copying.txt +23 -0
  7. data/data/rushcheck/doc/policy.txt +520 -0
  8. data/data/rushcheck/doc/rushcheck.txt +612 -0
  9. data/data/rushcheck/examples/printf.rb +22 -0
  10. data/data/rushcheck/examples/proc.rb +33 -0
  11. data/data/rushcheck/examples/roguetile.rb +153 -0
  12. data/data/rushcheck/examples/sample.rb +52 -0
  13. data/data/rushcheck/rdoc/classes/Arbitrary.html +148 -0
  14. data/data/rushcheck/rdoc/classes/Arbitrary.src/M000075.html +18 -0
  15. data/data/rushcheck/rdoc/classes/Assertion.html +183 -0
  16. data/data/rushcheck/rdoc/classes/Assertion.src/M000015.html +20 -0
  17. data/data/rushcheck/rdoc/classes/Assertion.src/M000016.html +45 -0
  18. data/data/rushcheck/rdoc/classes/Coarbitrary.html +135 -0
  19. data/data/rushcheck/rdoc/classes/Coarbitrary.src/M000095.html +18 -0
  20. data/data/rushcheck/rdoc/classes/FalseClass.html +177 -0
  21. data/data/rushcheck/rdoc/classes/FalseClass.src/M000018.html +18 -0
  22. data/data/rushcheck/rdoc/classes/FalseClass.src/M000019.html +18 -0
  23. data/data/rushcheck/rdoc/classes/FalseClass.src/M000020.html +18 -0
  24. data/data/rushcheck/rdoc/classes/Float.html +191 -0
  25. data/data/rushcheck/rdoc/classes/Float.src/M000047.html +21 -0
  26. data/data/rushcheck/rdoc/classes/Float.src/M000048.html +18 -0
  27. data/data/rushcheck/rdoc/classes/Float.src/M000049.html +22 -0
  28. data/data/rushcheck/rdoc/classes/Float.src/M000050.html +20 -0
  29. data/data/rushcheck/rdoc/classes/Gen.html +515 -0
  30. data/data/rushcheck/rdoc/classes/Gen.src/M000026.html +18 -0
  31. data/data/rushcheck/rdoc/classes/Gen.src/M000027.html +20 -0
  32. data/data/rushcheck/rdoc/classes/Gen.src/M000028.html +28 -0
  33. data/data/rushcheck/rdoc/classes/Gen.src/M000029.html +24 -0
  34. data/data/rushcheck/rdoc/classes/Gen.src/M000030.html +18 -0
  35. data/data/rushcheck/rdoc/classes/Gen.src/M000031.html +18 -0
  36. data/data/rushcheck/rdoc/classes/Gen.src/M000032.html +18 -0
  37. data/data/rushcheck/rdoc/classes/Gen.src/M000033.html +18 -0
  38. data/data/rushcheck/rdoc/classes/Gen.src/M000034.html +18 -0
  39. data/data/rushcheck/rdoc/classes/Gen.src/M000035.html +24 -0
  40. data/data/rushcheck/rdoc/classes/Gen.src/M000036.html +18 -0
  41. data/data/rushcheck/rdoc/classes/Gen.src/M000037.html +21 -0
  42. data/data/rushcheck/rdoc/classes/Gen.src/M000038.html +18 -0
  43. data/data/rushcheck/rdoc/classes/Gen.src/M000039.html +18 -0
  44. data/data/rushcheck/rdoc/classes/Gen.src/M000040.html +23 -0
  45. data/data/rushcheck/rdoc/classes/Gen.src/M000041.html +19 -0
  46. data/data/rushcheck/rdoc/classes/Gen.src/M000042.html +18 -0
  47. data/data/rushcheck/rdoc/classes/Gen.src/M000043.html +24 -0
  48. data/data/rushcheck/rdoc/classes/Guard.html +159 -0
  49. data/data/rushcheck/rdoc/classes/Guard.src/M000024.html +27 -0
  50. data/data/rushcheck/rdoc/classes/Guard.src/M000025.html +18 -0
  51. data/data/rushcheck/rdoc/classes/HsRandom.html +201 -0
  52. data/data/rushcheck/rdoc/classes/HsRandom.src/M000081.html +22 -0
  53. data/data/rushcheck/rdoc/classes/HsRandom.src/M000082.html +32 -0
  54. data/data/rushcheck/rdoc/classes/HsRandom.src/M000083.html +18 -0
  55. data/data/rushcheck/rdoc/classes/Integer.html +212 -0
  56. data/data/rushcheck/rdoc/classes/Integer.src/M000006.html +18 -0
  57. data/data/rushcheck/rdoc/classes/Integer.src/M000007.html +18 -0
  58. data/data/rushcheck/rdoc/classes/Integer.src/M000008.html +21 -0
  59. data/data/rushcheck/rdoc/classes/Integer.src/M000009.html +19 -0
  60. data/data/rushcheck/rdoc/classes/NilClass.html +177 -0
  61. data/data/rushcheck/rdoc/classes/NilClass.src/M000059.html +18 -0
  62. data/data/rushcheck/rdoc/classes/NilClass.src/M000060.html +18 -0
  63. data/data/rushcheck/rdoc/classes/NilClass.src/M000061.html +18 -0
  64. data/data/rushcheck/rdoc/classes/Property.html +174 -0
  65. data/data/rushcheck/rdoc/classes/Property.src/M000070.html +26 -0
  66. data/data/rushcheck/rdoc/classes/Property.src/M000071.html +18 -0
  67. data/data/rushcheck/rdoc/classes/RandomArray.html +184 -0
  68. data/data/rushcheck/rdoc/classes/RandomArray.src/M000021.html +18 -0
  69. data/data/rushcheck/rdoc/classes/RandomArray.src/M000022.html +35 -0
  70. data/data/rushcheck/rdoc/classes/RandomArray.src/M000023.html +22 -0
  71. data/data/rushcheck/rdoc/classes/RandomBool.html +146 -0
  72. data/data/rushcheck/rdoc/classes/RandomBool.src/M000079.html +18 -0
  73. data/data/rushcheck/rdoc/classes/RandomBool.src/M000080.html +19 -0
  74. data/data/rushcheck/rdoc/classes/RandomGen.html +196 -0
  75. data/data/rushcheck/rdoc/classes/RandomGen.src/M000076.html +18 -0
  76. data/data/rushcheck/rdoc/classes/RandomGen.src/M000077.html +18 -0
  77. data/data/rushcheck/rdoc/classes/RandomGen.src/M000078.html +18 -0
  78. data/data/rushcheck/rdoc/classes/RandomHash.html +197 -0
  79. data/data/rushcheck/rdoc/classes/RandomHash.src/M000044.html +18 -0
  80. data/data/rushcheck/rdoc/classes/RandomHash.src/M000045.html +26 -0
  81. data/data/rushcheck/rdoc/classes/RandomHash.src/M000046.html +22 -0
  82. data/data/rushcheck/rdoc/classes/RandomProc.html +192 -0
  83. data/data/rushcheck/rdoc/classes/RandomProc.src/M000055.html +18 -0
  84. data/data/rushcheck/rdoc/classes/RandomProc.src/M000056.html +30 -0
  85. data/data/rushcheck/rdoc/classes/RandomProc.src/M000057.html +26 -0
  86. data/data/rushcheck/rdoc/classes/RandomProc.src/M000058.html +20 -0
  87. data/data/rushcheck/rdoc/classes/Result.html +214 -0
  88. data/data/rushcheck/rdoc/classes/Result.src/M000051.html +18 -0
  89. data/data/rushcheck/rdoc/classes/Result.src/M000052.html +18 -0
  90. data/data/rushcheck/rdoc/classes/Result.src/M000053.html +18 -0
  91. data/data/rushcheck/rdoc/classes/RushCheckConfig.html +240 -0
  92. data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000001.html +23 -0
  93. data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000002.html +22 -0
  94. data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000003.html +18 -0
  95. data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000004.html +38 -0
  96. data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000005.html +55 -0
  97. data/data/rushcheck/rdoc/classes/RushCheckGuard.html +118 -0
  98. data/data/rushcheck/rdoc/classes/SpecialString.html +151 -0
  99. data/data/rushcheck/rdoc/classes/SpecialString.src/M000017.html +37 -0
  100. data/data/rushcheck/rdoc/classes/StdGen.html +252 -0
  101. data/data/rushcheck/rdoc/classes/StdGen.src/M000010.html +23 -0
  102. data/data/rushcheck/rdoc/classes/StdGen.src/M000011.html +21 -0
  103. data/data/rushcheck/rdoc/classes/StdGen.src/M000012.html +21 -0
  104. data/data/rushcheck/rdoc/classes/StdGen.src/M000013.html +18 -0
  105. data/data/rushcheck/rdoc/classes/StdGen.src/M000014.html +18 -0
  106. data/data/rushcheck/rdoc/classes/String.html +191 -0
  107. data/data/rushcheck/rdoc/classes/String.src/M000066.html +24 -0
  108. data/data/rushcheck/rdoc/classes/String.src/M000067.html +18 -0
  109. data/data/rushcheck/rdoc/classes/String.src/M000068.html +25 -0
  110. data/data/rushcheck/rdoc/classes/String.src/M000069.html +22 -0
  111. data/data/rushcheck/rdoc/classes/Testable.html +281 -0
  112. data/data/rushcheck/rdoc/classes/Testable.src/M000084.html +18 -0
  113. data/data/rushcheck/rdoc/classes/Testable.src/M000085.html +18 -0
  114. data/data/rushcheck/rdoc/classes/Testable.src/M000088.html +18 -0
  115. data/data/rushcheck/rdoc/classes/Testable.src/M000089.html +18 -0
  116. data/data/rushcheck/rdoc/classes/Testable.src/M000090.html +18 -0
  117. data/data/rushcheck/rdoc/classes/Testable.src/M000092.html +18 -0
  118. data/data/rushcheck/rdoc/classes/Testable.src/M000094.html +18 -0
  119. data/data/rushcheck/rdoc/classes/TheStdGen.html +200 -0
  120. data/data/rushcheck/rdoc/classes/TheStdGen.src/M000062.html +18 -0
  121. data/data/rushcheck/rdoc/classes/TheStdGen.src/M000063.html +20 -0
  122. data/data/rushcheck/rdoc/classes/TheStdGen.src/M000064.html +21 -0
  123. data/data/rushcheck/rdoc/classes/TheStdGen.src/M000065.html +18 -0
  124. data/data/rushcheck/rdoc/classes/TrueClass.html +177 -0
  125. data/data/rushcheck/rdoc/classes/TrueClass.src/M000072.html +18 -0
  126. data/data/rushcheck/rdoc/classes/TrueClass.src/M000073.html +18 -0
  127. data/data/rushcheck/rdoc/classes/TrueClass.src/M000074.html +18 -0
  128. data/data/rushcheck/rdoc/created.rid +1 -0
  129. data/data/rushcheck/rdoc/files/rushcheck/arbitrary_rb.html +114 -0
  130. data/data/rushcheck/rdoc/files/rushcheck/array_rb.html +117 -0
  131. data/data/rushcheck/rdoc/files/rushcheck/assertion_rb.html +120 -0
  132. data/data/rushcheck/rdoc/files/rushcheck/bool_rb.html +120 -0
  133. data/data/rushcheck/rdoc/files/rushcheck/config_rb.html +109 -0
  134. data/data/rushcheck/rdoc/files/rushcheck/float_rb.html +118 -0
  135. data/data/rushcheck/rdoc/files/rushcheck/gen_rb.html +111 -0
  136. data/data/rushcheck/rdoc/files/rushcheck/guard_rb.html +108 -0
  137. data/data/rushcheck/rdoc/files/rushcheck/hash_rb.html +117 -0
  138. data/data/rushcheck/rdoc/files/rushcheck/integer_rb.html +118 -0
  139. data/data/rushcheck/rdoc/files/rushcheck/proc_rb.html +118 -0
  140. data/data/rushcheck/rdoc/files/rushcheck/property_rb.html +119 -0
  141. data/data/rushcheck/rdoc/files/rushcheck/random_rb.html +126 -0
  142. data/data/rushcheck/rdoc/files/rushcheck/result_rb.html +118 -0
  143. data/data/rushcheck/rdoc/files/rushcheck/rushcheck_rb.html +123 -0
  144. data/data/rushcheck/rdoc/files/rushcheck/string_rb.html +121 -0
  145. data/data/rushcheck/rdoc/files/rushcheck/testable_rb.html +117 -0
  146. data/data/rushcheck/rdoc/fr_class_index.html +51 -0
  147. data/data/rushcheck/rdoc/fr_file_index.html +43 -0
  148. data/data/rushcheck/rdoc/fr_method_index.html +121 -0
  149. data/data/rushcheck/rdoc/index.html +24 -0
  150. data/data/rushcheck/rdoc/rdoc-style.css +208 -0
  151. data/lib/rushcheck/arbitrary.rb +28 -0
  152. data/lib/rushcheck/array.rb +49 -0
  153. data/lib/rushcheck/assertion.rb +67 -0
  154. data/lib/rushcheck/bool.rb +90 -0
  155. data/lib/rushcheck/config.rb +98 -0
  156. data/lib/rushcheck/float.rb +43 -0
  157. data/lib/rushcheck/gen.rb +189 -0
  158. data/lib/rushcheck/guard.rb +27 -0
  159. data/lib/rushcheck/hash.rb +45 -0
  160. data/lib/rushcheck/integer.rb +43 -0
  161. data/lib/rushcheck/proc.rb +53 -0
  162. data/lib/rushcheck/property.rb +29 -0
  163. data/lib/rushcheck/random.rb +215 -0
  164. data/lib/rushcheck/result.rb +26 -0
  165. data/lib/rushcheck/rushcheck.rb +17 -0
  166. data/lib/rushcheck/string.rb +100 -0
  167. data/lib/rushcheck/testable.rb +41 -0
  168. metadata +238 -0
@@ -0,0 +1,215 @@
1
+ # = random.rb - A library for psuedo-random number from Haskell
2
+ #
3
+ # This library deals with the common task of
4
+ # psuedo-random number generation from Haskell98. The library
5
+ # makes it possible to generate repeatable results, by starting
6
+ # with a specified initial random number generator; or to get
7
+ # different results on each run by using the system-initialised
8
+ # generator, or by supplying a seed from some other source.
9
+ #
10
+ # This file provides two module RandomGen, HsRandom, two classes
11
+ # StdGen and TheStdGen.
12
+
13
+
14
+ # The module RandomGen is an abstract module. This is included
15
+ # to add instance methods. The author considers that few developers
16
+ # need to read this implementation. See StdGen as an example.
17
+ # Check also Haskell's System.Random library.
18
+ module RandomGen
19
+
20
+ # gen_next should be overrided as an instance method.
21
+ # It is assumed that gen_next returns an array with length 2.
22
+ # Here, call 'Foo' the class which includes RandomGen.
23
+ # The first components of the result should be an integer, and the
24
+ # last components should be an object which belongs to the class
25
+ # Foo.
26
+ def gen_next
27
+ raise_not_implemented_error
28
+ end
29
+
30
+ # split should be overrided as an instance method.
31
+ # It is assumed that split returns an array with length 2.
32
+ # Here, call 'Foo' the class which includes RandomGen.
33
+ # Then the components of the result are objects which belongs to the
34
+ # class Foo.
35
+ def split
36
+ raise_not_implemented_error
37
+ end
38
+
39
+ # gen_range should be overrided as an instance method.
40
+ # It is assumed that split returns an array with length 2.
41
+ # Here, call 'Foo' the class which includes RandomGen.
42
+ # Then the components of the result are integers where
43
+ # the first components should be the lowest bound of
44
+ # the first components of gen_next. Another should be
45
+ # the highest bound of the first components of gen_next.
46
+ def gen_range
47
+ raise_not_implemented_error
48
+ end
49
+
50
+ private
51
+ def raise_not_implemented_error
52
+ raise(NotImplementedError, "This method should be overrided.")
53
+ end
54
+
55
+ end
56
+
57
+ # StdGen is a class (and the unique class) which includes RandomGen.
58
+ # This class provides a functional random number generator.
59
+ class StdGen
60
+
61
+ include RandomGen
62
+
63
+ @@min_bound = -(2**30)
64
+ @@max_bound = 2**30 - 1
65
+
66
+ # left and right are two seeds of random number generator.
67
+ attr_reader :left, :right
68
+ def initialize(left=nil, right=nil)
69
+ @left, @right = [left, right].map do |x|
70
+ if x.nil?
71
+ then random
72
+ else in_range(x)
73
+ end
74
+ end
75
+ end
76
+
77
+ # gen_next returns an array with length 2. The first component of
78
+ # result is a random integer. The last component is a new StdGen
79
+ # object as a new random number generator. See also RandomGen.
80
+ def gen_next
81
+ s, t = [@left, @right].map {|x| random(x) }
82
+ z = ((s - t) % (@@max_bound - @@min_bound)) + @@min_bound
83
+
84
+ [z, StdGen.new(s, t)]
85
+ end
86
+
87
+ # split returns an array with length 2. The components are
88
+ # two new StdGen objects as two new random number generators.
89
+ def split
90
+ g = gen_next[1]
91
+ s, t = g.left, g.right
92
+
93
+ [StdGen.new(s + 1, t), StdGen.new(s, t + 1)]
94
+ end
95
+
96
+ # gen_range returns an array with length 2 which represents
97
+ # a bound of generated random numbers.
98
+ def gen_range
99
+ [@@min_bound, @@max_bound]
100
+ end
101
+
102
+ def to_s
103
+ @left.to_s + ' ' + @right.to_s
104
+ end
105
+
106
+ private
107
+ def random(s=nil)
108
+ if s.nil? then srand else srand s end
109
+ rand(@@max_bound - @@min_bound) + @@min_bound
110
+ end
111
+
112
+ def in_range(n)
113
+ (n % (@@max_bound - @@min_bound)) + @@min_bound
114
+ end
115
+
116
+ end
117
+
118
+
119
+ require 'singleton'
120
+
121
+ # TheStdGen is a singleton class to get the unique random number
122
+ # generator using StdGen. TheStdGen includes ruby's Singleton module.
123
+ class TheStdGen
124
+
125
+ include RandomGen
126
+ include Singleton
127
+
128
+ def initialize
129
+ @gen = StdGen.new
130
+ end
131
+
132
+ def gen_next
133
+ @gen, result = @gen.split
134
+
135
+ result.gen_next
136
+ end
137
+
138
+ def split
139
+ result = @gen.split
140
+ @gen = @gen.gen_next[1]
141
+
142
+ result
143
+ end
144
+
145
+ def gen_range
146
+ @gen.gen_range
147
+ end
148
+
149
+ end
150
+
151
+
152
+ # HsRandom module provides several random number function with the
153
+ # functional random generator. This module is implemented Haskell\'s
154
+ # System.Random library. This module assumes that the class which
155
+ # includes HsRandom should have an instance method random_range to
156
+ # generate a random number and a new random number generator.
157
+ # It assumes also that the class which includes HsRandom should have
158
+ # a class method bound to give a bound of random numbers.
159
+ module HsRandom
160
+
161
+ # random requires the functional random number generater (StdGen
162
+ # object) and optionally requires the bound of random numbers.
163
+ # It returns an array with length 2, where the first component
164
+ # should be a new random number, and the last should be a new random
165
+ # number generator.
166
+ def random(gen, lo=nil, hi=nil)
167
+ lo = bound[0] if lo.nil?
168
+ hi = bound[1] if hi.nil?
169
+ random_range(gen, hi, lo) if lo > hi
170
+
171
+ random_range(gen, lo, hi)
172
+ end
173
+
174
+ # random_array requires the functional random number generater
175
+ # (StdGen object). Optionally, it requires the length of results and
176
+ # the bound of random numbers. This method returns different result
177
+ # whether the second argument length is nil or not. When the second
178
+ # argument is nil, then random_array returns a Proc which takes one
179
+ # variable as an integer and return a new random value, such as an
180
+ # infinite sequence of random numbers. Otherwise, the second
181
+ # argument of random_array is not nil but some integer, then
182
+ # random_array returns an array of random numbers with the length.
183
+ def random_array(gen, len=nil, lo=nil, hi=nil)
184
+ g = gen
185
+ if len.nil?
186
+ then
187
+ Proc.new do |i|
188
+ (i+1).times do
189
+ v, g = random(g, lo, hi)
190
+ end
191
+ v
192
+ end
193
+ else
194
+ (1..len).map do
195
+ v, g = random(g, lo, hi)
196
+ v
197
+ end
198
+ end
199
+ end
200
+
201
+ # random_std requires optionally the bound of random numbers.
202
+ # It returns an array with length 2, where the first component
203
+ # should be a new random number, and the last should be a new random
204
+ # number generator. This method uses the unique standard random
205
+ # generator TheStdGen.
206
+ def random_std(lo=nil, hi=nil)
207
+ random(TheStdGen.instance, lo, hi)
208
+ end
209
+
210
+ def random_range(gen, lo=nil, hi=nil)
211
+ raise(NotImplementedError, "This method should be overrided.")
212
+ end
213
+ private :random_range
214
+
215
+ end
@@ -0,0 +1,26 @@
1
+ # = result.rb
2
+ # This file defines results of testcase
3
+ # class Result is used for RushCheck internally
4
+
5
+ require 'rushcheck/property'
6
+ require 'rushcheck/testable'
7
+
8
+ class Result
9
+
10
+ include Testable
11
+
12
+ def self.nothing
13
+ Result.new(false)
14
+ end
15
+
16
+ attr_reader :ok, :stamp, :arguments
17
+ def initialize(ok=nil, stamp=[], arguments=[])
18
+ @ok, @stamp, @arguments = ok, stamp, arguments
19
+ end
20
+
21
+ def result
22
+ Property.new(@ok, @stamp, @arguments)
23
+ end
24
+ alias property :result
25
+
26
+ end
@@ -0,0 +1,17 @@
1
+ # = rushcheck.rb
2
+ # this is just a prelude include file
3
+ # this provides all of feature of RushCheck for random testing.
4
+
5
+ require 'rushcheck/arbitrary'
6
+ require 'rushcheck/assertion'
7
+ require 'rushcheck/gen'
8
+ require 'rushcheck/random'
9
+ require 'rushcheck/testable'
10
+
11
+ require 'rushcheck/array'
12
+ require 'rushcheck/bool'
13
+ require 'rushcheck/hash'
14
+ require 'rushcheck/integer'
15
+ require 'rushcheck/float'
16
+ require 'rushcheck/proc'
17
+ require 'rushcheck/string'
@@ -0,0 +1,100 @@
1
+ # = string.rb
2
+ # an extension to String class for RushCheck
3
+ # this file provides two classes String and SpecialString
4
+
5
+ require 'rushcheck/arbitrary'
6
+ require 'rushcheck/gen'
7
+ require 'rushcheck/integer'
8
+ require 'rushcheck/random'
9
+
10
+ class String
11
+
12
+ extend Arbitrary
13
+ extend HsRandom
14
+
15
+ include Coarbitrary
16
+
17
+ @@min_range = 0
18
+ @@max_range = 1024
19
+
20
+ def self.arbitrary
21
+ Gen.sized do |n|
22
+ Gen.choose(0, n).bind do |len|
23
+ Gen.vector(Integer, len).bind do |xs|
24
+ Gen.unit(xs.map{|x| (x % 128).chr}.join)
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ def self.bound
31
+ [@@min_range, @@max_range]
32
+ end
33
+
34
+ def self.random_range(gen, lo=@@min_range, hi=@@max_range)
35
+ len, g = Integer.random(gen, lo, hi)
36
+ result = ''
37
+ len.times do
38
+ v, g = Integer.random(g, 0, 127)
39
+ result += v.chr
40
+ end
41
+
42
+ [result. g]
43
+ end
44
+
45
+ def coarbitrary(g)
46
+ r = g.variant(0)
47
+ each_byte do |c|
48
+ r = c.coarbitrary(r.variant(1))
49
+ end
50
+ r
51
+ end
52
+
53
+ end
54
+
55
+ # class SpecialString is a subclass of String.
56
+ # SpecialString provides another generator which prefers
57
+ # control codes and special unprinted codes than usual alphabets or numbers.
58
+ # This class maybe useful to find a counter example efficiently than
59
+ # using the standard generator of String.
60
+ class SpecialString < String
61
+
62
+ # ASCII code (see man ascii)
63
+ @@alphabet = (65..90).to_a + (97..122).to_a
64
+ @@control = (0..32).to_a + [177]
65
+ @@number = (48..57).to_a
66
+ @@special =
67
+ [[33,47],[58,64],[91,96],[123,126]].inject([]) do |ary, pair|
68
+ lo, hi = pair
69
+ ary = ary + (lo..hi).to_a
70
+ end
71
+
72
+ @@frequency = { 'alphabet' => 3,
73
+ 'control' => 10,
74
+ 'number' => 2,
75
+ 'special' => 5 }
76
+
77
+ def self.arbitrary
78
+ f = @@frequency
79
+ frq = []
80
+ [f['alphabet'],f['control'],f['number'],f['special']].zip(
81
+ [ @@alphabet, @@control, @@number, @@special]) do
82
+ |weight, table|
83
+ gen = Gen.oneof(table.map {|n| Gen.unit(n.chr)})
84
+ frq << [weight, gen]
85
+ end
86
+
87
+ Gen.sized do |m|
88
+ Gen.choose(0, m).bind do |len|
89
+ Gen.new do |n, r|
90
+ r2 = r
91
+ (1..len).map do
92
+ r1, r2 = r2.split
93
+ Gen.frequency(frq).value(n, r1)
94
+ end.join
95
+ end
96
+ end
97
+ end
98
+ end
99
+
100
+ end
@@ -0,0 +1,41 @@
1
+ # = testable.rb
2
+ # this provides an abstract interface of Testable
3
+ # See also QuickCheck in Haskell
4
+
5
+ require 'rushcheck/config'
6
+
7
+ module Testable
8
+
9
+ def property
10
+ raise(NotImplementedError, "This method should be overrided.")
11
+ end
12
+
13
+ def check(config=RushCheckConfig.quick)
14
+ config.tests(property.gen, TheStdGen.instance)
15
+ end
16
+ alias quick_check :check
17
+ alias quickcheck :check
18
+
19
+ def classify(name)
20
+ yield ? label(name) : property
21
+ end
22
+
23
+ def imply
24
+ yield ? property : Result.nothing.result
25
+ end
26
+
27
+ def label(s)
28
+ Property.new(property.gen.fmap {|res| res.stamp << s.to_s; res })
29
+ end
30
+ alias collect :label
31
+
32
+ def test
33
+ check(RushCheckConfig.verbose)
34
+ end
35
+ alias verbose_check :test
36
+
37
+ def trivial
38
+ classify('trivial') { yield }
39
+ end
40
+
41
+ end
metadata ADDED
@@ -0,0 +1,238 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: rushcheck
5
+ version: !ruby/object:Gem::Version
6
+ version: "0.2"
7
+ date: 2006-08-09 00:00:00.000000 +09:00
8
+ summary: A lightweight random testing tool
9
+ require_paths:
10
+ - lib
11
+ email: ikegami@madscientist.jp
12
+ homepage: http://rushcheck.rubyforge.org
13
+ rubyforge_project:
14
+ description: RushCheck is a random testing tool which is one of implementations of QuichCheck in Haskell.
15
+ autorequire: rushcheck
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ -
22
+ - ">"
23
+ - !ruby/object:Gem::Version
24
+ version: 0.0.0
25
+ version:
26
+ platform: ruby
27
+ signing_key:
28
+ cert_chain:
29
+ post_install_message:
30
+ authors:
31
+ - Daisuke IKEGAMI
32
+ files:
33
+ - lib/rushcheck
34
+ - lib/rushcheck/arbitrary.rb
35
+ - lib/rushcheck/array.rb
36
+ - lib/rushcheck/assertion.rb
37
+ - lib/rushcheck/bool.rb
38
+ - lib/rushcheck/config.rb
39
+ - lib/rushcheck/float.rb
40
+ - lib/rushcheck/gen.rb
41
+ - lib/rushcheck/guard.rb
42
+ - lib/rushcheck/hash.rb
43
+ - lib/rushcheck/integer.rb
44
+ - lib/rushcheck/proc.rb
45
+ - lib/rushcheck/property.rb
46
+ - lib/rushcheck/random.rb
47
+ - lib/rushcheck/result.rb
48
+ - lib/rushcheck/rushcheck.rb
49
+ - lib/rushcheck/string.rb
50
+ - lib/rushcheck/testable.rb
51
+ - data/rushcheck
52
+ - data/rushcheck/doc
53
+ - data/rushcheck/examples
54
+ - data/rushcheck/rdoc
55
+ - data/rushcheck/doc/policy.txt
56
+ - data/rushcheck/doc/rushcheck.txt
57
+ - data/rushcheck/examples/printf.rb
58
+ - data/rushcheck/examples/proc.rb
59
+ - data/rushcheck/examples/roguetile.rb
60
+ - data/rushcheck/examples/sample.rb
61
+ - data/rushcheck/rdoc/classes
62
+ - data/rushcheck/rdoc/created.rid
63
+ - data/rushcheck/rdoc/files
64
+ - data/rushcheck/rdoc/fr_class_index.html
65
+ - data/rushcheck/rdoc/fr_file_index.html
66
+ - data/rushcheck/rdoc/fr_method_index.html
67
+ - data/rushcheck/rdoc/index.html
68
+ - data/rushcheck/rdoc/rdoc-style.css
69
+ - data/rushcheck/rdoc/classes/Arbitrary.html
70
+ - data/rushcheck/rdoc/classes/Arbitrary.src
71
+ - data/rushcheck/rdoc/classes/Assertion.html
72
+ - data/rushcheck/rdoc/classes/Assertion.src
73
+ - data/rushcheck/rdoc/classes/Coarbitrary.html
74
+ - data/rushcheck/rdoc/classes/Coarbitrary.src
75
+ - data/rushcheck/rdoc/classes/FalseClass.html
76
+ - data/rushcheck/rdoc/classes/FalseClass.src
77
+ - data/rushcheck/rdoc/classes/Float.html
78
+ - data/rushcheck/rdoc/classes/Float.src
79
+ - data/rushcheck/rdoc/classes/Gen.html
80
+ - data/rushcheck/rdoc/classes/Gen.src
81
+ - data/rushcheck/rdoc/classes/Guard.html
82
+ - data/rushcheck/rdoc/classes/Guard.src
83
+ - data/rushcheck/rdoc/classes/HsRandom.html
84
+ - data/rushcheck/rdoc/classes/HsRandom.src
85
+ - data/rushcheck/rdoc/classes/Integer.html
86
+ - data/rushcheck/rdoc/classes/Integer.src
87
+ - data/rushcheck/rdoc/classes/NilClass.html
88
+ - data/rushcheck/rdoc/classes/NilClass.src
89
+ - data/rushcheck/rdoc/classes/Property.html
90
+ - data/rushcheck/rdoc/classes/Property.src
91
+ - data/rushcheck/rdoc/classes/RandomArray.html
92
+ - data/rushcheck/rdoc/classes/RandomArray.src
93
+ - data/rushcheck/rdoc/classes/RandomBool.html
94
+ - data/rushcheck/rdoc/classes/RandomBool.src
95
+ - data/rushcheck/rdoc/classes/RandomGen.html
96
+ - data/rushcheck/rdoc/classes/RandomGen.src
97
+ - data/rushcheck/rdoc/classes/RandomHash.html
98
+ - data/rushcheck/rdoc/classes/RandomHash.src
99
+ - data/rushcheck/rdoc/classes/RandomProc.html
100
+ - data/rushcheck/rdoc/classes/RandomProc.src
101
+ - data/rushcheck/rdoc/classes/Result.html
102
+ - data/rushcheck/rdoc/classes/Result.src
103
+ - data/rushcheck/rdoc/classes/RushCheckConfig.html
104
+ - data/rushcheck/rdoc/classes/RushCheckConfig.src
105
+ - data/rushcheck/rdoc/classes/RushCheckGuard.html
106
+ - data/rushcheck/rdoc/classes/SpecialString.html
107
+ - data/rushcheck/rdoc/classes/SpecialString.src
108
+ - data/rushcheck/rdoc/classes/StdGen.html
109
+ - data/rushcheck/rdoc/classes/StdGen.src
110
+ - data/rushcheck/rdoc/classes/String.html
111
+ - data/rushcheck/rdoc/classes/String.src
112
+ - data/rushcheck/rdoc/classes/Testable.html
113
+ - data/rushcheck/rdoc/classes/Testable.src
114
+ - data/rushcheck/rdoc/classes/TheStdGen.html
115
+ - data/rushcheck/rdoc/classes/TheStdGen.src
116
+ - data/rushcheck/rdoc/classes/TrueClass.html
117
+ - data/rushcheck/rdoc/classes/TrueClass.src
118
+ - data/rushcheck/rdoc/classes/Arbitrary.src/M000075.html
119
+ - data/rushcheck/rdoc/classes/Assertion.src/M000015.html
120
+ - data/rushcheck/rdoc/classes/Assertion.src/M000016.html
121
+ - data/rushcheck/rdoc/classes/Coarbitrary.src/M000095.html
122
+ - data/rushcheck/rdoc/classes/FalseClass.src/M000018.html
123
+ - data/rushcheck/rdoc/classes/FalseClass.src/M000019.html
124
+ - data/rushcheck/rdoc/classes/FalseClass.src/M000020.html
125
+ - data/rushcheck/rdoc/classes/Float.src/M000047.html
126
+ - data/rushcheck/rdoc/classes/Float.src/M000048.html
127
+ - data/rushcheck/rdoc/classes/Float.src/M000049.html
128
+ - data/rushcheck/rdoc/classes/Float.src/M000050.html
129
+ - data/rushcheck/rdoc/classes/Gen.src/M000026.html
130
+ - data/rushcheck/rdoc/classes/Gen.src/M000027.html
131
+ - data/rushcheck/rdoc/classes/Gen.src/M000028.html
132
+ - data/rushcheck/rdoc/classes/Gen.src/M000029.html
133
+ - data/rushcheck/rdoc/classes/Gen.src/M000030.html
134
+ - data/rushcheck/rdoc/classes/Gen.src/M000031.html
135
+ - data/rushcheck/rdoc/classes/Gen.src/M000032.html
136
+ - data/rushcheck/rdoc/classes/Gen.src/M000033.html
137
+ - data/rushcheck/rdoc/classes/Gen.src/M000034.html
138
+ - data/rushcheck/rdoc/classes/Gen.src/M000035.html
139
+ - data/rushcheck/rdoc/classes/Gen.src/M000036.html
140
+ - data/rushcheck/rdoc/classes/Gen.src/M000037.html
141
+ - data/rushcheck/rdoc/classes/Gen.src/M000038.html
142
+ - data/rushcheck/rdoc/classes/Gen.src/M000039.html
143
+ - data/rushcheck/rdoc/classes/Gen.src/M000040.html
144
+ - data/rushcheck/rdoc/classes/Gen.src/M000041.html
145
+ - data/rushcheck/rdoc/classes/Gen.src/M000042.html
146
+ - data/rushcheck/rdoc/classes/Gen.src/M000043.html
147
+ - data/rushcheck/rdoc/classes/Guard.src/M000024.html
148
+ - data/rushcheck/rdoc/classes/Guard.src/M000025.html
149
+ - data/rushcheck/rdoc/classes/HsRandom.src/M000081.html
150
+ - data/rushcheck/rdoc/classes/HsRandom.src/M000082.html
151
+ - data/rushcheck/rdoc/classes/HsRandom.src/M000083.html
152
+ - data/rushcheck/rdoc/classes/Integer.src/M000006.html
153
+ - data/rushcheck/rdoc/classes/Integer.src/M000007.html
154
+ - data/rushcheck/rdoc/classes/Integer.src/M000008.html
155
+ - data/rushcheck/rdoc/classes/Integer.src/M000009.html
156
+ - data/rushcheck/rdoc/classes/NilClass.src/M000059.html
157
+ - data/rushcheck/rdoc/classes/NilClass.src/M000060.html
158
+ - data/rushcheck/rdoc/classes/NilClass.src/M000061.html
159
+ - data/rushcheck/rdoc/classes/Property.src/M000070.html
160
+ - data/rushcheck/rdoc/classes/Property.src/M000071.html
161
+ - data/rushcheck/rdoc/classes/RandomArray.src/M000021.html
162
+ - data/rushcheck/rdoc/classes/RandomArray.src/M000022.html
163
+ - data/rushcheck/rdoc/classes/RandomArray.src/M000023.html
164
+ - data/rushcheck/rdoc/classes/RandomBool.src/M000079.html
165
+ - data/rushcheck/rdoc/classes/RandomBool.src/M000080.html
166
+ - data/rushcheck/rdoc/classes/RandomGen.src/M000076.html
167
+ - data/rushcheck/rdoc/classes/RandomGen.src/M000077.html
168
+ - data/rushcheck/rdoc/classes/RandomGen.src/M000078.html
169
+ - data/rushcheck/rdoc/classes/RandomHash.src/M000044.html
170
+ - data/rushcheck/rdoc/classes/RandomHash.src/M000045.html
171
+ - data/rushcheck/rdoc/classes/RandomHash.src/M000046.html
172
+ - data/rushcheck/rdoc/classes/RandomProc.src/M000055.html
173
+ - data/rushcheck/rdoc/classes/RandomProc.src/M000056.html
174
+ - data/rushcheck/rdoc/classes/RandomProc.src/M000057.html
175
+ - data/rushcheck/rdoc/classes/RandomProc.src/M000058.html
176
+ - data/rushcheck/rdoc/classes/Result.src/M000051.html
177
+ - data/rushcheck/rdoc/classes/Result.src/M000052.html
178
+ - data/rushcheck/rdoc/classes/Result.src/M000053.html
179
+ - data/rushcheck/rdoc/classes/RushCheckConfig.src/M000001.html
180
+ - data/rushcheck/rdoc/classes/RushCheckConfig.src/M000002.html
181
+ - data/rushcheck/rdoc/classes/RushCheckConfig.src/M000003.html
182
+ - data/rushcheck/rdoc/classes/RushCheckConfig.src/M000004.html
183
+ - data/rushcheck/rdoc/classes/RushCheckConfig.src/M000005.html
184
+ - data/rushcheck/rdoc/classes/SpecialString.src/M000017.html
185
+ - data/rushcheck/rdoc/classes/StdGen.src/M000010.html
186
+ - data/rushcheck/rdoc/classes/StdGen.src/M000011.html
187
+ - data/rushcheck/rdoc/classes/StdGen.src/M000012.html
188
+ - data/rushcheck/rdoc/classes/StdGen.src/M000013.html
189
+ - data/rushcheck/rdoc/classes/StdGen.src/M000014.html
190
+ - data/rushcheck/rdoc/classes/String.src/M000066.html
191
+ - data/rushcheck/rdoc/classes/String.src/M000067.html
192
+ - data/rushcheck/rdoc/classes/String.src/M000068.html
193
+ - data/rushcheck/rdoc/classes/String.src/M000069.html
194
+ - data/rushcheck/rdoc/classes/Testable.src/M000084.html
195
+ - data/rushcheck/rdoc/classes/Testable.src/M000085.html
196
+ - data/rushcheck/rdoc/classes/Testable.src/M000088.html
197
+ - data/rushcheck/rdoc/classes/Testable.src/M000089.html
198
+ - data/rushcheck/rdoc/classes/Testable.src/M000090.html
199
+ - data/rushcheck/rdoc/classes/Testable.src/M000092.html
200
+ - data/rushcheck/rdoc/classes/Testable.src/M000094.html
201
+ - data/rushcheck/rdoc/classes/TheStdGen.src/M000062.html
202
+ - data/rushcheck/rdoc/classes/TheStdGen.src/M000063.html
203
+ - data/rushcheck/rdoc/classes/TheStdGen.src/M000064.html
204
+ - data/rushcheck/rdoc/classes/TheStdGen.src/M000065.html
205
+ - data/rushcheck/rdoc/classes/TrueClass.src/M000072.html
206
+ - data/rushcheck/rdoc/classes/TrueClass.src/M000073.html
207
+ - data/rushcheck/rdoc/classes/TrueClass.src/M000074.html
208
+ - data/rushcheck/rdoc/files/rushcheck
209
+ - data/rushcheck/rdoc/files/rushcheck/arbitrary_rb.html
210
+ - data/rushcheck/rdoc/files/rushcheck/array_rb.html
211
+ - data/rushcheck/rdoc/files/rushcheck/assertion_rb.html
212
+ - data/rushcheck/rdoc/files/rushcheck/bool_rb.html
213
+ - data/rushcheck/rdoc/files/rushcheck/config_rb.html
214
+ - data/rushcheck/rdoc/files/rushcheck/float_rb.html
215
+ - data/rushcheck/rdoc/files/rushcheck/gen_rb.html
216
+ - data/rushcheck/rdoc/files/rushcheck/guard_rb.html
217
+ - data/rushcheck/rdoc/files/rushcheck/hash_rb.html
218
+ - data/rushcheck/rdoc/files/rushcheck/integer_rb.html
219
+ - data/rushcheck/rdoc/files/rushcheck/proc_rb.html
220
+ - data/rushcheck/rdoc/files/rushcheck/property_rb.html
221
+ - data/rushcheck/rdoc/files/rushcheck/random_rb.html
222
+ - data/rushcheck/rdoc/files/rushcheck/result_rb.html
223
+ - data/rushcheck/rdoc/files/rushcheck/rushcheck_rb.html
224
+ - data/rushcheck/rdoc/files/rushcheck/string_rb.html
225
+ - data/rushcheck/rdoc/files/rushcheck/testable_rb.html
226
+ - COPYING
227
+ - INSTALL
228
+ - LICENSE
229
+ - Rakefile
230
+ - README
231
+ - copying.txt
232
+ test_files: []
233
+ rdoc_options: []
234
+ extra_rdoc_files: []
235
+ executables: []
236
+ extensions: []
237
+ requirements: []
238
+ dependencies: []