rushcheck 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/data/rushcheck/doc/policy.txt +107 -0
- data/data/rushcheck/doc/rushcheck.thtml +832 -0
- data/data/rushcheck/examples/candy.rb +6 -8
- data/data/rushcheck/examples/printf.rb +3 -3
- data/data/rushcheck/examples/proc.rb +4 -4
- data/data/rushcheck/examples/roguetile.rb +16 -16
- data/data/rushcheck/examples/sample.rb +10 -10
- data/data/rushcheck/rdoc/classes/Arbitrary.html +5 -5
- data/data/rushcheck/rdoc/classes/Arbitrary.src/M000082.html +18 -0
- data/data/rushcheck/rdoc/classes/Assertion.html +11 -11
- data/data/rushcheck/rdoc/classes/Assertion.src/M000019.html +20 -0
- data/data/rushcheck/rdoc/classes/Assertion.src/M000020.html +50 -0
- data/data/rushcheck/rdoc/classes/Coarbitrary.html +5 -5
- data/data/rushcheck/rdoc/classes/Coarbitrary.src/M000105.html +18 -0
- data/data/rushcheck/rdoc/classes/FalseClass.html +15 -15
- data/data/rushcheck/rdoc/classes/FalseClass.src/M000022.html +18 -0
- data/data/rushcheck/rdoc/classes/FalseClass.src/M000023.html +18 -0
- data/data/rushcheck/rdoc/classes/FalseClass.src/M000024.html +18 -0
- data/data/rushcheck/rdoc/classes/Float.html +20 -20
- data/data/rushcheck/rdoc/classes/Float.src/M000052.html +21 -0
- data/data/rushcheck/rdoc/classes/Float.src/M000053.html +18 -0
- data/data/rushcheck/rdoc/classes/Float.src/M000054.html +22 -0
- data/data/rushcheck/rdoc/classes/Float.src/M000055.html +20 -0
- data/data/rushcheck/rdoc/classes/Gen.html +102 -102
- data/data/rushcheck/rdoc/classes/Gen.src/M000030.html +4 -10
- data/data/rushcheck/rdoc/classes/Gen.src/M000031.html +29 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000032.html +6 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000033.html +14 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000034.html +10 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000035.html +4 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000036.html +4 -10
- data/data/rushcheck/rdoc/classes/Gen.src/M000037.html +4 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000038.html +4 -7
- data/data/rushcheck/rdoc/classes/Gen.src/M000039.html +4 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000040.html +10 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000041.html +4 -9
- data/data/rushcheck/rdoc/classes/Gen.src/M000042.html +7 -5
- data/data/rushcheck/rdoc/classes/Gen.src/M000043.html +4 -4
- data/data/rushcheck/rdoc/classes/Gen.src/M000044.html +4 -10
- data/data/rushcheck/rdoc/classes/Gen.src/M000045.html +23 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000046.html +19 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000047.html +18 -0
- data/data/rushcheck/rdoc/classes/Gen.src/M000048.html +24 -0
- data/data/rushcheck/rdoc/classes/Guard.html +10 -10
- data/data/rushcheck/rdoc/classes/Guard.src/M000028.html +27 -0
- data/data/rushcheck/rdoc/classes/Guard.src/M000029.html +18 -0
- data/data/rushcheck/rdoc/classes/HsRandom.html +20 -20
- data/data/rushcheck/rdoc/classes/HsRandom.src/M000088.html +22 -0
- data/data/rushcheck/rdoc/classes/HsRandom.src/M000089.html +32 -0
- data/data/rushcheck/rdoc/classes/HsRandom.src/M000090.html +18 -0
- data/data/rushcheck/rdoc/classes/Integer.html +20 -20
- data/data/rushcheck/rdoc/classes/Integer.src/M000010.html +18 -0
- data/data/rushcheck/rdoc/classes/Integer.src/M000011.html +18 -0
- data/data/rushcheck/rdoc/classes/Integer.src/M000012.html +21 -0
- data/data/rushcheck/rdoc/classes/Integer.src/M000013.html +19 -0
- data/data/rushcheck/rdoc/classes/NilClass.html +15 -15
- data/data/rushcheck/rdoc/classes/NilClass.src/M000064.html +18 -0
- data/data/rushcheck/rdoc/classes/NilClass.src/M000065.html +18 -0
- data/data/rushcheck/rdoc/classes/NilClass.src/M000066.html +18 -0
- data/data/rushcheck/rdoc/classes/Property.html +10 -10
- data/data/rushcheck/rdoc/classes/Property.src/M000077.html +26 -0
- data/data/rushcheck/rdoc/classes/Property.src/M000078.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomArray.html +15 -15
- data/data/rushcheck/rdoc/classes/RandomArray.src/M000025.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomArray.src/M000026.html +35 -0
- data/data/rushcheck/rdoc/classes/RandomArray.src/M000027.html +22 -0
- data/data/rushcheck/rdoc/classes/RandomBool.html +10 -10
- data/data/rushcheck/rdoc/classes/RandomBool.src/M000086.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomBool.src/M000087.html +19 -0
- data/data/rushcheck/rdoc/classes/RandomGen.html +20 -20
- data/data/rushcheck/rdoc/classes/RandomGen.src/M000083.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomGen.src/M000084.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomGen.src/M000085.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomHash.html +16 -16
- data/data/rushcheck/rdoc/classes/RandomHash.src/M000049.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomHash.src/M000050.html +26 -0
- data/data/rushcheck/rdoc/classes/RandomHash.src/M000051.html +22 -0
- data/data/rushcheck/rdoc/classes/RandomProc.html +20 -20
- data/data/rushcheck/rdoc/classes/RandomProc.src/M000060.html +18 -0
- data/data/rushcheck/rdoc/classes/RandomProc.src/M000061.html +30 -0
- data/data/rushcheck/rdoc/classes/RandomProc.src/M000062.html +26 -0
- data/data/rushcheck/rdoc/classes/RandomProc.src/M000063.html +20 -0
- data/data/rushcheck/rdoc/classes/Result.html +19 -19
- data/data/rushcheck/rdoc/classes/Result.src/M000056.html +18 -0
- data/data/rushcheck/rdoc/classes/Result.src/M000057.html +18 -0
- data/data/rushcheck/rdoc/classes/Result.src/M000058.html +18 -0
- data/data/rushcheck/rdoc/classes/RushCheckConfig.html +41 -11
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000001.html +1 -1
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000002.html +1 -1
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000003.html +8 -4
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000004.html +4 -24
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000005.html +22 -39
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000006.html +55 -0
- data/data/rushcheck/rdoc/classes/RushCheckConfig.src/M000007.html +50 -0
- data/data/rushcheck/rdoc/classes/SpecialString.html +5 -5
- data/data/rushcheck/rdoc/classes/SpecialString.src/M000021.html +37 -0
- data/data/rushcheck/rdoc/classes/StdGen.html +27 -27
- data/data/rushcheck/rdoc/classes/StdGen.src/M000014.html +9 -4
- data/data/rushcheck/rdoc/classes/StdGen.src/M000015.html +21 -0
- data/data/rushcheck/rdoc/classes/StdGen.src/M000016.html +21 -0
- data/data/rushcheck/rdoc/classes/StdGen.src/M000017.html +18 -0
- data/data/rushcheck/rdoc/classes/StdGen.src/M000018.html +18 -0
- data/data/rushcheck/rdoc/classes/String.html +20 -20
- data/data/rushcheck/rdoc/classes/String.src/M000073.html +24 -0
- data/data/rushcheck/rdoc/classes/String.src/M000074.html +18 -0
- data/data/rushcheck/rdoc/classes/String.src/M000075.html +25 -0
- data/data/rushcheck/rdoc/classes/String.src/M000076.html +22 -0
- data/data/rushcheck/rdoc/classes/TestExausted.html +113 -0
- data/data/rushcheck/rdoc/classes/TestFailed.html +155 -0
- data/data/rushcheck/rdoc/classes/TestFailed.src/M000067.html +18 -0
- data/data/rushcheck/rdoc/classes/TestOk.html +113 -0
- data/data/rushcheck/rdoc/classes/TestOptions.html +180 -0
- data/data/rushcheck/rdoc/classes/TestOptions.src/M000008.html +18 -0
- data/data/rushcheck/rdoc/classes/TestOptions.src/M000009.html +18 -0
- data/data/rushcheck/rdoc/classes/TestResult.html +164 -0
- data/data/rushcheck/rdoc/classes/TestResult.src/M000068.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.html +96 -51
- data/data/rushcheck/rdoc/classes/Testable.src/M000091.html +4 -4
- data/data/rushcheck/rdoc/classes/Testable.src/M000092.html +4 -4
- data/data/rushcheck/rdoc/classes/Testable.src/M000095.html +4 -4
- data/data/rushcheck/rdoc/classes/Testable.src/M000096.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000097.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000099.html +19 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000100.html +21 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000101.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000103.html +18 -0
- data/data/rushcheck/rdoc/classes/Testable.src/M000104.html +18 -0
- data/data/rushcheck/rdoc/classes/TheStdGen.html +20 -20
- data/data/rushcheck/rdoc/classes/TheStdGen.src/M000069.html +18 -0
- data/data/rushcheck/rdoc/classes/TheStdGen.src/M000070.html +20 -0
- data/data/rushcheck/rdoc/classes/TheStdGen.src/M000071.html +21 -0
- data/data/rushcheck/rdoc/classes/TheStdGen.src/M000072.html +18 -0
- data/data/rushcheck/rdoc/classes/TrueClass.html +15 -15
- data/data/rushcheck/rdoc/classes/TrueClass.src/M000079.html +18 -0
- data/data/rushcheck/rdoc/classes/TrueClass.src/M000080.html +18 -0
- data/data/rushcheck/rdoc/classes/TrueClass.src/M000081.html +18 -0
- data/data/rushcheck/rdoc/created.rid +1 -1
- data/data/rushcheck/rdoc/files/rushcheck/config_rb.html +8 -1
- data/data/rushcheck/rdoc/files/rushcheck/testable_rb.html +3 -1
- data/data/rushcheck/rdoc/files/rushcheck/testoptions_rb.html +109 -0
- data/data/rushcheck/rdoc/files/rushcheck/testresult_rb.html +105 -0
- data/data/rushcheck/rdoc/files/rushcheck_rb.html +127 -0
- data/data/rushcheck/rdoc/fr_class_index.html +5 -0
- data/data/rushcheck/rdoc/fr_file_index.html +3 -1
- data/data/rushcheck/rdoc/fr_method_index.html +103 -94
- data/lib/rushcheck/arbitrary.rb +16 -12
- data/lib/rushcheck/array.rb +7 -6
- data/lib/rushcheck/assertion.rb +53 -50
- data/lib/rushcheck/bool.rb +26 -24
- data/lib/rushcheck/config.rb +131 -81
- data/lib/rushcheck/float.rb +4 -4
- data/lib/rushcheck/gen.rb +194 -182
- data/lib/rushcheck/guard.rb +9 -10
- data/lib/rushcheck/hash.rb +4 -3
- data/lib/rushcheck/integer.rb +11 -6
- data/lib/rushcheck/proc.rb +7 -7
- data/lib/rushcheck/property.rb +19 -15
- data/lib/rushcheck/random.rb +162 -159
- data/lib/rushcheck/result.rb +16 -12
- data/lib/rushcheck/string.rb +12 -12
- data/lib/rushcheck/testable.rb +99 -25
- data/lib/rushcheck/testoptions.rb +20 -0
- data/lib/rushcheck/testresult.rb +25 -0
- data/lib/{rushcheck/rushcheck.rb → rushcheck.rb} +2 -1
- metadata +93 -4
- data/data/rushcheck/doc/rushcheck.txt +0 -670
@@ -0,0 +1,50 @@
|
|
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>test_batch (RushCheckConfig)</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/config.rb, line 108</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_batch</span>(<span class="ruby-identifier">gen</span>, <span class="ruby-identifier">rnd</span>, <span class="ruby-identifier">nt</span>=<span class="ruby-value">1</span>, <span class="ruby-identifier">nf</span>=<span class="ruby-value">0</span>, <span class="ruby-identifier">stamps</span>=[])
|
15
|
+
<span class="ruby-identifier">ntest</span>, <span class="ruby-identifier">nfail</span> = <span class="ruby-identifier">nt</span>, <span class="ruby-identifier">nf</span>
|
16
|
+
<span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
|
17
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">ntest</span> <span class="ruby-operator">></span> <span class="ruby-identifier">max_test</span>
|
18
|
+
<span class="ruby-identifier">tests_result</span> = <span class="ruby-constant">TestOk</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">"OK, passed"</span>, <span class="ruby-identifier">ntest</span>, <span class="ruby-identifier">stamps</span>)
|
19
|
+
<span class="ruby-keyword kw">break</span>
|
20
|
+
<span class="ruby-keyword kw">end</span>
|
21
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">nfail</span> <span class="ruby-operator">></span> <span class="ruby-identifier">max_fail</span>
|
22
|
+
<span class="ruby-identifier">test_result</span> = <span class="ruby-constant">TestExausted</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'Arguments exhausted after '</span>, <span class="ruby-identifier">ntest</span>, <span class="ruby-identifier">stamps</span>)
|
23
|
+
<span class="ruby-keyword kw">break</span>
|
24
|
+
<span class="ruby-keyword kw">end</span>
|
25
|
+
|
26
|
+
<span class="ruby-identifier">rnd_l</span>, <span class="ruby-identifier">rnd_r</span> = <span class="ruby-identifier">rnd</span>.<span class="ruby-identifier">split</span>
|
27
|
+
<span class="ruby-identifier">result</span> = <span class="ruby-identifier">gen</span>.<span class="ruby-identifier">generate</span>(<span class="ruby-identifier">size</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">ntest</span>), <span class="ruby-identifier">rnd_r</span>)
|
28
|
+
<span class="ruby-identifier">message</span> = <span class="ruby-identifier">every</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">ntest</span>, <span class="ruby-identifier">result</span>.<span class="ruby-identifier">arguments</span>)
|
29
|
+
<span class="ruby-identifier">print</span> <span class="ruby-identifier">message</span> <span class="ruby-comment cmt"># don't puts</span>
|
30
|
+
|
31
|
+
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">ok</span>
|
32
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-keyword kw">nil</span>
|
33
|
+
<span class="ruby-identifier">nfail</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
34
|
+
<span class="ruby-keyword kw">redo</span>
|
35
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-keyword kw">true</span>
|
36
|
+
<span class="ruby-identifier">stamps</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">result</span>.<span class="ruby-identifier">stamp</span>)
|
37
|
+
<span class="ruby-identifier">ntest</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
38
|
+
<span class="ruby-keyword kw">redo</span>
|
39
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-keyword kw">false</span>
|
40
|
+
<span class="ruby-identifier">tests_result</span> = <span class="ruby-constant">TestFailed</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">result</span>.<span class="ruby-identifier">arguments</span>, <span class="ruby-identifier">ntest</span>)
|
41
|
+
<span class="ruby-keyword kw">break</span>
|
42
|
+
<span class="ruby-keyword kw">else</span>
|
43
|
+
<span class="ruby-identifier">raise</span>(<span class="ruby-constant">RuntimeError</span>, <span class="ruby-value str">"RushCheck: illegal result"</span>)
|
44
|
+
<span class="ruby-keyword kw">end</span>
|
45
|
+
<span class="ruby-keyword kw">end</span>
|
46
|
+
|
47
|
+
<span class="ruby-identifier">test_result</span>
|
48
|
+
<span class="ruby-keyword kw">end</span></pre>
|
49
|
+
</body>
|
50
|
+
</html>
|
@@ -100,7 +100,7 @@ href="String.html">String</a>.
|
|
100
100
|
<h3 class="section-bar">Methods</h3>
|
101
101
|
|
102
102
|
<div class="name-list">
|
103
|
-
<a href="#
|
103
|
+
<a href="#M000021">arbitrary</a>
|
104
104
|
</div>
|
105
105
|
</div>
|
106
106
|
|
@@ -122,12 +122,12 @@ href="String.html">String</a>.
|
|
122
122
|
<div id="methods">
|
123
123
|
<h3 class="section-bar">Public Class methods</h3>
|
124
124
|
|
125
|
-
<div id="method-
|
126
|
-
<a name="
|
125
|
+
<div id="method-M000021" class="method-detail">
|
126
|
+
<a name="M000021"></a>
|
127
127
|
|
128
128
|
<div class="method-heading">
|
129
|
-
<a href="SpecialString.src/
|
130
|
-
onclick="popupCode('SpecialString.src/
|
129
|
+
<a href="SpecialString.src/M000021.html" target="Code" class="method-signature"
|
130
|
+
onclick="popupCode('SpecialString.src/M000021.html');return false;">
|
131
131
|
<span class="method-name">arbitrary</span><span class="method-args">()</span>
|
132
132
|
</a>
|
133
133
|
</div>
|
@@ -0,0 +1,37 @@
|
|
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 (SpecialString)</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/string.rb, line 77</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-identifier">f</span> = <span class="ruby-ivar">@@frequency</span>
|
16
|
+
<span class="ruby-identifier">frq</span> = []
|
17
|
+
[<span class="ruby-identifier">f</span>[<span class="ruby-value str">'alphabet'</span>],<span class="ruby-identifier">f</span>[<span class="ruby-value str">'control'</span>],<span class="ruby-identifier">f</span>[<span class="ruby-value str">'number'</span>],<span class="ruby-identifier">f</span>[<span class="ruby-value str">'special'</span>]].<span class="ruby-identifier">zip</span>(
|
18
|
+
[ <span class="ruby-ivar">@@alphabet</span>, <span class="ruby-ivar">@@control</span>, <span class="ruby-ivar">@@number</span>, <span class="ruby-ivar">@@special</span>]) <span class="ruby-keyword kw">do</span>
|
19
|
+
<span class="ruby-operator">|</span><span class="ruby-identifier">weight</span>, <span class="ruby-identifier">table</span><span class="ruby-operator">|</span>
|
20
|
+
<span class="ruby-identifier">gen</span> = <span class="ruby-constant">Gen</span>.<span class="ruby-identifier">oneof</span>(<span class="ruby-identifier">table</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span> <span class="ruby-constant">Gen</span>.<span class="ruby-identifier">unit</span>(<span class="ruby-identifier">n</span>.<span class="ruby-identifier">chr</span>)})
|
21
|
+
<span class="ruby-identifier">frq</span> <span class="ruby-operator"><<</span> [<span class="ruby-identifier">weight</span>, <span class="ruby-identifier">gen</span>]
|
22
|
+
<span class="ruby-keyword kw">end</span>
|
23
|
+
|
24
|
+
<span class="ruby-constant">Gen</span>.<span class="ruby-identifier">sized</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">m</span><span class="ruby-operator">|</span>
|
25
|
+
<span class="ruby-constant">Gen</span>.<span class="ruby-identifier">choose</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">m</span>).<span class="ruby-identifier">bind</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">len</span><span class="ruby-operator">|</span>
|
26
|
+
<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>
|
27
|
+
<span class="ruby-identifier">r2</span> = <span class="ruby-identifier">r</span>
|
28
|
+
(<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">len</span>).<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span>
|
29
|
+
<span class="ruby-identifier">r1</span>, <span class="ruby-identifier">r2</span> = <span class="ruby-identifier">r2</span>.<span class="ruby-identifier">split</span>
|
30
|
+
<span class="ruby-constant">Gen</span>.<span class="ruby-identifier">frequency</span>(<span class="ruby-identifier">frq</span>).<span class="ruby-identifier">value</span>(<span class="ruby-identifier">n</span>, <span class="ruby-identifier">r1</span>)
|
31
|
+
<span class="ruby-keyword kw">end</span>.<span class="ruby-identifier">join</span>
|
32
|
+
<span class="ruby-keyword kw">end</span>
|
33
|
+
<span class="ruby-keyword kw">end</span>
|
34
|
+
<span class="ruby-keyword kw">end</span>
|
35
|
+
<span class="ruby-keyword kw">end</span></pre>
|
36
|
+
</body>
|
37
|
+
</html>
|
@@ -94,11 +94,11 @@ functional random number generator.
|
|
94
94
|
<h3 class="section-bar">Methods</h3>
|
95
95
|
|
96
96
|
<div class="name-list">
|
97
|
-
<a href="#
|
98
|
-
<a href="#
|
99
|
-
<a href="#
|
100
|
-
<a href="#
|
101
|
-
<a href="#
|
97
|
+
<a href="#M000015">gen_next</a>
|
98
|
+
<a href="#M000017">gen_range</a>
|
99
|
+
<a href="#M000014">new</a>
|
100
|
+
<a href="#M000016">split</a>
|
101
|
+
<a href="#M000018">to_s</a>
|
102
102
|
</div>
|
103
103
|
</div>
|
104
104
|
|
@@ -151,12 +151,12 @@ left and right are two seeds of random number generator.
|
|
151
151
|
<div id="methods">
|
152
152
|
<h3 class="section-bar">Public Class methods</h3>
|
153
153
|
|
154
|
-
<div id="method-
|
155
|
-
<a name="
|
154
|
+
<div id="method-M000014" class="method-detail">
|
155
|
+
<a name="M000014"></a>
|
156
156
|
|
157
157
|
<div class="method-heading">
|
158
|
-
<a href="StdGen.src/
|
159
|
-
onclick="popupCode('StdGen.src/
|
158
|
+
<a href="StdGen.src/M000014.html" target="Code" class="method-signature"
|
159
|
+
onclick="popupCode('StdGen.src/M000014.html');return false;">
|
160
160
|
<span class="method-name">new</span><span class="method-args">(left=nil, right=nil)</span>
|
161
161
|
</a>
|
162
162
|
</div>
|
@@ -167,19 +167,19 @@ left and right are two seeds of random number generator.
|
|
167
167
|
|
168
168
|
<h3 class="section-bar">Public Instance methods</h3>
|
169
169
|
|
170
|
-
<div id="method-
|
171
|
-
<a name="
|
170
|
+
<div id="method-M000015" class="method-detail">
|
171
|
+
<a name="M000015"></a>
|
172
172
|
|
173
173
|
<div class="method-heading">
|
174
|
-
<a href="StdGen.src/
|
175
|
-
onclick="popupCode('StdGen.src/
|
174
|
+
<a href="StdGen.src/M000015.html" target="Code" class="method-signature"
|
175
|
+
onclick="popupCode('StdGen.src/M000015.html');return false;">
|
176
176
|
<span class="method-name">gen_next</span><span class="method-args">()</span>
|
177
177
|
</a>
|
178
178
|
</div>
|
179
179
|
|
180
180
|
<div class="method-description">
|
181
181
|
<p>
|
182
|
-
<a href="StdGen.html#
|
182
|
+
<a href="StdGen.html#M000015">gen_next</a> returns an array with length 2.
|
183
183
|
The first component of result is a random integer. The last component is a
|
184
184
|
new <a href="StdGen.html">StdGen</a> object as a new random number
|
185
185
|
generator. See also <a href="RandomGen.html">RandomGen</a>.
|
@@ -187,30 +187,30 @@ generator. See also <a href="RandomGen.html">RandomGen</a>.
|
|
187
187
|
</div>
|
188
188
|
</div>
|
189
189
|
|
190
|
-
<div id="method-
|
191
|
-
<a name="
|
190
|
+
<div id="method-M000017" class="method-detail">
|
191
|
+
<a name="M000017"></a>
|
192
192
|
|
193
193
|
<div class="method-heading">
|
194
|
-
<a href="StdGen.src/
|
195
|
-
onclick="popupCode('StdGen.src/
|
194
|
+
<a href="StdGen.src/M000017.html" target="Code" class="method-signature"
|
195
|
+
onclick="popupCode('StdGen.src/M000017.html');return false;">
|
196
196
|
<span class="method-name">gen_range</span><span class="method-args">()</span>
|
197
197
|
</a>
|
198
198
|
</div>
|
199
199
|
|
200
200
|
<div class="method-description">
|
201
201
|
<p>
|
202
|
-
<a href="StdGen.html#
|
202
|
+
<a href="StdGen.html#M000017">gen_range</a> returns an array with length 2
|
203
203
|
which represents a bound of generated random numbers.
|
204
204
|
</p>
|
205
205
|
</div>
|
206
206
|
</div>
|
207
207
|
|
208
|
-
<div id="method-
|
209
|
-
<a name="
|
208
|
+
<div id="method-M000016" class="method-detail">
|
209
|
+
<a name="M000016"></a>
|
210
210
|
|
211
211
|
<div class="method-heading">
|
212
|
-
<a href="StdGen.src/
|
213
|
-
onclick="popupCode('StdGen.src/
|
212
|
+
<a href="StdGen.src/M000016.html" target="Code" class="method-signature"
|
213
|
+
onclick="popupCode('StdGen.src/M000016.html');return false;">
|
214
214
|
<span class="method-name">split</span><span class="method-args">()</span>
|
215
215
|
</a>
|
216
216
|
</div>
|
@@ -223,12 +223,12 @@ href="StdGen.html">StdGen</a> objects as two new random number generators.
|
|
223
223
|
</div>
|
224
224
|
</div>
|
225
225
|
|
226
|
-
<div id="method-
|
227
|
-
<a name="
|
226
|
+
<div id="method-M000018" class="method-detail">
|
227
|
+
<a name="M000018"></a>
|
228
228
|
|
229
229
|
<div class="method-heading">
|
230
|
-
<a href="StdGen.src/
|
231
|
-
onclick="popupCode('StdGen.src/
|
230
|
+
<a href="StdGen.src/M000018.html" target="Code" class="method-signature"
|
231
|
+
onclick="popupCode('StdGen.src/M000018.html');return false;">
|
232
232
|
<span class="method-name">to_s</span><span class="method-args">()</span>
|
233
233
|
</a>
|
234
234
|
</div>
|
@@ -5,14 +5,19 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>new (StdGen)</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/random.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
15
|
-
<span class="ruby-ivar">@left</span
|
13
|
+
<pre><span class="ruby-comment cmt"># File rushcheck/random.rb, line 68</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">left</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">right</span>=<span class="ruby-keyword kw">nil</span>)
|
15
|
+
<span class="ruby-ivar">@left</span>, <span class="ruby-ivar">@right</span> = [<span class="ruby-identifier">left</span>, <span class="ruby-identifier">right</span>].<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span>
|
16
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">nil?</span>
|
17
|
+
<span class="ruby-keyword kw">then</span> <span class="ruby-identifier">random</span>
|
18
|
+
<span class="ruby-keyword kw">else</span> <span class="ruby-identifier">in_range</span>(<span class="ruby-identifier">x</span>)
|
19
|
+
<span class="ruby-keyword kw">end</span>
|
20
|
+
<span class="ruby-keyword kw">end</span>
|
16
21
|
<span class="ruby-keyword kw">end</span></pre>
|
17
22
|
</body>
|
18
23
|
</html>
|
@@ -0,0 +1,21 @@
|
|
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>gen_next (StdGen)</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/random.rb, line 80</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">gen_next</span>
|
15
|
+
<span class="ruby-identifier">s</span>, <span class="ruby-identifier">t</span> = [<span class="ruby-ivar">@left</span>, <span class="ruby-ivar">@right</span>].<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">random</span>(<span class="ruby-identifier">x</span>) }
|
16
|
+
<span class="ruby-identifier">z</span> = ((<span class="ruby-identifier">s</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">t</span>) <span class="ruby-operator">%</span> (<span class="ruby-ivar">@@max_bound</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@@min_bound</span>)) <span class="ruby-operator">+</span> <span class="ruby-ivar">@@min_bound</span>
|
17
|
+
|
18
|
+
[<span class="ruby-identifier">z</span>, <span class="ruby-constant">StdGen</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">s</span>, <span class="ruby-identifier">t</span>)]
|
19
|
+
<span class="ruby-keyword kw">end</span></pre>
|
20
|
+
</body>
|
21
|
+
</html>
|
@@ -0,0 +1,21 @@
|
|
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>split (StdGen)</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/random.rb, line 89</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">split</span>
|
15
|
+
<span class="ruby-identifier">g</span> = <span class="ruby-identifier">gen_next</span>[<span class="ruby-value">1</span>]
|
16
|
+
<span class="ruby-identifier">s</span>, <span class="ruby-identifier">t</span> = <span class="ruby-identifier">g</span>.<span class="ruby-identifier">left</span>, <span class="ruby-identifier">g</span>.<span class="ruby-identifier">right</span>
|
17
|
+
|
18
|
+
[<span class="ruby-constant">StdGen</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">s</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>, <span class="ruby-identifier">t</span>), <span class="ruby-constant">StdGen</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">s</span>, <span class="ruby-identifier">t</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>)]
|
19
|
+
<span class="ruby-keyword kw">end</span></pre>
|
20
|
+
</body>
|
21
|
+
</html>
|
@@ -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>gen_range (StdGen)</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/random.rb, line 98</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">gen_range</span>
|
15
|
+
[<span class="ruby-ivar">@@min_bound</span>, <span class="ruby-ivar">@@max_bound</span>]
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -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>to_s (StdGen)</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/random.rb, line 102</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
|
15
|
+
<span class="ruby-ivar">@left</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">' '</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@right</span>.<span class="ruby-identifier">to_s</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="#M000073">arbitrary</a>
|
90
|
+
<a href="#M000074">bound</a>
|
91
|
+
<a href="#M000076">coarbitrary</a>
|
92
|
+
<a href="#M000075">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-M000073" class="method-detail">
|
122
|
+
<a name="M000073"></a>
|
123
123
|
|
124
124
|
<div class="method-heading">
|
125
|
-
<a href="String.src/
|
126
|
-
onclick="popupCode('String.src/
|
125
|
+
<a href="String.src/M000073.html" target="Code" class="method-signature"
|
126
|
+
onclick="popupCode('String.src/M000073.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-M000074" class="method-detail">
|
136
|
+
<a name="M000074"></a>
|
137
137
|
|
138
138
|
<div class="method-heading">
|
139
|
-
<a href="String.src/
|
140
|
-
onclick="popupCode('String.src/
|
139
|
+
<a href="String.src/M000074.html" target="Code" class="method-signature"
|
140
|
+
onclick="popupCode('String.src/M000074.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-M000075" class="method-detail">
|
150
|
+
<a name="M000075"></a>
|
151
151
|
|
152
152
|
<div class="method-heading">
|
153
|
-
<a href="String.src/
|
154
|
-
onclick="popupCode('String.src/
|
153
|
+
<a href="String.src/M000075.html" target="Code" class="method-signature"
|
154
|
+
onclick="popupCode('String.src/M000075.html');return false;">
|
155
155
|
<span class="method-name">random_range</span><span class="method-args">(gen, lo=@@min_range, hi=@@max_range)</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-M000076" class="method-detail">
|
166
|
+
<a name="M000076"></a>
|
167
167
|
|
168
168
|
<div class="method-heading">
|
169
|
-
<a href="String.src/
|
170
|
-
onclick="popupCode('String.src/
|
169
|
+
<a href="String.src/M000076.html" target="Code" class="method-signature"
|
170
|
+
onclick="popupCode('String.src/M000076.html');return false;">
|
171
171
|
<span class="method-name">coarbitrary</span><span class="method-args">(g)</span>
|
172
172
|
</a>
|
173
173
|
</div>
|
@@ -0,0 +1,24 @@
|
|
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 (String)</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/string.rb, line 20</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">sized</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span>
|
16
|
+
<span class="ruby-constant">Gen</span>.<span class="ruby-identifier">choose</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">n</span>).<span class="ruby-identifier">bind</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">len</span><span class="ruby-operator">|</span>
|
17
|
+
<span class="ruby-constant">Gen</span>.<span class="ruby-identifier">vector</span>(<span class="ruby-constant">Integer</span>, <span class="ruby-identifier">len</span>).<span class="ruby-identifier">bind</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">xs</span><span class="ruby-operator">|</span>
|
18
|
+
<span class="ruby-constant">Gen</span>.<span class="ruby-identifier">unit</span>(<span class="ruby-identifier">xs</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> (<span class="ruby-identifier">x</span> <span class="ruby-operator">%</span> <span class="ruby-value">128</span>).<span class="ruby-identifier">chr</span>}.<span class="ruby-identifier">join</span>)
|
19
|
+
<span class="ruby-keyword kw">end</span>
|
20
|
+
<span class="ruby-keyword kw">end</span>
|
21
|
+
<span class="ruby-keyword kw">end</span>
|
22
|
+
<span class="ruby-keyword kw">end</span></pre>
|
23
|
+
</body>
|
24
|
+
</html>
|
@@ -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>bound (String)</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/string.rb, line 30</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_range</span>, <span class="ruby-ivar">@@max_range</span>]
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
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>random_range (String)</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/string.rb, line 34</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_range</span>, <span class="ruby-identifier">hi</span>=<span class="ruby-ivar">@@max_range</span>)
|
15
|
+
<span class="ruby-identifier">len</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>, <span class="ruby-identifier">lo</span>, <span class="ruby-identifier">hi</span>)
|
16
|
+
<span class="ruby-identifier">result</span> = <span class="ruby-value str">''</span>
|
17
|
+
<span class="ruby-identifier">len</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span>
|
18
|
+
<span class="ruby-identifier">v</span>, <span class="ruby-identifier">g</span> = <span class="ruby-constant">Integer</span>.<span class="ruby-identifier">random</span>(<span class="ruby-identifier">g</span>, <span class="ruby-value">0</span>, <span class="ruby-value">127</span>)
|
19
|
+
<span class="ruby-identifier">result</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">chr</span>
|
20
|
+
<span class="ruby-keyword kw">end</span>
|
21
|
+
|
22
|
+
[<span class="ruby-identifier">result</span>. <span class="ruby-identifier">g</span>]
|
23
|
+
<span class="ruby-keyword kw">end</span></pre>
|
24
|
+
</body>
|
25
|
+
</html>
|
@@ -0,0 +1,22 @@
|
|
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 (String)</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/string.rb, line 45</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">r</span> = <span class="ruby-identifier">g</span>.<span class="ruby-identifier">variant</span>(<span class="ruby-value">0</span>)
|
16
|
+
<span class="ruby-identifier">each_byte</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span>
|
17
|
+
<span class="ruby-identifier">r</span> = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">coarbitrary</span>(<span class="ruby-identifier">r</span>.<span class="ruby-identifier">variant</span>(<span class="ruby-value">1</span>))
|
18
|
+
<span class="ruby-keyword kw">end</span>
|
19
|
+
<span class="ruby-identifier">r</span>
|
20
|
+
<span class="ruby-keyword kw">end</span></pre>
|
21
|
+
</body>
|
22
|
+
</html>
|