sourcify 0.3.0 → 0.4.0
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/.infinity_test +32 -0
- data/HISTORY.txt +12 -0
- data/README.rdoc +69 -30
- data/Rakefile +2 -3
- data/VERSION +1 -1
- data/lib/sourcify.rb +2 -2
- data/lib/sourcify/proc.rb +144 -65
- data/lib/sourcify/proc/methods.rb +3 -0
- data/lib/sourcify/proc/methods/source_location.rb +61 -0
- data/lib/sourcify/proc/methods/to_sexp.rb +40 -0
- data/lib/sourcify/proc/methods/to_source.rb +48 -0
- data/lib/sourcify/proc/parser.rb +36 -17
- data/lib/sourcify/proc/scanner.rb +317 -271
- data/lib/sourcify/proc/scanner.rl +13 -2
- data/lib/sourcify/proc/scanner/extensions.rb +34 -10
- data/sourcify.gemspec +36 -6
- data/spec/proc/created_on_the_fly_proc_spec.rb +1 -1
- data/spec/proc/others_spec.rb +6 -2
- data/spec/proc/spec_helper.rb +1 -0
- data/spec/proc/to_sexp_from_multi_blocks_w_specified_attached_to_spec.rb +46 -0
- data/spec/proc/to_sexp_variables_spec.rb +1 -1
- data/spec/proc/to_sexp_w_specified_strip_enclosure_spec.rb +60 -0
- data/spec/proc/to_sexp_within_irb_spec.rb +1 -1
- data/spec/proc/to_source_from_braced_block_w_nested_braced_block_spec.rb +1 -1
- data/spec/proc/to_source_from_braced_block_w_nested_hash_spec.rb +2 -2
- data/spec/proc/to_source_from_braced_block_wo_nesting_complication_spec.rb +1 -1
- data/spec/proc/to_source_from_do_end_block_w_nested_begin_spec.rb +1 -1
- data/spec/proc/to_source_from_do_end_block_w_nested_case_spec.rb +1 -1
- data/spec/proc/to_source_from_do_end_block_w_nested_class_spec.rb +1 -1
- data/spec/proc/to_source_from_do_end_block_w_nested_do_end_block_spec.rb +1 -1
- data/spec/proc/to_source_from_do_end_block_w_nested_for_spec.rb +1 -1
- data/spec/proc/to_source_from_do_end_block_w_nested_if_spec.rb +1 -1
- data/spec/proc/to_source_from_do_end_block_w_nested_literal_keyword_spec.rb +1 -1
- data/spec/proc/to_source_from_do_end_block_w_nested_method_spec.rb +1 -1
- data/spec/proc/to_source_from_do_end_block_w_nested_module_spec.rb +1 -1
- data/spec/proc/to_source_from_do_end_block_w_nested_unless_spec.rb +1 -1
- data/spec/proc/to_source_from_do_end_block_w_nested_until_spec.rb +1 -1
- data/spec/proc/to_source_from_do_end_block_w_nested_while_spec.rb +1 -1
- data/spec/proc/to_source_from_do_end_block_wo_nesting_complication_spec.rb +1 -1
- data/spec/proc/to_source_from_multi_blocks_w_many_matches_spec.rb +20 -126
- data/spec/proc/to_source_from_multi_blocks_w_single_match_spec.rb +10 -89
- data/spec/proc/to_source_from_multi_blocks_w_specified_attached_to_and_many_matches_spec.rb +45 -0
- data/spec/proc/to_source_from_multi_blocks_w_specified_attached_to_and_no_match_spec.rb +45 -0
- data/spec/proc/to_source_from_multi_blocks_w_specified_attached_to_and_single_match_spec.rb +22 -0
- data/spec/proc/to_source_from_multi_blocks_w_specified_attached_to_spec.rb +83 -0
- data/spec/proc/to_source_from_multi_blocks_w_specified_body_matcher_and_many_matches_spec.rb +45 -0
- data/spec/proc/to_source_from_multi_blocks_w_specified_body_matcher_and_no_match_spec.rb +45 -0
- data/spec/proc/to_source_from_multi_blocks_w_specified_body_matcher_and_single_match_spec.rb +22 -0
- data/spec/proc/to_source_from_multi_blocks_w_specified_ignore_nested_spec.rb +43 -0
- data/spec/proc/to_source_from_multi_do_end_blocks_w_single_match_spec.rb +1 -1
- data/spec/proc/to_source_magic_file_var_spec.rb +1 -1
- data/spec/proc/to_source_magic_line_var_spec.rb +1 -1
- data/spec/proc/to_source_variables_spec.rb +1 -1
- data/spec/proc/to_source_w_specified_strip_enclosure_spec.rb +33 -0
- data/spec/proc/to_source_within_irb_spec.rb +1 -1
- data/spec/proc_scanner/block_comment_spec.rb +1 -1
- data/spec/proc_scanner/double_colons_spec.rb +1 -1
- data/spec/proc_scanner/double_quote_str_w_interpolation_spec.rb +9 -9
- data/spec/proc_scanner/double_quote_str_wo_interpolation_spec.rb +13 -13
- data/spec/proc_scanner/heredoc_spec.rb +1 -1
- data/spec/proc_scanner/kw_do_alias1_spec.rb +1 -1
- data/spec/proc_scanner/kw_do_alias2_spec.rb +1 -1
- data/spec/proc_scanner/per_line_comment_spec.rb +1 -1
- data/spec/proc_scanner/single_quote_str_spec.rb +1 -1
- data/spec/proc_scanner/slash_operator_spec.rb +75 -0
- data/spec/proc_scanner/spec_helper.rb +1 -1
- data/spec/spec_helper.rb +53 -45
- metadata +46 -16
- data/ext/sourcify/extconf.rb +0 -2
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
2
|
+
|
3
|
+
describe 'Proc#to_source w specified {:attached_to => ...} & single match' do
|
4
|
+
|
5
|
+
options = {:attached_to => :watever}
|
6
|
+
|
7
|
+
should 'handle no nesting on same line' do
|
8
|
+
b1 = lambda {|a| @x1+1 }; b2 = watever { @x1+2 }; b3 = lambda { @x1+3 }
|
9
|
+
b2.should.be having_source('proc { @x1+2 }', options)
|
10
|
+
end
|
11
|
+
|
12
|
+
should 'handle single level nesting on same line' do
|
13
|
+
b1 = lambda {|a| @x2+1 }; b2 = watever { lambda { @x2+2 } }
|
14
|
+
b2.should.be having_source('proc { lambda { @x2+2 } }', options)
|
15
|
+
end
|
16
|
+
|
17
|
+
should 'handle multi level nesting on same line' do
|
18
|
+
b2 = (lambda {|a| watever { lambda { @x3 } } }).call(1)
|
19
|
+
b2.should.be having_source('proc { lambda { @x3 } }', options)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
2
|
+
|
3
|
+
describe 'Proc#to_source w specified {:attached_to => ...}' do
|
4
|
+
unless has_parsetree?
|
5
|
+
|
6
|
+
err1 = Sourcify::MultipleMatchingProcsPerLineError
|
7
|
+
err2 = Sourcify::NoMatchingProcError
|
8
|
+
|
9
|
+
describe '>> w :attached_to as regexp' do
|
10
|
+
|
11
|
+
should "raise Sourcify::MultipleMatchingProcsPerLineError for multiple matches" do
|
12
|
+
b1 = lambda {|a| @x }; b2 = lambda { @x }; b3 = lambda { @x }
|
13
|
+
lambda { b2.to_source(:attached_to => /^(?:.*?\W|)lambda(?:\W)/) }.should.raise(err1)
|
14
|
+
end
|
15
|
+
|
16
|
+
should "raise Sourcify::NoMatchingProcError for no match" do
|
17
|
+
b1 = lambda {|a| @x }; b2 = lambda { @x }; b3 = lambda { @x }
|
18
|
+
lambda { b2.to_source(:attached_to => /^(?:.*?\W|)proc(?:\W)/) }.should.raise(err2)
|
19
|
+
end
|
20
|
+
|
21
|
+
should "handle for single match" do
|
22
|
+
b1 = lambda {|a| @x1 }; b2 = proc { @x2 }; b3 = lambda { @x3 }
|
23
|
+
b2.should.be having_source('proc { @x2 }', :attached_to => /^(?:.*?\W|)proc(?:\W)/)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '>> w :attached_to as string' do
|
29
|
+
|
30
|
+
should "raise Sourcify::MultipleMatchingProcsPerLineError for multiple matches" do
|
31
|
+
b1 = lambda {|a| @x }; b2 = lambda { @x }; b3 = lambda { @x }
|
32
|
+
lambda { b2.to_source(:attached_to => 'lambda') }.should.raise(err1)
|
33
|
+
end
|
34
|
+
|
35
|
+
should "raise Sourcify::NoMatchingProcError for no match" do
|
36
|
+
b1 = lambda {|a| @x }; b2 = lambda { @x }; b3 = lambda { @x }
|
37
|
+
lambda { b2.to_source(:attached_to => 'proc') }.should.raise(err2)
|
38
|
+
end
|
39
|
+
|
40
|
+
should "handle for single match" do
|
41
|
+
b1 = lambda {|a| @x1 }; b2 = proc { @x2 }; b3 = lambda { @x3 }
|
42
|
+
b2.should.be having_source('proc { @x2 }', :attached_to => 'proc')
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '>> w :attached_to as symbol' do
|
48
|
+
|
49
|
+
should "raise Sourcify::MultipleMatchingProcsPerLineError for multiple matches" do
|
50
|
+
b1 = lambda {|a| @x }; b2 = lambda { @x }; b3 = lambda { @x }
|
51
|
+
lambda { b2.to_source(:attached_to => :lambda) }.should.raise(err1)
|
52
|
+
end
|
53
|
+
|
54
|
+
should "raise Sourcify::NoMatchingProcError for no match" do
|
55
|
+
b1 = lambda {|a| @x }; b2 = lambda { @x }; b3 = lambda { @x }
|
56
|
+
lambda { b2.to_source(:attached_to => :proc) }.should.raise(err2)
|
57
|
+
end
|
58
|
+
|
59
|
+
should "handle for single match" do
|
60
|
+
b1 = lambda {|a| @x1 }; b2 = proc { @x2 }; b3 = lambda { @x3 }
|
61
|
+
b2.should.be having_source('proc { @x2 }', :attached_to => :proc)
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '>> w false start as a result of preceding hash' do
|
67
|
+
|
68
|
+
option = {:attached_to => :watever}
|
69
|
+
|
70
|
+
should 'handle for do ... end block' do
|
71
|
+
x = watever({:aa => 1, :bb => 3}) do :blah end
|
72
|
+
x.should.be having_source('proc { :blah }', option)
|
73
|
+
end
|
74
|
+
|
75
|
+
should 'handle for { ... } block' do
|
76
|
+
x = watever({:aa => 1, :bb => 3}) { :blah }
|
77
|
+
x.should.be having_source('proc { :blah }', option)
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
2
|
+
|
3
|
+
describe 'Proc#to_source w specified {:attached_to => ...} & single match' do
|
4
|
+
|
5
|
+
matcher = lambda {|code| code =~ /^(.*\W|)def\W/ }
|
6
|
+
|
7
|
+
if has_parsetree?
|
8
|
+
|
9
|
+
should 'handle no nesting on same line' do
|
10
|
+
b1 = lambda {|a| @x1+1 }; b2 = lambda { @x1+2 }; b3 = lambda { @x1+3 }
|
11
|
+
b2.should.be having_source('proc { @x1+2 }', &matcher)
|
12
|
+
end
|
13
|
+
|
14
|
+
should 'handle single level nesting on same line' do
|
15
|
+
b1 = lambda {|a| @x2+1 }; b2 = lambda { lambda { @x2+2 } }
|
16
|
+
b2.should.be having_source('proc { lambda { @x2+2 } }', &matcher)
|
17
|
+
end
|
18
|
+
|
19
|
+
should 'handle multi level nesting on same line' do
|
20
|
+
b2 = (lambda {|a| lambda { lambda { @x3 } } }).call(1)
|
21
|
+
b2.should.be having_source('proc { lambda { @x3 } }', &matcher)
|
22
|
+
end
|
23
|
+
|
24
|
+
else
|
25
|
+
|
26
|
+
error = Sourcify::MultipleMatchingProcsPerLineError
|
27
|
+
|
28
|
+
should "raise #{error} w no nesting on same line" do
|
29
|
+
b1 = lambda {|a| @x }; b2 = lambda { def a1; end }; b3 = lambda { def a2; end }
|
30
|
+
lambda { b2.to_source(&matcher) }.should.raise(error)
|
31
|
+
end
|
32
|
+
|
33
|
+
should "raise #{error} w single level nesting on same line" do
|
34
|
+
b1 = lambda {|a| @x }; b2 = lambda { lambda { def bb; end } }
|
35
|
+
lambda { b2.to_source(&matcher) }.should.raise(error)
|
36
|
+
end
|
37
|
+
|
38
|
+
should "raise #{error} w multi level nesting on same line" do
|
39
|
+
b2 = (lambda {|a| lambda { lambda { def cc; end } } }).call(1)
|
40
|
+
lambda { b2.to_source(&matcher) }.should.raise(error)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
2
|
+
|
3
|
+
describe 'Proc#to_source w specified body matcher & no match' do
|
4
|
+
|
5
|
+
matcher = lambda {|code| code =~ /^(.*\W|)def\W/ }
|
6
|
+
|
7
|
+
if has_parsetree?
|
8
|
+
|
9
|
+
should 'handle no nesting on same line' do
|
10
|
+
b1 = lambda do |a| @x1+1 end; b2 = lambda do @x1+2 end; b3 = lambda do @x1+3 end
|
11
|
+
b2.should.be having_source('proc { @x1+2 }', &matcher)
|
12
|
+
end
|
13
|
+
|
14
|
+
should 'handle single level nesting on same line' do
|
15
|
+
b1 = lambda do |a| @x2+1 end; b2 = lambda do lambda do @x2+2 end end
|
16
|
+
b2.should.be having_source('proc { lambda { @x2+2 } }', &matcher)
|
17
|
+
end
|
18
|
+
|
19
|
+
should 'handle multi level nesting on same line' do
|
20
|
+
b2 = (lambda do |a| lambda do lambda do @x3 end end end).call(1)
|
21
|
+
b2.should.be having_source('proc { lambda { @x3 } }', &matcher)
|
22
|
+
end
|
23
|
+
|
24
|
+
else
|
25
|
+
|
26
|
+
error = Sourcify::NoMatchingProcError
|
27
|
+
|
28
|
+
should "raise #{error} w no nesting on same line" do
|
29
|
+
b1 = lambda {|a| @x }; b2 = lambda { @x }; b3 = lambda { @x }
|
30
|
+
lambda { b2.to_source(&matcher) }.should.raise(error)
|
31
|
+
end
|
32
|
+
|
33
|
+
should "raise #{error} w single level nesting on same line" do
|
34
|
+
b1 = lambda {|a| @x }; b2 = lambda { lambda { @x } }
|
35
|
+
lambda { b2.to_source(&matcher) }.should.raise(error)
|
36
|
+
end
|
37
|
+
|
38
|
+
should "raise #{error} w multi level nesting on same line" do
|
39
|
+
b2 = (lambda {|a| lambda { lambda { @x } } }).call(1)
|
40
|
+
lambda { b2.to_source(&matcher) }.should.raise(error)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
2
|
+
|
3
|
+
describe 'Proc#to_source w specified body matcher & single match' do
|
4
|
+
|
5
|
+
matcher = lambda {|code| code =~ /^(.*\W|)def\W/ }
|
6
|
+
|
7
|
+
should 'handle no nesting on same line' do
|
8
|
+
b1 = lambda {|a| @x1+1 }; b2 = lambda { @x1+2 }; b3 = lambda { def aa; end }
|
9
|
+
b3.should.be having_source('proc { def aa; end }', &matcher)
|
10
|
+
end
|
11
|
+
|
12
|
+
should 'handle single level nesting on same line' do
|
13
|
+
b1 = lambda {|a| @x2+1 }; b2 = lambda { def bb; end; lambda { @x2+3 } }
|
14
|
+
b2.should.be having_source('proc { def bb; end; lambda { @x2+3 } }', &matcher)
|
15
|
+
end
|
16
|
+
|
17
|
+
should 'handle multi level nesting on same line' do
|
18
|
+
b2 = (lambda {|a| lambda { def cc; end; lambda { @x3+3 } } }).call(1)
|
19
|
+
b2.should.be having_source('proc { def cc; end; lambda { @x3+3 } }', &matcher)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
2
|
+
|
3
|
+
describe 'Proc#to_source w specified {:ignore_nested => ...}' do
|
4
|
+
|
5
|
+
options = {:ignore_nested => true}
|
6
|
+
|
7
|
+
if has_parsetree?
|
8
|
+
|
9
|
+
should 'handle no nesting on same line' do
|
10
|
+
b1 = lambda {|a| @x1+1 }; b2 = lambda { @x1+2 }; b3 = lambda { @x1+3 }
|
11
|
+
b2.should.be having_source('proc { @x1+2 }', options)
|
12
|
+
end
|
13
|
+
|
14
|
+
should 'handle single level nesting on same line' do
|
15
|
+
b1 = lambda {|a| @x2+1 }; b2 = lambda { lambda { @x2+2 } }
|
16
|
+
b2.should.be having_source('proc { lambda { @x2+2 } }', options)
|
17
|
+
end
|
18
|
+
|
19
|
+
should 'handle multi level nesting on same line (w outermost having diff arity)' do
|
20
|
+
b2 = (lambda {|a| lambda { lambda { @x3 } } }).call(1)
|
21
|
+
b2.should.be having_source('proc { lambda { @x3 } }', options)
|
22
|
+
end
|
23
|
+
|
24
|
+
else
|
25
|
+
|
26
|
+
should "raise Sourcify::MultipleMatchingProcsPerLineError w no nesting on same line" do
|
27
|
+
b1 = lambda {|a| @x1+1 }; b2 = lambda { @x1+2 }; b3 = lambda { @x1+3 }
|
28
|
+
lambda { b2.to_source(options) }.should.raise(Sourcify::MultipleMatchingProcsPerLineError)
|
29
|
+
end
|
30
|
+
|
31
|
+
should "handle w single level nesting on same line" do
|
32
|
+
b1 = lambda {|a| @x2+1 }; b2 = lambda { lambda { @x2+3 } }
|
33
|
+
b2.should.be having_source('proc { lambda { @x2+3 } }', options)
|
34
|
+
end
|
35
|
+
|
36
|
+
should "raise Sourcify::NoMatchingProcError w multi level nesting on same line (w outermost having diff arity)" do
|
37
|
+
b2 = (lambda {|a| lambda { lambda { @x3 } } }).call(1)
|
38
|
+
lambda { b2.to_source(options) }.should.raise(Sourcify::NoMatchingProcError)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
2
|
+
|
3
|
+
describe 'Proc#to_source w specified {:strip_enclosure => ...}' do
|
4
|
+
|
5
|
+
describe '>> w true' do
|
6
|
+
|
7
|
+
options = {:strip_enclosure => true}
|
8
|
+
|
9
|
+
should 'strip enclosing proc wo arg' do
|
10
|
+
lambda { a+b }.should.be having_source('a+b', options)
|
11
|
+
end
|
12
|
+
|
13
|
+
should 'strip enclosing proc w arg' do
|
14
|
+
lambda {|a| a+b }.should.be having_source('a+b', options)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '>> w false' do
|
20
|
+
|
21
|
+
options = {:strip_enclosure => false}
|
22
|
+
|
23
|
+
should 'not strip enclosing proc wo arg' do
|
24
|
+
lambda { a+b }.should.be having_source('proc { a+b }', options)
|
25
|
+
end
|
26
|
+
|
27
|
+
should 'not strip enclosing proc w arg' do
|
28
|
+
lambda {|a| a+b }.should.be having_source('proc {|a| a+b }', options)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'spec_helper')
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
2
2
|
|
3
3
|
unless has_parsetree?
|
4
4
|
describe 'Double quote strings (w interpolation)' do
|
@@ -10,23 +10,23 @@ describe 'Double quote strings (w interpolation)' do
|
|
10
10
|
['Q', 'W', 'x', 'r', ''].each do |t|
|
11
11
|
|
12
12
|
should "handle %#{t}#{q1}...#{q2} (wo nesting (single))" do
|
13
|
-
process(" xx %#{t}#{q1}h\#{%#{t}#{q1}ell#{q2}}o#{q2} ").
|
13
|
+
process(" xx; %#{t}#{q1}h\#{%#{t}#{q1}ell#{q2}}o#{q2} ").
|
14
14
|
should.include([:dstring, "%#{t}#{q1}h\#{%#{t}#{q1}ell#{q2}}o#{q2}"])
|
15
15
|
end
|
16
16
|
|
17
17
|
should "handle %#{t}#{q1}...#{q2} (wo nesting (multiple))" do
|
18
|
-
tokens = process(" xx %#{t}#{q1}h\#{%#{t}#{q1}ell#{q2}}o#{q2} %#{t}#{q1}w\#{%#{t}#{q1}orl#{q2}}d#{q2} ")
|
18
|
+
tokens = process(" xx; %#{t}#{q1}h\#{%#{t}#{q1}ell#{q2}}o#{q2} %#{t}#{q1}w\#{%#{t}#{q1}orl#{q2}}d#{q2} ")
|
19
19
|
tokens.should.include([:dstring, "%#{t}#{q1}h\#{%#{t}#{q1}ell#{q2}}o#{q2}"])
|
20
20
|
tokens.should.include([:dstring, "%#{t}#{q1}w\#{%#{t}#{q1}orl#{q2}}d#{q2}"])
|
21
21
|
end
|
22
22
|
|
23
23
|
should "handle %#{t}#{q1}...#{q2} (w nesting (single))" do
|
24
|
-
process(" xx %#{t}#{q1}h\#{%#{t}#{q1}e\#{%#{t}#{q1}l#{q2}}l#{q2}}o#{q2} ").
|
24
|
+
process(" xx; %#{t}#{q1}h\#{%#{t}#{q1}e\#{%#{t}#{q1}l#{q2}}l#{q2}}o#{q2} ").
|
25
25
|
should.include([:dstring, "%#{t}#{q1}h\#{%#{t}#{q1}e\#{%#{t}#{q1}l#{q2}}l#{q2}}o#{q2}"])
|
26
26
|
end
|
27
27
|
|
28
28
|
should "handle %#{t}#{q1}...#{q2} (w nesting (multiple))" do
|
29
|
-
tokens = process(" xx " +
|
29
|
+
tokens = process(" xx; " +
|
30
30
|
"%#{t}#{q1}h\#{%#{t}#{q1}e\#{%#{t}#{q1}l#{q2}}l#{q2}}o#{q2} " +
|
31
31
|
"%#{t}#{q1}w\#{%#{t}#{q1}o\#{%#{t}#{q1}r#{q2}}l#{q2}}d#{q2} "
|
32
32
|
)
|
@@ -40,22 +40,22 @@ describe 'Double quote strings (w interpolation)' do
|
|
40
40
|
%w{" / `}.each do |q|
|
41
41
|
|
42
42
|
should "handle #{q}...#{q} (wo escape (single))" do
|
43
|
-
process(%Q( xx #{q}hello#{q} )).should.include([:dstring, %Q(#{q}hello#{q})])
|
43
|
+
process(%Q( xx; #{q}hello#{q} )).should.include([:dstring, %Q(#{q}hello#{q})])
|
44
44
|
end
|
45
45
|
|
46
46
|
should "handle #{q}...#{q} (wo escape & multiple)" do
|
47
|
-
tokens = process(%Q( xx #{q}hello#{q} #{q}world#{q} ))
|
47
|
+
tokens = process(%Q( xx; #{q}hello#{q} ; #{q}world#{q} ))
|
48
48
|
tokens.should.include([:dstring, %Q(#{q}hello#{q})])
|
49
49
|
tokens.should.include([:dstring, %Q(#{q}world#{q})])
|
50
50
|
end
|
51
51
|
|
52
52
|
should "handle #{q}...#{q} (w escape (single))" do
|
53
|
-
process(%Q( xx #{q}hel\\#{q}lo#{q} )).should.
|
53
|
+
process(%Q( xx; #{q}hel\\#{q}lo#{q} )).should.
|
54
54
|
include([:dstring, %Q(#{q}hel\\#{q}lo#{q})])
|
55
55
|
end
|
56
56
|
|
57
57
|
should "handle #{q}...#{q} (w escape (multiple))" do
|
58
|
-
process(%Q( xx #{q}h\\#{q}el\\#{q}lo#{q} )).should.include([:dstring, %Q(#{q}h\\#{q}el\\#{q}lo#{q})])
|
58
|
+
process(%Q( xx; #{q}h\\#{q}el\\#{q}lo#{q} )).should.include([:dstring, %Q(#{q}h\\#{q}el\\#{q}lo#{q})])
|
59
59
|
end
|
60
60
|
|
61
61
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'spec_helper')
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
2
2
|
|
3
3
|
unless has_parsetree?
|
4
4
|
describe 'Double quote strings (wo interpolation)' do
|
@@ -9,11 +9,11 @@ describe 'Double quote strings (wo interpolation)' do
|
|
9
9
|
['Q', 'W', 'x', 'r', ''].each do |t|
|
10
10
|
|
11
11
|
should "handle %#{t}#{q1}...#{q2} (wo escape (single))" do
|
12
|
-
process(" xx %#{t}#{q1}hello#{q2} ").should.include([:dstring, "%#{t}#{q1}hello#{q2}"])
|
12
|
+
process(" xx; %#{t}#{q1}hello#{q2} ").should.include([:dstring, "%#{t}#{q1}hello#{q2}"])
|
13
13
|
end
|
14
14
|
|
15
15
|
should "handle %#{t}#{q1}...#{q2} (wo escape (multiple))" do
|
16
|
-
tokens = process(" xx
|
16
|
+
tokens = process(" xx; %#{t}#{q1}hello#{q2} %#{t}#{q1}world#{q2} ")
|
17
17
|
tokens.should.include([:dstring, "%#{t}#{q1}hello#{q2}"])
|
18
18
|
tokens.should.include([:dstring, "%#{t}#{q1}world#{q2}"])
|
19
19
|
end
|
@@ -23,22 +23,22 @@ describe 'Double quote strings (wo interpolation)' do
|
|
23
23
|
unless q1 == '\\'
|
24
24
|
|
25
25
|
should "handle %#{t}#{q1}...#{q2} (w escape (single))" do
|
26
|
-
process(" xx %#{t}#{q1}hel\\#{q2}lo#{q2} ").should.
|
26
|
+
process(" xx; %#{t}#{q1}hel\\#{q2}lo#{q2} ").should.
|
27
27
|
include([:dstring, "%#{t}#{q1}hel\\#{q2}lo#{q2}"])
|
28
28
|
end
|
29
29
|
|
30
30
|
should "handle %#{t}#{q1}...#{q2} (w escape (multiple))" do
|
31
|
-
process(" xx %#{t}#{q1}h\\#{q2}el\\#{q2}lo#{q2} ").should.
|
31
|
+
process(" xx; %#{t}#{q1}h\\#{q2}el\\#{q2}lo#{q2} ").should.
|
32
32
|
include([:dstring, "%#{t}#{q1}h\\#{q2}el\\#{q2}lo#{q2}"])
|
33
33
|
end
|
34
34
|
|
35
35
|
should "handle %#{t}#{q1}\\\\#{q2}" do
|
36
|
-
process(" xx %#{t}#{q1}\\\\#{q2} %#{t}#{q2}lo#{q2} ").should.
|
36
|
+
process(" xx; %#{t}#{q1}\\\\#{q2} %#{t}#{q2}lo#{q2} ").should.
|
37
37
|
include([:dstring, "%#{t}#{q1}\\\\#{q2}"])
|
38
38
|
end
|
39
39
|
|
40
40
|
should "handle %#{t}#{q1}#{q2}" do
|
41
|
-
process(" xx %#{t}#{q1}#{q2} %#{t}#{q2}lo#{q2} ").should.
|
41
|
+
process(" xx; %#{t}#{q1}#{q2} %#{t}#{q2}lo#{q2} ").should.
|
42
42
|
include([:dstring, "%#{t}#{q1}#{q2}"])
|
43
43
|
end
|
44
44
|
|
@@ -50,27 +50,27 @@ describe 'Double quote strings (wo interpolation)' do
|
|
50
50
|
%w{" / `}.each do |q|
|
51
51
|
|
52
52
|
should "handle #{q}...#{q} (wo escape (single))" do
|
53
|
-
process(%Q( xx #{q}hello#{q} )).should.include([:dstring, %Q(#{q}hello#{q})])
|
53
|
+
process(%Q( xx; #{q}hello#{q} )).should.include([:dstring, %Q(#{q}hello#{q})])
|
54
54
|
end
|
55
55
|
|
56
56
|
should "handle #{q}...#{q} (wo escape & multiple)" do
|
57
|
-
tokens = process(%Q( xx #{q}hello#{q} #{q}world#{q} ))
|
57
|
+
tokens = process(%Q( xx; #{q}hello#{q} ; #{q}world#{q} ))
|
58
58
|
tokens.should.include([:dstring, %Q(#{q}hello#{q})])
|
59
59
|
tokens.should.include([:dstring, %Q(#{q}world#{q})])
|
60
60
|
end
|
61
61
|
|
62
62
|
should "handle #{q}...#{q} (w escape (single))" do
|
63
|
-
process(%Q( xx #{q}hel\\#{q}lo#{q} )).should.include([:dstring, %Q(#{q}hel\\#{q}lo#{q})])
|
63
|
+
process(%Q( xx; #{q}hel\\#{q}lo#{q} )).should.include([:dstring, %Q(#{q}hel\\#{q}lo#{q})])
|
64
64
|
end
|
65
65
|
|
66
66
|
should "handle #{q}...#{q} (w escape (multiple))" do
|
67
|
-
process(%Q( xx #{q}h\\#{q}el\\#{q}lo#{q} )).should.
|
67
|
+
process(%Q( xx; #{q}h\\#{q}el\\#{q}lo#{q} )).should.
|
68
68
|
include([:dstring, %Q(#{q}h\\#{q}el\\#{q}lo#{q})])
|
69
69
|
end
|
70
70
|
|
71
71
|
should "handle #{q}\\\\#{q}" do
|
72
72
|
process(%Q(
|
73
|
-
aa #{q}\\\\#{q}
|
73
|
+
aa; #{q}\\\\#{q}
|
74
74
|
cc
|
75
75
|
#{q}dd#{q}
|
76
76
|
)).should.include([:dstring, "#{q}\\\\#{q}"])
|
@@ -78,7 +78,7 @@ describe 'Double quote strings (wo interpolation)' do
|
|
78
78
|
|
79
79
|
should "handle #{q}#{q}" do
|
80
80
|
process(%Q(
|
81
|
-
aa #{q}#{q}
|
81
|
+
aa; #{q}#{q}
|
82
82
|
cc
|
83
83
|
#{q}dd#{q}
|
84
84
|
)).should.include([:dstring, "#{q}#{q}"])
|