rdx 0.9.0.pre → 0.9.0.pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README +186 -12
- data/TODO +18 -0
- data/examples/minimal/.rdx +1 -0
- data/examples/minimal/rakefile +5 -2
- data/examples/ruby-2.0.0-p0/install/core/BUGS +70 -0
- data/examples/ruby-2.0.0-p0/install/core/HALL_OF_SHAME +53 -0
- data/examples/ruby-2.0.0-p0/install/core/README +14 -4
- data/examples/ruby-2.0.0-p0/install/core/Rakefile +9 -4
- data/examples/ruby-2.0.0-p0/install/core/TODO +5 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/array.c.diff +8 -7
- data/examples/ruby-2.0.0-p0/install/core/diffs/encoding.c.diff +1 -1
- data/examples/ruby-2.0.0-p0/install/core/diffs/enumerator.c.diff +4 -12
- data/examples/ruby-2.0.0-p0/install/core/diffs/eval.c.diff +3 -5
- data/examples/ruby-2.0.0-p0/install/core/diffs/file.c.diff +2 -2
- data/examples/ruby-2.0.0-p0/install/core/diffs/gc.c.diff +5 -4
- data/examples/ruby-2.0.0-p0/install/core/diffs/hash.c.diff +4 -3
- data/examples/ruby-2.0.0-p0/install/core/diffs/object.c.diff +5 -4
- data/examples/ruby-2.0.0-p0/install/core/diffs/proc.c.diff +7 -6
- data/examples/ruby-2.0.0-p0/install/core/diffs/random.c.diff +3 -3
- data/examples/ruby-2.0.0-p0/install/core/diffs/rational.c.diff +21 -18
- data/examples/ruby-2.0.0-p0/install/core/diffs/ruby.c.diff +1 -1
- data/examples/ruby-2.0.0-p0/install/stdlib/DOCUMENTATION +22 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/README +12 -4
- data/examples/ruby-2.0.0-p0/install/stdlib/Rakefile +10 -5
- data/examples/ruby-2.0.0-p0/install/stdlib/TODO +6 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/optparse.rb.diff +31 -11
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/uri/common.rb.diff +8 -7
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/weakref.rb.diff +2 -2
- data/lib/rdx.rb +42 -92
- data/lib/rdx/assertions.rb +8 -9
- data/lib/rdx/binding.rb +2 -2
- data/lib/rdx/comment.rb +7 -5
- data/lib/rdx/convention.rb +10 -9
- data/lib/rdx/directive.rb +51 -26
- data/lib/rdx/example.rb +94 -68
- data/lib/rdx/generator.rb +1 -1
- data/lib/rdx/generator/rdoc.rb +5 -6
- data/lib/rdx/options.rb +7 -3
- data/lib/rdx/reporter.rb +17 -0
- data/lib/rdx/ruby_lex.rb +3 -3
- data/lib/rdx/runner.rb +1 -1
- data/lib/rdx/statement.rb +1 -1
- data/lib/rdx/store.rb +1 -1
- data/lib/rdx/task.rb +1 -1
- data/lib/rdx/text.rb +1 -1
- data/lib/rdx/version.rb +1 -1
- data/rakefile +43 -14
- metadata +23 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7347a46f1423d751c02d5ad1900d302a56c492fd
|
4
|
+
data.tar.gz: ff1cbc6b9ac0a22511e97eb24f9986cff917d02c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fd1a4d3fac453eeb3dfad2dd865bde63b881e59e9d5f6fb27ef672d6ad2fd6173407bd8d95e643d10870f07e4f83465817eafec3a550e24df305873797ca09e
|
7
|
+
data.tar.gz: b7e9ee5856ddf5a190732f93a369fe65e885f29748cc0002d887edb7034c24447b32e7c263b58483462c8e52a948d81fe9ffcf7692ca385d26502677cd98ddea
|
data/README
CHANGED
@@ -1,19 +1,193 @@
|
|
1
1
|
|
2
2
|
= RDX: Ruby Documentation example eXecutor
|
3
|
+
:rdx: off
|
4
|
+
|
5
|
+
== Synopsis
|
3
6
|
|
4
7
|
The aim of RDX is to join the worlds of documentation and testing, which overlap in examples.
|
5
|
-
Relying on RDoc and Minitest RDX parses source files, generates documentation,
|
6
|
-
examples from comments and executes them as tests.
|
7
|
-
|
8
|
-
|
8
|
+
Relying on RDoc and Minitest RDX parses source files, generates documentation,
|
9
|
+
extracts examples from comments and executes them as tests.
|
10
|
+
|
11
|
+
== Why RDX?
|
12
|
+
|
13
|
+
The whole application is built on these four cornerstones:
|
14
|
+
|
15
|
+
* Document Well and Right!<br>
|
16
|
+
The library should be well documented. The examples can be the most direct way
|
17
|
+
to explain and show the use of the library - if these have been unit tested and work fine.
|
18
|
+
|
19
|
+
* DRY (Don't Repeat Yourself)!<br>
|
20
|
+
We want to avoid - honestly, we should hate - writing the same things more than once.
|
21
|
+
It's too tedious to translate back and forth all the examples between documentation and testing.
|
22
|
+
|
23
|
+
* Join coupled parts!<br>
|
24
|
+
Source, documentation and tests are different sides of the same thing - the programmer's idea -.
|
25
|
+
When some parts are tightly coupled, the more these are close the more straightforward the eventual
|
26
|
+
fix is. Documentation tools unify documentation with the source, RDX aims to the next step.
|
27
|
+
|
28
|
+
* Be Consistent!<br>
|
29
|
+
Most scripts of the Ruby Core and many of the Standard Library already have the examples
|
30
|
+
written in a conformed and accepted way. It was this coherency that allowed (and induced)
|
31
|
+
me to write RDX: a tool can easily automate tasks if they fit well into a general scheme.
|
32
|
+
|
33
|
+
== How RDX works
|
34
|
+
|
35
|
+
In order to achieve its goal it first deals with the documentation tool
|
36
|
+
(RDoc is the most commonly used, so currently only its support is built-in) asking to keep
|
37
|
+
track of examples. These are parsed and subdivided into statements: the comment at
|
38
|
+
their end can eventually become an expectation. The tests are build according to
|
39
|
+
conventions and directives.
|
40
|
+
|
41
|
+
The *conventions*, heart of RDX, define the rules to accept the ending comments and process the code
|
42
|
+
(for example the historical hash-rocket notation, <tt>#=></tt>, is implemented in RDX::Convention::result_eval:
|
43
|
+
it evaluates both the statement and the expectation, then compares those results through +assert_equal+).
|
44
|
+
See more details in the RDX::Convention class.
|
45
|
+
|
46
|
+
While conventions affect single statements, the *directives* operate on a larger scale.
|
47
|
+
Perhaps we may want to not execute an example, to interpret one as the output of the
|
48
|
+
previous, to locally change some of the assertions methods, to run it in a temporary directory,
|
49
|
+
to simulate a bash environment, and so on...
|
50
|
+
See the RDX::Directive class for more information about them.
|
51
|
+
|
52
|
+
Both the conventions and directives can be either built-in because of their popularity in the
|
53
|
+
Ruby Community or defined for convenience by the user.
|
54
|
+
|
55
|
+
Once these tests are built, the only thing left to do is to simply run them.
|
56
|
+
As a bonus, if everything is correct, RDX's signature is added to those made by the generator
|
57
|
+
tool: the user of our library now can know that the examples showed enjoy a high level of trust.
|
58
|
+
All this with a single run, either from the command line or through rake.
|
59
|
+
|
60
|
+
== Running RDX
|
61
|
+
|
62
|
+
RDX comes with an executable. When installed, try
|
63
|
+
$ rdx --help
|
64
|
+
to have a summary of the available options.
|
65
|
+
More details are explained in the RDX::Options class.
|
66
|
+
|
67
|
+
To process all the source files in the whole current directory tree use
|
68
|
+
$ rdx .
|
69
|
+
If you forget to specify any file, the dry-run mode is turned on for security
|
70
|
+
(see the Security section).
|
71
|
+
|
72
|
+
To run RDX programmatically, use:
|
73
|
+
gem 'rdx'
|
74
|
+
require 'rdx'
|
75
|
+
RDX.run(argv)
|
76
|
+
where _argv_ is the array of command-line arguments.
|
77
|
+
|
78
|
+
Currently however it's much better to run RDX through rake:
|
79
|
+
simply define the +rdx+ task in the rakefile.
|
80
|
+
The RDX::Task class allows you to do exactly this;
|
81
|
+
start from the rakefiles in the +examples+ subdirectories.
|
82
|
+
|
83
|
+
== Using RDX
|
84
|
+
|
85
|
+
What follows is a basic illustration of RDX.
|
86
|
+
Given this source ruby file
|
87
|
+
|
88
|
+
# File: lib/try_rdx.rb
|
89
|
+
|
90
|
+
# Contains various stuff
|
91
|
+
module Util
|
92
|
+
module_function
|
93
|
+
|
94
|
+
# Always returns +true+
|
95
|
+
# Util.return_true #=> true
|
96
|
+
def return_true
|
97
|
+
return false # LIBRARY BUG!
|
98
|
+
end
|
99
|
+
|
100
|
+
# Outputs the Fixnum <tt>5</tt>
|
101
|
+
# Util.print_five # prints: 5
|
102
|
+
# # DOCUMENTATION BUG (line above)!
|
103
|
+
def print_five
|
104
|
+
print "five"
|
105
|
+
end
|
106
|
+
|
107
|
+
# This raises a +RuntimeError+
|
108
|
+
# Util.bang! # raises RuntimeError: Boom!
|
109
|
+
# # All right here...
|
110
|
+
def bang!
|
111
|
+
raise "Boom!"
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
you can run RDX (if installed) from the shell with
|
117
|
+
|
118
|
+
$ rdx -I lib -r try_rdx lib/try_rdx.rb
|
119
|
+
|
120
|
+
This will show two errors in the report,
|
121
|
+
along with the relative file name and line number location.
|
122
|
+
|
123
|
+
The only purpose here is to clearly show how to write the source files,
|
124
|
+
even if this leads to a very little, dumb example.
|
125
|
+
For more serious examples, see the +examples+ subdirectories:
|
126
|
+
* <tt>minimal</tt>: contains still dumb examples,
|
127
|
+
but aims to illustrate the most common features of RDX;
|
128
|
+
* <tt>ruby-2.0.0-p0</tt>: try RDX on Ruby itself!
|
129
|
+
Once installed (just follow the README), you'll have the possibility
|
130
|
+
to run RDX on both the Core and the Standard Library.
|
131
|
+
The source files get patched so that RDX should work fine on these
|
132
|
+
(you can anyway run RDX on the original files).
|
133
|
+
These examples are clearly the most useful and realistic ones:
|
134
|
+
the whole RDX application has been built relying on these files.
|
135
|
+
|
136
|
+
== The results
|
137
|
+
|
138
|
+
When RDX has finished we can see the report of our tests, as if we had manually written all of
|
139
|
+
them transforming the comments. In fact, it's even better: if an example has something wrong - if it
|
140
|
+
doesn't work as declared - the error points us to its location in the comment, which is just above
|
141
|
+
the source code. This makes the tracking and fixing steps incredibly easy.
|
142
|
+
|
143
|
+
Through execution, <b>RDX gives formalism to the documentation examples</b>,
|
144
|
+
greatly increasing their strength. It gives all the section of a source file the deserved emphasis,
|
145
|
+
transforming fictitious examples into living ones!
|
146
|
+
|
147
|
+
A great point in its favour is that a developer familiar with the Ruby documentation
|
148
|
+
(of course most of them) doesn't have to learn a new DSL or syntax, but just
|
149
|
+
to code and document in the "standard" way, with very few alteration.
|
150
|
+
|
151
|
+
At the end, RDX allows to easily reach the following goals:
|
152
|
+
* Found library bugs;
|
153
|
+
* Avoid dumb errors in documentation examples;
|
154
|
+
* Have a complete documentation that's also very easy to maintain.
|
155
|
+
If you have installed the Ruby examples (see examples/ruby-2.0.0-p0/README),
|
156
|
+
you can see that these targets have been easily achieved.
|
157
|
+
The respective results are reported in these file:
|
158
|
+
* <tt>examples/ruby-2.0.0-p0/core/BUGS</tt>
|
159
|
+
* <tt>examples/ruby-2.0.0-p0/core/HALL_OF_SHAME</tt>
|
160
|
+
* <tt>examples/ruby-2.0.0-p0/stdlib/DOCUMENTATION</tt>
|
161
|
+
|
162
|
+
If you find these points helpful, then RDX is for you!
|
163
|
+
|
164
|
+
== Security
|
165
|
+
|
166
|
+
The point that +RDX+ evaluates the comments leads to the topic of security.
|
167
|
+
Never run blindly RDX on libraries that haven't been written for that, since it's never
|
168
|
+
a good idea to evaluate unknown code.
|
169
|
+
|
170
|
+
If you want, first you have to scan the files and find the examples.
|
171
|
+
The <tt>--dry-run</tt> option (see RDX::Options#dry_run) may help you:
|
172
|
+
it protects you from accidental dangerous example, but keep in mind that
|
173
|
+
this mode still process RDX directives. A security hole can occur
|
174
|
+
if one of these has been written with malicious intentions...
|
175
|
+
Once you have found that the code is safe you can give RDX a try.
|
9
176
|
|
10
|
-
|
11
|
-
|
12
|
-
|
177
|
+
However, if a library has been built RDX-compatible, you can run it
|
178
|
+
from your machine - if you _trust_ the producer. If you don't
|
179
|
+
you must be very careful: even a plain +require+ can be dangerous,
|
180
|
+
with RDX you have to pay an extra attention to the comments.
|
13
181
|
|
14
|
-
|
15
|
-
to interpret one as the output of the previous, to change its binding, to run it in a
|
16
|
-
temporary directory, to simulate a bash environment, and so on...
|
182
|
+
== Common gotchas
|
17
183
|
|
18
|
-
|
19
|
-
|
184
|
+
Since the rdx library patches the documentation generator tool,
|
185
|
+
it's highly recommend to use +rake+. This because the original
|
186
|
+
executable of the generator tool (say, +rdoc+) remains unaffected:
|
187
|
+
therefore producing documentation from the command line will lead to
|
188
|
+
a slightly different output, that doesn't consider the RDX patch.
|
189
|
+
In conclusion, just run
|
190
|
+
$ rake rdoc
|
191
|
+
instead of the simpler
|
192
|
+
$ rdoc
|
193
|
+
(this is also true for documenting RDX itself).
|
data/TODO
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
Targets to be achieved for the corresponding version:
|
3
|
+
|
4
|
+
Step 1) version 0.9.5.pre
|
5
|
+
* Finish the source patches, in order to have a complete view
|
6
|
+
on all the potential useful features to be included in RDX
|
7
|
+
(see TODOs in examples/ruby-2.0.0-p0/core and examples/ruby-2.0.0-p0/stdlib)
|
8
|
+
|
9
|
+
Step 2) version 0.9.5
|
10
|
+
* Write serious tests (at this point I think the internal will be quite stable)
|
11
|
+
|
12
|
+
GOAL) version 1.0
|
13
|
+
* Release the requirement RDoc::VERSION == 4.0
|
14
|
+
* Improve general interface
|
15
|
+
|
16
|
+
Successive steps) Future enhancements
|
17
|
+
* Add support for YARD
|
18
|
+
* Allow backward compatibility for Ruby (perhaps)
|
data/examples/minimal/.rdx
CHANGED
data/examples/minimal/rakefile
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
|
2
2
|
require 'rubygems'
|
3
3
|
require 'rake'
|
4
|
-
require 'rdoc/task'
|
5
4
|
|
6
5
|
RDX_ROOT = "#{File.dirname File.dirname File.dirname __FILE__}/lib"
|
7
6
|
$LOAD_PATH.unshift RDX_ROOT
|
8
7
|
require 'rdx'
|
9
8
|
|
9
|
+
|
10
|
+
require 'rdoc/task'
|
10
11
|
rdoc_task = RDoc::Task.new do |rdoc|
|
11
12
|
rdoc.title = "RDX: minimal examples"
|
12
13
|
rdoc.rdoc_files.add 'lib/*.rb'
|
@@ -17,11 +18,13 @@ RDX::Task.new do |task|
|
|
17
18
|
task.rdoc_task = rdoc_task # Import options
|
18
19
|
# Uncomment free:
|
19
20
|
# task.files.exclude /directives/
|
21
|
+
# task.warnings = false
|
20
22
|
# task.debug = true
|
21
23
|
# task.verbose = true
|
22
24
|
# task.dry_run = true
|
23
25
|
# task.doc_output = false
|
24
26
|
# task.full_trace = true
|
25
|
-
# task.reporter = '
|
27
|
+
# task.reporter = 'summary'
|
28
|
+
# task.extra_options << '--no-warnings'
|
26
29
|
# task.show << :Success
|
27
30
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
|
2
|
+
RDX can help you find out (and therefore fix) some bugs in the library.
|
3
|
+
To prove this, what follows is a collection of the bugs found thanks to examples
|
4
|
+
(these bugs can be shown in the report):
|
5
|
+
|
6
|
+
|
7
|
+
General bugs:
|
8
|
+
|
9
|
+
* In Encoding.find (file encoding.c, line 1072):
|
10
|
+
Search the encoding with specified <i>name</i>.
|
11
|
+
<i>name</i> should be a string or symbol.
|
12
|
+
Encoding.find("US-ASCII") #=> Encoding::US_ASCII
|
13
|
+
:rdx: bug symbols aren't accepted
|
14
|
+
Encoding.find(:Shift_JIS) #=> Encoding::Shift_JIS
|
15
|
+
|
16
|
+
* In Complex.new (file complex.c, line 2082):
|
17
|
+
A complex object is either an exact or an inexact number.
|
18
|
+
Complex(1, 1) / 2 # > ((1/2)+(1/2)*i)
|
19
|
+
:rdx: bug the result is again ((1/2)+(1/2)*i)
|
20
|
+
Complex(1, 1) / 2.0 # > (0.5+0.5i)
|
21
|
+
|
22
|
+
* In Rational.new (file rational.c, line 2422):
|
23
|
+
However, when an expression has inexact factor (numerical value or
|
24
|
+
operation), will produce an inexact result.
|
25
|
+
Rational(10) / 3 #=> 10/3
|
26
|
+
:rdx: bug the result is again 10/3
|
27
|
+
Rational(10) / 3.0 #=> 3.3333333333333335
|
28
|
+
|
29
|
+
|
30
|
+
Platform-specific bugs:
|
31
|
+
|
32
|
+
* In File::Stat#nlink (file file.c, line 481):
|
33
|
+
Returns the number of hard links to <i>stat</i>.
|
34
|
+
File.stat("testfile").nlink #=> 1
|
35
|
+
File.link("testfile", "testfile.bak") #=> 0
|
36
|
+
:rdx: bug on x64-mingw32 I obtained 1
|
37
|
+
File.stat("testfile").nlink #=> 2
|
38
|
+
|
39
|
+
* In ObjectSpace (file gc.c, line 4449):
|
40
|
+
ObjectSpace also provides support for object finalizers, procs that will be
|
41
|
+
called when a specific object is about to be destroyed by garbage
|
42
|
+
collection.
|
43
|
+
:rdx: bug on x64-mingw32 seems that the last object defined (c) isn't garbaged in this cycle...
|
44
|
+
:rdx: indicative_numbers
|
45
|
+
include ObjectSpace
|
46
|
+
a = "A"
|
47
|
+
b = "B"
|
48
|
+
c = "C"
|
49
|
+
define_finalizer(a, proc {|id| puts "Finalizer one on #{id}" })
|
50
|
+
define_finalizer(b, proc {|id| puts "Finalizer two on #{id}" })
|
51
|
+
define_finalizer(c, proc {|id| puts "Finalizer three on #{id}" })
|
52
|
+
a = b = c = nil; # Now those strings are no more referenced,
|
53
|
+
# but still alive until the next GC cycle...
|
54
|
+
GC.start # Garbage unreferenced objects now
|
55
|
+
<em>produces (your numbers may vary):</em>
|
56
|
+
:rdx: output
|
57
|
+
Finalizer one on 537763480
|
58
|
+
Finalizer two on 537763460
|
59
|
+
Finalzer three on 537763440
|
60
|
+
|
61
|
+
* In documentation (file doc/syntax/calling_methods.rdoc, line 303):
|
62
|
+
If the method definition uses <code>**</code> to gather arbitrary keyword
|
63
|
+
arguments they will not be gathered by <code>*</code>:
|
64
|
+
:rdx: bug on x64-mingw32 (but not on i386-mingw32) "3"=>4 is not captured by keywords
|
65
|
+
def my_method(*a, **kw)
|
66
|
+
p arguments: a, keywords: kw
|
67
|
+
end
|
68
|
+
my_method(1, 2, '3' => 4, five: 6)
|
69
|
+
Produces:
|
70
|
+
{:arguments=>[1, 2], :keywords=>{"3"=>4, :five=>6}}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
|
2
|
+
RDX can avoid commit errors in documentation examples.
|
3
|
+
To prove this, what follows is a collection of the best (worst) mistakes.
|
4
|
+
|
5
|
+
|
6
|
+
#7 - In Proc#arity:
|
7
|
+
Returns the number of arguments that would not be ignored.
|
8
|
+
[...]
|
9
|
+
proc { |x=0, y| }.arity #=> 0 # Epic Fail! (file proc.c, line 652)
|
10
|
+
|
11
|
+
|
12
|
+
#6 - In Array.new:
|
13
|
+
[...]
|
14
|
+
An array can also be created by explicitly calling Array.new with zero, one
|
15
|
+
(the initial size of the Array) or two arguments (the initial size and a
|
16
|
+
default object).
|
17
|
+
[...]
|
18
|
+
Array.new(3, true) #=> [0, 0, 0] # Epic Fail! (file array.c, line 5225)
|
19
|
+
|
20
|
+
|
21
|
+
#5 - In Rational#-:
|
22
|
+
Performs subtraction.
|
23
|
+
[...]
|
24
|
+
Rational(9, 8) - 4 #=> (23/8) # Epic Fail! (file rational.c, line 752)
|
25
|
+
|
26
|
+
|
27
|
+
#4 - In Hash.new:
|
28
|
+
[...]
|
29
|
+
Or by using the #default= method:
|
30
|
+
grades = {"Timmy Doe" => 8}
|
31
|
+
grades.default = 0
|
32
|
+
Accessing a value in a Hash requires using its key:
|
33
|
+
puts grades["Jane Doe"] # => 10 # Epic Fail! (file hash.c, line 3350)
|
34
|
+
|
35
|
+
|
36
|
+
#3 - In Kernel#Hash:
|
37
|
+
Converts <i>arg</i> to a <code>Hash</code> by calling
|
38
|
+
<i>arg</i><code>.to_hash</code>. Returns an empty <code>Hash</code> when
|
39
|
+
<i>arg</i> is <tt>nil</tt> or <tt>[]</tt>.
|
40
|
+
Hash([]) #=> {}
|
41
|
+
Hash(nil) #=> nil # Epic Fail! (file object.c, line 2787)
|
42
|
+
|
43
|
+
|
44
|
+
#2 - In Rational#floor:
|
45
|
+
Returns the truncated value (toward negative infinity).
|
46
|
+
[...]
|
47
|
+
Rational(-3, 2).floor #=> -1 # Epic Fail! (file rational.c, line 1284)
|
48
|
+
|
49
|
+
|
50
|
+
#1 - In Rational#+:
|
51
|
+
Performs addition.
|
52
|
+
[...]
|
53
|
+
Rational(900) + Rational(1) #=> 900/1 # Epic Fail! (file rational.c, line 710)
|
@@ -2,18 +2,28 @@
|
|
2
2
|
Directory structure:
|
3
3
|
|
4
4
|
core
|
5
|
+
|
|
5
6
|
|- README (this file)
|
6
7
|
|
|
7
8
|
|- orig
|
8
|
-
| +
|
9
|
+
| + Contains original (Ruby 2.0.0-p0) files (C sources and documentation ones)
|
9
10
|
|
|
10
11
|
|- patched
|
11
|
-
| +
|
12
|
+
| + Contains patched files (RDX works correctly on these)
|
12
13
|
|
|
13
14
|
|- rakefile
|
14
15
|
| Allows an easy interface for running RDX.
|
15
|
-
| The most useful action is to run
|
16
|
+
| The most useful action is to run:
|
16
17
|
| rake rdx
|
18
|
+
| You can also run RDX on the original files, but you'll encounter
|
19
|
+
| troubles (nothing harmful, anyway). Just use:
|
20
|
+
| rake rdx_on_orig
|
17
21
|
|
|
18
22
|
+- .rdx
|
19
|
-
|
23
|
+
| Contains the RDX::Specification
|
24
|
+
|
|
25
|
+
+- BUGS
|
26
|
+
| Contains the list of bugs in the Ruby interpreter found thanks to RDX
|
27
|
+
|
|
28
|
+
+- HALL_OF_SHAME
|
29
|
+
Contains the list of most relevant mistakes in documentation examples found thanks to RDX
|
@@ -1,4 +1,10 @@
|
|
1
1
|
|
2
|
+
current_ruby = "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
|
3
|
+
build_ruby = '2.0.0-p0'
|
4
|
+
unless current_ruby == build_ruby
|
5
|
+
raise "Run this example with Ruby #{build_ruby} (detected #{current_ruby})"
|
6
|
+
end
|
7
|
+
|
2
8
|
require 'rubygems'
|
3
9
|
require 'rake'
|
4
10
|
require 'pathname'
|
@@ -35,10 +41,9 @@ rdoc_task = RDoc::Task.new do |rdoc|
|
|
35
41
|
end
|
36
42
|
|
37
43
|
|
38
|
-
RDX::Task.new do |task|
|
39
|
-
# Do not touch:
|
40
|
-
task.name = :rdx_on_orig
|
44
|
+
RDX::Task.new :rdx_on_orig do |task|
|
41
45
|
task.description = 'Run RDX on the original core sources'
|
46
|
+
# Do not touch:
|
42
47
|
task.files.add OLD
|
43
48
|
# This will show where troubles happen:
|
44
49
|
task.verbose = true
|
@@ -46,8 +51,8 @@ end
|
|
46
51
|
|
47
52
|
|
48
53
|
RDX::Task.new do |task|
|
49
|
-
# Do not touch:
|
50
54
|
task.description = 'Run RDX on the patched core sources'
|
55
|
+
# Do not touch:
|
51
56
|
task.rdoc_task = rdoc_task
|
52
57
|
task.require_lib 'continuation'
|
53
58
|
task.require_lib 'fiber'
|