rdx 0.9.0.pre
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 +7 -0
- data/.rdx +20 -0
- data/README +19 -0
- data/bin/rdx +7 -0
- data/examples/minimal/.rdx +8 -0
- data/examples/minimal/README +10 -0
- data/examples/minimal/lib/other_conventions.rb +64 -0
- data/examples/minimal/lib/the_basics.rb +94 -0
- data/examples/minimal/lib/using_directives.rb +66 -0
- data/examples/minimal/rakefile +27 -0
- data/examples/ruby-2.0.0-p0/README +7 -0
- data/examples/ruby-2.0.0-p0/install/core/.rdx +6 -0
- data/examples/ruby-2.0.0-p0/install/core/README +19 -0
- data/examples/ruby-2.0.0-p0/install/core/Rakefile +61 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/array.c.diff +166 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/bignum.c.diff +11 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/class.c.diff +36 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/compar.c.diff +11 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/complex.c.diff +301 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/cont.c.diff +65 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/dir.c.diff +147 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/re.rdoc.diff +328 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/security.rdoc.diff +8 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/standard_library.rdoc.diff +0 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax.rdoc.diff +0 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/assignment.rdoc.diff +160 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/calling_methods.rdoc.diff +130 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/control_expressions.rdoc.diff +254 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/exceptions.rdoc.diff +0 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/literals.rdoc.diff +54 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/methods.rdoc.diff +157 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/miscellaneous.rdoc.diff +91 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/modules_and_classes.rdoc.diff +161 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/precedence.rdoc.diff +8 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/refinements.rdoc.diff +146 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/encoding.c.diff +276 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/enum.c.diff +281 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/enumerator.c.diff +479 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/error.c.diff +143 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/eval.c.diff +47 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/eval_jump.c.diff +23 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/file.c.diff +752 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/gc.c.diff +195 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/hash.c.diff +84 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/iseq.c.diff +354 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/load.c.diff +53 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/marshal.c.diff +98 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/math.c.diff +110 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/numeric.c.diff +103 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/object.c.diff +295 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/pack.c.diff +18 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/parse.y.diff +23 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/proc.c.diff +155 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/random.c.diff +126 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/range.c.diff +49 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/rational.c.diff +312 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/re.c.diff +207 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/ruby.c.diff +21 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/signal.c.diff +67 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/sprintf.c.diff +29 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/string.c.diff +73 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/struct.c.diff +20 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/time.c.diff +691 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/transcode.c.diff +435 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/variable.c.diff +62 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/vm_backtrace.c.diff +164 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/vm_eval.c.diff +99 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/vm_method.c.diff +17 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/vm_trace.c.diff +393 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/.rdx +6 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/README +19 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/Rakefile +53 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/abbrev.rb.diff +77 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/base64.rb.diff +42 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/benchmark.rb.diff +144 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/cmath.rb.diff +52 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/forwardable.rb.diff +150 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/mathn.rb.diff +58 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/matrix.rb.diff +657 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/observer.rb.diff +31 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/optparse.rb.diff +147 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/ostruct.rb.diff +78 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/prime.rb.diff +52 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/pstore.rb.diff +110 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/scanf.rb.diff +100 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/securerandom.rb.diff +144 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/set.rb.diff +637 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/shellwords.rb.diff +66 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/singleton.rb.diff +37 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/tempfile.rb.diff +104 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/thread.rb.diff +38 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/time.rb.diff +140 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/tmpdir.rb.diff +52 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/uri.rb.diff +39 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/uri/common.rb.diff +237 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/weakref.rb.diff +36 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/yaml/store.rb.diff +27 -0
- data/examples/ruby-2.0.0-p0/rakefile +165 -0
- data/lib/rdx.rb +331 -0
- data/lib/rdx/assertions.rb +484 -0
- data/lib/rdx/binding.rb +151 -0
- data/lib/rdx/code_object.rb +598 -0
- data/lib/rdx/comment.rb +338 -0
- data/lib/rdx/convention.rb +1174 -0
- data/lib/rdx/directive.rb +1432 -0
- data/lib/rdx/example.rb +679 -0
- data/lib/rdx/generator.rb +112 -0
- data/lib/rdx/generator/rdoc.rb +1006 -0
- data/lib/rdx/options.rb +359 -0
- data/lib/rdx/plain_text.rb +65 -0
- data/lib/rdx/reporter.rb +421 -0
- data/lib/rdx/ruby_lex.rb +324 -0
- data/lib/rdx/runner.rb +309 -0
- data/lib/rdx/source_file.rb +94 -0
- data/lib/rdx/specification.rb +194 -0
- data/lib/rdx/statement.rb +248 -0
- data/lib/rdx/store.rb +119 -0
- data/lib/rdx/task.rb +361 -0
- data/lib/rdx/text.rb +688 -0
- data/lib/rdx/version.rb +15 -0
- data/rakefile +64 -0
- metadata +203 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4829fee222c87078e0a61f49a92e3fa8aeb72508
|
4
|
+
data.tar.gz: 721963819a469824512101cdcb6cd38e82cf1883
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 879dd564e894198bbd70538468e374c3e8252765355a5b2de018897dd47a0cd7230da6d8dbfc3d0bb255bca6fd73ccd9bf9f39f25d0484c28a0b07c6be5673ee
|
7
|
+
data.tar.gz: 3b5ee5fb739942e3119e06bf6d31d6ca6df28c1831e70134e9d83adf57626958946c36cb2493f47ae55de9be56967d158a65014baa0ce48512a80275c8abf3f1
|
data/.rdx
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
RDX::Specification.new do
|
3
|
+
use_convention :result_indicative
|
4
|
+
use_convention :result_inspect
|
5
|
+
use_convention :numeric_inspect
|
6
|
+
use_convention :output_eval
|
7
|
+
use_convention :error_eval
|
8
|
+
define_convention :pass do
|
9
|
+
build_pattern /[Pp]ass(?:es)?!?/, :END_CODE_IN_LINE
|
10
|
+
process_statement{ |code| lambda{ eval(code) } }
|
11
|
+
dont_process_expectation
|
12
|
+
process_assertion{ |passing_proc| assert_nothing_raised(RDX::Assertion,&passing_proc) }
|
13
|
+
end
|
14
|
+
define_convention :fail do
|
15
|
+
build_pattern /[Ff]ails?!?/, :END_CODE_IN_LINE
|
16
|
+
process_statement{ |code| lambda{ eval(code) } }
|
17
|
+
dont_process_expectation
|
18
|
+
process_assertion{ |failing_proc| assert_raises(RDX::Assertion,&failing_proc) }
|
19
|
+
end
|
20
|
+
end
|
data/README
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
= RDX: Ruby Documentation example eXecutor
|
3
|
+
|
4
|
+
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, extracts
|
6
|
+
examples from comments and executes them as tests.
|
7
|
+
In the examples the significant data of a statement - like result, output or raised exception -
|
8
|
+
is pointed out with a comment at its end.
|
9
|
+
|
10
|
+
The conventions, heart of RDX, map specific patterns into those comments to a way of processing code
|
11
|
+
(for instance the hash-rocket convention "#=>" - pioneer from IRB - simply evals both statement and expectation
|
12
|
+
and compare those results through assert_equal).
|
13
|
+
|
14
|
+
Directives (explicit or implicit) operate on a larger scale: we may want not to execute an example,
|
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...
|
17
|
+
|
18
|
+
Either conventions and directives can be built-in because of their popularity or defined by the user.
|
19
|
+
By running those tests, RDX gives formalism to documentation examples, greatly increasing their strength.
|
data/bin/rdx
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
|
2
|
+
This directory contains a minimal example that shows the use of RDX.
|
3
|
+
|
4
|
+
To begin, launch
|
5
|
+
rake rdx
|
6
|
+
from the command line.
|
7
|
+
|
8
|
+
There will be many failures during the run: in this way you can see how this works.
|
9
|
+
|
10
|
+
You can then try to edit those files and the rakefile...
|
@@ -0,0 +1,64 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# The conventions in these examples are not default:
|
4
|
+
# you should add <tt>use_convention</tt> _name_ in the specification.
|
5
|
+
#
|
6
|
+
class OtherConventions
|
7
|
+
|
8
|
+
#
|
9
|
+
# Shows the result of +inspect+:
|
10
|
+
#
|
11
|
+
# # A success:
|
12
|
+
# /a/.match "asd" # > #<MatchData "a">
|
13
|
+
#
|
14
|
+
# # A failure:
|
15
|
+
# /a/.match "asd" # > #<Match "a">
|
16
|
+
#
|
17
|
+
def result_inspect
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# Shows an indicative result:
|
22
|
+
#
|
23
|
+
# # A success:
|
24
|
+
# rand(100) # -> 58
|
25
|
+
#
|
26
|
+
# # A failure:
|
27
|
+
# rand(100) # -> 0.7845
|
28
|
+
#
|
29
|
+
def result_indicative
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# +eval+ the output:
|
34
|
+
#
|
35
|
+
# # A success:
|
36
|
+
# puts "A line", " another line"
|
37
|
+
# # >> "A line\n another line\n"
|
38
|
+
#
|
39
|
+
# # A success with a Regexp:
|
40
|
+
# puts "A line", " another line"
|
41
|
+
# # >> /\sline\s/
|
42
|
+
#
|
43
|
+
# # A failure:
|
44
|
+
# puts "Some spaces: "
|
45
|
+
# # >> "Some spaces: "
|
46
|
+
#
|
47
|
+
def output_eval
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# <tt>eval</tt>s the exception message:
|
52
|
+
#
|
53
|
+
# # A success:
|
54
|
+
# raise ArgumentError, "Wrong number of arguments: 0 for (1..2)"
|
55
|
+
# # ~> ArgumentError: /\AWrong number of arguments: \d for \(\d\.\.\d\)\z/
|
56
|
+
#
|
57
|
+
# # A failure:
|
58
|
+
# raise 'An error occurred!'
|
59
|
+
# # ~> "An error"
|
60
|
+
#
|
61
|
+
def error_eval
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
#
|
2
|
+
# This is the file comment
|
3
|
+
#
|
4
|
+
|
5
|
+
#
|
6
|
+
# The basics on how RDX works.
|
7
|
+
#
|
8
|
+
# This comment is documenting (for the class).
|
9
|
+
#
|
10
|
+
# This is a text section
|
11
|
+
#
|
12
|
+
# # This is an example
|
13
|
+
#
|
14
|
+
# This is another text section.
|
15
|
+
#
|
16
|
+
# # And this is another example
|
17
|
+
#
|
18
|
+
class TheBasics
|
19
|
+
|
20
|
+
#
|
21
|
+
# A few +result_eval+ conventions:
|
22
|
+
#
|
23
|
+
# true #=> true # this will pass
|
24
|
+
# true #=> false # but this one won't...
|
25
|
+
#
|
26
|
+
# The expectation can begin in the next line:
|
27
|
+
#
|
28
|
+
# true
|
29
|
+
# # => false
|
30
|
+
#
|
31
|
+
# And you will see this failure. If this is evalued
|
32
|
+
# it can also span across multiple lines:
|
33
|
+
#
|
34
|
+
# [1,2,3] #=> [1,
|
35
|
+
# # 2,
|
36
|
+
# # 3,
|
37
|
+
# # 4]
|
38
|
+
#
|
39
|
+
# And even here the failure is reported.
|
40
|
+
#
|
41
|
+
def result_eval
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
# The +output_literal+ convention:
|
46
|
+
#
|
47
|
+
# # A success:
|
48
|
+
# puts 'Hello world!' # prints: Hello world!
|
49
|
+
#
|
50
|
+
# # A failure:
|
51
|
+
# puts 'Hello world!' # prints: HelloWorld!
|
52
|
+
#
|
53
|
+
def output_literal
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
# The +error_literal+ convention:
|
58
|
+
#
|
59
|
+
# # A success specifying the class:
|
60
|
+
# raise 'Boom!' # raises: RuntimeError
|
61
|
+
#
|
62
|
+
# # A success specifying both the class and message:
|
63
|
+
# raise 'Boom!' # raises RuntimeError: Boom!
|
64
|
+
#
|
65
|
+
# # This will also succeed if the message is partial:
|
66
|
+
# raise 'Undefined method "asd" for an object'
|
67
|
+
# # raises RuntimeError: Undefined method "asd"
|
68
|
+
#
|
69
|
+
def error_literal
|
70
|
+
end
|
71
|
+
|
72
|
+
#
|
73
|
+
# An example won't stop if a failure is encountered:
|
74
|
+
#
|
75
|
+
# 1 #=> 2
|
76
|
+
# 2 #=> 3
|
77
|
+
#
|
78
|
+
# You will see both these failures.
|
79
|
+
#
|
80
|
+
# Neither an error will stop it if there is an expectation:
|
81
|
+
#
|
82
|
+
# raise #=> nil # expectation: the rest is supposed to be runned
|
83
|
+
# true #=> false # so this will be reported
|
84
|
+
# raise # nothing here -> the error is unexpected, so it terminates this example
|
85
|
+
# 1 #=> 4 # and this won't be executed and reported
|
86
|
+
#
|
87
|
+
# However the execution will continue in this comment in other example:
|
88
|
+
#
|
89
|
+
# 1 #=> 5 # this will be seen
|
90
|
+
#
|
91
|
+
def failures
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# Let's make things more intresting using some +directive+!
|
4
|
+
#
|
5
|
+
class UsingDirectives
|
6
|
+
|
7
|
+
#
|
8
|
+
# Turn on/off RDX processing for examples:
|
9
|
+
#
|
10
|
+
# 1 #=> 2 # seen
|
11
|
+
# \:rdx: off
|
12
|
+
# :rdx: off
|
13
|
+
# 1 #=> 2 # not seen
|
14
|
+
# may contain anything!!!
|
15
|
+
# \:rdx: on
|
16
|
+
# :rdx: on
|
17
|
+
# 1 #=> 2 # seen again
|
18
|
+
#
|
19
|
+
def on_off
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# Specifies the output:
|
24
|
+
#
|
25
|
+
# puts 'Line 1', 'Line 2'
|
26
|
+
# # other stuff...
|
27
|
+
# true #=> true # an expectation
|
28
|
+
# puts 'Line 3'
|
29
|
+
# \:rdx: output
|
30
|
+
# :rdx: output
|
31
|
+
# Line 1
|
32
|
+
# Line 2
|
33
|
+
# Line 3
|
34
|
+
# Line 4 (missing)
|
35
|
+
#
|
36
|
+
# It's also recognized in a text section that contains only <tt>produces:</tt>.
|
37
|
+
# This allow you to write the comments in this way:
|
38
|
+
#
|
39
|
+
# puts 'a'
|
40
|
+
# puts 'b'
|
41
|
+
# puts 'c'
|
42
|
+
#
|
43
|
+
# produces:
|
44
|
+
#
|
45
|
+
# a
|
46
|
+
# b
|
47
|
+
# d
|
48
|
+
#
|
49
|
+
# And you will see this in the report
|
50
|
+
#
|
51
|
+
def output
|
52
|
+
end
|
53
|
+
|
54
|
+
# Simulates a bash session.
|
55
|
+
# This is recognized implicitly:
|
56
|
+
#
|
57
|
+
# $ cat > tty_file.rdx <<EOS
|
58
|
+
# > Hello world!!!
|
59
|
+
# > EOS
|
60
|
+
# $ ls | grep "\.rdx$"
|
61
|
+
# tty_file.rdx
|
62
|
+
#
|
63
|
+
def bash
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
require 'rdoc/task'
|
5
|
+
|
6
|
+
RDX_ROOT = "#{File.dirname File.dirname File.dirname __FILE__}/lib"
|
7
|
+
$LOAD_PATH.unshift RDX_ROOT
|
8
|
+
require 'rdx'
|
9
|
+
|
10
|
+
rdoc_task = RDoc::Task.new do |rdoc|
|
11
|
+
rdoc.title = "RDX: minimal examples"
|
12
|
+
rdoc.rdoc_files.add 'lib/*.rb'
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
RDX::Task.new do |task|
|
17
|
+
task.rdoc_task = rdoc_task # Import options
|
18
|
+
# Uncomment free:
|
19
|
+
# task.files.exclude /directives/
|
20
|
+
# task.debug = true
|
21
|
+
# task.verbose = true
|
22
|
+
# task.dry_run = true
|
23
|
+
# task.doc_output = false
|
24
|
+
# task.full_trace = true
|
25
|
+
# task.reporter = 'essential'
|
26
|
+
# task.show << :Success
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
Directory structure:
|
3
|
+
|
4
|
+
core
|
5
|
+
|- README (this file)
|
6
|
+
|
|
7
|
+
|- orig
|
8
|
+
| + Original (Ruby 2.0.0p0) files (C sources and documentation ones)
|
9
|
+
|
|
10
|
+
|- patched
|
11
|
+
| + Patched files (RDX works correctly on these)
|
12
|
+
|
|
13
|
+
|- rakefile
|
14
|
+
| Allows an easy interface for running RDX.
|
15
|
+
| The most useful action is to run
|
16
|
+
| rake rdx
|
17
|
+
|
|
18
|
+
+- .rdx
|
19
|
+
Contains the RDX::Specification
|
@@ -0,0 +1,61 @@
|
|
1
|
+
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
OLD = 'orig'
|
7
|
+
NEW = 'patched'
|
8
|
+
|
9
|
+
RDX_ROOT = Pathname(__FILE__).dirname.dirname.dirname.dirname + 'lib'
|
10
|
+
$LOAD_PATH.unshift RDX_ROOT
|
11
|
+
require 'rdx'
|
12
|
+
|
13
|
+
|
14
|
+
require 'rdoc/task'
|
15
|
+
rdoc_task = RDoc::Task.new do |rdoc|
|
16
|
+
# Do not touch:
|
17
|
+
rdoc.options << "--root=#{NEW}"
|
18
|
+
rdoc.options << '--all'
|
19
|
+
# Files to be parsed (will be passed to RDX):
|
20
|
+
# Base names of C source files:
|
21
|
+
%w[
|
22
|
+
*
|
23
|
+
].each{ |fname| rdoc.rdoc_files.add "#{NEW}/#{fname}.c" }
|
24
|
+
# Base names of documentation files:
|
25
|
+
%w[
|
26
|
+
*
|
27
|
+
].each{ |fname| rdoc.rdoc_files.add "#{NEW}/doc/**/#{fname}.rdoc" }
|
28
|
+
# Base names of C source files to exclude:
|
29
|
+
%w[
|
30
|
+
|
31
|
+
].each{ |fname| rdoc.rdoc_files.exclude "#{NEW}/#{fname}.c" }
|
32
|
+
# Insert what you want here:
|
33
|
+
rdoc.options << '--line-numbers' << '--tab-width=2'
|
34
|
+
rdoc.rdoc_dir = "rdoc"
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
RDX::Task.new do |task|
|
39
|
+
# Do not touch:
|
40
|
+
task.name = :rdx_on_orig
|
41
|
+
task.description = 'Run RDX on the original core sources'
|
42
|
+
task.files.add OLD
|
43
|
+
# This will show where troubles happen:
|
44
|
+
task.verbose = true
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
RDX::Task.new do |task|
|
49
|
+
# Do not touch:
|
50
|
+
task.description = 'Run RDX on the patched core sources'
|
51
|
+
task.rdoc_task = rdoc_task
|
52
|
+
task.require_lib 'continuation'
|
53
|
+
task.require_lib 'fiber'
|
54
|
+
# Uncomment free:
|
55
|
+
# task.debug = true
|
56
|
+
# task.verbose = true
|
57
|
+
# task.show << :Skip
|
58
|
+
# task.dry_run = true
|
59
|
+
# Comment free:
|
60
|
+
task.doc_output = false
|
61
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
--- core/orig/array.c 2015-06-11 07:51:44 +0000
|
2
|
+
+++ core/patched/array.c 2015-06-25 17:48:02 +0000
|
3
|
+
@@ -571,6 +571,7 @@
|
4
|
+
* Array.try_convert([1]) #=> [1]
|
5
|
+
* Array.try_convert("1") #=> nil
|
6
|
+
*
|
7
|
+
+ * :rdx: off
|
8
|
+
* if tmp = Array.try_convert(arg)
|
9
|
+
* # the argument is an array
|
10
|
+
* elsif tmp = String.try_convert(arg)
|
11
|
+
@@ -1287,7 +1288,7 @@
|
12
|
+
* a.fetch(-1) #=> 44
|
13
|
+
* a.fetch(4, 'cat') #=> "cat"
|
14
|
+
* a.fetch(100) { |i| puts "#{i} is out of bounds" }
|
15
|
+
- * #=> "100 is out of bounds"
|
16
|
+
+ * # prints: 100 is out of bounds
|
17
|
+
*/
|
18
|
+
|
19
|
+
static VALUE
|
20
|
+
@@ -1571,16 +1572,16 @@
|
21
|
+
* See also Array#push, and Array#unshift.
|
22
|
+
*
|
23
|
+
* a = Array.new
|
24
|
+
- * a[4] = "4"; #=> [nil, nil, nil, nil, "4"]
|
25
|
+
- * a[0, 3] = [ 'a', 'b', 'c' ] #=> ["a", "b", "c", nil, "4"]
|
26
|
+
- * a[1..2] = [ 1, 2 ] #=> ["a", 1, 2, nil, "4"]
|
27
|
+
- * a[0, 2] = "?" #=> ["?", 2, nil, "4"]
|
28
|
+
- * a[0..2] = "A" #=> ["A", "4"]
|
29
|
+
- * a[-1] = "Z" #=> ["A", "Z"]
|
30
|
+
- * a[1..-1] = nil #=> ["A", nil]
|
31
|
+
- * a[1..-1] = [] #=> ["A"]
|
32
|
+
- * a[0, 0] = [ 1, 2 ] #=> [1, 2, "A"]
|
33
|
+
- * a[3, 0] = "B" #=> [1, 2, "A", "B"]
|
34
|
+
+ * a[4] = "4"; a #=> [nil, nil, nil, nil, "4"]
|
35
|
+
+ * a[0, 3] = [ 'a', 'b', 'c' ]; a #=> ["a", "b", "c", nil, "4"]
|
36
|
+
+ * a[1..2] = [ 1, 2 ]; a #=> ["a", 1, 2, nil, "4"]
|
37
|
+
+ * a[0, 2] = "?"; a #=> ["?", 2, nil, "4"]
|
38
|
+
+ * a[0..2] = "A"; a #=> ["A", "4"]
|
39
|
+
+ * a[-1] = "Z"; a #=> ["A", "Z"]
|
40
|
+
+ * a[1..-1] = nil; a #=> ["A", nil]
|
41
|
+
+ * a[1..-1] = []; a #=> ["A"]
|
42
|
+
+ * a[0, 0] = [ 1, 2 ]; a #=> [1, 2, "A"]
|
43
|
+
+ * a[3, 0] = "B"; a #=> [1, 2, "A", "B"]
|
44
|
+
*/
|
45
|
+
|
46
|
+
static VALUE
|
47
|
+
@@ -2422,7 +2423,7 @@
|
48
|
+
*
|
49
|
+
* ary = [0, 4, 7, 10, 12]
|
50
|
+
* # try to find v such that 4 <= v < 8
|
51
|
+
- * ary.bsearch {|x| 1 - x / 4 } #=> 4 or 7
|
52
|
+
+ * ary.bsearch {|x| 1 - x / 4 } # -> 4 # may be 4 or 7
|
53
|
+
* # try to find v such that 8 <= v < 10
|
54
|
+
* ary.bsearch {|x| 4 - x / 2 } #=> nil
|
55
|
+
*
|
56
|
+
@@ -3344,8 +3345,8 @@
|
57
|
+
*
|
58
|
+
* [ 1, 2, 3 ] + [ 4, 5 ] #=> [ 1, 2, 3, 4, 5 ]
|
59
|
+
* a = [ "a", "b", "c" ]
|
60
|
+
- * a + [ "d", "e", "f" ]
|
61
|
+
- * a #=> [ "a", "b", "c", "d", "e", "f" ]
|
62
|
+
+ * a + [ "d", "e", "f" ] #=> [ "a", "b", "c", "d", "e", "f" ]
|
63
|
+
+ * a #=> [ "a", "b", "c" ]
|
64
|
+
*
|
65
|
+
* See also Array#concat.
|
66
|
+
*/
|
67
|
+
@@ -4325,11 +4326,11 @@
|
68
|
+
* Returns a new array with elements of +self+ shuffled.
|
69
|
+
*
|
70
|
+
* a = [ 1, 2, 3 ] #=> [1, 2, 3]
|
71
|
+
- * a.shuffle #=> [2, 3, 1]
|
72
|
+
+ * a.shuffle #-> [2, 3, 1]
|
73
|
+
*
|
74
|
+
* The optional +rng+ argument will be used as the random number generator.
|
75
|
+
*
|
76
|
+
- * a.shuffle(random: Random.new(1)) #=> [1, 3, 2]
|
77
|
+
+ * a.shuffle(random: Random.new(1)) #-> [1, 3, 2]
|
78
|
+
*/
|
79
|
+
|
80
|
+
static VALUE
|
81
|
+
@@ -4360,8 +4361,8 @@
|
82
|
+
* The optional +rng+ argument will be used as the random number generator.
|
83
|
+
*
|
84
|
+
* a = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
|
85
|
+
- * a.sample #=> 7
|
86
|
+
- * a.sample(4) #=> [6, 4, 2, 5]
|
87
|
+
+ * a.sample #-> 7
|
88
|
+
+ * a.sample(4) #-> [6, 4, 2, 5]
|
89
|
+
*/
|
90
|
+
|
91
|
+
|
92
|
+
@@ -4502,8 +4503,10 @@
|
93
|
+
* If no block is given, an Enumerator is returned instead.
|
94
|
+
*
|
95
|
+
* a = ["a", "b", "c"]
|
96
|
+
- * a.cycle { |x| puts x } # print, a, b, c, a, b, c,.. forever.
|
97
|
+
- * a.cycle(2) { |x| puts x } # print, a, b, c, a, b, c.
|
98
|
+
+ * :rdx: off
|
99
|
+
+ * a.cycle { |x| print x } # prints abcabcabc... forever
|
100
|
+
+ * :rdx:
|
101
|
+
+ * a.cycle(2) { |x| print x } # prints abcabc
|
102
|
+
*
|
103
|
+
*/
|
104
|
+
|
105
|
+
@@ -5222,7 +5225,7 @@
|
106
|
+
*
|
107
|
+
* ary = Array.new #=> []
|
108
|
+
* Array.new(3) #=> [nil, nil, nil]
|
109
|
+
- * Array.new(3, true) #=> [0, 0, 0]
|
110
|
+
+ * Array.new(3, true) #=> [true, true, true]
|
111
|
+
*
|
112
|
+
* Note that the second argument populates the array with references to the
|
113
|
+
* same object. Therefore, it is only recommended in cases when you need to
|
114
|
+
@@ -5242,8 +5245,8 @@
|
115
|
+
*
|
116
|
+
* An array can also be created by using the Array() method, provided by
|
117
|
+
* Kernel, which calls #to_ary or #to_a on it's argument.
|
118
|
+
- *
|
119
|
+
- * Array({:a => "a", :b => "b"}) #=> [[:a, "a"], [:b, "b"]]
|
120
|
+
+ *
|
121
|
+
+ * Array({:a => "a", :b => "b"}) #=> [[:a, "a"], [:b, "b"]]
|
122
|
+
*
|
123
|
+
* == Example Usage
|
124
|
+
*
|
125
|
+
@@ -5275,8 +5278,7 @@
|
126
|
+
* To raise an error for indices outside of the array bounds or else to
|
127
|
+
* provide a default value when that happens, you can use #fetch.
|
128
|
+
*
|
129
|
+
- * arr = ['a', 'b', 'c', 'd', 'e', 'f']
|
130
|
+
- * arr.fetch(100) #=> IndexError: index 100 outside of array bounds: -6...6
|
131
|
+
+ * arr.fetch(100) # raises IndexError: index 100 outside of array bounds: -6...6
|
132
|
+
* arr.fetch(100, "oops") #=> "oops"
|
133
|
+
*
|
134
|
+
* The special methods #first and #last will return the first and last
|
135
|
+
@@ -5353,7 +5355,8 @@
|
136
|
+
* To delete a particular element anywhere in an array, use #delete:
|
137
|
+
*
|
138
|
+
* arr = [1, 2, 2, 3]
|
139
|
+
- * arr.delete(2) #=> [1, 3]
|
140
|
+
+ * arr.delete(2) #=> 2
|
141
|
+
+ * arr #=> [1, 3]
|
142
|
+
*
|
143
|
+
* A useful method if you need to remove +nil+ values from an array is
|
144
|
+
* #compact:
|
145
|
+
@@ -5381,9 +5384,9 @@
|
146
|
+
* Note that this operation leaves the array unchanged.
|
147
|
+
*
|
148
|
+
* arr = [1, 2, 3, 4, 5]
|
149
|
+
- * arr.each { |a| print a -= 10, " " }
|
150
|
+
- * # prints: -9 -8 -7 -6 -5
|
151
|
+
- * #=> [1, 2, 3, 4, 5]
|
152
|
+
+ * arr.each { |a| print a -= 10, " " } #=> arr
|
153
|
+
+ * produces:
|
154
|
+
+ * -9 -8 -7 -6 -5
|
155
|
+
*
|
156
|
+
* Another sometimes useful iterator is #reverse_each which will iterate over
|
157
|
+
* the elements in the array in reverse order.
|
158
|
+
@@ -5413,7 +5416,7 @@
|
159
|
+
*
|
160
|
+
* arr = [1, 2, 3, 4, 5, 6]
|
161
|
+
* arr.select { |a| a > 3 } #=> [4, 5, 6]
|
162
|
+
- * arr.reject { |a| a < 3 } #=> [4, 5, 6]
|
163
|
+
+ * arr.reject { |a| a < 3 } #=> [3, 4, 5, 6]
|
164
|
+
* arr.drop_while { |a| a < 4 } #=> [4, 5, 6]
|
165
|
+
* arr #=> [1, 2, 3, 4, 5, 6]
|
166
|
+
*
|