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,39 @@
|
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
|
2
|
+
|
|
3
|
+
describe 'Method#to_source' do
|
|
4
|
+
describe 'w specified {:strip_enclosure => ...}' do
|
|
5
|
+
|
|
6
|
+
describe '>> w true' do
|
|
7
|
+
|
|
8
|
+
options = {:strip_enclosure => true}
|
|
9
|
+
|
|
10
|
+
should 'strip enclosing proc wo arg' do
|
|
11
|
+
def m1; a+b; end
|
|
12
|
+
method(:m1).should.be having_source(%(a + b), options)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
should 'strip enclosing proc w arg' do
|
|
16
|
+
def m2(a); a+b; end
|
|
17
|
+
method(:m2).should.be having_source(%(a+b), options)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe '>> w false' do
|
|
23
|
+
|
|
24
|
+
options = {:strip_enclosure => false}
|
|
25
|
+
|
|
26
|
+
should 'not strip enclosing proc wo arg' do
|
|
27
|
+
def m3; a+b; end
|
|
28
|
+
method(:m3).should.be having_source(%(def m3; a+b; end), options)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
should 'not strip enclosing proc w arg' do
|
|
32
|
+
def m4(a); a+b; end
|
|
33
|
+
method(:m4).should.be having_source(%(def m4(a); a+b; end), options)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
|
2
|
+
|
|
3
|
+
describe "Unsupported Platform" do
|
|
4
|
+
|
|
5
|
+
thing = Class.new do
|
|
6
|
+
def self.echo
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
should 'raise Sourcify::PlatformNotSupportedError when calling Method#to_source' do
|
|
11
|
+
lambda{ thing.method(:echo).to_source }.should.
|
|
12
|
+
raise(Sourcify::PlatformNotSupportedError)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
should 'raise Sourcify::PlatformNotSupportedError when calling Method#to_sexp' do
|
|
16
|
+
lambda{ thing.method(:echo).to_sexp }.should.
|
|
17
|
+
raise(Sourcify::PlatformNotSupportedError)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
should 'raise Sourcify::PlatformNotSupportedError when calling Method#to_raw_source' do
|
|
21
|
+
lambda{ thing.method(:echo).to_raw_source }.should.
|
|
22
|
+
raise(Sourcify::PlatformNotSupportedError)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
|
2
|
+
|
|
3
|
+
unless has_parsetree?
|
|
4
|
+
describe "Proc's raw scanner > block comment (=begin ... =end)" do
|
|
5
|
+
extend Sourcify::Proc::Parser::RawScanner::Spec::GenericSupport
|
|
6
|
+
behaves_like "Block comment (=begin ... =end)"
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
|
2
|
+
|
|
3
|
+
unless has_parsetree?
|
|
4
|
+
describe "Proc's raw scanner > double quote strings (w interpolation)" do
|
|
5
|
+
extend Sourcify::Proc::Parser::RawScanner::Spec::GenericSupport
|
|
6
|
+
behaves_like "Double quote strings (w interpolation)"
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
|
2
|
+
|
|
3
|
+
unless has_parsetree?
|
|
4
|
+
describe "Proc's raw scanner > double quote strings (wo interpolation)" do
|
|
5
|
+
extend Sourcify::Proc::Parser::RawScanner::Spec::GenericSupport
|
|
6
|
+
behaves_like "Double quote strings (wo interpolation)"
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
|
2
|
+
|
|
3
|
+
unless has_parsetree?
|
|
4
|
+
describe "Proc's raw scanner > keyword block start alias #1 (incrementing counter by 1)" do
|
|
5
|
+
|
|
6
|
+
extend Sourcify::Proc::Parser::RawScanner::Spec::KwBlockStartSupport
|
|
7
|
+
behaves_like "Keyword block start alias #1 (incrementing counter by 1)"
|
|
8
|
+
|
|
9
|
+
kw_block_start_alias1.each do |kw|
|
|
10
|
+
should "increment counter with ... do #{kw} ..." do
|
|
11
|
+
kw_block_start_counter(<<EOL
|
|
12
|
+
aa do #{kw} bb ...
|
|
13
|
+
cc
|
|
14
|
+
EOL
|
|
15
|
+
).should.equal([2,2])
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
|
2
|
+
|
|
3
|
+
unless has_parsetree?
|
|
4
|
+
describe "Proc's raw scanner > keyword block start alias #2 (incrementing counter by 0..1)" do
|
|
5
|
+
|
|
6
|
+
extend Sourcify::Proc::Parser::RawScanner::Spec::KwBlockStartSupport
|
|
7
|
+
behaves_like "Keyword block start alias #2 (incrementing counter by 0..1)"
|
|
8
|
+
|
|
9
|
+
kw_block_start_alias2.each do |kw|
|
|
10
|
+
should "increment counter with ... do #{kw} ..." do
|
|
11
|
+
kw_block_start_counter(<<EOL
|
|
12
|
+
aa do #{kw} bb ...
|
|
13
|
+
cc
|
|
14
|
+
EOL
|
|
15
|
+
).should.equal([1,2])
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
|
2
|
+
|
|
3
|
+
unless has_parsetree?
|
|
4
|
+
describe "Proc's raw scanner > single quote strings (\', %q & %w)" do
|
|
5
|
+
extend Sourcify::Proc::Parser::RawScanner::Spec::GenericSupport
|
|
6
|
+
behaves_like 'Single quote strings (\', %q & %w)'
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
|
2
|
+
require File.expand_path('../../../raw_scanner/shared_specs', __FILE__)
|
|
3
|
+
|
|
4
|
+
module Sourcify::Proc::Parser::RawScanner
|
|
5
|
+
|
|
6
|
+
SCANNER = self
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
attr_reader :tokens, :do_end_counter
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
module Spec
|
|
13
|
+
|
|
14
|
+
module GenericSupport
|
|
15
|
+
def self.extended(base)
|
|
16
|
+
base.instance_eval do
|
|
17
|
+
def process(data)
|
|
18
|
+
SCANNER.process(data)
|
|
19
|
+
SCANNER.tokens
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
module KwBlockStartSupport
|
|
26
|
+
def self.extended(base)
|
|
27
|
+
base.instance_eval do
|
|
28
|
+
|
|
29
|
+
before do
|
|
30
|
+
counter(:DoEndBlockCounter).class_eval do
|
|
31
|
+
alias_method :orig_started?, :started?
|
|
32
|
+
def started?; true; end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
after do
|
|
37
|
+
counter(:DoEndBlockCounter).class_eval do
|
|
38
|
+
alias_method :started?, :orig_started?
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def counter(type)
|
|
43
|
+
Sourcify::Proc::Parser::RawScanner::Extensions.const_get(type)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def kw_block_start_counter(data)
|
|
47
|
+
SCANNER.process(data)
|
|
48
|
+
SCANNER.do_end_counter.counts
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def kw_block_start_alias1
|
|
52
|
+
%w{class def module begin case module if unless}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def kw_block_start_alias2
|
|
56
|
+
%w{while until for}
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
unless has_parsetree?
|
|
4
|
-
describe "Block comment (=begin ... =end)" do
|
|
1
|
+
shared "Block comment (=begin ... =end)" do
|
|
5
2
|
|
|
6
3
|
should 'handle =begin\n ... =end\n' do
|
|
7
4
|
process(<<EOL
|
|
@@ -58,4 +55,3 @@ EOL
|
|
|
58
55
|
end
|
|
59
56
|
|
|
60
57
|
end
|
|
61
|
-
end
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
unless has_parsetree?
|
|
4
|
-
describe "Double colons" do
|
|
1
|
+
shared "Double colons" do
|
|
5
2
|
|
|
6
3
|
should "handle A::B as :const" do
|
|
7
4
|
process(" A::B ").should.include([:const, 'A::B'])
|
|
@@ -12,4 +9,3 @@ describe "Double colons" do
|
|
|
12
9
|
end
|
|
13
10
|
|
|
14
11
|
end
|
|
15
|
-
end
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
unless has_parsetree?
|
|
4
|
-
describe 'Double quote strings (w interpolation)' do
|
|
1
|
+
shared 'Double quote strings (w interpolation)' do
|
|
5
2
|
|
|
6
3
|
# NOTE: we skip %Q#...# cos %Q#..#{..}..# is invalid syntax.
|
|
7
4
|
%w{~ ` ! @ $ % ^ & * _ - + = | ; : ' " , . ? / \\}.map{|w| [w,w] }.concat(
|
|
@@ -61,4 +58,3 @@ describe 'Double quote strings (w interpolation)' do
|
|
|
61
58
|
end
|
|
62
59
|
|
|
63
60
|
end
|
|
64
|
-
end
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
unless has_parsetree?
|
|
4
|
-
describe 'Double quote strings (wo interpolation)' do
|
|
1
|
+
shared 'Double quote strings (wo interpolation)' do
|
|
5
2
|
|
|
6
3
|
%w{~ ` ! @ # $ % ^ & * _ - + = | \\ ; : ' " , . ? /}.map{|w| [w,w] }.concat(
|
|
7
4
|
[%w{( )}, %w{[ ]}, %w({ }), %w{< >}]
|
|
@@ -87,4 +84,3 @@ describe 'Double quote strings (wo interpolation)' do
|
|
|
87
84
|
end
|
|
88
85
|
|
|
89
86
|
end
|
|
90
|
-
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
shared "Heredoc (w indent)" do
|
|
2
|
+
%w{X "X" 'X'}.each do |tag|
|
|
3
|
+
|
|
4
|
+
should "handle <<-#{tag}\\n .. \\nX\\n" do
|
|
5
|
+
process(%Q(
|
|
6
|
+
s <<-#{tag}
|
|
7
|
+
aa
|
|
8
|
+
X
|
|
9
|
+
)).should.include([:heredoc, "<<-#{tag}\n aa \nX"])
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
should "handle <<-#{tag}\\n .. \\n X\\n" do
|
|
13
|
+
process(%Q(
|
|
14
|
+
s <<-#{tag}
|
|
15
|
+
aa
|
|
16
|
+
X
|
|
17
|
+
)).should.include([:heredoc, "<<-#{tag}\n aa \n X"])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
should "not handle <<-#{tag} \\n .. \\nX\\n" do
|
|
21
|
+
process(%Q(
|
|
22
|
+
s <<-#{tag}
|
|
23
|
+
aa
|
|
24
|
+
X
|
|
25
|
+
)).should.not.include([:heredoc, "<<-#{tag} \n aa \n X"])
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
should "not handle <<-#{tag}\\n .. \\nX \\n" do
|
|
29
|
+
process(%Q(
|
|
30
|
+
s <<-#{tag}
|
|
31
|
+
aa
|
|
32
|
+
X
|
|
33
|
+
)).should.not.include([:heredoc, "<<-#{tag}\n aa \nX "])
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
should "not handle class <<-#{tag}\\n .. \\nX \\n" do
|
|
37
|
+
process(%Q(
|
|
38
|
+
class <<-#{tag}
|
|
39
|
+
aa
|
|
40
|
+
X
|
|
41
|
+
)).should.not.include([:heredoc, "<<-#{tag}\n aa \nX"])
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
should "handle xclass <<-#{tag}\\n .. \\nX \\n" do
|
|
45
|
+
process(%Q(
|
|
46
|
+
xclass <<-#{tag}
|
|
47
|
+
aa
|
|
48
|
+
X
|
|
49
|
+
)).should.include([:heredoc, "<<-#{tag}\n aa \nX"])
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
should "handle classx <<-#{tag}\\n .. \\nX \\n" do
|
|
53
|
+
process(%Q(
|
|
54
|
+
classx <<-#{tag}
|
|
55
|
+
aa
|
|
56
|
+
X
|
|
57
|
+
)).should.include([:heredoc, "<<-#{tag}\n aa \nX"])
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
should "handle <<-#{tag}\\n .. \\nX \\n" do
|
|
61
|
+
process(%Q(
|
|
62
|
+
<<-#{tag}
|
|
63
|
+
aa
|
|
64
|
+
X
|
|
65
|
+
)).should.include([:heredoc, "<<-#{tag}\n aa \nX"])
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
shared "Heredoc (wo indent)" do
|
|
2
|
+
%w{X "X" 'X'}.each do |tag|
|
|
3
|
+
|
|
4
|
+
should "handle <<#{tag}\\n .. \\nX\\n" do
|
|
5
|
+
process(%Q(
|
|
6
|
+
s <<#{tag}
|
|
7
|
+
aa
|
|
8
|
+
X
|
|
9
|
+
)).should.include([:heredoc, "<<#{tag}\n aa \nX"])
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
should "not handle <<#{tag} \\n .. \\nX\\n" do
|
|
13
|
+
process(%Q(
|
|
14
|
+
s << #{tag}
|
|
15
|
+
aa
|
|
16
|
+
X
|
|
17
|
+
)).should.not.include([:heredoc, "<<#{tag} \n aa \nX"])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
should "not handle <<#{tag}\\n .. \\n X\\n" do
|
|
21
|
+
process(%Q(
|
|
22
|
+
s <<#{tag}
|
|
23
|
+
aa
|
|
24
|
+
X
|
|
25
|
+
)).should.not.include([:heredoc, "<<#{tag} \n aa \n X"])
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
should "not handle <<#{tag}\\n .. \\nX \\n" do
|
|
29
|
+
process(%Q(
|
|
30
|
+
s <<#{tag}
|
|
31
|
+
aa
|
|
32
|
+
X
|
|
33
|
+
)).should.not.include([:heredoc, "<<#{tag} \n aa \nX "])
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
should "not handle class <<#{tag}\\n .. \\nX \\n" do
|
|
37
|
+
process(%Q(
|
|
38
|
+
|
|
39
|
+
class <<#{tag}
|
|
40
|
+
aa
|
|
41
|
+
X
|
|
42
|
+
)).should.not.include([:heredoc, "<<#{tag}\n aa \nX"])
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
should "handle xclass <<#{tag}\\n .. \\nX \\n" do
|
|
46
|
+
process(%Q(
|
|
47
|
+
xclass <<#{tag}
|
|
48
|
+
aa
|
|
49
|
+
X
|
|
50
|
+
)).should.include([:heredoc, "<<#{tag}\n aa \nX"])
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
should "handle classx <<#{tag}\\n .. \\nX \\n" do
|
|
54
|
+
process(%Q(
|
|
55
|
+
classx <<#{tag}
|
|
56
|
+
aa
|
|
57
|
+
X
|
|
58
|
+
)).should.include([:heredoc, "<<#{tag}\n aa \nX"])
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
should "handle <<#{tag}\\n .. \\nX \\n" do
|
|
62
|
+
process(%Q(
|
|
63
|
+
<<#{tag}
|
|
64
|
+
aa
|
|
65
|
+
X
|
|
66
|
+
)).should.include([:heredoc, "<<#{tag}\n aa \nX"])
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
end
|