sourcify 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/.infinity_test +32 -0
  2. data/HISTORY.txt +12 -0
  3. data/README.rdoc +69 -30
  4. data/Rakefile +2 -3
  5. data/VERSION +1 -1
  6. data/lib/sourcify.rb +2 -2
  7. data/lib/sourcify/proc.rb +144 -65
  8. data/lib/sourcify/proc/methods.rb +3 -0
  9. data/lib/sourcify/proc/methods/source_location.rb +61 -0
  10. data/lib/sourcify/proc/methods/to_sexp.rb +40 -0
  11. data/lib/sourcify/proc/methods/to_source.rb +48 -0
  12. data/lib/sourcify/proc/parser.rb +36 -17
  13. data/lib/sourcify/proc/scanner.rb +317 -271
  14. data/lib/sourcify/proc/scanner.rl +13 -2
  15. data/lib/sourcify/proc/scanner/extensions.rb +34 -10
  16. data/sourcify.gemspec +36 -6
  17. data/spec/proc/created_on_the_fly_proc_spec.rb +1 -1
  18. data/spec/proc/others_spec.rb +6 -2
  19. data/spec/proc/spec_helper.rb +1 -0
  20. data/spec/proc/to_sexp_from_multi_blocks_w_specified_attached_to_spec.rb +46 -0
  21. data/spec/proc/to_sexp_variables_spec.rb +1 -1
  22. data/spec/proc/to_sexp_w_specified_strip_enclosure_spec.rb +60 -0
  23. data/spec/proc/to_sexp_within_irb_spec.rb +1 -1
  24. data/spec/proc/to_source_from_braced_block_w_nested_braced_block_spec.rb +1 -1
  25. data/spec/proc/to_source_from_braced_block_w_nested_hash_spec.rb +2 -2
  26. data/spec/proc/to_source_from_braced_block_wo_nesting_complication_spec.rb +1 -1
  27. data/spec/proc/to_source_from_do_end_block_w_nested_begin_spec.rb +1 -1
  28. data/spec/proc/to_source_from_do_end_block_w_nested_case_spec.rb +1 -1
  29. data/spec/proc/to_source_from_do_end_block_w_nested_class_spec.rb +1 -1
  30. data/spec/proc/to_source_from_do_end_block_w_nested_do_end_block_spec.rb +1 -1
  31. data/spec/proc/to_source_from_do_end_block_w_nested_for_spec.rb +1 -1
  32. data/spec/proc/to_source_from_do_end_block_w_nested_if_spec.rb +1 -1
  33. data/spec/proc/to_source_from_do_end_block_w_nested_literal_keyword_spec.rb +1 -1
  34. data/spec/proc/to_source_from_do_end_block_w_nested_method_spec.rb +1 -1
  35. data/spec/proc/to_source_from_do_end_block_w_nested_module_spec.rb +1 -1
  36. data/spec/proc/to_source_from_do_end_block_w_nested_unless_spec.rb +1 -1
  37. data/spec/proc/to_source_from_do_end_block_w_nested_until_spec.rb +1 -1
  38. data/spec/proc/to_source_from_do_end_block_w_nested_while_spec.rb +1 -1
  39. data/spec/proc/to_source_from_do_end_block_wo_nesting_complication_spec.rb +1 -1
  40. data/spec/proc/to_source_from_multi_blocks_w_many_matches_spec.rb +20 -126
  41. data/spec/proc/to_source_from_multi_blocks_w_single_match_spec.rb +10 -89
  42. data/spec/proc/to_source_from_multi_blocks_w_specified_attached_to_and_many_matches_spec.rb +45 -0
  43. data/spec/proc/to_source_from_multi_blocks_w_specified_attached_to_and_no_match_spec.rb +45 -0
  44. data/spec/proc/to_source_from_multi_blocks_w_specified_attached_to_and_single_match_spec.rb +22 -0
  45. data/spec/proc/to_source_from_multi_blocks_w_specified_attached_to_spec.rb +83 -0
  46. data/spec/proc/to_source_from_multi_blocks_w_specified_body_matcher_and_many_matches_spec.rb +45 -0
  47. data/spec/proc/to_source_from_multi_blocks_w_specified_body_matcher_and_no_match_spec.rb +45 -0
  48. data/spec/proc/to_source_from_multi_blocks_w_specified_body_matcher_and_single_match_spec.rb +22 -0
  49. data/spec/proc/to_source_from_multi_blocks_w_specified_ignore_nested_spec.rb +43 -0
  50. data/spec/proc/to_source_from_multi_do_end_blocks_w_single_match_spec.rb +1 -1
  51. data/spec/proc/to_source_magic_file_var_spec.rb +1 -1
  52. data/spec/proc/to_source_magic_line_var_spec.rb +1 -1
  53. data/spec/proc/to_source_variables_spec.rb +1 -1
  54. data/spec/proc/to_source_w_specified_strip_enclosure_spec.rb +33 -0
  55. data/spec/proc/to_source_within_irb_spec.rb +1 -1
  56. data/spec/proc_scanner/block_comment_spec.rb +1 -1
  57. data/spec/proc_scanner/double_colons_spec.rb +1 -1
  58. data/spec/proc_scanner/double_quote_str_w_interpolation_spec.rb +9 -9
  59. data/spec/proc_scanner/double_quote_str_wo_interpolation_spec.rb +13 -13
  60. data/spec/proc_scanner/heredoc_spec.rb +1 -1
  61. data/spec/proc_scanner/kw_do_alias1_spec.rb +1 -1
  62. data/spec/proc_scanner/kw_do_alias2_spec.rb +1 -1
  63. data/spec/proc_scanner/per_line_comment_spec.rb +1 -1
  64. data/spec/proc_scanner/single_quote_str_spec.rb +1 -1
  65. data/spec/proc_scanner/slash_operator_spec.rb +75 -0
  66. data/spec/proc_scanner/spec_helper.rb +1 -1
  67. data/spec/spec_helper.rb +53 -45
  68. metadata +46 -16
  69. data/ext/sourcify/extconf.rb +0 -2
@@ -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
  describe "Proc#to_source from do ... end block (w nested begin)" do
4
4
 
@@ -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
  describe "Proc#to_source from do ... end block (w nested case)" do
4
4
 
@@ -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
  describe "Proc#to_source from do ... end block (w nested class)" do
4
4
 
@@ -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
  describe "Proc#to_source from do ... end block (w nested do ... end block)" do
4
4
 
@@ -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
  describe "Proc#to_source from do ... end block (w nested for block)" do
4
4
 
@@ -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
  describe "Proc#to_source from do ... end block (w nested if)" do
4
4
 
@@ -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
  describe "Proc#to_source from do ... end block (w nested literal keyword)" do
4
4
 
@@ -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
  describe "Proc#to_source from do ... end block (w nested method)" do
4
4
 
@@ -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
  describe "Proc#to_source from do ... end block (w nested module)" do
4
4
 
@@ -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
  describe "Proc#to_source from do ... end block (w nested unless)" do
4
4
 
@@ -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
  describe "Proc#to_source from do ... end block (w nested until block)" do
4
4
 
@@ -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
  describe "Proc#to_source from do ... end block (w nested while block)" do
4
4
 
@@ -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
  describe "Proc#to_source from do ... end block (wo nesting complication)" do
4
4
 
@@ -1,147 +1,41 @@
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
  describe 'Proc#to_source from multi blocks w many matches' do
4
4
 
5
5
  if has_parsetree?
6
6
 
7
- expected = 'proc { @x%s }'
8
-
9
- should 'skip non-matching (all do...end blocks)' do
10
- (
11
- b1 = lambda do |a| @x1 end; b2 = lambda do @x1 end; b3 = lambda do @x10 end; b2
12
- ).should.be having_source(expected%1)
13
- end
14
-
15
- should 'skip non-matching (all {...} blocks)' do
16
- (
17
- b1 = lambda {|a| @x2 }; b2 = lambda { @x2 }; b3 = lambda { @x20 }; b2
18
- ).should.be having_source(expected%2)
7
+ should "handle w no nesting on same line" do
8
+ b1 = lambda {|a| @x1+1 }; b2 = lambda { @x1+2 }; b3 = lambda { @x1+3 }
9
+ b2.should.be having_source('proc { @x1+2 }')
19
10
  end
20
11
 
21
- should 'skip non-matching (mixed {...} with do...end blocks)' do
22
- (
23
- b1 = lambda {|a| @x3 }; b2 = lambda do @x3 end; b3 = lambda { @x30 } ; b2
24
- ).should.be having_source(expected%3)
12
+ should "handle w single level nesting on same line" do
13
+ b1 = lambda {|a| @x2+1 }; b2 = lambda { lambda { @x2+2 } }
14
+ b2.should.be having_source('proc { lambda { @x2+2 } }')
25
15
  end
26
16
 
27
- should 'skip non-matching (mixed do...end with {...} blocks)' do
28
- (
29
- b1 = lambda do |a| @x4 end; b2 = lambda { @x4 }; b3 = lambda do @x40 end; b2
30
- ).should.be having_source(expected%4)
17
+ should "handle w multi level nesting on same line" do
18
+ b2 = (lambda {|a| lambda { lambda { @x3 } } }).call(1)
19
+ b2.should.be having_source('proc { lambda { @x3 } }')
31
20
  end
32
21
 
33
22
  else
34
23
 
35
- describe 'wo nesting on same line' do
36
-
37
- should 'raise Sourcify::MultipleMatchingProcsPerLineError (all do...end blocks)' do
38
- lambda {
39
- (
40
- b1 = lambda do |a| @x1 end; b2 = lambda do @x1 end; b3 = lambda do @x1 end ; b2
41
- ).to_source
42
- }.should.raise(Sourcify::MultipleMatchingProcsPerLineError)
43
- end
44
-
45
- should 'raise Sourcify::MultipleMatchingProcsPerLineError (all {...} blocks)' do
46
- lambda {
47
- (
48
- b1 = lambda {|a| @x2 }; b2 = lambda { @x2 }; b3 = lambda { @x2 } ; b2
49
- ).to_source
50
- }.should.raise(Sourcify::MultipleMatchingProcsPerLineError)
51
- end
52
-
53
- should 'raise Sourcify::MultipleMatchingProcsPerLineError (mixed {...} w do...end blocks)' do
54
- lambda {
55
- (
56
- b1 = lambda {|a| @x3 }; b2 = lambda do @x3 end; b3 = lambda { @x4 } ; b2
57
- ).to_source
58
- }.should.raise(Sourcify::MultipleMatchingProcsPerLineError)
59
- end
60
-
61
- should 'raise Sourcify::MultipleMatchingProcsPerLineError (mixed do...end w {...} blocks)' do
62
- lambda {
63
- (
64
- b1 = lambda do |a| @x4 end; b2 = lambda { @x4 }; b3 = lambda do @x4 end ; b2
65
- ).to_source
66
- }.should.raise(Sourcify::MultipleMatchingProcsPerLineError)
67
- end
24
+ error = Sourcify::MultipleMatchingProcsPerLineError
68
25
 
26
+ should "raise #{error} w no nesting on same line" do
27
+ b1 = lambda {|a| @x }; b2 = lambda { @x }; b3 = lambda { @x }
28
+ lambda { b2.to_source }.should.raise(error)
69
29
  end
70
30
 
71
- describe 'w single level nesting on same line' do
72
-
73
- should 'raise Sourcify::MultipleMatchingProcsPerLineError (all do...end blocks)' do
74
- lambda {
75
- (
76
- b1 = lambda do |a| @x1 end; b2 = lambda do lambda do @x1 end end; b2
77
- ).to_source
78
- }.should.raise(Sourcify::MultipleMatchingProcsPerLineError)
79
- end
80
-
81
- should 'raise Sourcify::MultipleMatchingProcsPerLineError (all {...} blocks)' do
82
- lambda {
83
- (
84
- b1 = lambda {|a| @x2 }; b2 = lambda { lambda { @x2 } }; b2
85
- ).to_source
86
- }.should.raise(Sourcify::MultipleMatchingProcsPerLineError)
87
- end
88
-
89
- should 'raise Sourcify::MultipleMatchingProcsPerLineError (mixed {...} w do...end blocks)' do
90
- lambda {
91
- (
92
- b1 = lambda {|a| @x3 }; b2 = lambda do lambda { @x4 } end; b2
93
- ).to_source
94
- }.should.raise(Sourcify::MultipleMatchingProcsPerLineError)
95
- end
96
-
97
- should 'raise Sourcify::MultipleMatchingProcsPerLineError (mixed do...end w {...} blocks)' do
98
- lambda {
99
- (
100
- b1 = lambda do |a| @x4 end; b2 = lambda { lambda do @x4 end }; b2
101
- ).to_source
102
- }.should.raise(Sourcify::MultipleMatchingProcsPerLineError)
103
- end
104
-
31
+ should "raise #{error} w single level nesting on same line" do
32
+ b1 = lambda {|a| @x }; b2 = lambda { lambda { @x } }
33
+ lambda { b2.to_source }.should.raise(error)
105
34
  end
106
35
 
107
- describe 'w multi level nesting on same line' do
108
-
109
- should 'raise Sourcify::MultipleMatchingProcsPerLineError (all do...end blocks)' do
110
- lambda {
111
- (
112
- b1 = lambda do |a| lambda do lambda do @x1 end end end
113
- b2 = b1.call(1)
114
- ).to_source
115
- }.should.raise(Sourcify::MultipleMatchingProcsPerLineError)
116
- end
117
-
118
- should 'raise Sourcify::MultipleMatchingProcsPerLineError (all {...} blocks)' do
119
- lambda {
120
- (
121
- b1 = lambda {|a| lambda { lambda { @x2 } } }
122
- b2 = b1.call(1)
123
- ).to_source
124
- }.should.raise(Sourcify::MultipleMatchingProcsPerLineError)
125
- end
126
-
127
- should 'raise Sourcify::MultipleMatchingProcsPerLineError (mixed {...} w do...end blocks)' do
128
- lambda {
129
- (
130
- b1 = lambda {|a| lambda do lambda { @x4 } end }
131
- b2 = b1.call(1)
132
- ).to_source
133
- }.should.raise(Sourcify::MultipleMatchingProcsPerLineError)
134
- end
135
-
136
- should 'raise Sourcify::MultipleMatchingProcsPerLineError (mixed do...end w {...} blocks)' do
137
- lambda {
138
- (
139
- b1 = lambda do |a| lambda { lambda do @x4 end } end
140
- b2 = b1.call(1)
141
- ).to_source
142
- }.should.raise(Sourcify::MultipleMatchingProcsPerLineError)
143
- end
144
-
36
+ should "raise #{error} w multi level nesting on same line" do
37
+ b2 = (lambda {|a| lambda { lambda { @x } } }).call(1)
38
+ lambda { b2.to_source }.should.raise(error)
145
39
  end
146
40
 
147
41
  end
@@ -1,99 +1,20 @@
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
  describe 'Proc#to_source from multi blocks w single match' do
4
4
 
5
- expected = 'proc { @x%s }'
6
-
7
- describe 'wo nesting on same line' do
8
-
9
- should 'skip non-matching (all do...end blocks)' do
10
- (
11
- b1 = lambda do |a| @x1 end; b2 = lambda do @x1 end; b2
12
- ).should.be having_source(expected%1)
13
- end
14
-
15
- should 'skip non-matching (all {...} blocks)' do
16
- (
17
- b1 = lambda {|a| @x2 }; b2 = lambda { @x2 }; b2
18
- ).should.be having_source(expected%2)
19
- end
20
-
21
- should 'skip non-matching (mixed {...} with do...end blocks)' do
22
- (
23
- b1 = lambda {|a| @x3 }; b2 = lambda do @x3 end; b2
24
- ).should.be having_source(expected%3)
25
- end
26
-
27
- should 'skip non-matching (mixed do...end with {...} blocks)' do
28
- (
29
- b1 = lambda do |a| @x4 end; b2 = lambda { @x4 }; b2
30
- ).should.be having_source(expected%4)
31
- end
32
-
5
+ should 'skip non-matching w no nesting on same line' do
6
+ b1 = lambda do |a| @x1 end; b2 = lambda do @x1 end
7
+ b2.should.be having_source('proc { @x1 }')
33
8
  end
34
9
 
35
- describe 'w single level nesting on same line' do
36
-
37
- should 'skip non-matching (all do...end blocks)' do
38
- (
39
- b1 = lambda do |a| lambda do @x1 end end
40
- b2 = b1.call(1) # returns the inner proc
41
- ).should.be having_source(expected%1)
42
- end
43
-
44
- should 'skip non-matching (all {...} blocks)' do
45
- (
46
- b1 = lambda {|a| lambda { @x2 } }
47
- b2 = b1.call(1) # returns the inner proc
48
- ).should.be having_source(expected%2)
49
- end
50
-
51
- should 'skip non-matching (mixed {...} with do...end blocks)' do
52
- (
53
- b1 = lambda {|a| lambda do @x3 end }
54
- b2 = b1.call(1) # returns the inner proc
55
- ).should.be having_source(expected%3)
56
- end
57
-
58
- should 'skip non-matching (mixed do...end with {...} blocks)' do
59
- (
60
- b1 = lambda do |a| lambda { @x4 } end
61
- b2 = b1.call(1) # returns the inner proc
62
- ).should.be having_source(expected%4)
63
- end
64
-
10
+ should 'skip non-matching w single level nesting on same line' do
11
+ b2 = (lambda {|a| lambda { @x2 } }).call(1)
12
+ b2.should.be having_source('proc { @x2 }')
65
13
  end
66
14
 
67
- describe 'w multi level nesting on same line' do
68
-
69
- should 'skip non-matching (all do...end blocks)' do
70
- (
71
- b1 = lambda do |a| lambda do |a| b2 = lambda do @x1 end end end
72
- b2 = b1.call(1).call(1) # returns the inner-most proc
73
- ).should.be having_source(expected%1)
74
- end
75
-
76
- should 'skip non-matching (all {...} blocks)' do
77
- (
78
- b1 = lambda {|a| lambda {|a| b2 = lambda { @x2 } } }
79
- b2 = b1.call(1).call(1) # returns the inner-most proc
80
- ).should.be having_source(expected%2)
81
- end
82
-
83
- should 'skip non-matching (mixed {...} with do...end blocks)' do
84
- (
85
- b1 = lambda {|a| lambda do |a| b2 = lambda do @x3 end end }
86
- b2 = b1.call(1).call(1) # returns the inner-most proc
87
- ).should.be having_source(expected%3)
88
- end
89
-
90
- should 'skip non-matching (mixed do...end with {...} blocks)' do
91
- (
92
- b1 = lambda do |a| lambda do |a| lambda { @x4 } end end
93
- b2 = b1.call(1).call(1) # returns the inner-most proc
94
- ).should.be having_source(expected%4)
95
- end
96
-
15
+ should 'skip non-matching w multi level nesting on same line' do
16
+ b2 = (lambda {|a| lambda {|a| b2 = lambda { @x3 } } }).call(1).call(1)
17
+ b2.should.be having_source('proc { @x3 }')
97
18
  end
98
19
 
99
20
  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
+ options = {:attached_to => :lambda}
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' 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
+ error = Sourcify::MultipleMatchingProcsPerLineError
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(options) }.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(options) }.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(options) }.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 {:attached_to => ...} & no match' do
4
+
5
+ options = {:attached_to => :forever}
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 }', options)
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 } }', options)
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 } }', options)
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 = watever { @x }; b3 = lambda { @x }
30
+ lambda { b2.to_source(options) }.should.raise(error)
31
+ end
32
+
33
+ should "raise #{error} w single level nesting on same line" do
34
+ b1 = lambda {|a| @x }; b2 = watever { lambda { @x } }
35
+ lambda { b2.to_source(options) }.should.raise(error)
36
+ end
37
+
38
+ should "raise #{error} w multi level nesting on same line" do
39
+ b2 = (lambda {|a| watever { lambda { @x } } }).call(1)
40
+ lambda { b2.to_source(options) }.should.raise(error)
41
+ end
42
+
43
+ end
44
+
45
+ end