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.
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,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 while block" do
5
+
6
+ should 'handle w do' do
7
+ def m1
8
+ while true do @x1 = 1 end
9
+ end
10
+ method(:m1).should.be having_source(%(
11
+ def m1
12
+ while true do @x1 = 1 end
13
+ end
14
+ ))
15
+ end
16
+
17
+ should 'handle w \ do' do
18
+ def m2
19
+ while true \
20
+ do @x1 = 2 end
21
+ end
22
+ method(:m2).should.be having_source(%(
23
+ def m2
24
+ while true do @x1 = 2 end
25
+ end
26
+ ))
27
+ end
28
+
29
+ should 'handle wo do (w newline)' do
30
+ def m3
31
+ while true
32
+ @x1 = 3
33
+ end
34
+ end
35
+ method(:m3).should.be having_source(%(
36
+ def m3
37
+ while true
38
+ @x1 = 3
39
+ end
40
+ end
41
+ ))
42
+ end
43
+
44
+ should 'handle wo do (w semicolon)' do
45
+ def m4
46
+ while true; @x1 = 4; end
47
+ end
48
+ method(:m4).should.be having_source(%(
49
+ def m4
50
+ while 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
+ while true do
60
+ while true; @x1 = 5; end
61
+ end
62
+ end
63
+ method(:m5).should.be having_source(%(
64
+ def m5
65
+ while true do
66
+ while 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
+ while true
77
+ while true; @x1 = 6; end
78
+ end
79
+ end
80
+ method(:m6).should.be having_source(%(
81
+ def m6
82
+ while true
83
+ while 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
+ while true
94
+ while true do @x1 = 7 end
95
+ end
96
+ end
97
+ method(:m7).should.be having_source(%(
98
+ def m7
99
+ while true
100
+ while 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
+ while true do
111
+ while true do @x1 = 8 end
112
+ end
113
+ end
114
+ method(:m8).should.be having_source(%(
115
+ def m8
116
+ while true
117
+ while 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 while true
128
+ end
129
+ method(:m9).should.be having_source(%(
130
+ def m9
131
+ @x1 = 9 while true
132
+ end
133
+ ))
134
+ end
135
+
136
+ should 'handle block within modifier' do
137
+ def m10
138
+ @x1 = 10 while (
139
+ while true do @x1 = 10 end
140
+ )
141
+ end
142
+ method(:m10).should.be having_source(%(
143
+ def m10
144
+ @x1 = 10 while (
145
+ while true do @x1 = 10 end
146
+ )
147
+ end
148
+ ))
149
+ end
150
+
151
+ should 'handle modifier within block' do
152
+ def m11
153
+ while true
154
+ @x1 = 11 while true
155
+ end
156
+ end
157
+ method(:m11).should.be having_source(%(
158
+ def m11
159
+ while true
160
+ @x1 = 11 while true
161
+ end
162
+ end
163
+ ))
164
+ end
165
+
166
+ should 'handle modifier w trailing backslash' do
167
+ def m12
168
+ @x1 = 9 \
169
+ while true
170
+ end
171
+ method(:m12).should.be having_source(%(
172
+ def m12
173
+ @x1 = 9 while true
174
+ end
175
+ ))
176
+ end
177
+
178
+ end
179
+ end
@@ -0,0 +1,19 @@
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 singleton method' do
5
+
6
+ should 'strip object' do
7
+ thing = Object.new
8
+ def m
9
+ @x1 = 1
10
+ end
11
+ method(:m).should.be having_source(%(
12
+ def m
13
+ @x1 = 1
14
+ end
15
+ ))
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,30 @@
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 '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
+ def m1; x; end
21
+ method(:m1).to_source
22
+ )).should.be equal_to(%(
23
+ def m1
24
+ x
25
+ end
26
+ ))
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,30 @@
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 multi blocks and many matches' do
5
+
6
+ if has_parsetree?
7
+ # TODO: Should we support this ??
8
+ else
9
+
10
+ error = Sourcify::MultipleMatchingMethodsPerLineError
11
+
12
+ should "raise #{error} w no nesting on same line" do
13
+ def m1; @x1; end; def m1; @x2; end
14
+ lambda { method(:m1).to_source }.should.raise(error)
15
+ end
16
+
17
+ should "raise #{error} w single level nesting on same line" do
18
+ def m2; class << self; def m2; @x1; end; end; end
19
+ lambda { method(:m2).to_source }.should.raise(error)
20
+ end
21
+
22
+ should "raise #{error} w multi level nesting on same line" do
23
+ def m3; class << self; def m3; class << self; def m3; @x1; end; end; end; end; end
24
+ lambda { method(:m3).to_source }.should.raise(error)
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,36 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
2
+
3
+ describe 'Method#to_source (from def...end)' do
4
+ describe 'w single blocks and many matches' do
5
+
6
+ should 'skip non-matching w no nesting on same line' do
7
+ def m1(a); @x1; end; def m1(b); @x2; end
8
+ method(:m1).should.be having_source(%(
9
+ def m1(b)
10
+ @x2
11
+ end
12
+ ))
13
+ end
14
+
15
+ should 'skip non-matching w single level nesting on same line' do
16
+ def m2(a); class << self; def m2(b); @x1; end; end; end
17
+ m2(1) # calling m2 has the side effect of redefining m2
18
+ method(:m2).should.be having_source(%(
19
+ def m2(b)
20
+ @x1
21
+ end
22
+ ))
23
+ end
24
+
25
+ should 'skip non-matching w multi level nesting on same line' do
26
+ def m3(a); class << self; def m3(b); class << self; def m3(c); @x1; end; end; end; end; end
27
+ m3(1); m3(2) # calling m3 twice has the side effect of redefining m3 twice
28
+ method(:m3).should.be having_source(%(
29
+ def m3(c)
30
+ @x1
31
+ end
32
+ ))
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,113 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
2
+
3
+ describe "Method#to_source (from define_method)" do
4
+ describe "w braced block" do
5
+
6
+ before { @thing = Object.new }
7
+
8
+ describe 'w block declared elsewhere' do
9
+
10
+ should 'wo arg' do
11
+ blk = lambda { x = 1 }
12
+ @thing.class.send(:define_method, :m1, &blk)
13
+ @thing.method(:m1).should.be having_source(%(
14
+ def m1
15
+ x = 1
16
+ end
17
+ ))
18
+ end
19
+
20
+ should 'w one required arg' do
21
+ blk = lambda {|a| x = 1 }
22
+ @thing.class.send(:define_method, :m2, &blk)
23
+ @thing.method(:m2).should.be having_source(%(
24
+ def m2(a)
25
+ x = 1
26
+ end
27
+ ))
28
+ end
29
+
30
+ should 'w one optional arg' do
31
+ blk = lambda {|a=1| x = 1 }
32
+ @thing.class.send(:define_method, :m3, &blk)
33
+ @thing.method(:m3).should.be having_source(%(
34
+ def m3(a = 1)
35
+ x = 1
36
+ end
37
+ ))
38
+ end
39
+
40
+ should 'w multiple required args' do
41
+ blk = lambda {|a, b, c| x = 1 }
42
+ @thing.class.send(:define_method, :m5, &blk)
43
+ @thing.method(:m5).should.be having_source(%(
44
+ def m5(a, b, c)
45
+ x = 1
46
+ end
47
+ ))
48
+ end
49
+
50
+ should 'w multiple args w one optional' do
51
+ blk = lambda {|a, b, c=1| x = 1 }
52
+ @thing.class.send(:define_method, :m6, &blk)
53
+ @thing.method(:m6).should.be having_source(%(
54
+ def m6(a, b, c = 1)
55
+ x = 1
56
+ end
57
+ ))
58
+ end
59
+
60
+ end
61
+
62
+
63
+ describe 'w block attached' do
64
+
65
+ should 'wo arg' do
66
+ @thing.class.send(:define_method, :m1) { x = 1 }
67
+ @thing.method(:m1).should.be having_source(%(
68
+ def m1
69
+ x = 1
70
+ end
71
+ ))
72
+ end
73
+
74
+ should 'w one required arg' do
75
+ @thing.class.send(:define_method, :m2) {|a| x = 1 }
76
+ @thing.method(:m2).should.be having_source(%(
77
+ def m2(a)
78
+ x = 1
79
+ end
80
+ ))
81
+ end
82
+
83
+ should 'w one optional arg' do
84
+ @thing.class.send(:define_method, :m3) {|a=1| x = 1 }
85
+ @thing.method(:m3).should.be having_source(%(
86
+ def m3(a = 1)
87
+ x = 1
88
+ end
89
+ ))
90
+ end
91
+
92
+ should 'w multiple required args' do
93
+ @thing.class.send(:define_method, :m5) {|a, b, c| x = 1 }
94
+ @thing.method(:m5).should.be having_source(%(
95
+ def m5(a, b, c)
96
+ x = 1
97
+ end
98
+ ))
99
+ end
100
+
101
+ should 'w multiple args w one optional' do
102
+ @thing.class.send(:define_method, :m6) {|a, b, c=1| x = 1 }
103
+ @thing.method(:m6).should.be having_source(%(
104
+ def m6(a, b, c = 1)
105
+ x = 1
106
+ end
107
+ ))
108
+ end
109
+
110
+ end
111
+
112
+ end
113
+ end
@@ -0,0 +1,145 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
2
+
3
+ describe "Method#to_source (from define_method)" do
4
+ describe "w do..end block" do
5
+
6
+ before { @thing = Object.new }
7
+
8
+ describe 'w block declared elsewhere' do
9
+
10
+ should 'wo arg' do
11
+ blk = lambda do
12
+ x = 1
13
+ end
14
+ @thing.class.send(:define_method, :m1, &blk)
15
+ @thing.method(:m1).should.be having_source(%(
16
+ def m1
17
+ x = 1
18
+ end
19
+ ))
20
+ end
21
+
22
+ should 'w one required arg' do
23
+ blk = lambda do |a|
24
+ x = 1
25
+ end
26
+ @thing.class.send(:define_method, :m2, &blk)
27
+ @thing.method(:m2).should.be having_source(%(
28
+ def m2(a)
29
+ x = 1
30
+ end
31
+ ))
32
+ end
33
+
34
+ should 'w one optional arg' do
35
+ blk = lambda do |a=1|
36
+ x = 1
37
+ end
38
+ @thing.class.send(:define_method, :m3, &blk)
39
+ @thing.method(:m3).should.be having_source(%(
40
+ def m3(a = 1)
41
+ x = 1
42
+ end
43
+ ))
44
+ end
45
+
46
+ should 'w multiple required args' do
47
+ blk = lambda do |a, b, c|
48
+ x = 1
49
+ end
50
+ @thing.class.send(:define_method, :m5, &blk)
51
+ @thing.method(:m5).should.be having_source(%(
52
+ def m5(a, b, c)
53
+ x = 1
54
+ end
55
+ ))
56
+ end
57
+
58
+ should 'w multiple args w one optional' do
59
+ blk = lambda do |a, b, c=1|
60
+ x = 1
61
+ end
62
+ @thing.class.send(:define_method, :m6, &blk)
63
+ @thing.method(:m6).should.be having_source(%(
64
+ def m6(a, b, c = 1)
65
+ x = 1
66
+ end
67
+ ))
68
+ end
69
+
70
+ # should 'w multiple args w one required group' do
71
+ # blk = lambda do |a, b, (c,d)|
72
+ # x = 1
73
+ # end
74
+ # @thing.class.send(:define_method, :m7, &blk)
75
+ # @thing.method(:m7).should.be having_source(%(
76
+ # def m7(a, b, (c,d))
77
+ # x = 1
78
+ # end
79
+ # ))
80
+ # end
81
+
82
+ end
83
+
84
+
85
+ describe 'w block attached' do
86
+
87
+ should 'wo arg' do
88
+ @thing.class.send(:define_method, :m1) do
89
+ x = 1
90
+ end
91
+ @thing.method(:m1).should.be having_source(%(
92
+ def m1
93
+ x = 1
94
+ end
95
+ ))
96
+ end
97
+
98
+ should 'w one required arg' do
99
+ @thing.class.send(:define_method, :m2) do |a|
100
+ x = 1
101
+ end
102
+ @thing.method(:m2).should.be having_source(%(
103
+ def m2(a)
104
+ x = 1
105
+ end
106
+ ))
107
+ end
108
+
109
+ should 'w one optional arg' do
110
+ @thing.class.send(:define_method, :m3) do |a=1|
111
+ x = 1
112
+ end
113
+ @thing.method(:m3).should.be having_source(%(
114
+ def m3(a = 1)
115
+ x = 1
116
+ end
117
+ ))
118
+ end
119
+
120
+ should 'w multiple required args' do
121
+ @thing.class.send(:define_method, :m5) do |a, b, c|
122
+ x = 1
123
+ end
124
+ @thing.method(:m5).should.be having_source(%(
125
+ def m5(a, b, c)
126
+ x = 1
127
+ end
128
+ ))
129
+ end
130
+
131
+ should 'w multiple args w one optional' do
132
+ @thing.class.send(:define_method, :m6) do |a, b, c=1|
133
+ x = 1
134
+ end
135
+ @thing.method(:m6).should.be having_source(%(
136
+ def m6(a, b, c = 1)
137
+ x = 1
138
+ end
139
+ ))
140
+ end
141
+
142
+ end
143
+
144
+ end
145
+ end