queencheck 0.1.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,16 +0,0 @@
1
- require 'queencheck/arbitrary'
2
-
3
- class Integer
4
- extend QueenCheck::Arbitrary
5
-
6
- @@bound = 25
7
-
8
- set_arbitrary do |seed|
9
- if seed == 0
10
- 0
11
- else
12
- max = 10 ** ((@@bound * seed).ceil)
13
- rand(max) * (rand(2).zero? ? 1 : -1)
14
- end
15
- end
16
- end
@@ -1,22 +0,0 @@
1
- require 'pp'
2
-
3
- module RSpec
4
- module Core
5
- class ExampleGroup
6
- def self.qcheck(instance, method, arbitraries, options = {}, &block)
7
- describe "QC: #{instance.class}##{method}(#{arbitraries.join(', ')})" do
8
- QueenCheck(instance, method, *arbitraries).run(options) do | result, args, error |
9
- it("Gen: #{args.join(', ')}"){
10
- begin
11
- self.instance_eval_with_args(*[result, args, error], &block)
12
- rescue => e
13
- e.set_backtrace(e.backtrace.slice(0,6) + e.backtrace.slice(9, 100))
14
- raise e
15
- end
16
- }
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,47 +0,0 @@
1
- require 'queencheck/arbitrary'
2
-
3
- class String
4
- extend QueenCheck::Arbitrary
5
-
6
- @@max_length = 256
7
-
8
- set_arbitrary do | seed |
9
- max = (@@max_length * (seed * seed)).ceil
10
-
11
- charset = []
12
- if seed == 0
13
- return ''
14
- elsif seed < 0.1
15
- charset = (0x61 ... 0x7b).to_a + (0x41 ... 0x5b).to_a
16
- elsif seed < 0.3 # ASCII
17
- charset = (0x32 ... 0x7f).to_a
18
- elsif seed < 0.5
19
- charset = (0x00 ... 0x80).to_a
20
- elsif seed < 0.7
21
- charset = (0x00 ... 0x80).to_a
22
- charset += (0x80 ... 0x800).to_a
23
- elsif seed < 0.9
24
- charset = (0x00 ... 0x80).to_a
25
- charset += (0x80 ... 0x800).to_a
26
- charset += (0x800 ... 0x8000).to_a
27
- elsif seed <= 1
28
- charset = (0x00 ... 0x80).to_a
29
- charset += (0x80 ... 0x800).to_a
30
- charset += (0x800 ... 0x8000).to_a
31
- charset += (0x1000 ... 0x20000).to_a
32
- end
33
-
34
- if !charset.respond_to?(:sample)
35
- class << charset
36
- def sample; self[rand(self.length)]; end
37
- end
38
- end
39
-
40
- ret = []
41
- (rand(max/2) + (max/2)).ceil.times do
42
- ret << charset.sample
43
- end
44
-
45
- return ret.pack('U*')
46
- end
47
- end
@@ -1,22 +0,0 @@
1
- require 'queencheck/elements_of'
2
-
3
- describe QueenCheck::ElementsOf do
4
- before(:each) do
5
- @samples = ['a', 'b', 'c']
6
- @elements_of = QueenCheck::ElementsOf.new(@samples)
7
- end
8
-
9
- it 'choose one' do
10
- 100.times do
11
- @samples.should be_include(@elements_of.arbitrary(rand(10).to_f / 10))
12
- end
13
- end
14
-
15
- it 'named type' do
16
- named = QueenCheck::ElementsOf(:names, ['test', 'sample'])
17
-
18
- named.should be_kind_of(QueenCheck::ElementsOf)
19
- QueenCheck::ElementsOf(:names).should eq(named)
20
- QueenCheck::Arbitrary(:elements_of_names).should eq(named)
21
- end
22
- end
@@ -1,17 +0,0 @@
1
- require 'queencheck/integer'
2
-
3
- describe Integer do
4
- it ".arbitrary?" do
5
- Integer.arbitrary?.should be_true
6
- end
7
-
8
- it ".arbitrary" do
9
- 100.times do
10
- Integer.arbitrary(0).should be_zero
11
- end
12
-
13
- 100.times do |n|
14
- n = n / 100.0
15
- end
16
- end
17
- end
@@ -1,13 +0,0 @@
1
- require 'queencheck/string'
2
-
3
- describe String do
4
- it ".arbitrary?" do
5
- String.arbitrary?.should be_true
6
- end
7
-
8
- it ".arbitrary" do
9
- 100.times do
10
- String.arbitrary(0.05).match(/^[a-zA-Z]+$/).should_not be_nil
11
- end
12
- end
13
- end