rubycheck 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/LICENSE.md +23 -23
- data/lib/rubycheck.rb +44 -12
- data/lib/version.rb +1 -1
- metadata +76 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b196a43a2d5c9836723dec5fa660e0456590b22
|
4
|
+
data.tar.gz: e665ad91305e0753191a1c61f789051bb554f23f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aad20f029872739210b28368da6d5b75c530b248efc1d4eebab0e3950b40c5763a364c47bd09eca823b1a2436efb49f26f5cb0da1205d8eac66f4e41d78feef5
|
7
|
+
data.tar.gz: ef02cca93b8e8ae34ffb72790ac28fc24d73fcebeee98c8a6677b94e1434ff53d22070336bb6d22a411ec733bca357dd5a17cb1c99bbc18918ca0f1d5fdf79d8
|
data/LICENSE.md
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
# FreeBSD License
|
2
|
-
|
3
|
-
# Copyright 2013 Andrew Pennebaker. All rights reserved.
|
4
|
-
|
5
|
-
Redistribution and use in source and binary forms, with or without modification,
|
6
|
-
are permitted provided that the following conditions are met:
|
7
|
-
|
8
|
-
1. Redistributions of source code must retain the above copyright notice, this
|
9
|
-
list of conditions and the following disclaimer.
|
10
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
11
|
-
this list of conditions and the following disclaimer in the documentation and/or
|
12
|
-
other materials provided with the distribution.
|
13
|
-
|
14
|
-
THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
15
|
-
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
16
|
-
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
17
|
-
SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
18
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
19
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
20
|
-
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
21
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
22
|
-
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
23
|
-
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
# FreeBSD License
|
2
|
+
|
3
|
+
# Copyright 2013 Andrew Pennebaker. All rights reserved.
|
4
|
+
|
5
|
+
Redistribution and use in source and binary forms, with or without modification,
|
6
|
+
are permitted provided that the following conditions are met:
|
7
|
+
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
list of conditions and the following disclaimer.
|
10
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
this list of conditions and the following disclaimer in the documentation and/or
|
12
|
+
other materials provided with the distribution.
|
13
|
+
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
15
|
+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
16
|
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
17
|
+
SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
18
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
19
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
20
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
21
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
22
|
+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
23
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/lib/rubycheck.rb
CHANGED
@@ -12,6 +12,19 @@ include Contracts
|
|
12
12
|
# and encourages monkeypatching for defining generators for custom types.
|
13
13
|
#
|
14
14
|
module RubyCheck
|
15
|
+
Contract nil => Bool
|
16
|
+
#
|
17
|
+
# Generate a random boolean.
|
18
|
+
#
|
19
|
+
# Example:
|
20
|
+
#
|
21
|
+
# RubyCheck::gen_bool
|
22
|
+
# => false
|
23
|
+
#
|
24
|
+
def self.gen_bool
|
25
|
+
Random.rand < 0.5
|
26
|
+
end
|
27
|
+
|
15
28
|
Contract nil => Float
|
16
29
|
#
|
17
30
|
# Generate a random float in [0, 10^10 - 1].
|
@@ -27,17 +40,36 @@ module RubyCheck
|
|
27
40
|
|
28
41
|
Contract nil => Integer
|
29
42
|
#
|
30
|
-
# Generate a random integer in [0, 10^10 - 1].
|
43
|
+
# Generate a random unsigned integer in [0, 10^10 - 1].
|
31
44
|
#
|
32
45
|
# Example:
|
33
46
|
#
|
34
|
-
# RubyCheck::
|
47
|
+
# RubyCheck::gen_uint
|
35
48
|
# => 4
|
36
49
|
#
|
37
|
-
def self.
|
50
|
+
def self.gen_uint
|
38
51
|
Random.rand(10e10).to_i
|
39
52
|
end
|
40
53
|
|
54
|
+
Contract nil => Integer
|
55
|
+
#
|
56
|
+
# Generate a random integer in [(-1 * 10^10) + 1, 10^10 - 1].
|
57
|
+
#
|
58
|
+
# Example:
|
59
|
+
#
|
60
|
+
# RubyCheck::gen_int
|
61
|
+
# => -4
|
62
|
+
#
|
63
|
+
def self.gen_int
|
64
|
+
i = Random.rand(10e10).to_i
|
65
|
+
|
66
|
+
if gen_bool
|
67
|
+
i
|
68
|
+
else
|
69
|
+
i * -1
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
41
73
|
Contract nil => Integer
|
42
74
|
#
|
43
75
|
# Generate a random byte in [0, 255].
|
@@ -48,7 +80,7 @@ module RubyCheck
|
|
48
80
|
# => 96
|
49
81
|
#
|
50
82
|
def self.gen_byte
|
51
|
-
|
83
|
+
gen_uint % 256
|
52
84
|
end
|
53
85
|
|
54
86
|
Contract nil => Integer
|
@@ -61,7 +93,7 @@ module RubyCheck
|
|
61
93
|
# => "Q"
|
62
94
|
#
|
63
95
|
def self.gen_char
|
64
|
-
(
|
96
|
+
(gen_uint % 128).chr
|
65
97
|
end
|
66
98
|
|
67
99
|
Contract Proc => Array
|
@@ -70,13 +102,13 @@ module RubyCheck
|
|
70
102
|
#
|
71
103
|
# Example:
|
72
104
|
#
|
73
|
-
# RubyCheck::gen_array(:
|
105
|
+
# RubyCheck::gen_array(:gen_uint)
|
74
106
|
# => [1, 3, 3, 7]
|
75
107
|
#
|
76
108
|
def self.gen_array(gen_sym)
|
77
|
-
len =
|
109
|
+
len = gen_uint % 100
|
78
110
|
|
79
|
-
0.upto(len).map {
|
111
|
+
0.upto(len).map { || send(gen_sym) }
|
80
112
|
end
|
81
113
|
|
82
114
|
Contract nil => String
|
@@ -93,7 +125,7 @@ module RubyCheck
|
|
93
125
|
end
|
94
126
|
|
95
127
|
# Number of test cases to generate per <i>for_all</i> run
|
96
|
-
TRIALS =
|
128
|
+
TRIALS = 10_000
|
97
129
|
|
98
130
|
#
|
99
131
|
# Defines an error class to capture test case input
|
@@ -125,14 +157,14 @@ module RubyCheck
|
|
125
157
|
#
|
126
158
|
# Example:
|
127
159
|
#
|
128
|
-
# RubyCheck::for_all( ->(i) { i.even? }, [:
|
160
|
+
# RubyCheck::for_all( ->(i) { i.even? }, [:gen_uint])
|
129
161
|
# => [9]
|
130
162
|
#
|
131
|
-
# RubyCheck::for_all( ->(i) { i.even? || i.odd? }, [:
|
163
|
+
# RubyCheck::for_all( ->(i) { i.even? || i.odd? }, [:gen_uint])
|
132
164
|
# => true
|
133
165
|
#
|
134
166
|
def self.for_all(property, gen_syms)
|
135
|
-
|
167
|
+
TRIALS.times do ||
|
136
168
|
test_case = gen_syms.map { |gen_sym| send(gen_sym) }
|
137
169
|
fail PropertyFailure.new(test_case), 'test case error' unless property.call(*test_case)
|
138
170
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubycheck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Pennebaker
|
@@ -14,221 +14,235 @@ dependencies:
|
|
14
14
|
name: contracts
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '0.4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '0.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '10.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '10.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: reek
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '1.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: flay
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '2.5'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '2.5'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: flog
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '4.3'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '4.3'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: roodi
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
89
|
+
version: '4.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
96
|
+
version: '4.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: churn
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
103
|
+
version: '1.0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
110
|
+
version: '1.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: cane
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
117
|
+
version: '2.6'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ~>
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
124
|
+
version: '2.6'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: excellent
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ~>
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
131
|
+
version: '2.1'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - ~>
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
138
|
+
version: '2.1'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: rubocop
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - ~>
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
145
|
+
version: '0.25'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
150
|
+
- - ~>
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
152
|
+
version: '0.25'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: tailor
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- -
|
157
|
+
- - ~>
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
159
|
+
version: '1.4'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- -
|
164
|
+
- - ~>
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
166
|
+
version: '1.4'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: guard
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- -
|
171
|
+
- - ~>
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: '
|
173
|
+
version: '2.6'
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- -
|
178
|
+
- - ~>
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: '
|
180
|
+
version: '2.6'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: guard-shell
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- -
|
185
|
+
- - ~>
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0.6'
|
188
188
|
type: :development
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- -
|
192
|
+
- - ~>
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0.6'
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
name: rspec
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
|
-
- -
|
199
|
+
- - ~>
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: '0'
|
201
|
+
version: '3.0'
|
202
202
|
type: :development
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
|
-
- -
|
206
|
+
- - ~>
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version: '0'
|
208
|
+
version: '3.0'
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
210
|
name: aspelllint
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
|
-
- -
|
213
|
+
- - ~>
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
version: '0'
|
215
|
+
version: '0.10'
|
216
216
|
type: :development
|
217
217
|
prerelease: false
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
|
-
- -
|
220
|
+
- - ~>
|
221
221
|
- !ruby/object:Gem::Version
|
222
|
-
version: '0'
|
222
|
+
version: '0.10'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: lili
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ~>
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0.2'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ~>
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0.2'
|
223
237
|
description: See specs/ tests for example usage.
|
224
238
|
email: andrew.pennebaker@gmail.com
|
225
239
|
executables: []
|
226
240
|
extensions: []
|
227
241
|
extra_rdoc_files: []
|
228
242
|
files:
|
243
|
+
- LICENSE.md
|
229
244
|
- lib/rubycheck.rb
|
230
245
|
- lib/version.rb
|
231
|
-
- LICENSE.md
|
232
246
|
homepage: http://www.yellosoft.us/quickcheck
|
233
247
|
licenses:
|
234
248
|
- FreeBSD
|
@@ -241,7 +255,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
241
255
|
requirements:
|
242
256
|
- - '>='
|
243
257
|
- !ruby/object:Gem::Version
|
244
|
-
version: '
|
258
|
+
version: '1.9'
|
245
259
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
246
260
|
requirements:
|
247
261
|
- - '>='
|
@@ -249,9 +263,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
249
263
|
version: '0'
|
250
264
|
requirements: []
|
251
265
|
rubyforge_project:
|
252
|
-
rubygems_version: 2.
|
266
|
+
rubygems_version: 2.4.5
|
253
267
|
signing_key:
|
254
268
|
specification_version: 4
|
255
269
|
summary: a Ruby port of the QuickCheck unit test framework
|
256
270
|
test_files: []
|
257
|
-
has_rdoc:
|