sourcify 0.5.0 → 0.6.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. data/.gitignore +1 -0
  2. data/HISTORY.txt +5 -0
  3. data/README.rdoc +86 -3
  4. data/Rakefile +47 -15
  5. data/lib/sourcify.rb +13 -0
  6. data/lib/sourcify/common/parser/converter.rb +29 -0
  7. data/lib/sourcify/common/parser/raw_scanner/comment.rb +23 -0
  8. data/lib/sourcify/common/parser/raw_scanner/counter.rb +43 -0
  9. data/lib/sourcify/common/parser/raw_scanner/dstring.rb +60 -0
  10. data/lib/sourcify/common/parser/raw_scanner/extensions.rb +121 -0
  11. data/lib/sourcify/common/parser/raw_scanner/heredoc.rb +26 -0
  12. data/lib/sourcify/common/parser/source_code.rb +33 -0
  13. data/lib/sourcify/common/ragel/common.rl +5 -0
  14. data/lib/sourcify/common/ragel/expressions.rl +38 -0
  15. data/lib/sourcify/{proc/scanner.rl → common/ragel/machines.rl} +10 -178
  16. data/lib/sourcify/errors.rb +4 -0
  17. data/lib/sourcify/method.rb +134 -0
  18. data/lib/sourcify/method/methods.rb +3 -0
  19. data/lib/sourcify/method/methods/to_raw_source.rb +30 -0
  20. data/lib/sourcify/method/methods/to_sexp.rb +30 -0
  21. data/lib/sourcify/method/methods/to_source.rb +30 -0
  22. data/lib/sourcify/method/parser.rb +104 -0
  23. data/lib/sourcify/method/parser/converter.rb +8 -0
  24. data/lib/sourcify/method/parser/raw_scanner.rb +2494 -0
  25. data/lib/sourcify/method/parser/raw_scanner.rl +144 -0
  26. data/lib/sourcify/method/parser/raw_scanner_extensions.rb +64 -0
  27. data/lib/sourcify/method/parser/scanner.rb +48 -0
  28. data/lib/sourcify/method/parser/source_code.rb +8 -0
  29. data/lib/sourcify/proc.rb +0 -2
  30. data/lib/sourcify/proc/parser.rb +2 -5
  31. data/lib/sourcify/proc/parser/converter.rb +2 -23
  32. data/lib/sourcify/proc/{scanner.rb → parser/raw_scanner.rb} +808 -806
  33. data/lib/sourcify/proc/parser/raw_scanner.rl +149 -0
  34. data/lib/sourcify/proc/parser/raw_scanner_extensions.rb +72 -0
  35. data/lib/sourcify/proc/parser/{code_scanner.rb → scanner.rb} +9 -5
  36. data/lib/sourcify/proc/parser/source_code.rb +2 -27
  37. data/lib/sourcify/version.rb +1 -1
  38. data/spec/method/others_from_def_end_block_spec.rb +49 -0
  39. data/spec/method/others_from_define_method_spec.rb +62 -0
  40. data/spec/method/raw_scanner/block_comment_spec.rb +8 -0
  41. data/spec/method/raw_scanner/double_colons_spec.rb +8 -0
  42. data/spec/method/raw_scanner/double_quote_str_w_interpolation_spec.rb +8 -0
  43. data/spec/method/raw_scanner/double_quote_str_wo_interpolation_spec.rb +8 -0
  44. data/spec/method/raw_scanner/heredoc_w_indent_spec.rb +8 -0
  45. data/spec/method/raw_scanner/heredoc_wo_indent_spec.rb +8 -0
  46. data/spec/method/raw_scanner/kw_block_start_alias1_spec.rb +20 -0
  47. data/spec/method/raw_scanner/kw_block_start_alias2_spec.rb +20 -0
  48. data/spec/method/raw_scanner/per_line_comment_spec.rb +8 -0
  49. data/spec/method/raw_scanner/single_quote_str_spec.rb +8 -0
  50. data/spec/method/raw_scanner/slash_operator_spec.rb +8 -0
  51. data/spec/method/raw_scanner/spec_helper.rb +80 -0
  52. data/spec/method/spec_helper.rb +1 -0
  53. data/spec/method/to_raw_source_spec.rb +31 -0
  54. data/spec/method/to_raw_source_w_specified_strip_enclosure_spec.rb +148 -0
  55. data/spec/method/to_sexp_from_def_end_block_w_variables_spec.rb +46 -0
  56. data/spec/method/to_sexp_from_def_end_block_within_irb_spec.rb +38 -0
  57. data/spec/method/to_sexp_from_define_method_w_multi_blocks_and_specified_attached_to_spec.rb +56 -0
  58. data/spec/method/to_sexp_from_define_method_w_variables_spec.rb +52 -0
  59. data/spec/method/to_sexp_from_define_method_within_irb_spec.rb +42 -0
  60. data/spec/method/to_sexp_w_specified_strip_enclosure_spec.rb +74 -0
  61. data/spec/method/to_source_from_def_end_block_w_19_extras_spec.rb +23 -0
  62. data/spec/method/to_source_from_def_end_block_w_nested_begin_spec.rb +35 -0
  63. data/spec/method/to_source_from_def_end_block_w_nested_case_spec.rb +35 -0
  64. data/spec/method/to_source_from_def_end_block_w_nested_class_spec.rb +51 -0
  65. data/spec/method/to_source_from_def_end_block_w_nested_do_end_block_spec.rb +33 -0
  66. data/spec/method/to_source_from_def_end_block_w_nested_for_spec.rb +126 -0
  67. data/spec/method/to_source_from_def_end_block_w_nested_if_spec.rb +82 -0
  68. data/spec/method/to_source_from_def_end_block_w_nested_literal_keyword_spec.rb +141 -0
  69. data/spec/method/to_source_from_def_end_block_w_nested_method_spec.rb +33 -0
  70. data/spec/method/to_source_from_def_end_block_w_nested_module_spec.rb +59 -0
  71. data/spec/method/to_source_from_def_end_block_w_nested_unless_spec.rb +82 -0
  72. data/spec/method/to_source_from_def_end_block_w_nested_until_spec.rb +179 -0
  73. data/spec/method/to_source_from_def_end_block_w_nested_while_spec.rb +179 -0
  74. data/spec/method/to_source_from_def_end_block_w_singleton_method_spec.rb +19 -0
  75. data/spec/method/to_source_from_def_end_block_within_irb_spec.rb +30 -0
  76. data/spec/method/to_source_from_def_end_w_multi_blocks_and_many_matches_spec.rb +30 -0
  77. data/spec/method/to_source_from_def_end_w_multi_blocks_and_single_match_spec.rb +36 -0
  78. data/spec/method/to_source_from_define_method_w_braced_block_spec.rb +113 -0
  79. data/spec/method/to_source_from_define_method_w_do_end_block_spec.rb +145 -0
  80. data/spec/method/to_source_from_define_method_w_multi_blocks_and_many_matches_spec.rb +56 -0
  81. data/spec/method/to_source_from_define_method_w_multi_blocks_and_single_match_spec.rb +73 -0
  82. data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_attached_to_and_many_matches_spec.rb +36 -0
  83. data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_attached_to_and_no_match_spec.rb +36 -0
  84. data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_attached_to_and_single_match_spec.rb +28 -0
  85. data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_attached_to_spec.rb +103 -0
  86. data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_body_matcher_and_many_matches_spec.rb +36 -0
  87. data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_body_matcher_and_no_match_spec.rb +36 -0
  88. data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_body_matcher_and_single_match_spec.rb +28 -0
  89. data/spec/method/to_source_from_define_method_w_multi_blocks_and_specified_ignore_nested_spec.rb +36 -0
  90. data/spec/method/to_source_from_define_method_within_irb_spec.rb +32 -0
  91. data/spec/method/to_source_magic_file_var_spec.rb +176 -0
  92. data/spec/method/to_source_magic_line_var_spec.rb +298 -0
  93. data/spec/method/to_source_w_specified_strip_enclosure_spec.rb +39 -0
  94. data/spec/no_method/unsupported_platform_spec.rb +26 -0
  95. data/spec/proc/raw_scanner/block_comment_spec.rb +8 -0
  96. data/spec/proc/raw_scanner/double_colons_spec.rb +8 -0
  97. data/spec/proc/raw_scanner/double_quote_str_w_interpolation_spec.rb +8 -0
  98. data/spec/proc/raw_scanner/double_quote_str_wo_interpolation_spec.rb +8 -0
  99. data/spec/proc/raw_scanner/heredoc_w_indent_spec.rb +8 -0
  100. data/spec/proc/raw_scanner/heredoc_wo_indent_spec.rb +8 -0
  101. data/spec/proc/raw_scanner/kw_block_start_alias1_spec.rb +20 -0
  102. data/spec/proc/raw_scanner/kw_block_start_alias2_spec.rb +20 -0
  103. data/spec/proc/raw_scanner/per_line_comment_spec.rb +8 -0
  104. data/spec/proc/raw_scanner/single_quote_str_spec.rb +8 -0
  105. data/spec/proc/raw_scanner/slash_operator_spec.rb +8 -0
  106. data/spec/proc/raw_scanner/spec_helper.rb +63 -0
  107. data/spec/{proc_scanner/block_comment_spec.rb → raw_scanner/block_comment_shared_spec.rb} +1 -5
  108. data/spec/{proc_scanner/double_colons_spec.rb → raw_scanner/double_colons_shared_spec.rb} +1 -5
  109. data/spec/{proc_scanner/double_quote_str_w_interpolation_spec.rb → raw_scanner/double_quote_str_w_interpolation_shared_spec.rb} +1 -5
  110. data/spec/{proc_scanner/double_quote_str_wo_interpolation_spec.rb → raw_scanner/double_quote_str_wo_interpolation_shared_spec.rb} +1 -5
  111. data/spec/raw_scanner/heredoc_w_indent_shared_spec.rb +69 -0
  112. data/spec/raw_scanner/heredoc_wo_indent_shared_spec.rb +70 -0
  113. data/spec/{proc_scanner/kw_do_alias1_spec.rb → raw_scanner/kw_block_start_alias1_shared_spec.rb} +10 -26
  114. data/spec/{proc_scanner/kw_do_alias2_spec.rb → raw_scanner/kw_block_start_alias2_shared_spec.rb} +10 -25
  115. data/spec/{proc_scanner/per_line_comment_spec.rb → raw_scanner/per_line_comment_shared_spec.rb} +1 -5
  116. data/spec/raw_scanner/shared_specs.rb +3 -0
  117. data/spec/{proc_scanner/single_quote_str_spec.rb → raw_scanner/single_quote_str_shared_spec.rb} +1 -5
  118. data/spec/{proc_scanner/slash_operator_spec.rb → raw_scanner/slash_operator_shared_spec.rb} +1 -5
  119. data/spec/run_spec.sh +7 -1
  120. data/spec/spec_helper.rb +8 -25
  121. metadata +204 -47
  122. data/.rvmrc +0 -1
  123. data/VERSION +0 -1
  124. data/lib/sourcify/proc/scanner/comment.rb +0 -21
  125. data/lib/sourcify/proc/scanner/counter.rb +0 -44
  126. data/lib/sourcify/proc/scanner/dstring.rb +0 -59
  127. data/lib/sourcify/proc/scanner/extensions.rb +0 -171
  128. data/lib/sourcify/proc/scanner/heredoc.rb +0 -24
  129. data/spec/proc_scanner/heredoc_spec.rb +0 -144
  130. data/spec/proc_scanner/spec_helper.rb +0 -33
@@ -0,0 +1,32 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
2
+
3
+ describe 'Method#to_source (from define_method)' do
4
+ describe 'within IRB' do
5
+
6
+ class << self
7
+
8
+ def irb_eval(string)
9
+ irb_exec(string)[-1]
10
+ end
11
+
12
+ def equal_to(expected)
13
+ lambda {|found| normalize_code(found) == normalize_code(expected) }
14
+ end
15
+
16
+ end
17
+
18
+ should 'handle' do
19
+ irb_eval(%\
20
+ thing = Object.new
21
+ blk = lambda { x }
22
+ thing.class.send(:define_method, :m1, &blk)
23
+ thing.method(:m1).to_source
24
+ \).should.be equal_to(%(
25
+ def m1
26
+ x
27
+ end
28
+ ))
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,176 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
2
+
3
+ describe "Method#to_source (magic var __FILE__)" do
4
+
5
+ should 'handle single standalone' do
6
+ def m1; __FILE__; end
7
+ method(:m1).should.be having_source(%(
8
+ def m1; "#{__FILE__}"; end
9
+ ))
10
+ end
11
+
12
+ should 'handle multiple standalones' do
13
+ def m2
14
+ [
15
+ __FILE__, __FILE__,
16
+ __FILE__
17
+ ]
18
+ end
19
+ method(:m2).should.be having_source(%Q(
20
+ def m2
21
+ [
22
+ "#{__FILE__}", "#{__FILE__}",
23
+ "#{__FILE__}"
24
+ ]
25
+ end
26
+ ))
27
+ end
28
+
29
+ should 'handle single interpolation' do
30
+ def m3; "#{__FILE__}"; end
31
+ method(:m3).should.be having_source(%(
32
+ def m3; "#{__FILE__}"; end
33
+ ))
34
+ end
35
+
36
+ should 'handle multiple interpolation (separate)' do
37
+ def m4
38
+ [
39
+ "#{__FILE__}", "#{__FILE__}",
40
+ "#{__FILE__}"
41
+ ]
42
+ end
43
+ method(:m4).should.be having_source(%(
44
+ def m4
45
+ [
46
+ "#{__FILE__}", "#{__FILE__}",
47
+ "#{__FILE__}"
48
+ ]
49
+ end
50
+ ))
51
+ end
52
+
53
+ should 'handle multiple interpolation (together)' do
54
+ def m5
55
+ <<EOL
56
+ #{__FILE__}, #{__FILE__},
57
+ #{__FILE__}
58
+ EOL
59
+ end
60
+ method(:m5).should.be having_source(%(
61
+ def m5
62
+ <<EOL
63
+ #{__FILE__}, #{__FILE__},
64
+ #{__FILE__}
65
+ EOL
66
+ end
67
+ ))
68
+ end
69
+
70
+ should 'handle interpolation in (") quoted string' do
71
+ def m6; "#{__FILE__}"; end
72
+ method(:m6).should.be having_source(%(
73
+ def m6; "#{__FILE__}"; end
74
+ ))
75
+ end
76
+
77
+ should 'handle interpolation in (%) quoted string' do
78
+ def m7; %(#{__FILE__}); end
79
+ method(:m7).should.be having_source(%(
80
+ def m7; "#{__FILE__}"; end
81
+ ))
82
+ end
83
+
84
+ should 'handle interpolation in (%Q) quoted string' do
85
+ def m8; %Q(#{__FILE__}); end
86
+ method(:m8).should.be having_source(%(
87
+ def m8; "#{__FILE__}"; end
88
+ ))
89
+ end
90
+
91
+ should 'handle interpolation in heredoc string' do
92
+ def m9
93
+ <<-EOL
94
+ #{__FILE__}
95
+ EOL
96
+ end
97
+ method(:m9).should.be having_source(%(
98
+ def m9
99
+ <<-EOL
100
+ #{__FILE__}
101
+ EOL
102
+ end
103
+ ))
104
+ end
105
+
106
+ should 'handle interpolation in (%r) regexp' do
107
+ def m10; %r(#{__FILE__}); end
108
+ method(:m10).should.be having_source(%(
109
+ def m10; %r(#{__FILE__}); end
110
+ ))
111
+ end
112
+
113
+ should 'handle interpolation in (/) regexp' do
114
+ def m11; /#{__FILE__}/ ; end
115
+ method(:m11).should.be having_source(%(
116
+ def m11; %r(#{__FILE__}); end
117
+ ))
118
+ end
119
+
120
+ should 'handle interpolation in (%x) command' do
121
+ def m12; %x(echo #{__FILE__}); end
122
+ method(:m12).should.be having_source(%(
123
+ def m12; %x(echo #{__FILE__}); end
124
+ ))
125
+ end
126
+
127
+ should 'handle interpolation in (`) command' do
128
+ def m13; `echo #{__FILE__}`; end
129
+ method(:m13).should.be having_source(%(
130
+ def m13; `echo #{__FILE__}`; end
131
+ ))
132
+ end
133
+
134
+ should 'handle interpolation in (%W) array' do
135
+ def m14; %W(#{__FILE__}); end
136
+ method(:m14).should.be having_source(%(
137
+ def m14; %W(#{__FILE__}); end
138
+ ))
139
+ end
140
+
141
+ should 'not handle interpolation in (\') quoted string' do
142
+ def m15; '#{__FILE__}'; end
143
+ method(:m15).should.be having_source(%(
144
+ def m15; '\#{__FILE__}'; end
145
+ ))
146
+ end
147
+
148
+ should 'not handle interpolation in (%q) quoted string' do
149
+ def m16; %q(#{__FILE__}); end
150
+ method(:m16).should.be having_source(%(
151
+ def m16; '\#{__FILE__}'; end
152
+ ))
153
+ end
154
+
155
+ should 'not handle interpolation in (%w) array' do
156
+ def m17; %w(#{__FILE__}); end
157
+ method(:m17).should.be having_source(%(
158
+ def m17; %w{\#{__FILE__}}; end
159
+ ))
160
+ end
161
+
162
+ should 'not handle escaped-interpolation' do
163
+ def m18; "\#{__FILE__}"; end
164
+ method(:m18).should.be having_source(%(
165
+ def m18; "\\\#{__FILE__}"; end
166
+ ))
167
+ end
168
+
169
+ should 'not handle non-interpolated' do
170
+ def m19; "__FILE__"; end
171
+ method(:m19).should.be having_source(%(
172
+ def m19; "__FILE__"; end
173
+ ))
174
+ end
175
+
176
+ end
@@ -0,0 +1,298 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
2
+
3
+ describe "Method#to_source (magic var __LINE__)" do
4
+
5
+ should 'handle single standalone' do
6
+ def m1; __LINE__; end
7
+ method(:m1).should.be having_source(%(
8
+ def m1; #{__LINE__ - 2}; end
9
+ ))
10
+ end
11
+
12
+ should 'handle multiple standalones' do
13
+ def m2
14
+ [
15
+ __LINE__, __LINE__,
16
+ __LINE__
17
+ ]
18
+ end
19
+ method(:m2).should.be having_source(%Q(
20
+ def m2
21
+ [
22
+ #{__LINE__ - 7}, #{__LINE__ - 7},
23
+ #{__LINE__ - 7}
24
+ ]
25
+ end
26
+ ))
27
+ end
28
+
29
+ should 'handle single interpolation' do
30
+ def m3; "#{__LINE__}"; end
31
+ method(:m3).should.be having_source(%(
32
+ def m3; "\#{#{__LINE__ - 2}}"; end
33
+ ))
34
+ end
35
+
36
+ should 'handle multiple interpolation (separate)' do
37
+ def m4
38
+ [
39
+ "#{__LINE__}", "#{__LINE__}",
40
+ "#{__LINE__}"
41
+ ]
42
+ end
43
+ method(:m4).should.be having_source(%(
44
+ def m4
45
+ [
46
+ "\#{#{__LINE__ - 7}}", "\#{#{__LINE__ - 7}}",
47
+ "\#{#{__LINE__ - 7}}"
48
+ ]
49
+ end
50
+ ))
51
+ end
52
+
53
+ should 'handle multiple interpolation (together)' do
54
+ def m5
55
+ <<EOL
56
+ #{__LINE__}, #{__LINE__},
57
+ #{__LINE__}
58
+ EOL
59
+ end
60
+ method(:m5).should.be having_source(%(
61
+ def m5
62
+ <<EOL
63
+ \#{#{__LINE__ - 7}}, \#{#{__LINE__ - 7}},
64
+ \#{#{__LINE__ - 7}}
65
+ EOL
66
+ end
67
+ ))
68
+ end
69
+
70
+ should 'handle interpolation in (") quoted string' do
71
+ def m6; "#{__LINE__}"; end
72
+ method(:m6).should.be having_source(%(
73
+ def m6; "\#{#{__LINE__ - 2}}"; end
74
+ ))
75
+ end
76
+
77
+ should 'handle interpolation in (%) quoted string' do
78
+ def m7; %(#{__LINE__}); end
79
+ method(:m7).should.be having_source(%(
80
+ def m7; "\#{#{__LINE__ - 2}}"; end
81
+ ))
82
+ end
83
+
84
+ should 'handle interpolation in (%Q) quoted string' do
85
+ def m8; %Q(#{__LINE__}); end
86
+ method(:m8).should.be having_source(%(
87
+ def m8; "\#{#{__LINE__ - 2}}"; end
88
+ ))
89
+ end
90
+
91
+ should 'handle interpolation in heredoc string' do
92
+ def m9
93
+ <<-EOL
94
+ #{__LINE__}
95
+ EOL
96
+ end
97
+ method(:m9).should.be having_source(%(
98
+ def m9
99
+ <<-EOL
100
+ \#{#{__LINE__ - 6}}
101
+ EOL
102
+ end
103
+ ))
104
+ end
105
+
106
+ should 'handle interpolation in (%r) regexp' do
107
+ def m10; %r(#{__LINE__}); end
108
+ method(:m10).should.be having_source(%(
109
+ def m10; %r(\#{#{__LINE__ - 2}}); end
110
+ ))
111
+ end
112
+
113
+ should 'handle interpolation in (/) regexp' do
114
+ def m11; /#{__LINE__}/ ; end
115
+ method(:m11).should.be having_source(%(
116
+ def m11; %r(\#{#{__LINE__ - 2}}); end
117
+ ))
118
+ end
119
+
120
+ should 'handle interpolation in (%x) command' do
121
+ def m12; %x(echo #{__LINE__}); end
122
+ method(:m12).should.be having_source(%(
123
+ def m12; %x(echo \#{#{__LINE__ - 2}}); end
124
+ ))
125
+ end
126
+
127
+ should 'handle interpolation in (`) command' do
128
+ def m13; `echo #{__LINE__}`; end
129
+ method(:m13).should.be having_source(%(
130
+ def m13; `echo \#{#{__LINE__ - 2}}`; end
131
+ ))
132
+ end
133
+
134
+ should 'handle interpolation in (%W) array' do
135
+ def m14; %W(#{__LINE__}); end
136
+ method(:m14).should.be having_source(%(
137
+ def m14; %W(\#{#{__LINE__ - 2}}); end
138
+ ))
139
+ end
140
+
141
+ should 'not handle interpolation in (\') quoted string' do
142
+ def m15; '#{__LINE__}'; end
143
+ method(:m15).should.be having_source(%(
144
+ def m15; '\#{__LINE__}'; end
145
+ ))
146
+ end
147
+
148
+ should 'not handle interpolation in (%q) quoted string' do
149
+ def m16; %q(#{__LINE__}); end
150
+ method(:m16).should.be having_source(%(
151
+ def m16; '\#{__LINE__}'; end
152
+ ))
153
+ end
154
+
155
+ should 'not handle interpolation in (%w) array' do
156
+ def m17; %w(#{__LINE__}); end
157
+ method(:m17).should.be having_source(%(
158
+ def m17; %w{\#{__LINE__}}; end
159
+ ))
160
+ end
161
+
162
+ should 'not handle escaped-interpolation' do
163
+ def m18; "\#{__LINE__}"; end
164
+ method(:m18).should.be having_source(%(
165
+ def m18; "\\\#{__LINE__}"; end
166
+ ))
167
+ end
168
+
169
+ should 'not handle non-interpolated' do
170
+ def m19; "__LINE__"; end
171
+ method(:m19).should.be having_source(%(
172
+ def m19; "__LINE__"; end
173
+ ))
174
+ end
175
+
176
+ # should 'handle single standalone' do
177
+ # lambda { __LINE__ }.should.be having_source(%(proc { #{__LINE__} }))
178
+ # end
179
+ #
180
+ # should 'handle multiple standalones' do
181
+ # lambda {
182
+ # [
183
+ # __LINE__, __LINE__,
184
+ # __LINE__
185
+ # ]
186
+ # }.should.be having_source(%Q(
187
+ # proc do
188
+ # [
189
+ # #{__LINE__ - 6}, #{__LINE__ - 6},
190
+ # #{__LINE__ - 6}
191
+ # ]
192
+ # end
193
+ # ))
194
+ # end
195
+ #
196
+ # should 'handle single interpolation' do
197
+ # lambda { "#{__LINE__}" }.should.be having_source(%(proc { "\#{#{__LINE__}}" }))
198
+ # end
199
+ #
200
+ # should 'handle multiple interpolation (separate)' do
201
+ # lambda {
202
+ # [
203
+ # "#{__LINE__}", "#{__LINE__}",
204
+ # "#{__LINE__}"
205
+ # ]
206
+ # }.should.be having_source(%Q(
207
+ # proc do
208
+ # [
209
+ # "\#{#{__LINE__ - 6}}", "\#{#{__LINE__ - 6}}",
210
+ # "\#{#{__LINE__ - 6}}"
211
+ # ]
212
+ # end
213
+ # ))
214
+ # end
215
+ #
216
+ # should 'handle multiple interpolation (together)' do
217
+ # lambda {
218
+ # <<EOL
219
+ ##{__LINE__}, #{__LINE__},
220
+ ##{__LINE__}
221
+ #EOL
222
+ # }.should.be having_source(%Q(
223
+ # proc do
224
+ # <<EOL
225
+ #\#{#{__LINE__ - 6}}, \#{#{__LINE__ - 6}},
226
+ #\#{#{__LINE__ - 6}}
227
+ #EOL
228
+ # end
229
+ # ))
230
+ # end
231
+ #
232
+ # should 'handle interpolation in (") quoted string' do
233
+ # lambda { "#{__LINE__}" }.should.be having_source(%Q(proc { "\#{#{__LINE__}}" }))
234
+ # end
235
+ #
236
+ # should 'handle interpolation in (%) quoted string' do
237
+ # lambda { %(#{__LINE__}) }.should.be having_source(%Q(proc { "\#{#{__LINE__}}" }))
238
+ # end
239
+ #
240
+ # should 'handle interpolation in (%Q) quoted string' do
241
+ # lambda { %Q(#{__LINE__}) }.should.be having_source(%Q(proc { "\#{#{__LINE__}}" }))
242
+ # end
243
+ #
244
+ # should 'handle interpolation in heredoc string' do
245
+ # lambda {
246
+ # <<-EOL
247
+ ##{__LINE__}
248
+ #EOL
249
+ # }.should.be having_source(%Q(
250
+ # proc do
251
+ # <<-EOL
252
+ #\#{#{__LINE__ - 5}}
253
+ #EOL
254
+ # end
255
+ # ))
256
+ # end
257
+ #
258
+ # should 'handle interpolation in (%r) regexp' do
259
+ # lambda { %r(#{__LINE__}) }.should.be having_source(%Q(proc { %r(\#{#{__LINE__}}) }))
260
+ # end
261
+ #
262
+ # should 'handle interpolation in (/) regexp' do
263
+ # lambda { /#{__LINE__}/ }.should.be having_source(%Q(proc { %r(\#{#{__LINE__}}) }))
264
+ # end
265
+ #
266
+ # should 'handle interpolation in (%x) command' do
267
+ # lambda { %x(echo #{__LINE__}) }.should.be having_source(%Q(proc { %x(echo \#{#{__LINE__}}) }))
268
+ # end
269
+ #
270
+ # should 'handle interpolation in (`) command' do
271
+ # lambda { `echo #{__LINE__}` }.should.be having_source(%Q(proc { `echo \#{#{__LINE__}}` }))
272
+ # end
273
+ #
274
+ # should 'handle interpolation in (%W) array' do
275
+ # lambda { %W(#{__LINE__}) }.should.be having_source(%Q(proc { %W(\#{#{__LINE__}}) }))
276
+ # end
277
+ #
278
+ # should 'not handle interpolation in (\') quoted string' do
279
+ # lambda { '#{__LINE__}' }.should.be having_source(%Q(proc { '\#{__LINE__}' }))
280
+ # end
281
+ #
282
+ # should 'not handle interpolation in (%q) quoted string' do
283
+ # lambda { %q(#{__LINE__}) }.should.be having_source(%Q(proc { '\#{__LINE__}' }))
284
+ # end
285
+ #
286
+ # should 'not handle interpolation in (%w) array' do
287
+ # lambda { %w(#{__LINE__}) }.should.be having_source(%Q(proc { %w{\#{__LINE__}} }))
288
+ # end
289
+ #
290
+ # should 'not handle escaped-interpolation' do
291
+ # lambda { "\#{__LINE__}" }.should.be having_source('proc { "\#{__LINE__}" }')
292
+ # end
293
+ #
294
+ # should 'not handle non-interpolated' do
295
+ # lambda { "__LINE__" }.should.be having_source(%(proc { "__LINE__" }))
296
+ # end
297
+
298
+ end