sourcify 0.5.0 → 0.6.0.rc1
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/.gitignore +1 -0
- data/HISTORY.txt +5 -0
- data/README.rdoc +86 -3
- data/Rakefile +47 -15
- data/lib/sourcify.rb +13 -0
- data/lib/sourcify/common/parser/converter.rb +29 -0
- data/lib/sourcify/common/parser/raw_scanner/comment.rb +23 -0
- data/lib/sourcify/common/parser/raw_scanner/counter.rb +43 -0
- data/lib/sourcify/common/parser/raw_scanner/dstring.rb +60 -0
- data/lib/sourcify/common/parser/raw_scanner/extensions.rb +121 -0
- data/lib/sourcify/common/parser/raw_scanner/heredoc.rb +26 -0
- data/lib/sourcify/common/parser/source_code.rb +33 -0
- data/lib/sourcify/common/ragel/common.rl +5 -0
- data/lib/sourcify/common/ragel/expressions.rl +38 -0
- data/lib/sourcify/{proc/scanner.rl → common/ragel/machines.rl} +10 -178
- data/lib/sourcify/errors.rb +4 -0
- data/lib/sourcify/method.rb +134 -0
- data/lib/sourcify/method/methods.rb +3 -0
- data/lib/sourcify/method/methods/to_raw_source.rb +30 -0
- data/lib/sourcify/method/methods/to_sexp.rb +30 -0
- data/lib/sourcify/method/methods/to_source.rb +30 -0
- data/lib/sourcify/method/parser.rb +104 -0
- data/lib/sourcify/method/parser/converter.rb +8 -0
- data/lib/sourcify/method/parser/raw_scanner.rb +2494 -0
- data/lib/sourcify/method/parser/raw_scanner.rl +144 -0
- data/lib/sourcify/method/parser/raw_scanner_extensions.rb +64 -0
- data/lib/sourcify/method/parser/scanner.rb +48 -0
- data/lib/sourcify/method/parser/source_code.rb +8 -0
- data/lib/sourcify/proc.rb +0 -2
- data/lib/sourcify/proc/parser.rb +2 -5
- data/lib/sourcify/proc/parser/converter.rb +2 -23
- data/lib/sourcify/proc/{scanner.rb → parser/raw_scanner.rb} +808 -806
- data/lib/sourcify/proc/parser/raw_scanner.rl +149 -0
- data/lib/sourcify/proc/parser/raw_scanner_extensions.rb +72 -0
- data/lib/sourcify/proc/parser/{code_scanner.rb → scanner.rb} +9 -5
- data/lib/sourcify/proc/parser/source_code.rb +2 -27
- data/lib/sourcify/version.rb +1 -1
- data/spec/method/others_from_def_end_block_spec.rb +49 -0
- data/spec/method/others_from_define_method_spec.rb +62 -0
- data/spec/method/raw_scanner/block_comment_spec.rb +8 -0
- data/spec/method/raw_scanner/double_colons_spec.rb +8 -0
- data/spec/method/raw_scanner/double_quote_str_w_interpolation_spec.rb +8 -0
- data/spec/method/raw_scanner/double_quote_str_wo_interpolation_spec.rb +8 -0
- data/spec/method/raw_scanner/heredoc_w_indent_spec.rb +8 -0
- data/spec/method/raw_scanner/heredoc_wo_indent_spec.rb +8 -0
- data/spec/method/raw_scanner/kw_block_start_alias1_spec.rb +20 -0
- data/spec/method/raw_scanner/kw_block_start_alias2_spec.rb +20 -0
- data/spec/method/raw_scanner/per_line_comment_spec.rb +8 -0
- data/spec/method/raw_scanner/single_quote_str_spec.rb +8 -0
- data/spec/method/raw_scanner/slash_operator_spec.rb +8 -0
- data/spec/method/raw_scanner/spec_helper.rb +80 -0
- data/spec/method/spec_helper.rb +1 -0
- data/spec/method/to_raw_source_spec.rb +31 -0
- data/spec/method/to_raw_source_w_specified_strip_enclosure_spec.rb +148 -0
- data/spec/method/to_sexp_from_def_end_block_w_variables_spec.rb +46 -0
- data/spec/method/to_sexp_from_def_end_block_within_irb_spec.rb +38 -0
- data/spec/method/to_sexp_from_define_method_w_multi_blocks_and_specified_attached_to_spec.rb +56 -0
- data/spec/method/to_sexp_from_define_method_w_variables_spec.rb +52 -0
- data/spec/method/to_sexp_from_define_method_within_irb_spec.rb +42 -0
- data/spec/method/to_sexp_w_specified_strip_enclosure_spec.rb +74 -0
- data/spec/method/to_source_from_def_end_block_w_19_extras_spec.rb +23 -0
- data/spec/method/to_source_from_def_end_block_w_nested_begin_spec.rb +35 -0
- data/spec/method/to_source_from_def_end_block_w_nested_case_spec.rb +35 -0
- data/spec/method/to_source_from_def_end_block_w_nested_class_spec.rb +51 -0
- data/spec/method/to_source_from_def_end_block_w_nested_do_end_block_spec.rb +33 -0
- data/spec/method/to_source_from_def_end_block_w_nested_for_spec.rb +126 -0
- data/spec/method/to_source_from_def_end_block_w_nested_if_spec.rb +82 -0
- data/spec/method/to_source_from_def_end_block_w_nested_literal_keyword_spec.rb +141 -0
- data/spec/method/to_source_from_def_end_block_w_nested_method_spec.rb +33 -0
- data/spec/method/to_source_from_def_end_block_w_nested_module_spec.rb +59 -0
- data/spec/method/to_source_from_def_end_block_w_nested_unless_spec.rb +82 -0
- data/spec/method/to_source_from_def_end_block_w_nested_until_spec.rb +179 -0
- data/spec/method/to_source_from_def_end_block_w_nested_while_spec.rb +179 -0
- data/spec/method/to_source_from_def_end_block_w_singleton_method_spec.rb +19 -0
- data/spec/method/to_source_from_def_end_block_within_irb_spec.rb +30 -0
- data/spec/method/to_source_from_def_end_w_multi_blocks_and_many_matches_spec.rb +30 -0
- data/spec/method/to_source_from_def_end_w_multi_blocks_and_single_match_spec.rb +36 -0
- data/spec/method/to_source_from_define_method_w_braced_block_spec.rb +113 -0
- data/spec/method/to_source_from_define_method_w_do_end_block_spec.rb +145 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_many_matches_spec.rb +56 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_single_match_spec.rb +73 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_attached_to_and_many_matches_spec.rb +36 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_attached_to_and_no_match_spec.rb +36 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_attached_to_and_single_match_spec.rb +28 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_attached_to_spec.rb +103 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_body_matcher_and_many_matches_spec.rb +36 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_body_matcher_and_no_match_spec.rb +36 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_body_matcher_and_single_match_spec.rb +28 -0
- data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_ignore_nested_spec.rb +36 -0
- data/spec/method/to_source_from_define_method_within_irb_spec.rb +32 -0
- data/spec/method/to_source_magic_file_var_spec.rb +176 -0
- data/spec/method/to_source_magic_line_var_spec.rb +298 -0
- data/spec/method/to_source_w_specified_strip_enclosure_spec.rb +39 -0
- data/spec/no_method/unsupported_platform_spec.rb +26 -0
- data/spec/proc/raw_scanner/block_comment_spec.rb +8 -0
- data/spec/proc/raw_scanner/double_colons_spec.rb +8 -0
- data/spec/proc/raw_scanner/double_quote_str_w_interpolation_spec.rb +8 -0
- data/spec/proc/raw_scanner/double_quote_str_wo_interpolation_spec.rb +8 -0
- data/spec/proc/raw_scanner/heredoc_w_indent_spec.rb +8 -0
- data/spec/proc/raw_scanner/heredoc_wo_indent_spec.rb +8 -0
- data/spec/proc/raw_scanner/kw_block_start_alias1_spec.rb +20 -0
- data/spec/proc/raw_scanner/kw_block_start_alias2_spec.rb +20 -0
- data/spec/proc/raw_scanner/per_line_comment_spec.rb +8 -0
- data/spec/proc/raw_scanner/single_quote_str_spec.rb +8 -0
- data/spec/proc/raw_scanner/slash_operator_spec.rb +8 -0
- data/spec/proc/raw_scanner/spec_helper.rb +63 -0
- data/spec/{proc_scanner/block_comment_spec.rb → raw_scanner/block_comment_shared_spec.rb} +1 -5
- data/spec/{proc_scanner/double_colons_spec.rb → raw_scanner/double_colons_shared_spec.rb} +1 -5
- data/spec/{proc_scanner/double_quote_str_w_interpolation_spec.rb → raw_scanner/double_quote_str_w_interpolation_shared_spec.rb} +1 -5
- data/spec/{proc_scanner/double_quote_str_wo_interpolation_spec.rb → raw_scanner/double_quote_str_wo_interpolation_shared_spec.rb} +1 -5
- data/spec/raw_scanner/heredoc_w_indent_shared_spec.rb +69 -0
- data/spec/raw_scanner/heredoc_wo_indent_shared_spec.rb +70 -0
- data/spec/{proc_scanner/kw_do_alias1_spec.rb → raw_scanner/kw_block_start_alias1_shared_spec.rb} +10 -26
- data/spec/{proc_scanner/kw_do_alias2_spec.rb → raw_scanner/kw_block_start_alias2_shared_spec.rb} +10 -25
- data/spec/{proc_scanner/per_line_comment_spec.rb → raw_scanner/per_line_comment_shared_spec.rb} +1 -5
- data/spec/raw_scanner/shared_specs.rb +3 -0
- data/spec/{proc_scanner/single_quote_str_spec.rb → raw_scanner/single_quote_str_shared_spec.rb} +1 -5
- data/spec/{proc_scanner/slash_operator_spec.rb → raw_scanner/slash_operator_shared_spec.rb} +1 -5
- data/spec/run_spec.sh +7 -1
- data/spec/spec_helper.rb +8 -25
- metadata +204 -47
- data/.rvmrc +0 -1
- data/VERSION +0 -1
- data/lib/sourcify/proc/scanner/comment.rb +0 -21
- data/lib/sourcify/proc/scanner/counter.rb +0 -44
- data/lib/sourcify/proc/scanner/dstring.rb +0 -59
- data/lib/sourcify/proc/scanner/extensions.rb +0 -171
- data/lib/sourcify/proc/scanner/heredoc.rb +0 -24
- data/spec/proc_scanner/heredoc_spec.rb +0 -144
- data/spec/proc_scanner/spec_helper.rb +0 -33
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
|
2
|
+
|
|
3
|
+
describe "Method#to_source (from def ... end block)" do
|
|
4
|
+
describe "w nested if" do
|
|
5
|
+
|
|
6
|
+
should 'handle simple block' do
|
|
7
|
+
def m1
|
|
8
|
+
if @x1 then @x1 = 1 end
|
|
9
|
+
end
|
|
10
|
+
method(:m1).should.be having_source(%(
|
|
11
|
+
def m1
|
|
12
|
+
if @x1 then @x1 = 1 end
|
|
13
|
+
end
|
|
14
|
+
))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
should 'handle nested block' do
|
|
18
|
+
def m2
|
|
19
|
+
if @x1
|
|
20
|
+
if @x2 then @x2 = 1 end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
method(:m2).should.be having_source(%(
|
|
24
|
+
def m2
|
|
25
|
+
if @x1
|
|
26
|
+
if @x2 then @x2 = 1 end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
))
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
should 'handle simple modifier' do
|
|
33
|
+
def m3
|
|
34
|
+
@x1 = 1 if true
|
|
35
|
+
end
|
|
36
|
+
method(:m3).should.be having_source(%(
|
|
37
|
+
def m3
|
|
38
|
+
@x1 = 1 if true
|
|
39
|
+
end
|
|
40
|
+
))
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
should 'handle block within modifier' do
|
|
44
|
+
def m4
|
|
45
|
+
@x1 = 1 if (if @x1 then true end)
|
|
46
|
+
end
|
|
47
|
+
method(:m4).should.be having_source(%(
|
|
48
|
+
def m4
|
|
49
|
+
@x1 = 1 if (if @x1 then true end)
|
|
50
|
+
end
|
|
51
|
+
))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
should 'handle modifier w trailing backslash' do
|
|
55
|
+
def m5
|
|
56
|
+
@x1 = 1 \
|
|
57
|
+
if true
|
|
58
|
+
end
|
|
59
|
+
method(:m5).should.be having_source(%(
|
|
60
|
+
def m5
|
|
61
|
+
@x1 = 1 if true
|
|
62
|
+
end
|
|
63
|
+
))
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
should 'handle modifier within block' do
|
|
67
|
+
def m6
|
|
68
|
+
if @x1
|
|
69
|
+
@x1 = 1 if @x2
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
method(:m6).should.be having_source(%(
|
|
73
|
+
def m6
|
|
74
|
+
if @x1
|
|
75
|
+
@x1 = 1 if @x2
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
))
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
|
2
|
+
|
|
3
|
+
describe "Method#to_source (from def ... end block)" do
|
|
4
|
+
describe "w nested literal keyword" do
|
|
5
|
+
|
|
6
|
+
# See http://redmine.ruby-lang.org/issues/show/3764
|
|
7
|
+
|
|
8
|
+
should 'handle :class' do
|
|
9
|
+
def m1
|
|
10
|
+
x = :class
|
|
11
|
+
end
|
|
12
|
+
method(:m1).should.be having_source(%(
|
|
13
|
+
def m1
|
|
14
|
+
x = :class
|
|
15
|
+
end
|
|
16
|
+
))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
should 'handle :module' do
|
|
20
|
+
def m2
|
|
21
|
+
x = :module
|
|
22
|
+
end
|
|
23
|
+
method(:m2).should.be having_source(%(
|
|
24
|
+
def m2
|
|
25
|
+
x = :module
|
|
26
|
+
end
|
|
27
|
+
))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
should 'handle :def' do
|
|
31
|
+
def m3
|
|
32
|
+
x = :def
|
|
33
|
+
end
|
|
34
|
+
method(:m3).should.be having_source(%(
|
|
35
|
+
def m3
|
|
36
|
+
x = :def
|
|
37
|
+
end
|
|
38
|
+
))
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
should 'handle :if' do
|
|
42
|
+
def m4
|
|
43
|
+
x = :if
|
|
44
|
+
end
|
|
45
|
+
method(:m4).should.be having_source(%(
|
|
46
|
+
def m4
|
|
47
|
+
x = :if
|
|
48
|
+
end
|
|
49
|
+
))
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
should 'handle :unless' do
|
|
53
|
+
def m5
|
|
54
|
+
x = :unless
|
|
55
|
+
end
|
|
56
|
+
method(:m5).should.be having_source(%(
|
|
57
|
+
def m5
|
|
58
|
+
x = :unless
|
|
59
|
+
end
|
|
60
|
+
))
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
should 'handle :for' do
|
|
64
|
+
def m6
|
|
65
|
+
x = :for
|
|
66
|
+
end
|
|
67
|
+
method(:m6).should.be having_source(%(
|
|
68
|
+
def m6
|
|
69
|
+
x = :for
|
|
70
|
+
end
|
|
71
|
+
))
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
should 'handle :while' do
|
|
75
|
+
def m7
|
|
76
|
+
x = :while
|
|
77
|
+
end
|
|
78
|
+
method(:m7).should.be having_source(%(
|
|
79
|
+
def m7
|
|
80
|
+
x = :while
|
|
81
|
+
end
|
|
82
|
+
))
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
should 'handle :until' do
|
|
86
|
+
def m8
|
|
87
|
+
x = :until
|
|
88
|
+
end
|
|
89
|
+
method(:m8).should.be having_source(%(
|
|
90
|
+
def m8
|
|
91
|
+
x = :until
|
|
92
|
+
end
|
|
93
|
+
))
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
should 'handle :begin' do
|
|
97
|
+
def m9
|
|
98
|
+
x = :begin
|
|
99
|
+
end
|
|
100
|
+
method(:m9).should.be having_source(%(
|
|
101
|
+
def m9
|
|
102
|
+
x = :begin
|
|
103
|
+
end
|
|
104
|
+
))
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
should 'handle :case' do
|
|
108
|
+
def m10
|
|
109
|
+
x = :case
|
|
110
|
+
end
|
|
111
|
+
method(:m10).should.be having_source(%(
|
|
112
|
+
def m10
|
|
113
|
+
x = :case
|
|
114
|
+
end
|
|
115
|
+
))
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
should 'handle :do' do
|
|
119
|
+
def m11
|
|
120
|
+
x = :do
|
|
121
|
+
end
|
|
122
|
+
method(:m11).should.be having_source(%(
|
|
123
|
+
def m11
|
|
124
|
+
x = :do
|
|
125
|
+
end
|
|
126
|
+
))
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
should 'handle :end' do
|
|
130
|
+
def m12
|
|
131
|
+
x = :end
|
|
132
|
+
end
|
|
133
|
+
method(:m12).should.be having_source(%(
|
|
134
|
+
def m12
|
|
135
|
+
x = :end
|
|
136
|
+
end
|
|
137
|
+
))
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
end
|
|
141
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
|
2
|
+
|
|
3
|
+
describe "Method#to_source (from def ... end block)" do
|
|
4
|
+
describe "w nested method" do
|
|
5
|
+
|
|
6
|
+
should 'handle simple' do
|
|
7
|
+
def m1
|
|
8
|
+
def aa; x = 1; end
|
|
9
|
+
end
|
|
10
|
+
method(:m1).should.be having_source(%(
|
|
11
|
+
def m1
|
|
12
|
+
def aa; x = 1; end
|
|
13
|
+
end
|
|
14
|
+
))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
should 'handle nested' do
|
|
18
|
+
def m2
|
|
19
|
+
def aa
|
|
20
|
+
def bb; x = 2; end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
method(:m2).should.be having_source(%(
|
|
24
|
+
def m2
|
|
25
|
+
def aa
|
|
26
|
+
def bb; x = 2; end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
))
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
|
2
|
+
|
|
3
|
+
describe "Method#to_source (from def ... end block)" do
|
|
4
|
+
describe "w nested module" do
|
|
5
|
+
|
|
6
|
+
class AA; end
|
|
7
|
+
|
|
8
|
+
should 'handle simple' do
|
|
9
|
+
def m1
|
|
10
|
+
class << AA
|
|
11
|
+
module BB
|
|
12
|
+
def aa
|
|
13
|
+
@x1 = 1
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
method(:m1).should.be having_source(%(
|
|
19
|
+
def m1
|
|
20
|
+
class << AA
|
|
21
|
+
module BB
|
|
22
|
+
def aa
|
|
23
|
+
@x1 = 1
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
should 'handle nested' do
|
|
32
|
+
def m2
|
|
33
|
+
class << AA
|
|
34
|
+
module BB
|
|
35
|
+
module CC
|
|
36
|
+
def bb
|
|
37
|
+
@x1 = 1
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
method(:m2).should.be having_source(%(
|
|
44
|
+
def m2
|
|
45
|
+
class << AA
|
|
46
|
+
module BB
|
|
47
|
+
module CC
|
|
48
|
+
def bb
|
|
49
|
+
@x1 = 1
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
))
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
|
2
|
+
|
|
3
|
+
describe "Method#to_source (from def ... end block)" do
|
|
4
|
+
describe "w nested unless" do
|
|
5
|
+
|
|
6
|
+
should 'handle simple block' do
|
|
7
|
+
def m1
|
|
8
|
+
unless @x1 then @x1 = 1 end
|
|
9
|
+
end
|
|
10
|
+
method(:m1).should.be having_source(%(
|
|
11
|
+
def m1
|
|
12
|
+
unless @x1 then @x1 = 1 end
|
|
13
|
+
end
|
|
14
|
+
))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
should 'handle nested block' do
|
|
18
|
+
def m2
|
|
19
|
+
unless @x1
|
|
20
|
+
unless @x2 then @x2 = 1 end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
method(:m2).should.be having_source(%(
|
|
24
|
+
def m2
|
|
25
|
+
unless @x1
|
|
26
|
+
unless @x2 then @x2 = 1 end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
))
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
should 'handle simple modifier' do
|
|
33
|
+
def m3
|
|
34
|
+
@x1 = 1 unless true
|
|
35
|
+
end
|
|
36
|
+
method(:m3).should.be having_source(%(
|
|
37
|
+
def m3
|
|
38
|
+
@x1 = 1 unless true
|
|
39
|
+
end
|
|
40
|
+
))
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
should 'handle block within modifier' do
|
|
44
|
+
def m4
|
|
45
|
+
@x1 = 1 unless (unless @x1 then true end)
|
|
46
|
+
end
|
|
47
|
+
method(:m4).should.be having_source(%(
|
|
48
|
+
def m4
|
|
49
|
+
@x1 = 1 unless (unless @x1 then true end)
|
|
50
|
+
end
|
|
51
|
+
))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
should 'handle modifier within block' do
|
|
55
|
+
def m5
|
|
56
|
+
unless @x1
|
|
57
|
+
@x1 = 1 unless @x2
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
method(:m5).should.be having_source(%(
|
|
61
|
+
def m5
|
|
62
|
+
unless @x1
|
|
63
|
+
@x1 = 1 unless @x2
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
))
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
should 'handle modifier w trailing backslash' do
|
|
70
|
+
def m6
|
|
71
|
+
@x1 = 1 \
|
|
72
|
+
unless true
|
|
73
|
+
end
|
|
74
|
+
method(:m6).should.be having_source(%(
|
|
75
|
+
def m6
|
|
76
|
+
@x1 = 1 unless true
|
|
77
|
+
end
|
|
78
|
+
))
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
|
2
|
+
|
|
3
|
+
describe "Method#to_source (from def ... end block)" do
|
|
4
|
+
describe "w nested until block" do
|
|
5
|
+
|
|
6
|
+
should 'handle w do' do
|
|
7
|
+
def m1
|
|
8
|
+
until true do @x1 = 1 end
|
|
9
|
+
end
|
|
10
|
+
method(:m1).should.be having_source(%(
|
|
11
|
+
def m1
|
|
12
|
+
until true do @x1 = 1 end
|
|
13
|
+
end
|
|
14
|
+
))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
should 'handle w \ do' do
|
|
18
|
+
def m2
|
|
19
|
+
until true \
|
|
20
|
+
do @x1 = 2 end
|
|
21
|
+
end
|
|
22
|
+
method(:m2).should.be having_source(%(
|
|
23
|
+
def m2
|
|
24
|
+
until true do @x1 = 2 end
|
|
25
|
+
end
|
|
26
|
+
))
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
should 'handle wo do (w newline)' do
|
|
30
|
+
def m3
|
|
31
|
+
until true
|
|
32
|
+
@x1 = 3
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
method(:m3).should.be having_source(%(
|
|
36
|
+
def m3
|
|
37
|
+
until true
|
|
38
|
+
@x1 = 3
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
))
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
should 'handle wo do (w semicolon)' do
|
|
45
|
+
def m4
|
|
46
|
+
until true; @x1 = 4; end
|
|
47
|
+
end
|
|
48
|
+
method(:m4).should.be having_source(%(
|
|
49
|
+
def m4
|
|
50
|
+
until true
|
|
51
|
+
@x1 = 4
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
))
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
should 'handle nested wo do within w do' do
|
|
58
|
+
def m5
|
|
59
|
+
until true do
|
|
60
|
+
until true; @x1 = 5; end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
method(:m5).should.be having_source(%(
|
|
64
|
+
def m5
|
|
65
|
+
until true do
|
|
66
|
+
until true
|
|
67
|
+
@x1 = 5
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
))
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
should 'handle nested wo do within wo do' do
|
|
75
|
+
def m6
|
|
76
|
+
until true
|
|
77
|
+
until true; @x1 = 6; end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
method(:m6).should.be having_source(%(
|
|
81
|
+
def m6
|
|
82
|
+
until true
|
|
83
|
+
until true
|
|
84
|
+
@x1 = 6
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
))
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
should 'handle nested w do within wo do' do
|
|
92
|
+
def m7
|
|
93
|
+
until true
|
|
94
|
+
until true do @x1 = 7 end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
method(:m7).should.be having_source(%(
|
|
98
|
+
def m7
|
|
99
|
+
until true
|
|
100
|
+
until true
|
|
101
|
+
@x1 = 7
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
))
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
should 'handle nested w do within w do' do
|
|
109
|
+
def m8
|
|
110
|
+
until true do
|
|
111
|
+
until true do @x1 = 8 end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
method(:m8).should.be having_source(%(
|
|
115
|
+
def m8
|
|
116
|
+
until true
|
|
117
|
+
until true
|
|
118
|
+
@x1 = 8
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
))
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
should 'handle simple modifier' do
|
|
126
|
+
def m9
|
|
127
|
+
@x1 = 9 until true
|
|
128
|
+
end
|
|
129
|
+
method(:m9).should.be having_source(%(
|
|
130
|
+
def m9
|
|
131
|
+
@x1 = 9 until true
|
|
132
|
+
end
|
|
133
|
+
))
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
should 'handle block within modifier' do
|
|
137
|
+
def m10
|
|
138
|
+
@x1 = 10 until (
|
|
139
|
+
until true do @x1 = 10 end
|
|
140
|
+
)
|
|
141
|
+
end
|
|
142
|
+
method(:m10).should.be having_source(%(
|
|
143
|
+
def m10
|
|
144
|
+
@x1 = 10 until (
|
|
145
|
+
until true do @x1 = 10 end
|
|
146
|
+
)
|
|
147
|
+
end
|
|
148
|
+
))
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
should 'handle modifier within block' do
|
|
152
|
+
def m11
|
|
153
|
+
until true
|
|
154
|
+
@x1 = 11 until true
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
method(:m11).should.be having_source(%(
|
|
158
|
+
def m11
|
|
159
|
+
until true
|
|
160
|
+
@x1 = 11 until true
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
))
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
should 'handle modifier w trailing backslash' do
|
|
167
|
+
def m12
|
|
168
|
+
@x1 = 9 \
|
|
169
|
+
until true
|
|
170
|
+
end
|
|
171
|
+
method(:m12).should.be having_source(%(
|
|
172
|
+
def m12
|
|
173
|
+
@x1 = 9 until true
|
|
174
|
+
end
|
|
175
|
+
))
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
end
|
|
179
|
+
end
|