queencheck 0.1.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/Guardfile +2 -1
- data/README.md +119 -0
- data/Rakefile +11 -0
- data/VERSION +1 -1
- data/lib/queencheck.rb +16 -13
- data/lib/queencheck/arbitraries/all.rb +5 -0
- data/lib/queencheck/arbitraries/boolean.rb +5 -0
- data/lib/queencheck/arbitraries/integer.rb +17 -0
- data/lib/queencheck/arbitraries/string.rb +39 -0
- data/lib/queencheck/arbitrary.rb +84 -40
- data/lib/queencheck/condition.rb +112 -0
- data/lib/queencheck/core.rb +82 -97
- data/lib/queencheck/exception.rb +4 -0
- data/lib/queencheck/gen.rb +254 -0
- data/lib/queencheck/result.rb +107 -0
- data/lib/queencheck/rspec.rb +50 -9
- data/queencheck.gemspec +26 -18
- data/spec/queencheck/arbitrary_spec.rb +8 -34
- data/spec/queencheck/core_spec.rb +12 -40
- data/spec/queencheck/gen_spec.rb +68 -0
- data/spec/queencheck/rspec_spec.rb +14 -14
- metadata +76 -42
- data/README.markdown +0 -24
- data/lib/queencheck/array.rb +0 -33
- data/lib/queencheck/boolean.rb +0 -9
- data/lib/queencheck/config.rb +0 -16
- data/lib/queencheck/elements_of.rb +0 -44
- data/lib/queencheck/float.rb +0 -23
- data/lib/queencheck/integer.rb +0 -16
- data/lib/queencheck/rspec/dsl.rb +0 -22
- data/lib/queencheck/string.rb +0 -47
- data/spec/queencheck/elements_of_spec.rb +0 -22
- data/spec/queencheck/integer_spec.rb +0 -17
- data/spec/queencheck/string_spec.rb +0 -13
@@ -1,19 +1,19 @@
|
|
1
1
|
require 'queencheck/rspec'
|
2
2
|
|
3
|
-
describe
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
describe QueenCheck do
|
4
|
+
QueenCheck('stadard check', String) { | x |
|
5
|
+
x.class.should == String
|
6
|
+
}
|
7
|
+
|
8
|
+
verboseQueenCheck('verbose check', QueenCheck::ASCIIChar) { | x |
|
9
|
+
x.size.should == 1
|
10
|
+
}
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
else
|
16
|
-
result.should == 1 / arguments[0]
|
17
|
-
end
|
12
|
+
labelingQueenCheck('labelig check', {
|
13
|
+
"x > y" => proc{|x,y| x > y },
|
14
|
+
"x < y" => proc{|x,y| x < y },
|
15
|
+
"x = y" => proc{|x,y| x == y },
|
16
|
+
},Integer, Integer) do | x, y |
|
17
|
+
(x + y).should == y + x
|
18
18
|
end
|
19
19
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: queencheck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: colorize
|
16
|
+
requirement: &70160982288100 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.5.8
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70160982288100
|
14
25
|
- !ruby/object:Gem::Dependency
|
15
26
|
name: rake
|
16
|
-
requirement: &
|
27
|
+
requirement: &70160982287160 !ruby/object:Gem::Requirement
|
17
28
|
none: false
|
18
29
|
requirements:
|
19
30
|
- - ! '>='
|
@@ -21,10 +32,10 @@ dependencies:
|
|
21
32
|
version: 0.9.2.2
|
22
33
|
type: :development
|
23
34
|
prerelease: false
|
24
|
-
version_requirements: *
|
35
|
+
version_requirements: *70160982287160
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: rspec
|
27
|
-
requirement: &
|
38
|
+
requirement: &70160982286680 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
40
|
requirements:
|
30
41
|
- - ! '>='
|
@@ -32,10 +43,10 @@ dependencies:
|
|
32
43
|
version: 2.8.0
|
33
44
|
type: :development
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *70160982286680
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
48
|
name: fuubar
|
38
|
-
requirement: &
|
49
|
+
requirement: &70160982286200 !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
52
|
- - ! '>='
|
@@ -43,10 +54,10 @@ dependencies:
|
|
43
54
|
version: 0.0.6
|
44
55
|
type: :development
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *70160982286200
|
47
58
|
- !ruby/object:Gem::Dependency
|
48
59
|
name: jeweler
|
49
|
-
requirement: &
|
60
|
+
requirement: &70160982285720 !ruby/object:Gem::Requirement
|
50
61
|
none: false
|
51
62
|
requirements:
|
52
63
|
- - ! '>='
|
@@ -54,10 +65,10 @@ dependencies:
|
|
54
65
|
version: 1.8.3
|
55
66
|
type: :development
|
56
67
|
prerelease: false
|
57
|
-
version_requirements: *
|
68
|
+
version_requirements: *70160982285720
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: growl
|
60
|
-
requirement: &
|
71
|
+
requirement: &70160982285240 !ruby/object:Gem::Requirement
|
61
72
|
none: false
|
62
73
|
requirements:
|
63
74
|
- - ! '>='
|
@@ -65,10 +76,10 @@ dependencies:
|
|
65
76
|
version: 1.0.3
|
66
77
|
type: :development
|
67
78
|
prerelease: false
|
68
|
-
version_requirements: *
|
79
|
+
version_requirements: *70160982285240
|
69
80
|
- !ruby/object:Gem::Dependency
|
70
81
|
name: spork
|
71
|
-
requirement: &
|
82
|
+
requirement: &70160982284760 !ruby/object:Gem::Requirement
|
72
83
|
none: false
|
73
84
|
requirements:
|
74
85
|
- - ! '>='
|
@@ -76,10 +87,10 @@ dependencies:
|
|
76
87
|
version: 0.9.0.rc9
|
77
88
|
type: :development
|
78
89
|
prerelease: false
|
79
|
-
version_requirements: *
|
90
|
+
version_requirements: *70160982284760
|
80
91
|
- !ruby/object:Gem::Dependency
|
81
92
|
name: rb-fsevent
|
82
|
-
requirement: &
|
93
|
+
requirement: &70160982284280 !ruby/object:Gem::Requirement
|
83
94
|
none: false
|
84
95
|
requirements:
|
85
96
|
- - ! '>='
|
@@ -87,10 +98,10 @@ dependencies:
|
|
87
98
|
version: 0.9.0
|
88
99
|
type: :development
|
89
100
|
prerelease: false
|
90
|
-
version_requirements: *
|
101
|
+
version_requirements: *70160982284280
|
91
102
|
- !ruby/object:Gem::Dependency
|
92
103
|
name: guard-spork
|
93
|
-
requirement: &
|
104
|
+
requirement: &70160982283720 !ruby/object:Gem::Requirement
|
94
105
|
none: false
|
95
106
|
requirements:
|
96
107
|
- - ! '>='
|
@@ -98,10 +109,10 @@ dependencies:
|
|
98
109
|
version: 0.5.1
|
99
110
|
type: :development
|
100
111
|
prerelease: false
|
101
|
-
version_requirements: *
|
112
|
+
version_requirements: *70160982283720
|
102
113
|
- !ruby/object:Gem::Dependency
|
103
114
|
name: guard-rspec
|
104
|
-
requirement: &
|
115
|
+
requirement: &70160982283200 !ruby/object:Gem::Requirement
|
105
116
|
none: false
|
106
117
|
requirements:
|
107
118
|
- - ! '>='
|
@@ -109,10 +120,10 @@ dependencies:
|
|
109
120
|
version: 0.6.0
|
110
121
|
type: :development
|
111
122
|
prerelease: false
|
112
|
-
version_requirements: *
|
123
|
+
version_requirements: *70160982283200
|
113
124
|
- !ruby/object:Gem::Dependency
|
114
125
|
name: guard-bundler
|
115
|
-
requirement: &
|
126
|
+
requirement: &70160982282720 !ruby/object:Gem::Requirement
|
116
127
|
none: false
|
117
128
|
requirements:
|
118
129
|
- - ! '>='
|
@@ -120,10 +131,10 @@ dependencies:
|
|
120
131
|
version: 0.1.3
|
121
132
|
type: :development
|
122
133
|
prerelease: false
|
123
|
-
version_requirements: *
|
134
|
+
version_requirements: *70160982282720
|
124
135
|
- !ruby/object:Gem::Dependency
|
125
136
|
name: guard-yard
|
126
|
-
requirement: &
|
137
|
+
requirement: &70160982282240 !ruby/object:Gem::Requirement
|
127
138
|
none: false
|
128
139
|
requirements:
|
129
140
|
- - ! '>='
|
@@ -131,10 +142,10 @@ dependencies:
|
|
131
142
|
version: 1.0.2
|
132
143
|
type: :development
|
133
144
|
prerelease: false
|
134
|
-
version_requirements: *
|
145
|
+
version_requirements: *70160982282240
|
135
146
|
- !ruby/object:Gem::Dependency
|
136
147
|
name: yard
|
137
|
-
requirement: &
|
148
|
+
requirement: &70160982425520 !ruby/object:Gem::Requirement
|
138
149
|
none: false
|
139
150
|
requirements:
|
140
151
|
- - ! '>='
|
@@ -142,10 +153,10 @@ dependencies:
|
|
142
153
|
version: 0.7.4
|
143
154
|
type: :development
|
144
155
|
prerelease: false
|
145
|
-
version_requirements: *
|
156
|
+
version_requirements: *70160982425520
|
146
157
|
- !ruby/object:Gem::Dependency
|
147
158
|
name: yard-tomdoc
|
148
|
-
requirement: &
|
159
|
+
requirement: &70160982424980 !ruby/object:Gem::Requirement
|
149
160
|
none: false
|
150
161
|
requirements:
|
151
162
|
- - ! '>='
|
@@ -153,42 +164,62 @@ dependencies:
|
|
153
164
|
version: 0.3.0
|
154
165
|
type: :development
|
155
166
|
prerelease: false
|
156
|
-
version_requirements: *
|
167
|
+
version_requirements: *70160982424980
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: redcarpet
|
170
|
+
requirement: &70160982424500 !ruby/object:Gem::Requirement
|
171
|
+
none: false
|
172
|
+
requirements:
|
173
|
+
- - ! '>='
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
176
|
+
type: :development
|
177
|
+
prerelease: false
|
178
|
+
version_requirements: *70160982424500
|
179
|
+
- !ruby/object:Gem::Dependency
|
180
|
+
name: pry
|
181
|
+
requirement: &70160982424020 !ruby/object:Gem::Requirement
|
182
|
+
none: false
|
183
|
+
requirements:
|
184
|
+
- - ! '>='
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
type: :development
|
188
|
+
prerelease: false
|
189
|
+
version_requirements: *70160982424020
|
157
190
|
description: QueenCheck is random test library. Inspired by QuickCheck library in
|
158
191
|
Haskell.
|
159
192
|
email: rosylilly@aduca.org
|
160
193
|
executables: []
|
161
194
|
extensions: []
|
162
195
|
extra_rdoc_files:
|
163
|
-
- README.
|
196
|
+
- README.md
|
164
197
|
files:
|
165
198
|
- .rspec
|
166
199
|
- .rvmrc
|
167
200
|
- .travis.yml
|
168
201
|
- Gemfile
|
169
202
|
- Guardfile
|
170
|
-
- README.
|
203
|
+
- README.md
|
171
204
|
- Rakefile
|
172
205
|
- VERSION
|
173
206
|
- lib/queencheck.rb
|
207
|
+
- lib/queencheck/arbitraries/all.rb
|
208
|
+
- lib/queencheck/arbitraries/boolean.rb
|
209
|
+
- lib/queencheck/arbitraries/integer.rb
|
210
|
+
- lib/queencheck/arbitraries/string.rb
|
174
211
|
- lib/queencheck/arbitrary.rb
|
175
|
-
- lib/queencheck/
|
176
|
-
- lib/queencheck/boolean.rb
|
177
|
-
- lib/queencheck/config.rb
|
212
|
+
- lib/queencheck/condition.rb
|
178
213
|
- lib/queencheck/core.rb
|
179
|
-
- lib/queencheck/
|
180
|
-
- lib/queencheck/
|
181
|
-
- lib/queencheck/
|
214
|
+
- lib/queencheck/exception.rb
|
215
|
+
- lib/queencheck/gen.rb
|
216
|
+
- lib/queencheck/result.rb
|
182
217
|
- lib/queencheck/rspec.rb
|
183
|
-
- lib/queencheck/rspec/dsl.rb
|
184
|
-
- lib/queencheck/string.rb
|
185
218
|
- queencheck.gemspec
|
186
219
|
- spec/queencheck/arbitrary_spec.rb
|
187
220
|
- spec/queencheck/core_spec.rb
|
188
|
-
- spec/queencheck/
|
189
|
-
- spec/queencheck/integer_spec.rb
|
221
|
+
- spec/queencheck/gen_spec.rb
|
190
222
|
- spec/queencheck/rspec_spec.rb
|
191
|
-
- spec/queencheck/string_spec.rb
|
192
223
|
- spec/spec_helper.rb
|
193
224
|
homepage: https://github.com/rosylilly/QueenCheck
|
194
225
|
licenses: []
|
@@ -202,6 +233,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
202
233
|
- - ! '>='
|
203
234
|
- !ruby/object:Gem::Version
|
204
235
|
version: '0'
|
236
|
+
segments:
|
237
|
+
- 0
|
238
|
+
hash: 2669412712847825288
|
205
239
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
240
|
none: false
|
207
241
|
requirements:
|
@@ -210,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
244
|
version: '0'
|
211
245
|
requirements: []
|
212
246
|
rubyforge_project:
|
213
|
-
rubygems_version: 1.8.
|
247
|
+
rubygems_version: 1.8.11
|
214
248
|
signing_key:
|
215
249
|
specification_version: 3
|
216
250
|
summary: like haskell's QuickCheck
|
data/README.markdown
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# QueenCheck [![Build Status](https://secure.travis-ci.org/rosylilly/QueenCheck.png)](http://travis-ci.org/rosylilly/QueenCheck) [![Gem Status](https://gemnasium.com/rosylilly/QueenCheck.png)](https://gemnasium.com/rosylilly/QueenCheck)
|
2
|
-
|
3
|
-
QueenCheck is random test library.
|
4
|
-
|
5
|
-
Inspired by QuickCheck library in Haskell.
|
6
|
-
|
7
|
-
## Usage
|
8
|
-
|
9
|
-
$ gem install queencheck
|
10
|
-
|
11
|
-
|
12
|
-
## Example
|
13
|
-
|
14
|
-
require 'queencheck'
|
15
|
-
|
16
|
-
number = 100
|
17
|
-
|
18
|
-
check = QueenCheck(number, :+, Integer)
|
19
|
-
|
20
|
-
res = check.run(verbose: true) do | result, arguments, error |
|
21
|
-
result == number + arguments[0]
|
22
|
-
end
|
23
|
-
|
24
|
-
puts "#{res.passes} / #{res.examples}"
|
data/lib/queencheck/array.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'queencheck/arbitrary'
|
2
|
-
|
3
|
-
class Array
|
4
|
-
extend QueenCheck::Arbitrary
|
5
|
-
|
6
|
-
@@bound = 10
|
7
|
-
|
8
|
-
set_arbitrary do |seed|
|
9
|
-
if seed == 0
|
10
|
-
return []
|
11
|
-
else
|
12
|
-
base = ((@@bound * seed).ceil)
|
13
|
-
|
14
|
-
ary = Array.new(rand(base) + 1)
|
15
|
-
|
16
|
-
if seed > 0.3
|
17
|
-
ary.map!{|ar| Array.new(rand(base) + 1) }
|
18
|
-
end
|
19
|
-
|
20
|
-
if seed > 0.5
|
21
|
-
ary.map!{|ar| ar.map!{|a| Array.new(rand(base) + 1) } }
|
22
|
-
end
|
23
|
-
|
24
|
-
if seed > 0.8
|
25
|
-
ary.map!{|ar| ar.map!{|a| a.map!{|item| Array.new(rand(base) + 1) } } }
|
26
|
-
end
|
27
|
-
|
28
|
-
return ary
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
|
data/lib/queencheck/boolean.rb
DELETED
data/lib/queencheck/config.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
|
2
|
-
module QueenCheck
|
3
|
-
class Config
|
4
|
-
attr_reader :count, :log
|
5
|
-
|
6
|
-
def initialize(options = nil)
|
7
|
-
options ||= {}
|
8
|
-
|
9
|
-
@count = options[:count] || 100 # デフォルトの試行回数は 100 回
|
10
|
-
@verbose = options[:verbose] || false
|
11
|
-
@log = options[:log] || STDOUT
|
12
|
-
end
|
13
|
-
|
14
|
-
def verbose?; @verbose; end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
|
2
|
-
module QueenCheck
|
3
|
-
class << self
|
4
|
-
def ElementsOf(name, elements = nil)
|
5
|
-
if elements.nil? && !name.kind_of?(Array)
|
6
|
-
return QueenCheck::ElementsOf.get_by_id(name)
|
7
|
-
else
|
8
|
-
return QueenCheck::ElementsOf.new(name, elements)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class ElementsOf
|
14
|
-
@@instances = {}
|
15
|
-
|
16
|
-
def self.get_by_id(id)
|
17
|
-
return @@instances[id.to_s.to_sym]
|
18
|
-
end
|
19
|
-
|
20
|
-
attr_reader :elements, :name
|
21
|
-
|
22
|
-
def arbitrary?; true; end
|
23
|
-
|
24
|
-
def arbitrary(seed)
|
25
|
-
@elements[rand(@elements.length)]
|
26
|
-
end
|
27
|
-
|
28
|
-
def initialize(name, elements = nil)
|
29
|
-
if elements.nil? && name.kind_of?(Array)
|
30
|
-
elements = name
|
31
|
-
name = nil
|
32
|
-
end
|
33
|
-
|
34
|
-
raise ArgumentError, 'elements length require over 1' if !elements.respond_to?(:length) || elements.length < 0
|
35
|
-
@elements = elements
|
36
|
-
|
37
|
-
if name
|
38
|
-
@name = name.to_s.to_sym
|
39
|
-
@@instances[@name] = self
|
40
|
-
QueenCheck::Arbitrary::Instance.collection["elements_of_#{@name}".to_sym] = self
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/lib/queencheck/float.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'queencheck/arbitrary'
|
2
|
-
|
3
|
-
class Float
|
4
|
-
extend QueenCheck::Arbitrary
|
5
|
-
|
6
|
-
@@bound = 25
|
7
|
-
|
8
|
-
set_arbitrary do |seed|
|
9
|
-
if seed == 0
|
10
|
-
0.0
|
11
|
-
else
|
12
|
-
if seed > 0.9 && rand(3) > 0
|
13
|
-
return rand(2).zero? ? 0.0/0.0 : rand(2).zero? ? 1.0/0 : -1.0/0
|
14
|
-
end
|
15
|
-
base = ((@@bound * seed).ceil).to_f
|
16
|
-
max = 10.0 ** base
|
17
|
-
num = rand(max)
|
18
|
-
nod = num.to_s.length
|
19
|
-
num.to_f / (10 ** ((rand(nod / 2) + nod / 2) / 2)) * (rand(2).zero? ? 1.0 : -1.0)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|