rushcheck 0.2 → 0.3
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/Rakefile +1 -1
- data/data/rushcheck/doc/rushcheck.txt +68 -10
- data/data/rushcheck/examples/candy.rb +43 -0
- data/data/rushcheck/rdoc/classes/Arbitrary.html +5 -5
- data/data/rushcheck/rdoc/classes/Arbitrary.src/M000076.html +18 -0
- data/data/rushcheck/rdoc/classes/Assertion.src/M000016.html +9 -4
- data/data/rushcheck/rdoc/classes/Coarbitrary.html +5 -5
- data/data/rushcheck/rdoc/classes/Coarbitrary.src/M000096.html +18 -0
- data/data/rushcheck/rdoc/classes/Float.html +20 -20
- data/data/rushcheck/rdoc/classes/Float.src/M000048.html +7 -4
- data/data/rushcheck/rdoc/classes/Float.src/M000049.html +4 -8
- data/data/rushcheck/rdoc/classes/Float.src/M000050.html +8 -6
- data/data/rushcheck/rdoc/classes/Float.src/M000051.html +20 -0
- data/data/rushcheck/rdoc/classes/Gen.html +109 -87
- data/data/rushcheck/rdoc/classes/Gen.src/M000026.html +1 -1
- data/data/rushcheck/rdoc/classes/Gen.src/M000027.html +28 -5
- data/data/rushcheck/rdoc/classes/Gen.src/M000028.html +6 -14
- data/data/rushcheck/rdoc/classes/Gen.src/M000029.html +13 -9
- data/data/rushcheck/rdoc/classes/Gen.src/M000030.html +10 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000031.html +4 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000032.html +4 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000033.html +4 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000034.html +4 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000035.html +4 -10
- data/data/rushcheck/rdoc/classes/Gen.src/M000036.html +10 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000037.html +4 -7
- data/data/rushcheck/rdoc/classes/Gen.src/M000038.html +7 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000039.html +4 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000040.html +4 -9
- data/data/rushcheck/rdoc/classes/Gen.src/M000041.html +9 -5
- data/data/rushcheck/rdoc/classes/Gen.src/M000042.html +5 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000043.html +4 -10
- data/data/rushcheck/rdoc/classes/Gen.src/M000044.html +24 -0
- data/data/rushcheck/rdoc/classes/HsRandom.html +20 -20
- data/data/rushcheck/rdoc/classes/HsRandom.src/M000082.html +8 -18
- data/data/rushcheck/rdoc/classes/HsRandom.src/M000083.html +18 -4
- data/data/rushcheck/rdoc/classes/HsRandom.src/M000084.html +18 -0
- data/data/rushcheck/rdoc/classes/NilClass.html +15 -15
- data/data/rushcheck/rdoc/classes/NilClass.src/M000060.html +4 -4
- data/data/rushcheck/rdoc/classes/NilClass.src/M000061.html +4 -4
- data/data/rushcheck/rdoc/classes/NilClass.src/M000062.html +18 -0
- data/data/rushcheck/rdoc/classes/Property.html +10 -10
- data/data/rushcheck/rdoc/classes/Property.src/M000071.html +12 -4
- data/data/rushcheck/rdoc/classes/Property.src/M000072.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomArray.src/M000022.html +2 -2
- data/data/rushcheck/rdoc/classes/RandomBool.html +10 -10
- data/data/rushcheck/rdoc/classes/RandomBool.src/M000080.html +4 -5
- data/data/rushcheck/rdoc/classes/RandomBool.src/M000081.html +19 -0
- data/data/rushcheck/rdoc/classes/RandomGen.html +20 -20
- data/data/rushcheck/rdoc/classes/RandomGen.src/M000077.html +3 -3
- data/data/rushcheck/rdoc/classes/RandomGen.src/M000078.html +3 -3
- data/data/rushcheck/rdoc/classes/RandomGen.src/M000079.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomHash.html +16 -16
- data/data/rushcheck/rdoc/classes/RandomHash.src/M000045.html +4 -12
- data/data/rushcheck/rdoc/classes/RandomHash.src/M000046.html +11 -7
- data/data/rushcheck/rdoc/classes/RandomHash.src/M000047.html +22 -0
- data/data/rushcheck/rdoc/classes/RandomProc.html +20 -20
- data/data/rushcheck/rdoc/classes/RandomProc.src/M000056.html +4 -16
- data/data/rushcheck/rdoc/classes/RandomProc.src/M000057.html +13 -9
- data/data/rushcheck/rdoc/classes/RandomProc.src/M000058.html +11 -5
- data/data/rushcheck/rdoc/classes/RandomProc.src/M000059.html +20 -0
- data/data/rushcheck/rdoc/classes/Result.html +19 -19
- data/data/rushcheck/rdoc/classes/Result.src/M000052.html +4 -4
- data/data/rushcheck/rdoc/classes/Result.src/M000053.html +4 -4
- data/data/rushcheck/rdoc/classes/Result.src/M000054.html +18 -0
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000004.html +1 -1
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000005.html +1 -1
- data/data/rushcheck/rdoc/classes/String.html +20 -20
- data/data/rushcheck/rdoc/classes/String.src/M000067.html +10 -4
- data/data/rushcheck/rdoc/classes/String.src/M000068.html +4 -11
- data/data/rushcheck/rdoc/classes/String.src/M000069.html +10 -7
- data/data/rushcheck/rdoc/classes/String.src/M000070.html +22 -0
- data/data/rushcheck/rdoc/classes/Testable.html +54 -54
- data/data/rushcheck/rdoc/classes/Testable.src/M000085.html +4 -4
- data/data/rushcheck/rdoc/classes/Testable.src/M000086.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000089.html +4 -4
- data/data/rushcheck/rdoc/classes/Testable.src/M000090.html +4 -4
- data/data/rushcheck/rdoc/classes/Testable.src/M000091.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000093.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000095.html +18 -0
- data/data/rushcheck/rdoc/classes/TheStdGen.html +20 -20
- data/data/rushcheck/rdoc/classes/TheStdGen.src/M000063.html +4 -6
- data/data/rushcheck/rdoc/classes/TheStdGen.src/M000064.html +6 -7
- data/data/rushcheck/rdoc/classes/TheStdGen.src/M000065.html +7 -4
- data/data/rushcheck/rdoc/classes/TheStdGen.src/M000066.html +18 -0
- data/data/rushcheck/rdoc/classes/TrueClass.html +15 -15
- data/data/rushcheck/rdoc/classes/TrueClass.src/M000073.html +4 -4
- data/data/rushcheck/rdoc/classes/TrueClass.src/M000074.html +4 -4
- data/data/rushcheck/rdoc/classes/TrueClass.src/M000075.html +18 -0
- data/data/rushcheck/rdoc/created.rid +1 -1
- data/data/rushcheck/rdoc/files/rushcheck/array_rb.html +1 -1
- data/data/rushcheck/rdoc/files/rushcheck/assertion_rb.html +1 -1
- data/data/rushcheck/rdoc/files/rushcheck/config_rb.html +1 -1
- data/data/rushcheck/rdoc/files/rushcheck/gen_rb.html +8 -1
- data/data/rushcheck/rdoc/files/rushcheck/rushcheck_rb.html +6 -2
- data/data/rushcheck/rdoc/files/rushcheck/testable_rb.html +1 -1
- data/data/rushcheck/rdoc/fr_method_index.html +75 -74
- data/lib/rushcheck/gen.rb +40 -3
- metadata +22 -2
data/Rakefile
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
RushCheck - a random testing tool for Ruby
|
|
2
|
-
Tutorial for version 0.
|
|
2
|
+
Tutorial for version 0.3
|
|
3
3
|
2006-08-08 Daisuke IKEGAMI <ikegami@madscientist.jp>
|
|
4
4
|
|
|
5
5
|
This document is a draft and may be obsoleted in future.
|
|
@@ -433,6 +433,7 @@ Check also the web page
|
|
|
433
433
|
class Candy
|
|
434
434
|
|
|
435
435
|
def initialize(name, price)
|
|
436
|
+
raise unless price >= 0
|
|
436
437
|
@name, @price = name, price
|
|
437
438
|
end
|
|
438
439
|
|
|
@@ -448,16 +449,42 @@ Check also the web page
|
|
|
448
449
|
|
|
449
450
|
To write random generator, we have to look up 'initialize'.
|
|
450
451
|
Here, assume that @name belongs String and @price belongs Integer.
|
|
452
|
+
It is natural that we assumes @price should be positive.
|
|
451
453
|
|
|
452
454
|
One simple random generator for Candy:
|
|
453
455
|
|
|
454
|
-
(1) using Gen
|
|
456
|
+
(1) using Gen.create
|
|
455
457
|
class Candy
|
|
456
458
|
extend Arbitrary
|
|
457
459
|
|
|
458
460
|
def self.arbitrary
|
|
459
|
-
Integer.
|
|
460
|
-
|
|
461
|
+
xs = [String, Integer].map {|c| c.arbitrary}
|
|
462
|
+
Gen.create(xs) do |name, price, g|
|
|
463
|
+
g.guard { price >= 0 }
|
|
464
|
+
new(name, price)
|
|
465
|
+
end
|
|
466
|
+
end
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
Gen.create takes an array of Gen object (here, [Integer.arbitrary,
|
|
470
|
+
String.arbitrary]) and a block. The block takes variables which is
|
|
471
|
+
corresponded to the array, as Assertion.new. If guard is failed,
|
|
472
|
+
then RushCheck retry to create another random instance.
|
|
473
|
+
|
|
474
|
+
Note that we can use a trick instead of the guard property.
|
|
475
|
+
price = - price if price < 0 # g.guard { price >= 0 }
|
|
476
|
+
In this case, this is more efficient to generate random instance
|
|
477
|
+
than with the guard. However, sometimes we don't have this kind
|
|
478
|
+
trick and we can use some guards.
|
|
479
|
+
|
|
480
|
+
(2) using Gen#bind and Gen.unit
|
|
481
|
+
class Candy
|
|
482
|
+
extend Arbitrary
|
|
483
|
+
|
|
484
|
+
def self.arbitrary
|
|
485
|
+
String.arbitrary.bind do |name|
|
|
486
|
+
Integer.arbitrary.bind do |price|
|
|
487
|
+
price = - price if price < 0 # trick
|
|
461
488
|
Gen.unit(new(name, price))
|
|
462
489
|
end
|
|
463
490
|
end
|
|
@@ -466,8 +493,8 @@ Check also the web page
|
|
|
466
493
|
|
|
467
494
|
Puzzled? OK, they can be readed as follows:
|
|
468
495
|
|
|
469
|
-
take a random (arbitrary)
|
|
470
|
-
take a random
|
|
496
|
+
take a random (arbitrary) string and call it 'name'
|
|
497
|
+
take a random integer and call it 'price'
|
|
471
498
|
return a Gen object which has a new Candy(name, price)
|
|
472
499
|
|
|
473
500
|
In general, the class method arbitrary should return a Gen object.
|
|
@@ -477,17 +504,18 @@ Check also the web page
|
|
|
477
504
|
There are several way to implement random generators. The next
|
|
478
505
|
example is to use Gen.new without bind and unit.
|
|
479
506
|
|
|
480
|
-
(
|
|
507
|
+
(3) using Gen.new
|
|
481
508
|
class Candy
|
|
482
509
|
extend Arbitrary
|
|
483
510
|
|
|
484
511
|
def self.arbitrary
|
|
485
512
|
Gen.new do |n, r|
|
|
486
513
|
r2 = r
|
|
487
|
-
name, price = [
|
|
514
|
+
name, price = [String, Integer].map do |c|
|
|
488
515
|
r1, r2 = r2.split
|
|
489
516
|
c.arbitrary.value(n. r1)
|
|
490
517
|
end
|
|
518
|
+
price = - price if price < 0 # trick
|
|
491
519
|
new(name, price)
|
|
492
520
|
end
|
|
493
521
|
end
|
|
@@ -506,6 +534,7 @@ Check also the web page
|
|
|
506
534
|
get new two random generator r1 and r2 from old r2
|
|
507
535
|
assign a random value by generating 'arbitrary.value(n, r1)'
|
|
508
536
|
and discard the random generator r1
|
|
537
|
+
...
|
|
509
538
|
|
|
510
539
|
Note that we need new random generator for each random object.
|
|
511
540
|
Here we create new random generator by spliting. If you use same
|
|
@@ -513,13 +542,32 @@ Check also the web page
|
|
|
513
542
|
distribution of objects are same (not generated randomly).
|
|
514
543
|
|
|
515
544
|
Because sometimes the initialize of YourClass is complecated,
|
|
516
|
-
then the random generator self.arbitrary turns to be
|
|
545
|
+
then the random generator self.arbitrary turns to be complicated
|
|
517
546
|
also.
|
|
518
547
|
|
|
519
548
|
In next sections, I will introduce several generators in gen.rb.
|
|
520
549
|
They may be useful to create your own random genrator. See also rdoc
|
|
521
550
|
of Gen.
|
|
522
551
|
|
|
552
|
+
Appendix: expensive candy.
|
|
553
|
+
|
|
554
|
+
Using Gen.create to generate random instance, if we gives another
|
|
555
|
+
guard such as
|
|
556
|
+
g.guard { price >= 100000 } # very expensive candy!
|
|
557
|
+
then it consumes much time to generate random instance because the
|
|
558
|
+
guard fails so many times. When RushCheck creates random instances,
|
|
559
|
+
it starts smallest as possible, then the size becomes larger in
|
|
560
|
+
repeating tests. Therefore, if the guard instance seems failed so
|
|
561
|
+
often, then we need another seeds of generators. Here is another
|
|
562
|
+
generators for expensive candy instance.
|
|
563
|
+
|
|
564
|
+
lo = 100000
|
|
565
|
+
g = Gen.sized { |n| Gen.choose(lo, n + lo)}
|
|
566
|
+
xs = [String.arbitrary, g]
|
|
567
|
+
|
|
568
|
+
See gen.rb and the following sections in details for how to get
|
|
569
|
+
another generator.
|
|
570
|
+
|
|
523
571
|
6.2 Gen.choose
|
|
524
572
|
|
|
525
573
|
Gen.choose(lo, hi) returns a Gen object which generates a random
|
|
@@ -596,7 +644,17 @@ Check also the web page
|
|
|
596
644
|
|
|
597
645
|
Gen.vector(Integer, 3) # => Gen [Integer, Integer, Integer]
|
|
598
646
|
|
|
599
|
-
7.
|
|
647
|
+
7. how to write random Proc which returns objects in YourClass
|
|
648
|
+
|
|
649
|
+
It is complecated, and see some examples.
|
|
650
|
+
- rushcheck/bool.rb
|
|
651
|
+
- rushcheck/integer.rb
|
|
652
|
+
- rushcheck/string.rb
|
|
653
|
+
so on, grep 'coarbitrary'
|
|
654
|
+
|
|
655
|
+
FIXME: how to write coarbitrary
|
|
656
|
+
|
|
657
|
+
8. Further information
|
|
600
658
|
|
|
601
659
|
Webpage should have another useful information:
|
|
602
660
|
http://rushcheck.rubyforge.org/
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# candy.rb
|
|
2
|
+
# an example to write a random generator
|
|
3
|
+
|
|
4
|
+
require 'rushcheck/rushcheck'
|
|
5
|
+
|
|
6
|
+
class Candy
|
|
7
|
+
|
|
8
|
+
extend Arbitrary
|
|
9
|
+
|
|
10
|
+
def initialize(name, price)
|
|
11
|
+
raise unless price >= 0
|
|
12
|
+
@name, @price = name, price
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.arbitrary
|
|
16
|
+
xs = [String, Integer].map {|c| c.arbitrary}
|
|
17
|
+
Gen.create(xs) do |name, price, g|
|
|
18
|
+
g.guard { price >= 0 }
|
|
19
|
+
new(name, price)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class ExpensiveCandy < Candy
|
|
26
|
+
|
|
27
|
+
def initialize(name, price)
|
|
28
|
+
raise unless price >= 100000
|
|
29
|
+
@name, @price = name, price
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.arbitrary
|
|
33
|
+
# xs = [String, Integer].map {|c| c.arbitrary}
|
|
34
|
+
lo = 100000
|
|
35
|
+
g = Gen.sized { |n| Gen.choose(lo, n + lo)}
|
|
36
|
+
xs = [String.arbitrary, g]
|
|
37
|
+
Gen.create(xs) do |name, price, g|
|
|
38
|
+
g.guard { price >= 100000 }
|
|
39
|
+
new(name, price)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
@@ -92,7 +92,7 @@ each class after include/extend them.
|
|
|
92
92
|
<h3 class="section-bar">Methods</h3>
|
|
93
93
|
|
|
94
94
|
<div class="name-list">
|
|
95
|
-
<a href="#
|
|
95
|
+
<a href="#M000076">arbitrary</a>
|
|
96
96
|
</div>
|
|
97
97
|
</div>
|
|
98
98
|
|
|
@@ -114,12 +114,12 @@ each class after include/extend them.
|
|
|
114
114
|
<div id="methods">
|
|
115
115
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
116
116
|
|
|
117
|
-
<div id="method-
|
|
118
|
-
<a name="
|
|
117
|
+
<div id="method-M000076" class="method-detail">
|
|
118
|
+
<a name="M000076"></a>
|
|
119
119
|
|
|
120
120
|
<div class="method-heading">
|
|
121
|
-
<a href="Arbitrary.src/
|
|
122
|
-
onclick="popupCode('Arbitrary.src/
|
|
121
|
+
<a href="Arbitrary.src/M000076.html" target="Code" class="method-signature"
|
|
122
|
+
onclick="popupCode('Arbitrary.src/M000076.html');return false;">
|
|
123
123
|
<span class="method-name">arbitrary</span><span class="method-args">()</span>
|
|
124
124
|
</a>
|
|
125
125
|
</div>
|
|
@@ -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>
|
|
@@ -14,12 +14,17 @@
|
|
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">property</span>
|
|
15
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
16
|
<span class="ruby-identifier">r2</span> = <span class="ruby-identifier">r</span>
|
|
17
|
-
<span class="ruby-
|
|
18
|
-
|
|
19
|
-
<span class="ruby-
|
|
17
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@inputs</span>
|
|
18
|
+
<span class="ruby-keyword kw">then</span>
|
|
19
|
+
<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>
|
|
20
|
+
<span class="ruby-identifier">r1</span>, <span class="ruby-identifier">r2</span> = <span class="ruby-identifier">r2</span>.<span class="ruby-identifier">split</span>
|
|
21
|
+
<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>)
|
|
22
|
+
<span class="ruby-keyword kw">end</span>
|
|
23
|
+
<span class="ruby-keyword kw">else</span>
|
|
24
|
+
[]
|
|
20
25
|
<span class="ruby-keyword kw">end</span>
|
|
21
26
|
<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>)
|
|
27
|
+
<span class="ruby-identifier">guards</span> = <span class="ruby-ivar">@nguard</span> <span class="ruby-operator">>=</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</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>) <span class="ruby-operator">:</span> []
|
|
23
28
|
<span class="ruby-identifier">test</span> = <span class="ruby-keyword kw">begin</span>
|
|
24
29
|
<span class="ruby-identifier">xs</span> = <span class="ruby-identifier">args</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">guards</span>
|
|
25
30
|
<span class="ruby-ivar">@proc</span>.<span class="ruby-identifier">call</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">xs</span>)
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
<h3 class="section-bar">Methods</h3>
|
|
81
81
|
|
|
82
82
|
<div class="name-list">
|
|
83
|
-
<a href="#
|
|
83
|
+
<a href="#M000096">coarbitrary</a>
|
|
84
84
|
</div>
|
|
85
85
|
</div>
|
|
86
86
|
|
|
@@ -102,12 +102,12 @@
|
|
|
102
102
|
<div id="methods">
|
|
103
103
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
104
104
|
|
|
105
|
-
<div id="method-
|
|
106
|
-
<a name="
|
|
105
|
+
<div id="method-M000096" class="method-detail">
|
|
106
|
+
<a name="M000096"></a>
|
|
107
107
|
|
|
108
108
|
<div class="method-heading">
|
|
109
|
-
<a href="Coarbitrary.src/
|
|
110
|
-
onclick="popupCode('Coarbitrary.src/
|
|
109
|
+
<a href="Coarbitrary.src/M000096.html" target="Code" class="method-signature"
|
|
110
|
+
onclick="popupCode('Coarbitrary.src/M000096.html');return false;">
|
|
111
111
|
<span class="method-name">coarbitrary</span><span class="method-args">(g)</span>
|
|
112
112
|
</a>
|
|
113
113
|
</div>
|
|
@@ -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>coarbitrary (Coarbitrary)</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 24</span>
|
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">coarbitrary</span>(<span class="ruby-identifier">g</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>
|
|
@@ -86,10 +86,10 @@
|
|
|
86
86
|
<h3 class="section-bar">Methods</h3>
|
|
87
87
|
|
|
88
88
|
<div class="name-list">
|
|
89
|
-
<a href="#
|
|
90
|
-
<a href="#
|
|
91
|
-
<a href="#
|
|
92
|
-
<a href="#
|
|
89
|
+
<a href="#M000048">arbitrary</a>
|
|
90
|
+
<a href="#M000049">bound</a>
|
|
91
|
+
<a href="#M000051">coarbitrary</a>
|
|
92
|
+
<a href="#M000050">random_range</a>
|
|
93
93
|
</div>
|
|
94
94
|
</div>
|
|
95
95
|
|
|
@@ -118,12 +118,12 @@
|
|
|
118
118
|
<div id="methods">
|
|
119
119
|
<h3 class="section-bar">Public Class methods</h3>
|
|
120
120
|
|
|
121
|
-
<div id="method-
|
|
122
|
-
<a name="
|
|
121
|
+
<div id="method-M000048" class="method-detail">
|
|
122
|
+
<a name="M000048"></a>
|
|
123
123
|
|
|
124
124
|
<div class="method-heading">
|
|
125
|
-
<a href="Float.src/
|
|
126
|
-
onclick="popupCode('Float.src/
|
|
125
|
+
<a href="Float.src/M000048.html" target="Code" class="method-signature"
|
|
126
|
+
onclick="popupCode('Float.src/M000048.html');return false;">
|
|
127
127
|
<span class="method-name">arbitrary</span><span class="method-args">()</span>
|
|
128
128
|
</a>
|
|
129
129
|
</div>
|
|
@@ -132,12 +132,12 @@
|
|
|
132
132
|
</div>
|
|
133
133
|
</div>
|
|
134
134
|
|
|
135
|
-
<div id="method-
|
|
136
|
-
<a name="
|
|
135
|
+
<div id="method-M000049" class="method-detail">
|
|
136
|
+
<a name="M000049"></a>
|
|
137
137
|
|
|
138
138
|
<div class="method-heading">
|
|
139
|
-
<a href="Float.src/
|
|
140
|
-
onclick="popupCode('Float.src/
|
|
139
|
+
<a href="Float.src/M000049.html" target="Code" class="method-signature"
|
|
140
|
+
onclick="popupCode('Float.src/M000049.html');return false;">
|
|
141
141
|
<span class="method-name">bound</span><span class="method-args">()</span>
|
|
142
142
|
</a>
|
|
143
143
|
</div>
|
|
@@ -146,12 +146,12 @@
|
|
|
146
146
|
</div>
|
|
147
147
|
</div>
|
|
148
148
|
|
|
149
|
-
<div id="method-
|
|
150
|
-
<a name="
|
|
149
|
+
<div id="method-M000050" class="method-detail">
|
|
150
|
+
<a name="M000050"></a>
|
|
151
151
|
|
|
152
152
|
<div class="method-heading">
|
|
153
|
-
<a href="Float.src/
|
|
154
|
-
onclick="popupCode('Float.src/
|
|
153
|
+
<a href="Float.src/M000050.html" target="Code" class="method-signature"
|
|
154
|
+
onclick="popupCode('Float.src/M000050.html');return false;">
|
|
155
155
|
<span class="method-name">random_range</span><span class="method-args">(gen, lo=@@min_bound, hi=@@max_bound)</span>
|
|
156
156
|
</a>
|
|
157
157
|
</div>
|
|
@@ -162,12 +162,12 @@
|
|
|
162
162
|
|
|
163
163
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
164
164
|
|
|
165
|
-
<div id="method-
|
|
166
|
-
<a name="
|
|
165
|
+
<div id="method-M000051" class="method-detail">
|
|
166
|
+
<a name="M000051"></a>
|
|
167
167
|
|
|
168
168
|
<div class="method-heading">
|
|
169
|
-
<a href="Float.src/
|
|
170
|
-
onclick="popupCode('Float.src/
|
|
169
|
+
<a href="Float.src/M000051.html" target="Code" class="method-signature"
|
|
170
|
+
onclick="popupCode('Float.src/M000051.html');return false;">
|
|
171
171
|
<span class="method-name">coarbitrary</span><span class="method-args">(g)</span>
|
|
172
172
|
</a>
|
|
173
173
|
</div>
|
|
@@ -5,14 +5,17 @@
|
|
|
5
5
|
|
|
6
6
|
<html>
|
|
7
7
|
<head>
|
|
8
|
-
<title>
|
|
8
|
+
<title>arbitrary (Float)</title>
|
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
11
|
</head>
|
|
12
12
|
<body class="standalone-code">
|
|
13
|
-
<pre><span class="ruby-comment cmt"># File rushcheck/float.rb, line
|
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">
|
|
15
|
-
|
|
13
|
+
<pre><span class="ruby-comment cmt"># File rushcheck/float.rb, line 18</span>
|
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">arbitrary</span>
|
|
15
|
+
<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">a</span>, <span class="ruby-identifier">b</span>, <span class="ruby-identifier">c</span> = (<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">3</span>).<span class="ruby-identifier">map</span> { <span class="ruby-constant">Integer</span>.<span class="ruby-identifier">arbitrary</span>.<span class="ruby-identifier">value</span>(<span class="ruby-identifier">n</span>, <span class="ruby-identifier">r</span>) }
|
|
17
|
+
<span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">b</span> <span class="ruby-operator">/</span> (<span class="ruby-identifier">c</span>.<span class="ruby-identifier">abs</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>))
|
|
18
|
+
<span class="ruby-keyword kw">end</span>
|
|
16
19
|
<span class="ruby-keyword kw">end</span></pre>
|
|
17
20
|
</body>
|
|
18
21
|
</html>
|
|
@@ -5,18 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
<html>
|
|
7
7
|
<head>
|
|
8
|
-
<title>
|
|
8
|
+
<title>bound (Float)</title>
|
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
11
|
</head>
|
|
12
12
|
<body class="standalone-code">
|
|
13
|
-
<pre><span class="ruby-comment cmt"># File rushcheck/float.rb, line
|
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">
|
|
15
|
-
<span class="ruby-
|
|
16
|
-
<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span> = <span class="ruby-constant">Integer</span>.<span class="ruby-identifier">bound</span>
|
|
17
|
-
<span class="ruby-identifier">r</span> = (<span class="ruby-identifier">lo</span><span class="ruby-operator">+</span><span class="ruby-identifier">hi</span><span class="ruby-operator">/</span><span class="ruby-value">2</span>).<span class="ruby-identifier">to_f</span> <span class="ruby-operator">+</span> ((<span class="ruby-identifier">hi</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">lo</span>).<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> (<span class="ruby-identifier">b</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">a</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">x</span>)
|
|
18
|
-
|
|
19
|
-
[<span class="ruby-identifier">r</span>, <span class="ruby-identifier">g</span>]
|
|
13
|
+
<pre><span class="ruby-comment cmt"># File rushcheck/float.rb, line 25</span>
|
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">bound</span>
|
|
15
|
+
[<span class="ruby-ivar">@@min_bound</span>, <span class="ruby-ivar">@@max_bound</span>]
|
|
20
16
|
<span class="ruby-keyword kw">end</span></pre>
|
|
21
17
|
</body>
|
|
22
18
|
</html>
|
|
@@ -5,16 +5,18 @@
|
|
|
5
5
|
|
|
6
6
|
<html>
|
|
7
7
|
<head>
|
|
8
|
-
<title>
|
|
8
|
+
<title>random_range (Float)</title>
|
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
11
|
</head>
|
|
12
12
|
<body class="standalone-code">
|
|
13
|
-
<pre><span class="ruby-comment cmt"># File rushcheck/float.rb, line
|
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
|
15
|
-
<span class="ruby-identifier">
|
|
16
|
-
<span class="ruby-identifier">
|
|
17
|
-
<span class="ruby-identifier">
|
|
13
|
+
<pre><span class="ruby-comment cmt"># File rushcheck/float.rb, line 29</span>
|
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">random_range</span>(<span class="ruby-identifier">gen</span>, <span class="ruby-identifier">lo</span>=<span class="ruby-ivar">@@min_bound</span>, <span class="ruby-identifier">hi</span>=<span class="ruby-ivar">@@max_bound</span>)
|
|
15
|
+
<span class="ruby-identifier">x</span>, <span class="ruby-identifier">g</span> = <span class="ruby-constant">Integer</span>.<span class="ruby-identifier">random</span>(<span class="ruby-identifier">gen</span>)
|
|
16
|
+
<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span> = <span class="ruby-constant">Integer</span>.<span class="ruby-identifier">bound</span>
|
|
17
|
+
<span class="ruby-identifier">r</span> = (<span class="ruby-identifier">lo</span><span class="ruby-operator">+</span><span class="ruby-identifier">hi</span><span class="ruby-operator">/</span><span class="ruby-value">2</span>).<span class="ruby-identifier">to_f</span> <span class="ruby-operator">+</span> ((<span class="ruby-identifier">hi</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">lo</span>).<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> (<span class="ruby-identifier">b</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">a</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">x</span>)
|
|
18
|
+
|
|
19
|
+
[<span class="ruby-identifier">r</span>, <span class="ruby-identifier">g</span>]
|
|
18
20
|
<span class="ruby-keyword kw">end</span></pre>
|
|
19
21
|
</body>
|
|
20
22
|
</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>coarbitrary (Float)</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/float.rb, line 37</span>
|
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">coarbitrary</span>(<span class="ruby-identifier">g</span>)
|
|
15
|
+
<span class="ruby-identifier">h</span> = <span class="ruby-identifier">truncate</span>
|
|
16
|
+
<span class="ruby-identifier">t</span> = (<span class="ruby-keyword kw">self</span> <span class="ruby-operator">*</span> (<span class="ruby-value">10</span> <span class="ruby-operator">**</span> ((<span class="ruby-keyword kw">self</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">h</span>).<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-value">2</span>))).<span class="ruby-identifier">truncate</span>
|
|
17
|
+
<span class="ruby-identifier">h</span>.<span class="ruby-identifier">coarbitrary</span>(<span class="ruby-identifier">t</span>.<span class="ruby-identifier">coarbitrary</span>(<span class="ruby-identifier">g</span>))
|
|
18
|
+
<span class="ruby-keyword kw">end</span></pre>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|