seeing_is_believing 2.1.3 → 2.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -0
- data/Readme.md +1 -0
- data/features/flags.feature +2 -2
- data/features/regression.feature +95 -0
- data/features/support/env.rb +2 -2
- data/lib/seeing_is_believing.rb +6 -4
- data/lib/seeing_is_believing/binary/clean_body.rb +1 -1
- data/lib/seeing_is_believing/binary/comment_formatter.rb +8 -1
- data/lib/seeing_is_believing/binary/comment_lines.rb +1 -0
- data/lib/seeing_is_believing/binary/commentable_lines.rb +3 -0
- data/lib/seeing_is_believing/evaluate_by_moving_files.rb +2 -2
- data/lib/seeing_is_believing/has_exception.rb +17 -1
- data/lib/seeing_is_believing/line.rb +33 -0
- data/lib/seeing_is_believing/result.rb +31 -0
- data/lib/seeing_is_believing/the_matrix.rb +25 -9
- data/lib/seeing_is_believing/version.rb +1 -1
- data/lib/seeing_is_believing/wrap_expressions.rb +16 -8
- data/seeing_is_believing.gemspec +4 -2
- data/spec/binary/clean_body_spec.rb +45 -44
- data/spec/binary/comment_formatter_spec.rb +24 -23
- data/spec/binary/comment_lines_spec.rb +31 -30
- data/spec/binary/parse_args_spec.rb +130 -129
- data/spec/binary/rewrite_comments_spec.rb +10 -9
- data/spec/debugger_spec.rb +9 -8
- data/spec/evaluate_by_moving_files_spec.rb +26 -19
- data/spec/hard_core_ensure_spec.rb +32 -20
- data/spec/line_spec.rb +27 -26
- data/spec/seeing_is_believing_spec.rb +155 -132
- data/spec/spec_helper.rb +3 -0
- data/spec/wrap_expressions_spec.rb +376 -313
- metadata +37 -6
data/spec/spec_helper.rb
ADDED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'spec_helper'
|
1
2
|
require 'seeing_is_believing/wrap_expressions'
|
2
3
|
|
3
4
|
describe SeeingIsBelieving::WrapExpressions do
|
@@ -12,7 +13,7 @@ describe SeeingIsBelieving::WrapExpressions do
|
|
12
13
|
end
|
13
14
|
|
14
15
|
it 'can inject syntax errors with __TOTAL_FUCKING_FAILURE__' do
|
15
|
-
wrap('__TOTAL_FUCKING_FAILURE__').
|
16
|
+
expect(wrap('__TOTAL_FUCKING_FAILURE__')).to eq '<.....TOTAL FUCKING FAILURE!.....>'
|
16
17
|
end
|
17
18
|
|
18
19
|
describe 'wrapping the body' do
|
@@ -22,25 +23,25 @@ describe SeeingIsBelieving::WrapExpressions do
|
|
22
23
|
after_each: -> * { '>' } } }
|
23
24
|
|
24
25
|
it 'wraps the entire body, ignoring leading comments and the data segment' do
|
25
|
-
described_class.call("#comment\nA\n__END__\n1", options).
|
26
|
+
expect(described_class.call("#comment\nA\n__END__\n1", options)).to eq "#comment\n[<A>]\n__END__\n1"
|
26
27
|
end
|
27
28
|
|
28
29
|
it 'does nothing when there are only comments' do
|
29
|
-
described_class.call("# abc", options).
|
30
|
+
expect(described_class.call("# abc", options)).to eq "# abc"
|
30
31
|
end
|
31
32
|
|
32
33
|
it 'comes in before trailing comments' do
|
33
|
-
described_class.call("1# abc", options).
|
34
|
+
expect(described_class.call("1# abc", options)).to eq "[<1>]# abc"
|
34
35
|
end
|
35
36
|
|
36
37
|
it 'wraps bodies that are wrapped in parentheses' do
|
37
|
-
wrap('(1)').
|
38
|
-
wrap("(\n<<doc\ndoc\n)").
|
38
|
+
expect(wrap('(1)')).to eq '<(1)>'
|
39
|
+
expect(wrap("(\n<<doc\ndoc\n)")).to eq "<(\n<<<doc>\ndoc\n)>"
|
39
40
|
end
|
40
41
|
|
41
42
|
context 'fucking heredocs' do
|
42
43
|
example 'single heredoc' do
|
43
|
-
described_class.call("<<A\nA", options).
|
44
|
+
expect(described_class.call("<<A\nA", options)).to eq "[<<<A>]\nA"
|
44
45
|
end
|
45
46
|
|
46
47
|
example 'multiple heredocs' do
|
@@ -50,18 +51,30 @@ describe SeeingIsBelieving::WrapExpressions do
|
|
50
51
|
# "[<<<<A>\nA\n<<B>]\nB"
|
51
52
|
# instead of
|
52
53
|
# "[<<<A>\nA\n<<<B>]\nB"
|
53
|
-
described_class.call("<<A\nA\n<<B\nB", options).
|
54
|
+
expect(described_class.call("<<A\nA\n<<B\nB", options)).to eq "[<<<<A>\nA\n<<B>]\nB"
|
54
55
|
end
|
55
56
|
|
56
57
|
example 'heredocs as targets and arguments to methods' do
|
57
|
-
described_class.call("<<A.size 1\nA", options).
|
58
|
-
described_class.call("<<A.size\nA", options).
|
59
|
-
described_class.call("<<A.size()\nA", options).
|
60
|
-
described_class.call("a.size <<A\nA", options).
|
61
|
-
described_class.call("<<A.size <<B\nA\nB", options).
|
62
|
-
described_class.call("<<A.size(<<B)\nA\nB", options).
|
58
|
+
expect(described_class.call("<<A.size 1\nA", options)).to eq "[<<<A.size 1>]\nA"
|
59
|
+
expect(described_class.call("<<A.size\nA", options)).to eq "[<<<A.size>]\nA"
|
60
|
+
expect(described_class.call("<<A.size()\nA", options)).to eq "[<<<A.size()>]\nA"
|
61
|
+
expect(described_class.call("a.size <<A\nA", options)).to eq "[<a.size <<A>]\nA"
|
62
|
+
expect(described_class.call("<<A.size <<B\nA\nB", options)).to eq "[<<<A.size <<B>]\nA\nB"
|
63
|
+
expect(described_class.call("<<A.size(<<B)\nA\nB", options)).to eq "[<<<A.size(<<B)>]\nA\nB"
|
63
64
|
end
|
64
65
|
end
|
66
|
+
|
67
|
+
it 'identifies the last line of the body' do
|
68
|
+
expect(described_class.call("a\n"\
|
69
|
+
"def b\n"\
|
70
|
+
" c = 1\n"\
|
71
|
+
"end",
|
72
|
+
options)
|
73
|
+
).to eq "[<a>\n"\
|
74
|
+
"def b\n"\
|
75
|
+
" <c = 1>\n"\
|
76
|
+
"end]"
|
77
|
+
end
|
65
78
|
end
|
66
79
|
|
67
80
|
it 'passes the current line number to the before_each and after_each wrappers' do
|
@@ -70,20 +83,20 @@ describe SeeingIsBelieving::WrapExpressions do
|
|
70
83
|
before_each: -> _pre_line_num { pre_line_num = _pre_line_num; '<' },
|
71
84
|
after_each: -> _post_line_num { post_line_num = _post_line_num; '>' }
|
72
85
|
)
|
73
|
-
pre_line_num.
|
74
|
-
post_line_num.
|
86
|
+
expect(pre_line_num).to eq 2
|
87
|
+
expect(post_line_num).to eq 2
|
75
88
|
end
|
76
89
|
|
77
90
|
it 'does nothing for an empty program' do
|
78
|
-
wrap("").
|
79
|
-
wrap("\n").
|
91
|
+
expect(wrap("")).to eq ""
|
92
|
+
expect(wrap("\n")).to eq "\n"
|
80
93
|
end
|
81
94
|
|
82
95
|
it 'ignores comments' do
|
83
|
-
wrap
|
84
|
-
wrap
|
85
|
-
wrap
|
86
|
-
wrap
|
96
|
+
expect(wrap "# comment" ).to eq "# comment"
|
97
|
+
expect(wrap "1 #abc\n#def" ).to eq "<1> #abc\n#def"
|
98
|
+
expect(wrap "1\n=begin\n2\n=end").to eq "<1>\n=begin\n2\n=end"
|
99
|
+
expect(wrap "=begin\n1\n=end\n2").to eq "=begin\n1\n=end\n<2>"
|
87
100
|
end
|
88
101
|
|
89
102
|
describe 'void value expressions' do
|
@@ -97,91 +110,91 @@ describe SeeingIsBelieving::WrapExpressions do
|
|
97
110
|
end
|
98
111
|
|
99
112
|
it 'knows a `return`, `next`, `redo`, `retry`, and `break` are void values' do
|
100
|
-
void_value?(ast_for("def a; return; end").children.last).
|
101
|
-
void_value?(ast_for("loop { next }").children.last).
|
102
|
-
void_value?(ast_for("loop { redo }").children.last).
|
103
|
-
void_value?(ast_for("loop { break }").children.last).
|
113
|
+
expect(void_value?(ast_for("def a; return; end").children.last)).to be true
|
114
|
+
expect(void_value?(ast_for("loop { next }" ).children.last)).to be true
|
115
|
+
expect(void_value?(ast_for("loop { redo }" ).children.last)).to be true
|
116
|
+
expect(void_value?(ast_for("loop { break }" ).children.last)).to be true
|
104
117
|
|
105
118
|
the_retry = ast_for("begin; rescue; retry; end").children.first.children[1].children.last
|
106
|
-
the_retry.type.
|
107
|
-
void_value?
|
119
|
+
expect(the_retry.type).to eq :retry
|
120
|
+
expect(void_value? the_retry).to eq true
|
108
121
|
end
|
109
122
|
it 'knows an `if` is a void value if either side is a void value' do
|
110
123
|
the_if = ast_for("def a; if 1; return 2; else; 3; end; end").children.last
|
111
|
-
the_if.type.
|
112
|
-
void_value?(the_if).
|
124
|
+
expect(the_if.type).to eq :if
|
125
|
+
expect(void_value?(the_if)).to be true
|
113
126
|
|
114
127
|
the_if = ast_for("def a; if 1; 2; else; return 3; end; end").children.last
|
115
|
-
the_if.type.
|
116
|
-
void_value?(the_if).
|
128
|
+
expect(the_if.type).to eq :if
|
129
|
+
expect(void_value?(the_if)).to be true
|
117
130
|
|
118
131
|
the_if = ast_for("def a; if 1; 2; else; 3; end; end").children.last
|
119
|
-
the_if.type.
|
120
|
-
void_value?(the_if).
|
132
|
+
expect(the_if.type).to eq :if
|
133
|
+
expect(void_value?(the_if)).to be false
|
121
134
|
end
|
122
135
|
it 'knows a begin is a void value if its last element is a void value' do
|
123
136
|
the_begin = ast_for("loop { begin; break; end }").children.last
|
124
|
-
[:begin, :kwbegin].
|
125
|
-
void_value?(the_begin).
|
137
|
+
expect([:begin, :kwbegin]).to include the_begin.type
|
138
|
+
expect(void_value?(the_begin)).to be true
|
126
139
|
|
127
140
|
the_begin = ast_for("loop { begin; 1; end }").children.last
|
128
|
-
[:begin, :kwbegin].
|
129
|
-
void_value?(the_begin).
|
141
|
+
expect([:begin, :kwbegin]).to include the_begin.type
|
142
|
+
expect(void_value?(the_begin)).to be false
|
130
143
|
end
|
131
144
|
it 'knows a rescue is a void value if its last child or its else is a void value' do
|
132
145
|
the_rescue = ast_for("begin; rescue; retry; end").children.first
|
133
|
-
the_rescue.type.
|
134
|
-
void_value?(the_rescue).
|
146
|
+
expect(the_rescue.type).to eq :rescue
|
147
|
+
expect(void_value?(the_rescue)).to be true
|
135
148
|
|
136
149
|
the_rescue = ast_for("begin; rescue; 1; else; retry; end").children.first
|
137
|
-
the_rescue.type.
|
138
|
-
void_value?(the_rescue).
|
150
|
+
expect(the_rescue.type).to eq :rescue
|
151
|
+
expect(void_value?(the_rescue)).to be true
|
139
152
|
|
140
153
|
the_rescue = ast_for("begin; rescue; 1; else; 2; end").children.first
|
141
|
-
the_rescue.type.
|
142
|
-
void_value?(the_rescue).
|
154
|
+
expect(the_rescue.type).to eq :rescue
|
155
|
+
expect(void_value?(the_rescue)).to be false
|
143
156
|
end
|
144
157
|
it 'knows an ensure is a void value if its body or ensure portion are void values' do
|
145
158
|
the_ensure = ast_for("loop { begin; break; ensure; 1; end }").children.last.children.last
|
146
|
-
the_ensure.type.
|
147
|
-
void_value?(the_ensure).
|
159
|
+
expect(the_ensure.type).to eq :ensure
|
160
|
+
expect(void_value?(the_ensure)).to be true
|
148
161
|
|
149
162
|
the_ensure = ast_for("loop { begin; 1; ensure; break; end }").children.last.children.last
|
150
|
-
the_ensure.type.
|
151
|
-
void_value?(the_ensure).
|
163
|
+
expect(the_ensure.type).to eq :ensure
|
164
|
+
expect(void_value?(the_ensure)).to be true
|
152
165
|
|
153
166
|
the_ensure = ast_for("loop { begin; 1; ensure; 2; end }").children.last.children.last
|
154
|
-
the_ensure.type.
|
155
|
-
void_value?(the_ensure).
|
167
|
+
expect(the_ensure.type).to eq :ensure
|
168
|
+
expect(void_value?(the_ensure)).to be false
|
156
169
|
end
|
157
170
|
it 'knows other things are not void values' do
|
158
|
-
void_value?(ast_for "123").
|
171
|
+
expect(void_value?(ast_for "123")).to be false
|
159
172
|
end
|
160
173
|
end
|
161
174
|
|
162
175
|
describe 'basic expressions' do
|
163
176
|
it 'wraps an expression' do
|
164
|
-
wrap("A").
|
177
|
+
expect(wrap("A")).to eq "<A>"
|
165
178
|
end
|
166
179
|
|
167
180
|
it 'wraps multiple expressions' do
|
168
|
-
wrap("A\nB").
|
169
|
-
wrap("(1\n2)").
|
170
|
-
wrap("(1\n2\n)").
|
171
|
-
wrap("begin\n1\n2\nend").
|
181
|
+
expect(wrap("A\nB")).to eq "<A>\n<B>"
|
182
|
+
expect(wrap("(1\n2)")).to eq "<(<1>\n2)>"
|
183
|
+
expect(wrap("(1\n2\n)")).to eq "<(<1>\n<2>\n)>"
|
184
|
+
expect(wrap("begin\n1\n2\nend")).to eq "<begin\n<1>\n<2>\nend>"
|
172
185
|
end
|
173
186
|
|
174
187
|
it 'does not wrap multiple expressions when they constitute a void value' do
|
175
|
-
wrap("def a\n1\nreturn 2\nend").
|
176
|
-
wrap("def a\nreturn 1\n2\nend").
|
188
|
+
expect(wrap("def a\n1\nreturn 2\nend")).to eq "def a\n<1>\nreturn <2>\nend"
|
189
|
+
expect(wrap("def a\nreturn 1\n2\nend")).to eq "def a\nreturn <1>\n<2>\nend"
|
177
190
|
end
|
178
191
|
|
179
192
|
it 'wraps nested expressions' do
|
180
|
-
wrap("A do\nB\nend").
|
193
|
+
expect(wrap("A do\nB\nend")).to eq "<A do\n<B>\nend>"
|
181
194
|
end
|
182
195
|
|
183
196
|
it 'wraps multiple expressions on the same line' do
|
184
|
-
wrap("a;b").
|
197
|
+
expect(wrap("a;b")).to eq "a;<b>"
|
185
198
|
end
|
186
199
|
|
187
200
|
# many of these taken from http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Literals
|
@@ -237,447 +250,500 @@ describe SeeingIsBelieving::WrapExpressions do
|
|
237
250
|
|.each do |literal|
|
238
251
|
actual = wrap(literal)
|
239
252
|
expected = "<#{literal}>"
|
240
|
-
actual.
|
253
|
+
expect(actual).to eq(expected), "expected #{literal.inspect} to equal #{expected.inspect}, got #{actual.inspect}"
|
241
254
|
end
|
242
255
|
end
|
243
256
|
|
244
257
|
it 'wraps macros' do
|
245
258
|
# should this actually replace __FILE__ and __LINE__ so as to avoid fucking up values with the rewrite?
|
246
259
|
# there is also __dir__, but it's only 2.0
|
247
|
-
wrap("__FILE__").
|
248
|
-
wrap("__LINE__").
|
249
|
-
wrap("defined? a").
|
260
|
+
expect(wrap("__FILE__")).to eq "<__FILE__>"
|
261
|
+
expect(wrap("__LINE__")).to eq "<__LINE__>"
|
262
|
+
expect(wrap("defined? a")).to eq "<defined? a>"
|
250
263
|
end
|
251
264
|
|
252
265
|
it 'does not wrap alias, undef' do
|
253
|
-
wrap("alias tos to_s").
|
254
|
-
wrap("undef tos").
|
266
|
+
expect(wrap("alias tos to_s")).to eq "alias tos to_s"
|
267
|
+
expect(wrap("undef tos")).to eq "undef tos"
|
255
268
|
end
|
256
269
|
|
257
270
|
it 'wraps syscalls, but not code interpolated into them' do
|
258
|
-
wrap("`a\nb`").
|
259
|
-
wrap("`a\n\#{1\n2\n3}b`").
|
271
|
+
expect(wrap("`a\nb`")).to eq "<`a\nb`>"
|
272
|
+
expect(wrap("`a\n\#{1\n2\n3}b`")).to eq "<`a\n\#{1\n2\n3}b`>"
|
260
273
|
end
|
261
274
|
end
|
262
275
|
|
263
276
|
describe 'variable lookups' do
|
264
277
|
it 'wraps them' do
|
265
|
-
wrap('a').
|
266
|
-
wrap("$a").
|
267
|
-
wrap("@a").
|
268
|
-
wrap("@@a").
|
278
|
+
expect(wrap('a')).to eq "<a>"
|
279
|
+
expect(wrap("$a")).to eq "<$a>"
|
280
|
+
expect(wrap("@a")).to eq "<@a>"
|
281
|
+
expect(wrap("@@a")).to eq "<@@a>"
|
269
282
|
end
|
270
283
|
end
|
271
284
|
|
272
285
|
describe 'method invocations' do
|
273
286
|
it 'wraps the whole invocation with or without parens' do
|
274
|
-
wrap("a").
|
275
|
-
wrap("a()").
|
276
|
-
wrap("a()").
|
287
|
+
expect(wrap("a")).to eq "<a>"
|
288
|
+
expect(wrap("a()")).to eq "<a()>"
|
289
|
+
expect(wrap("a()")).to eq "<a()>"
|
277
290
|
end
|
278
291
|
|
279
292
|
it 'does not wrap arguments' do
|
280
|
-
wrap("a b").
|
281
|
-
wrap("a(b,c=1,*d,&e)").
|
293
|
+
expect(wrap("a b")).to eq "<a b>"
|
294
|
+
expect(wrap("a(b,c=1,*d,&e)")).to eq "<a(b,c=1,*d,&e)>"
|
282
295
|
end
|
283
296
|
|
284
297
|
it 'wraps blocks' do
|
285
|
-
wrap("a { }").
|
286
|
-
wrap("a {\n}").
|
287
|
-
wrap("a(b) {\n}").
|
298
|
+
expect(wrap("a { }")).to eq "<a { }>"
|
299
|
+
expect(wrap("a {\n}")).to eq "<a {\n}>"
|
300
|
+
expect(wrap("a(b) {\n}")).to eq "<a(b) {\n}>"
|
288
301
|
end
|
289
302
|
|
290
303
|
it 'wraps method calls with an explicit receiver' do
|
291
|
-
wrap("1.mod(2)").
|
292
|
-
wrap("1.mod 2").
|
304
|
+
expect(wrap("1.mod(2)")).to eq "<1.mod(2)>"
|
305
|
+
expect(wrap("1.mod 2")).to eq "<1.mod 2>"
|
293
306
|
end
|
294
307
|
|
295
308
|
it 'wraps operators calls' do
|
296
|
-
wrap("1+1").
|
297
|
-
wrap("a.b+1").
|
298
|
-
wrap("a.b - 1").
|
299
|
-
wrap("a.b -1").
|
300
|
-
wrap("!1").
|
301
|
-
wrap("~1").
|
309
|
+
expect(wrap("1+1")).to eq "<1+1>"
|
310
|
+
expect(wrap("a.b+1")).to eq "<a.b+1>"
|
311
|
+
expect(wrap("a.b - 1")).to eq "<a.b - 1>"
|
312
|
+
expect(wrap("a.b -1")).to eq "<a.b -1>"
|
313
|
+
expect(wrap("!1")).to eq "<!1>"
|
314
|
+
expect(wrap("~1")).to eq "<~1>"
|
302
315
|
end
|
303
316
|
|
304
317
|
it 'wraps methods that end in bangs and questions' do
|
305
|
-
wrap("a.b!").
|
306
|
-
wrap("a.b?").
|
318
|
+
expect(wrap("a.b!")).to eq "<a.b!>"
|
319
|
+
expect(wrap("a.b?")).to eq "<a.b?>"
|
307
320
|
end
|
308
321
|
|
309
322
|
it 'wraps method invocations that span multiple lines' do
|
310
|
-
wrap("a\n.b\n.c").
|
311
|
-
wrap("a\n.b{\n}").
|
312
|
-
wrap("a\n.b{}").
|
313
|
-
wrap("[*1..5]\n.map { |n| n * 2 }\n.take(2).\nsize").
|
323
|
+
expect(wrap("a\n.b\n.c")).to eq "<<<a>\n.b>\n.c>"
|
324
|
+
expect(wrap("a\n.b{\n}")).to eq "<<a>\n.b{\n}>"
|
325
|
+
expect(wrap("a\n.b{}")).to eq "<<a>\n.b{}>"
|
326
|
+
expect(wrap("[*1..5]\n.map { |n| n * 2 }\n.take(2).\nsize")).to eq\
|
314
327
|
"<<<<[*1..5]>\n.map { |n| n * 2 }>\n.take(2)>.\nsize>"
|
315
|
-
wrap("a = b\n.c\na").
|
328
|
+
expect(wrap("a = b\n.c\na")).to eq "<a = <b>\n.c>\n<a>"
|
316
329
|
end
|
317
330
|
|
318
331
|
it 'wraps args in method arguments when the method spans multiple lines' do
|
319
|
-
wrap("a 1,\n2").
|
332
|
+
expect(wrap("a 1,\n2")).to eq "<a <1>,\n2>"
|
320
333
|
end
|
321
334
|
|
322
335
|
it 'does not wrap splat args' do
|
323
|
-
wrap("a(\n*a\n)").
|
324
|
-
wrap("a(\n*1..2\n)").
|
336
|
+
expect(wrap("a(\n*a\n)")).to eq "<a(\n*a\n)>"
|
337
|
+
expect(wrap("a(\n*1..2\n)")).to eq "<a(\n*1..2\n)>"
|
325
338
|
end
|
326
339
|
|
327
340
|
it 'does not wrap hash args' do
|
328
|
-
wrap("a(b: 1,\nc: 2\n)").
|
341
|
+
expect(wrap("a(b: 1,\nc: 2\n)")).to eq "<a(b: <1>,\nc: <2>\n)>"
|
329
342
|
end
|
330
343
|
end
|
331
344
|
|
332
345
|
describe 'assignment' do
|
333
346
|
it 'wraps entire simple assignment' do
|
334
|
-
wrap("a=1").
|
335
|
-
wrap("a.b=1").
|
336
|
-
wrap("A=1").
|
337
|
-
wrap("::A=1").
|
338
|
-
wrap("A::B=1").
|
339
|
-
wrap("@a=1").
|
340
|
-
wrap("@@a=1").
|
341
|
-
wrap("$a=1").
|
347
|
+
expect(wrap("a=1")).to eq "<a=1>"
|
348
|
+
expect(wrap("a.b=1")).to eq "<a.b=1>"
|
349
|
+
expect(wrap("A=1")).to eq "<A=1>"
|
350
|
+
expect(wrap("::A=1")).to eq "<::A=1>"
|
351
|
+
expect(wrap("A::B=1")).to eq "<A::B=1>"
|
352
|
+
expect(wrap("@a=1")).to eq "<@a=1>"
|
353
|
+
expect(wrap("@@a=1")).to eq "<@@a=1>"
|
354
|
+
expect(wrap("$a=1")).to eq "<$a=1>"
|
342
355
|
end
|
343
356
|
|
344
357
|
it 'wraps multiple assignments' do
|
345
|
-
wrap("a,b=c").
|
346
|
-
wrap("a,b=1,2").
|
347
|
-
wrap("a,b.c=1,2").
|
348
|
-
wrap("a,B=1,2").
|
349
|
-
wrap("a,B::C=1,2").
|
350
|
-
wrap("a,@b=1,2").
|
351
|
-
wrap("a,@@b=1,2").
|
352
|
-
wrap("a,$b=1,2").
|
353
|
-
wrap("a, b = x.()").
|
354
|
-
wrap("a, b = c\n.d,\ne\n.f").
|
358
|
+
expect(wrap("a,b=c")).to eq "<a,b=c>"
|
359
|
+
expect(wrap("a,b=1,2")).to eq "<a,b=1,2>"
|
360
|
+
expect(wrap("a,b.c=1,2")).to eq "<a,b.c=1,2>"
|
361
|
+
expect(wrap("a,B=1,2")).to eq "<a,B=1,2>"
|
362
|
+
expect(wrap("a,B::C=1,2")).to eq "<a,B::C=1,2>"
|
363
|
+
expect(wrap("a,@b=1,2")).to eq "<a,@b=1,2>"
|
364
|
+
expect(wrap("a,@@b=1,2")).to eq "<a,@@b=1,2>"
|
365
|
+
expect(wrap("a,$b=1,2")).to eq "<a,$b=1,2>"
|
366
|
+
expect(wrap("a, b = x.()")).to eq "<a, b = x.()>"
|
367
|
+
expect(wrap("a, b = c\n.d,\ne\n.f")).to eq "<a, b = <<c>\n.d>,\n<e>\n.f>"
|
355
368
|
end
|
356
369
|
|
357
370
|
it 'wraps multiple assignment on each line' do
|
358
|
-
wrap("a,b=1,\n2").
|
359
|
-
wrap("a,b=[1,2]\n.map(&:to_s)").
|
360
|
-
wrap("a,b=[1,\n2\n.even?\n]").
|
371
|
+
expect(wrap("a,b=1,\n2")).to eq "<a,b=<1>,\n2>"
|
372
|
+
expect(wrap("a,b=[1,2]\n.map(&:to_s)")).to eq "<a,b=<[1,2]>\n.map(&:to_s)>"
|
373
|
+
expect(wrap("a,b=[1,\n2\n.even?\n]")).to eq "<a,b=[<1>,\n<<2>\n.even?>\n]>"
|
361
374
|
end
|
362
375
|
|
363
376
|
it 'wraps multiple assignment with splats' do
|
364
|
-
wrap("a,* =1,2,3").
|
377
|
+
expect(wrap("a,* =1,2,3")).to eq "<a,* =1,2,3>"
|
365
378
|
end
|
366
379
|
|
367
380
|
it 'wraps the array equivalent' do
|
368
|
-
wrap("a,* =[1,2,3]").
|
369
|
-
wrap("a,* = [ 1,2,3 ] ").
|
381
|
+
expect(wrap("a,* =[1,2,3]")).to eq "<a,* =[1,2,3]>"
|
382
|
+
expect(wrap("a,* = [ 1,2,3 ] ")).to eq "<a,* = [ 1,2,3 ]> "
|
370
383
|
end
|
371
384
|
|
372
385
|
it 'wraps repeated assignments' do
|
373
|
-
wrap("a=b=1").
|
374
|
-
wrap("a=b=\n1").
|
375
|
-
wrap("a=\nb=\n1").
|
386
|
+
expect(wrap("a=b=1")).to eq "<a=b=1>"
|
387
|
+
expect(wrap("a=b=\n1")).to eq "<a=b=\n1>"
|
388
|
+
expect(wrap("a=\nb=\n1")).to eq "<a=\nb=\n1>"
|
376
389
|
end
|
377
390
|
|
378
391
|
it 'wraps operator assignment' do
|
379
|
-
wrap("a += 1").
|
380
|
-
wrap("a *= 1").
|
381
|
-
wrap("a -= 1").
|
382
|
-
wrap("a /= 1").
|
383
|
-
wrap("a **= 1").
|
384
|
-
wrap("a |= 1").
|
385
|
-
wrap("a &= 1").
|
386
|
-
wrap("a ||= 1").
|
387
|
-
wrap("a &&= 1").
|
388
|
-
wrap("a[1] = 2").
|
389
|
-
wrap("a[1] ||= 2").
|
390
|
-
wrap("@a ||= 123").
|
391
|
-
wrap("$a ||= 123").
|
392
|
-
wrap("@@a ||= 123").
|
393
|
-
wrap("B ||= 123").
|
394
|
-
wrap("@a ||= begin\n123\nend").
|
395
|
-
wrap("$a ||= begin\n123\nend").
|
396
|
-
wrap("@@a ||= begin\n123\nend").
|
397
|
-
wrap("B ||= begin\n123\nend").
|
392
|
+
expect(wrap("a += 1")).to eq "<a += 1>"
|
393
|
+
expect(wrap("a *= 1")).to eq "<a *= 1>"
|
394
|
+
expect(wrap("a -= 1")).to eq "<a -= 1>"
|
395
|
+
expect(wrap("a /= 1")).to eq "<a /= 1>"
|
396
|
+
expect(wrap("a **= 1")).to eq "<a **= 1>"
|
397
|
+
expect(wrap("a |= 1")).to eq "<a |= 1>"
|
398
|
+
expect(wrap("a &= 1")).to eq "<a &= 1>"
|
399
|
+
expect(wrap("a ||= 1")).to eq "<a ||= 1>"
|
400
|
+
expect(wrap("a &&= 1")).to eq "<a &&= 1>"
|
401
|
+
expect(wrap("a[1] = 2")).to eq "<a[1] = 2>"
|
402
|
+
expect(wrap("a[1] ||= 2")).to eq "<a[1] ||= 2>"
|
403
|
+
expect(wrap("@a ||= 123")).to eq "<@a ||= 123>"
|
404
|
+
expect(wrap("$a ||= 123")).to eq "<$a ||= 123>"
|
405
|
+
expect(wrap("@@a ||= 123")).to eq "<@@a ||= 123>"
|
406
|
+
expect(wrap("B ||= 123")).to eq "<B ||= 123>"
|
407
|
+
expect(wrap("@a ||= begin\n123\nend")).to eq "<@a ||= begin\n<123>\nend>"
|
408
|
+
expect(wrap("$a ||= begin\n123\nend")).to eq "<$a ||= begin\n<123>\nend>"
|
409
|
+
expect(wrap("@@a ||= begin\n123\nend")).to eq "<@@a ||= begin\n<123>\nend>"
|
410
|
+
expect(wrap("B ||= begin\n123\nend")).to eq "<B ||= begin\n<123>\nend>"
|
411
|
+
end
|
412
|
+
|
413
|
+
it 'wraps assignments that span multiple lines' do
|
414
|
+
# simple assignment
|
415
|
+
expect(wrap("a={\n}")).to eq "<a={\n}>"
|
416
|
+
expect(wrap("a, b = c,{\n}")).to eq "<a, b = <c>,{\n}>"
|
417
|
+
expect(wrap("a.b={\n}")).to eq "<<a>.b={\n}>"
|
418
|
+
expect(wrap("A={\n}")).to eq "<A={\n}>"
|
419
|
+
expect(wrap("::A={\n}")).to eq "<::A={\n}>"
|
420
|
+
expect(wrap("A::B={\n}")).to eq "<A::B={\n}>"
|
421
|
+
expect(wrap("@a={\n}")).to eq "<@a={\n}>"
|
422
|
+
expect(wrap("@@a={\n}")).to eq "<@@a={\n}>"
|
423
|
+
expect(wrap("$a={\n}")).to eq "<$a={\n}>"
|
424
|
+
|
425
|
+
# multiple assignment
|
426
|
+
expect(wrap("a,b={\n}")).to eq "<a,b={\n}>"
|
427
|
+
expect(wrap("a,b={\n},{\n}")).to eq "<a,b=<{\n}>,{\n}>"
|
428
|
+
expect(wrap("a,b.c={\n},{\n}")).to eq "<a,b.c=<{\n}>,{\n}>"
|
429
|
+
expect(wrap("a,B={\n},{\n}")).to eq "<a,B=<{\n}>,{\n}>"
|
430
|
+
expect(wrap("a,B::C={\n},{\n}")).to eq "<a,B::C=<{\n}>,{\n}>"
|
431
|
+
expect(wrap("a,@b={\n},{\n}")).to eq "<a,@b=<{\n}>,{\n}>"
|
432
|
+
expect(wrap("a,@@b={\n},{\n}")).to eq "<a,@@b=<{\n}>,{\n}>"
|
433
|
+
expect(wrap("a,$b={\n},{\n}")).to eq "<a,$b=<{\n}>,{\n}>"
|
434
|
+
|
435
|
+
# repeated assignments
|
436
|
+
expect(wrap("a=\nb={\n}")).to eq "<a=\nb={\n}>"
|
437
|
+
|
438
|
+
# operator assignment
|
439
|
+
expect(wrap("a +={\n}")).to eq "<a +={\n}>"
|
440
|
+
expect(wrap("a *= {\n}")).to eq "<a *= {\n}>"
|
441
|
+
expect(wrap("a -= {\n}")).to eq "<a -= {\n}>"
|
442
|
+
expect(wrap("a /= {\n}")).to eq "<a /= {\n}>"
|
443
|
+
expect(wrap("a **= {\n}")).to eq "<a **= {\n}>"
|
444
|
+
expect(wrap("a |= {\n}")).to eq "<a |= {\n}>"
|
445
|
+
expect(wrap("a &= {\n}")).to eq "<a &= {\n}>"
|
446
|
+
expect(wrap("a ||= {\n}")).to eq "<a ||= {\n}>"
|
447
|
+
expect(wrap("a &&= {\n}")).to eq "<a &&= {\n}>"
|
448
|
+
expect(wrap("a[1] = {\n}")).to eq "<a[<1>] = {\n}>"
|
449
|
+
expect(wrap("a[1] ||= {\n}")).to eq "<a[1] ||= {\n}>"
|
450
|
+
expect(wrap("@a ||= {\n}")).to eq "<@a ||= {\n}>"
|
451
|
+
expect(wrap("$a ||= {\n}")).to eq "<$a ||= {\n}>"
|
452
|
+
expect(wrap("@@a ||= {\n}")).to eq "<@@a ||= {\n}>"
|
453
|
+
expect(wrap("B ||= {\n}")).to eq "<B ||= {\n}>"
|
454
|
+
expect(wrap("{}[:a] ||= {\n}")).to eq "<{}[:a] ||= {\n}>"
|
455
|
+
|
456
|
+
# LHS with values in it on all the operator assignments
|
457
|
+
expect(wrap("a.b += {\n}")).to eq "<a.b += {\n}>"
|
458
|
+
expect(wrap("a.b *= {\n}")).to eq "<a.b *= {\n}>"
|
459
|
+
expect(wrap("a.b -= {\n}")).to eq "<a.b -= {\n}>"
|
460
|
+
expect(wrap("a.b /= {\n}")).to eq "<a.b /= {\n}>"
|
461
|
+
expect(wrap("a.b **= {\n}")).to eq "<a.b **= {\n}>"
|
462
|
+
expect(wrap("a.b |= {\n}")).to eq "<a.b |= {\n}>"
|
463
|
+
expect(wrap("a.b &= {\n}")).to eq "<a.b &= {\n}>"
|
464
|
+
expect(wrap("a.b &&= {\n}")).to eq "<a.b &&= {\n}>"
|
398
465
|
end
|
399
466
|
|
400
467
|
it 'wraps arguments in the assignment' do
|
401
|
-
wrap("a[1\n]=2").
|
402
|
-
wrap("a[1,\n2\n]=3").
|
468
|
+
expect(wrap("a[1\n]=2")).to eq "<a[<1>\n]=2>"
|
469
|
+
expect(wrap("a[1,\n2\n]=3")).to eq "<a[<1>,\n<2>\n]=3>"
|
403
470
|
end
|
404
471
|
end
|
405
472
|
|
406
473
|
describe 'conditionals' do
|
407
474
|
it 'wraps if/elsif/else/end, the whole thing, their conditionals, and their bodies' do
|
408
|
-
wrap("if 1\n2\nelsif 2\n3\nelsif 4\n5\nend").
|
409
|
-
wrap("if 1\n2\nelsif 2\n3\nelse\n4\nend").
|
410
|
-
wrap("if 1\n2\nelsif 3\n4\nend").
|
411
|
-
wrap("if 1\n2\nelse\n2\nend").
|
412
|
-
wrap("if 1\n2\nend").
|
475
|
+
expect(wrap("if 1\n2\nelsif 2\n3\nelsif 4\n5\nend")).to eq "<if <1>\n<2>\nelsif <2>\n<3>\nelsif <4>\n<5>\nend>" # multiple elsif
|
476
|
+
expect(wrap("if 1\n2\nelsif 2\n3\nelse\n4\nend")).to eq "<if <1>\n<2>\nelsif <2>\n<3>\nelse\n<4>\nend>" # elisf and else
|
477
|
+
expect(wrap("if 1\n2\nelsif 3\n4\nend")).to eq "<if <1>\n<2>\nelsif <3>\n<4>\nend>" # elsif only
|
478
|
+
expect(wrap("if 1\n2\nelse\n2\nend")).to eq "<if <1>\n<2>\nelse\n<2>\nend>" # else only
|
479
|
+
expect(wrap("if 1\n2\nend")).to eq "<if <1>\n<2>\nend>" # if only
|
413
480
|
|
414
481
|
# same as above, but with then
|
415
|
-
wrap("if 1 then\n2\nelsif 2 then\n3\nelsif 4 then\n5\nend").
|
416
|
-
wrap("if 1 then\n2\nelsif 2 then\n3\nelse\n4\nend").
|
417
|
-
wrap("if 1 then\n2\nelsif 3 then\n4\nend").
|
418
|
-
wrap("if 1 then\n2\nelse\n2\nend").
|
419
|
-
wrap("if 1 then\n2\nend").
|
482
|
+
expect(wrap("if 1 then\n2\nelsif 2 then\n3\nelsif 4 then\n5\nend")).to eq "<if <1> then\n<2>\nelsif <2> then\n<3>\nelsif <4> then\n<5>\nend>"
|
483
|
+
expect(wrap("if 1 then\n2\nelsif 2 then\n3\nelse\n4\nend")).to eq "<if <1> then\n<2>\nelsif <2> then\n<3>\nelse\n<4>\nend>"
|
484
|
+
expect(wrap("if 1 then\n2\nelsif 3 then\n4\nend")).to eq "<if <1> then\n<2>\nelsif <3> then\n<4>\nend>"
|
485
|
+
expect(wrap("if 1 then\n2\nelse\n2\nend")).to eq "<if <1> then\n<2>\nelse\n<2>\nend>"
|
486
|
+
expect(wrap("if 1 then\n2\nend")).to eq "<if <1> then\n<2>\nend>"
|
420
487
|
|
421
488
|
# inline
|
422
|
-
wrap("1 if 2").
|
489
|
+
expect(wrap("1 if 2")).to eq "<1 if 2>"
|
423
490
|
end
|
424
491
|
|
425
492
|
it 'ignores conditionals that are implicit regexes' do
|
426
|
-
wrap("if /a/\n1\nend").
|
493
|
+
expect(wrap("if /a/\n1\nend")).to eq "<if /a/\n<1>\nend>"
|
427
494
|
end
|
428
495
|
|
429
496
|
it 'wraps ternaries' do
|
430
|
-
wrap("1 ? 2 : 3").
|
431
|
-
wrap("1\\\n?\\\n2\\\n:\\\n3").
|
497
|
+
expect(wrap("1 ? 2 : 3")).to eq "<1 ? 2 : 3>"
|
498
|
+
expect(wrap("1\\\n?\\\n2\\\n:\\\n3")).to eq "<<1>\\\n?\\\n<2>\\\n:\\\n3>"
|
432
499
|
end
|
433
500
|
|
434
501
|
it 'wraps "unless" statements' do
|
435
|
-
wrap("unless 1\n2\nelse\n3\nend").
|
436
|
-
wrap("unless 1\n2\nend").
|
437
|
-
wrap("unless 1 then\n2\nelse\n3\nend").
|
438
|
-
wrap("unless 1 then\n2\nend").
|
439
|
-
wrap("1 unless 2").
|
502
|
+
expect(wrap("unless 1\n2\nelse\n3\nend")).to eq "<unless <1>\n<2>\nelse\n<3>\nend>"
|
503
|
+
expect(wrap("unless 1\n2\nend")).to eq "<unless <1>\n<2>\nend>"
|
504
|
+
expect(wrap("unless 1 then\n2\nelse\n3\nend")).to eq "<unless <1> then\n<2>\nelse\n<3>\nend>"
|
505
|
+
expect(wrap("unless 1 then\n2\nend")).to eq "<unless <1> then\n<2>\nend>"
|
506
|
+
expect(wrap("1 unless 2")).to eq "<1 unless 2>"
|
440
507
|
end
|
441
508
|
|
442
509
|
it 'wraps case statements, and the value they are initialized with, but not the conditionals' do
|
443
|
-
wrap("case 1\nwhen 2\n3\nwhen 4, 5\nelse\n6\nend").
|
444
|
-
wrap("case 1\nwhen 2\nend").
|
445
|
-
wrap("case\nwhen 2\nend").
|
446
|
-
wrap("case\nwhen 2, 3\n4\n5\nend").
|
510
|
+
expect(wrap("case 1\nwhen 2\n3\nwhen 4, 5\nelse\n6\nend")).to eq "<case <1>\nwhen 2\n<3>\nwhen 4, 5\nelse\n<6>\nend>"
|
511
|
+
expect(wrap("case 1\nwhen 2\nend")).to eq "<case <1>\nwhen 2\nend>"
|
512
|
+
expect(wrap("case\nwhen 2\nend")).to eq "<case\nwhen 2\nend>"
|
513
|
+
expect(wrap("case\nwhen 2, 3\n4\n5\nend")).to eq "<case\nwhen 2, 3\n<4>\n<5>\nend>"
|
447
514
|
|
448
|
-
wrap("case 1\nwhen 2 then\n3\nwhen 4, 5 then\nelse\n6\nend").
|
449
|
-
wrap("case 1\nwhen 2 then\nend").
|
450
|
-
wrap("case\nwhen 2 then\nend").
|
451
|
-
wrap("case\nwhen 2, 3 then\n4\n5\nend").
|
515
|
+
expect(wrap("case 1\nwhen 2 then\n3\nwhen 4, 5 then\nelse\n6\nend")).to eq "<case <1>\nwhen 2 then\n<3>\nwhen 4, 5 then\nelse\n<6>\nend>"
|
516
|
+
expect(wrap("case 1\nwhen 2 then\nend")).to eq "<case <1>\nwhen 2 then\nend>"
|
517
|
+
expect(wrap("case\nwhen 2 then\nend")).to eq "<case\nwhen 2 then\nend>"
|
518
|
+
expect(wrap("case\nwhen 2, 3 then\n4\n5\nend")).to eq "<case\nwhen 2, 3 then\n<4>\n<5>\nend>"
|
452
519
|
end
|
453
520
|
|
454
521
|
it 'does not wrap if the last value in any portion is a void value expression' do
|
455
|
-
wrap("def a\nif true\nreturn 1\nend\nend").
|
456
|
-
wrap("def a\nif true\n1\nelse\nreturn 2\nend\nend").
|
457
|
-
wrap("def a\nif true\n1\nelsif true\n2\nelse\nreturn 3\nend\nend").
|
458
|
-
wrap("def a\nif true\nif true\nreturn 1\nend\nend\nend").
|
459
|
-
wrap("def a\nunless true\nreturn 1\nend\nend").
|
460
|
-
wrap("def a\nunless true\n1\nelse\nreturn 2\nend\nend").
|
461
|
-
wrap("def a\ntrue ?\n(return 1) :\n2\nend").
|
462
|
-
wrap("def a\ntrue ?\n1 :\n(return 2)\nend").
|
522
|
+
expect(wrap("def a\nif true\nreturn 1\nend\nend")).to eq "def a\nif <true>\nreturn <1>\nend\nend"
|
523
|
+
expect(wrap("def a\nif true\n1\nelse\nreturn 2\nend\nend")).to eq "def a\nif <true>\n<1>\nelse\nreturn <2>\nend\nend"
|
524
|
+
expect(wrap("def a\nif true\n1\nelsif true\n2\nelse\nreturn 3\nend\nend")).to eq "def a\nif <true>\n<1>\nelsif <true>\n<2>\nelse\nreturn <3>\nend\nend"
|
525
|
+
expect(wrap("def a\nif true\nif true\nreturn 1\nend\nend\nend")).to eq "def a\nif <true>\nif <true>\nreturn <1>\nend\nend\nend"
|
526
|
+
expect(wrap("def a\nunless true\nreturn 1\nend\nend")).to eq "def a\nunless <true>\nreturn <1>\nend\nend"
|
527
|
+
expect(wrap("def a\nunless true\n1\nelse\nreturn 2\nend\nend")).to eq "def a\nunless <true>\n<1>\nelse\nreturn <2>\nend\nend"
|
528
|
+
expect(wrap("def a\ntrue ?\n(return 1) :\n2\nend")).to eq "def a\n<true> ?\n(return <1>) :\n<2>\nend"
|
529
|
+
expect(wrap("def a\ntrue ?\n1 :\n(return 2)\nend")).to eq "def a\n<true> ?\n<1> :\n(return <2>)\nend"
|
463
530
|
end
|
464
531
|
|
465
532
|
# not sure if I actually want this, or if it's just easier b/c it falls out of the current implementation
|
466
533
|
it 'wraps the conditional from an inline if, when it cannot wrap the entire if' do
|
467
|
-
wrap("def a\nreturn if 1\nend").
|
534
|
+
expect(wrap("def a\nreturn if 1\nend")).to eq "def a\nreturn if <1>\nend"
|
468
535
|
end
|
469
536
|
|
470
537
|
it 'does not wrap &&, and, ||, or, not' do
|
471
|
-
wrap("1\\\n&& 2").
|
472
|
-
wrap("1\\\nand 2").
|
473
|
-
wrap("1\\\n|| 2").
|
474
|
-
wrap("1\\\nor 2").
|
475
|
-
wrap("not\\\n1").
|
476
|
-
wrap("!\\\n1").
|
538
|
+
expect(wrap("1\\\n&& 2")).to eq "<<1>\\\n&& 2>"
|
539
|
+
expect(wrap("1\\\nand 2")).to eq "<<1>\\\nand 2>"
|
540
|
+
expect(wrap("1\\\n|| 2")).to eq "<<1>\\\n|| 2>"
|
541
|
+
expect(wrap("1\\\nor 2")).to eq "<<1>\\\nor 2>"
|
542
|
+
expect(wrap("not\\\n1")).to eq "<not\\\n1>"
|
543
|
+
expect(wrap("!\\\n1")).to eq "<!\\\n1>"
|
477
544
|
end
|
478
545
|
end
|
479
546
|
|
480
547
|
describe 'loops' do
|
481
548
|
it 'wraps the until condition and body' do
|
482
|
-
wrap("until 1\n2\nend").
|
483
|
-
wrap("1 until 2").
|
484
|
-
wrap("begin\n1\nend until true").
|
549
|
+
expect(wrap("until 1\n2\nend")).to eq "<until <1>\n<2>\nend>"
|
550
|
+
expect(wrap("1 until 2")).to eq "<1 until 2>"
|
551
|
+
expect(wrap("begin\n1\nend until true")).to eq "<begin\n<1>\nend until true>"
|
485
552
|
end
|
486
553
|
it 'wraps the while condition and body' do
|
487
|
-
wrap("while 1\n2\nend").
|
488
|
-
wrap("1 while 2").
|
489
|
-
wrap("begin\n1\nend while true").
|
554
|
+
expect(wrap("while 1\n2\nend")).to eq "<while <1>\n<2>\nend>"
|
555
|
+
expect(wrap("1 while 2")).to eq "<1 while 2>"
|
556
|
+
expect(wrap("begin\n1\nend while true")).to eq "<begin\n<1>\nend while true>"
|
490
557
|
end
|
491
558
|
it 'wraps for/in loops collections and bodies' do
|
492
|
-
wrap("for a in range;1;end").
|
493
|
-
wrap("for a in range\n1\nend").
|
494
|
-
wrap("for a in range do\n1\nend").
|
495
|
-
wrap("for a,b in whatev\n1\nend").
|
559
|
+
expect(wrap("for a in range;1;end")).to eq "<for a in range;1;end>"
|
560
|
+
expect(wrap("for a in range\n1\nend")).to eq "<for a in <range>\n<1>\nend>"
|
561
|
+
expect(wrap("for a in range do\n1\nend")).to eq "<for a in <range> do\n<1>\nend>"
|
562
|
+
expect(wrap("for a,b in whatev\n1\nend")).to eq "<for a,b in <whatev>\n<1>\nend>"
|
496
563
|
# this one just isn't worth it for now, too edge and I'm fucking tired
|
497
564
|
# wrap("for char in <<HERE.each_char\nabc\nHERE\nputs char\nend").should ==
|
498
565
|
# "<for char in <<<HERE.each_char>\nabc\nHERE\n<puts char>\nend>"
|
499
566
|
end
|
500
567
|
it 'does not wrap redo' do
|
501
|
-
wrap("loop do\nredo\nend").
|
568
|
+
expect(wrap("loop do\nredo\nend")).to eq "<loop do\nredo\nend>"
|
502
569
|
end
|
503
570
|
it 'wraps the value of break' do
|
504
|
-
wrap("loop do\nbreak 1\nend").
|
571
|
+
expect(wrap("loop do\nbreak 1\nend")).to eq "<loop do\nbreak <1>\nend>"
|
505
572
|
end
|
506
573
|
it 'wraps the value of next' do
|
507
|
-
wrap("loop do\nnext 10\nend").
|
574
|
+
expect(wrap("loop do\nnext 10\nend")).to eq "<loop do\nnext <10>\nend>"
|
508
575
|
end
|
509
576
|
end
|
510
577
|
|
511
578
|
describe 'constant access' do
|
512
579
|
it 'wraps simple constant access' do
|
513
|
-
wrap("A").
|
580
|
+
expect(wrap("A")).to eq "<A>"
|
514
581
|
end
|
515
582
|
|
516
583
|
it 'wraps namespaced constant access' do
|
517
|
-
wrap("::A").
|
518
|
-
wrap("A::B").
|
584
|
+
expect(wrap("::A")).to eq "<::A>"
|
585
|
+
expect(wrap("A::B")).to eq "<A::B>"
|
519
586
|
end
|
520
587
|
end
|
521
588
|
|
522
589
|
describe 'hash literals' do
|
523
590
|
it 'wraps the whole hash and values that are on their own lines' do
|
524
|
-
wrap("{}").
|
525
|
-
wrap("{\n1 => 2}").
|
526
|
-
wrap("{\n1 => 2,\n:abc => 3,\ndef: 4\n}").
|
591
|
+
expect(wrap("{}")).to eq "<{}>"
|
592
|
+
expect(wrap("{\n1 => 2}")).to eq "<{\n1 => 2}>"
|
593
|
+
expect(wrap("{\n1 => 2,\n:abc => 3,\ndef: 4\n}")).to eq "<{\n1 => <2>,\n:abc => <3>,\ndef: <4>\n}>"
|
527
594
|
end
|
528
595
|
end
|
529
596
|
|
530
597
|
describe 'array literals' do
|
531
598
|
it 'wraps the array and each element that is on its own line' do
|
532
|
-
wrap("[1]").
|
533
|
-
wrap("[1,\n2,\n]").
|
534
|
-
wrap("[1, 2,\n]").
|
599
|
+
expect(wrap("[1]")).to eq "<[1]>"
|
600
|
+
expect(wrap("[1,\n2,\n]")).to eq "<[<1>,\n<2>,\n]>"
|
601
|
+
expect(wrap("[1, 2,\n]")).to eq "<[1, <2>,\n]>"
|
535
602
|
end
|
536
603
|
|
537
604
|
it 'does not wrap magic arrays' do
|
538
|
-
wrap("%w[\n1\n]").
|
605
|
+
expect(wrap("%w[\n1\n]")).to eq "<%w[\n1\n]>"
|
539
606
|
end
|
540
607
|
|
541
608
|
it 'does not wrap splat elements' do
|
542
|
-
wrap("[1,\n*2..3,\n4\n]").
|
609
|
+
expect(wrap("[1,\n*2..3,\n4\n]")).to eq "<[<1>,\n*2..3,\n<4>\n]>"
|
543
610
|
end
|
544
611
|
end
|
545
612
|
|
546
613
|
describe 'regex literals' do
|
547
614
|
it 'wraps regexes' do
|
548
|
-
wrap("/a/").
|
549
|
-
wrap("/(?<a>x)/").
|
615
|
+
expect(wrap("/a/")).to eq "</a/>"
|
616
|
+
expect(wrap("/(?<a>x)/")).to eq "</(?<a>x)/>"
|
550
617
|
end
|
551
618
|
|
552
619
|
it 'wraps regexes with %r' do
|
553
|
-
wrap("%r(a)").
|
554
|
-
wrap("%r'a'").
|
620
|
+
expect(wrap("%r(a)")).to eq "<%r(a)>"
|
621
|
+
expect(wrap("%r'a'")).to eq "<%r'a'>"
|
555
622
|
end
|
556
623
|
|
557
624
|
it 'wraps regexes that span mulitple lines' do
|
558
|
-
wrap("/a\nb/").
|
559
|
-
wrap("/a\nb/i").
|
625
|
+
expect(wrap("/a\nb/")).to eq "</a\nb/>"
|
626
|
+
expect(wrap("/a\nb/i")).to eq "</a\nb/i>"
|
560
627
|
end
|
561
628
|
|
562
629
|
# eventually it would be nice if it wraped the interpolated portion,
|
563
630
|
# when the end of the line was not back inside the regexp
|
564
631
|
it 'wraps regexes with interpolation, but not the interpolated portion' do
|
565
|
-
wrap("/a\#{1}/").
|
566
|
-
wrap("/a\n\#{1}\nb/").
|
567
|
-
wrap("/a\n\#{1\n}b/").
|
632
|
+
expect(wrap("/a\#{1}/")).to eq "</a\#{1}/>"
|
633
|
+
expect(wrap("/a\n\#{1}\nb/")).to eq "</a\n\#{1}\nb/>"
|
634
|
+
expect(wrap("/a\n\#{1\n}b/")).to eq "</a\n\#{1\n}b/>"
|
568
635
|
end
|
569
636
|
end
|
570
637
|
|
571
638
|
describe 'string literals (except heredocs)' do
|
572
639
|
it 'wraps single and double quoted strings' do
|
573
|
-
wrap("'a'").
|
574
|
-
wrap('"a"').
|
640
|
+
expect(wrap("'a'")).to eq "<'a'>"
|
641
|
+
expect(wrap('"a"')).to eq '<"a">'
|
575
642
|
end
|
576
643
|
|
577
644
|
it 'wraps strings with %, %Q, and %q' do
|
578
|
-
wrap("%'a'").
|
579
|
-
wrap("%q'a'").
|
580
|
-
wrap("%Q'a'").
|
645
|
+
expect(wrap("%'a'")).to eq "<%'a'>"
|
646
|
+
expect(wrap("%q'a'")).to eq "<%q'a'>"
|
647
|
+
expect(wrap("%Q'a'")).to eq "<%Q'a'>"
|
581
648
|
end
|
582
649
|
|
583
650
|
it 'wraps strings that span mulitple lines' do
|
584
|
-
wrap("'a\nb'").
|
585
|
-
wrap(%'"a\nb"').
|
651
|
+
expect(wrap("'a\nb'")).to eq "<'a\nb'>"
|
652
|
+
expect(wrap(%'"a\nb"')).to eq %'<"a\nb">'
|
586
653
|
end
|
587
654
|
|
588
655
|
# eventually it would be nice if it wraped the interpolated portion,
|
589
656
|
# when the end of the line was not back inside the string
|
590
657
|
it 'wraps strings with interpolation, but not the interpolated portion' do
|
591
|
-
wrap('"a#{1}"').
|
592
|
-
wrap(%'"a\n\#{1}\nb"').
|
593
|
-
wrap(%'"a\n\#{1\n}b"').
|
658
|
+
expect(wrap('"a#{1}"')).to eq '<"a#{1}">'
|
659
|
+
expect(wrap(%'"a\n\#{1}\nb"')).to eq %'<"a\n\#{1}\nb">'
|
660
|
+
expect(wrap(%'"a\n\#{1\n}b"')).to eq %'<"a\n\#{1\n}b">'
|
594
661
|
end
|
595
662
|
|
596
663
|
it 'wraps %, %q, %Q' do
|
597
|
-
wrap('%(A)').
|
598
|
-
wrap('%.A.').
|
599
|
-
wrap('%q(A)').
|
600
|
-
wrap('%q.A.').
|
601
|
-
wrap('%Q(A)').
|
602
|
-
wrap('%Q.A.').
|
664
|
+
expect(wrap('%(A)')).to eq '<%(A)>'
|
665
|
+
expect(wrap('%.A.')).to eq '<%.A.>'
|
666
|
+
expect(wrap('%q(A)')).to eq '<%q(A)>'
|
667
|
+
expect(wrap('%q.A.')).to eq '<%q.A.>'
|
668
|
+
expect(wrap('%Q(A)')).to eq '<%Q(A)>'
|
669
|
+
expect(wrap('%Q.A.')).to eq '<%Q.A.>'
|
603
670
|
end
|
604
671
|
|
605
672
|
it 'wraps heredocs with call defined on them (edge cases on edge cases *sigh*)' do
|
606
|
-
wrap("<<HERE.()\na\nHERE").
|
673
|
+
expect(wrap("<<HERE.()\na\nHERE")).to eq "<<<HERE.()>\na\nHERE"
|
607
674
|
end
|
608
675
|
end
|
609
676
|
|
610
677
|
describe 'heredocs' do
|
611
678
|
it 'wraps heredocs on their first line' do
|
612
|
-
wrap("<<A\nA").
|
613
|
-
wrap("<<A\n123\nA").
|
614
|
-
wrap("<<-A\nA").
|
615
|
-
wrap("<<-A\n123\nA").
|
616
|
-
wrap("1\n<<A\nA").
|
617
|
-
wrap("<<A + <<B\n1\nA\n2\nB").
|
618
|
-
wrap("<<A\n1\nA\n<<B\n2\nB").
|
619
|
-
wrap("puts <<A\nA\nputs <<B\nB").
|
679
|
+
expect(wrap("<<A\nA")).to eq "<<<A>\nA"
|
680
|
+
expect(wrap("<<A\n123\nA")).to eq "<<<A>\n123\nA"
|
681
|
+
expect(wrap("<<-A\nA")).to eq "<<<-A>\nA"
|
682
|
+
expect(wrap("<<-A\n123\nA")).to eq "<<<-A>\n123\nA"
|
683
|
+
expect(wrap("1\n<<A\nA")).to eq "<<1>\n<<A>\nA"
|
684
|
+
expect(wrap("<<A + <<B\n1\nA\n2\nB")).to eq "<<<A + <<B>\n1\nA\n2\nB"
|
685
|
+
expect(wrap("<<A\n1\nA\n<<B\n2\nB")).to eq "<<<<A>\n1\nA\n<<B>\n2\nB"
|
686
|
+
expect(wrap("puts <<A\nA\nputs <<B\nB")).to eq "<puts <<A>\nA\n<puts <<B>\nB"
|
620
687
|
end
|
621
688
|
|
622
689
|
it "wraps methods that wrap heredocs, even whent hey don't have parentheses" do
|
623
|
-
wrap("a(<<HERE)\nHERE").
|
624
|
-
wrap("a <<HERE\nHERE").
|
625
|
-
wrap("a 1, <<HERE\nHERE").
|
626
|
-
wrap("a.b 1, 2, <<HERE1, <<-HERE2 \nHERE1\n HERE2").
|
690
|
+
expect(wrap("a(<<HERE)\nHERE")).to eq "<a(<<HERE)>\nHERE"
|
691
|
+
expect(wrap("a <<HERE\nHERE")).to eq "<a <<HERE>\nHERE"
|
692
|
+
expect(wrap("a 1, <<HERE\nHERE")).to eq "<a 1, <<HERE>\nHERE"
|
693
|
+
expect(wrap("a.b 1, 2, <<HERE1, <<-HERE2 \nHERE1\n HERE2")).to eq\
|
627
694
|
"<a.b 1, 2, <<HERE1, <<-HERE2> \nHERE1\n HERE2"
|
628
|
-
wrap("a.b 1,\n2,\n<<HERE\nHERE").
|
695
|
+
expect(wrap("a.b 1,\n2,\n<<HERE\nHERE")).to eq "<a.b <1>,\n<2>,\n<<HERE>\nHERE"
|
629
696
|
end
|
630
697
|
|
631
698
|
it "wraps assignments whose value is a heredoc" do
|
632
|
-
wrap("a=<<A\nA").
|
633
|
-
wrap("a,b=<<A,<<B\nA\nB").
|
634
|
-
wrap("a,b=1,<<B\nB").
|
635
|
-
wrap("a,b=<<A,1\nA").
|
699
|
+
expect(wrap("a=<<A\nA")).to eq "<a=<<A>\nA"
|
700
|
+
expect(wrap("a,b=<<A,<<B\nA\nB")).to eq "<a,b=<<A,<<B>\nA\nB"
|
701
|
+
expect(wrap("a,b=1,<<B\nB")).to eq "<a,b=1,<<B>\nB"
|
702
|
+
expect(wrap("a,b=<<A,1\nA")).to eq "<a,b=<<A,1>\nA"
|
636
703
|
end
|
637
704
|
|
638
705
|
it 'wraps methods tacked onto the end of heredocs' do
|
639
|
-
wrap("<<A.size\nA").
|
640
|
-
wrap("<<A.size 1\nA").
|
641
|
-
wrap("<<A.size(1)\nA").
|
642
|
-
wrap("<<A.whatever <<B\nA\nB").
|
643
|
-
wrap("<<A.whatever(<<B)\nA\nB").
|
644
|
-
wrap("<<A.size()\nA").
|
706
|
+
expect(wrap("<<A.size\nA")).to eq "<<<A.size>\nA"
|
707
|
+
expect(wrap("<<A.size 1\nA")).to eq "<<<A.size 1>\nA"
|
708
|
+
expect(wrap("<<A.size(1)\nA")).to eq "<<<A.size(1)>\nA"
|
709
|
+
expect(wrap("<<A.whatever <<B\nA\nB")).to eq "<<<A.whatever <<B>\nA\nB"
|
710
|
+
expect(wrap("<<A.whatever(<<B)\nA\nB")).to eq "<<<A.whatever(<<B)>\nA\nB"
|
711
|
+
expect(wrap("<<A.size()\nA")).to eq "<<<A.size()>\nA"
|
645
712
|
end
|
646
713
|
end
|
647
714
|
|
648
715
|
# raises can be safely ignored, they're just method invocations
|
649
716
|
describe 'begin/rescue/else/ensure/end blocks' do
|
650
717
|
it 'wraps begin/rescue/else/ensure/end blocks' do
|
651
|
-
wrap("begin\nrescue\nelse\nensure\nend").
|
652
|
-
wrap("begin\nrescue e\ne\nend").
|
653
|
-
wrap("begin\nrescue Exception\n$!\nend").
|
718
|
+
expect(wrap("begin\nrescue\nelse\nensure\nend")).to eq "<begin\nrescue\nelse\nensure\nend>"
|
719
|
+
expect(wrap("begin\nrescue e\ne\nend")).to eq "<begin\nrescue e\n<e>\nend>"
|
720
|
+
expect(wrap("begin\nrescue Exception\n$!\nend")).to eq "<begin\nrescue Exception\n<$!>\nend>"
|
654
721
|
end
|
655
722
|
it 'wraps inline rescues' do
|
656
|
-
pending "can't figure out how to identify these as different from begin/rescue/end"
|
657
|
-
|
658
|
-
end
|
723
|
+
pending "can't figure out how to identify these as different from begin/rescue/end"
|
724
|
+
expect(wrap("1 rescue nil")).to eq "<1 rescue nil>"
|
659
725
|
end
|
660
726
|
it 'wraps the bodies' do
|
661
|
-
wrap("begin\n1\nrescue\n2\nelse\n3\nensure\n4\nend").
|
727
|
+
expect(wrap("begin\n1\nrescue\n2\nelse\n3\nensure\n4\nend")).to eq\
|
662
728
|
"<begin\n<1>\nrescue\n<2>\nelse\n<3>\nensure\n<4>\nend>"
|
663
729
|
end
|
664
730
|
it 'wraps bodies with various pieces missing' do
|
665
|
-
wrap("begin\n1\nrescue\n2\nelse\n3\nensure\n4\nend").
|
666
|
-
wrap("begin\n1\nrescue\n2\nelse\n3\nend").
|
667
|
-
wrap("begin\n1\nrescue\n2\nend").
|
668
|
-
wrap("begin\n1\nend").
|
669
|
-
wrap("begin\nend").
|
670
|
-
wrap("begin\n1\nensure\n2\nend").
|
731
|
+
expect(wrap("begin\n1\nrescue\n2\nelse\n3\nensure\n4\nend")).to eq "<begin\n<1>\nrescue\n<2>\nelse\n<3>\nensure\n<4>\nend>"
|
732
|
+
expect(wrap("begin\n1\nrescue\n2\nelse\n3\nend")).to eq "<begin\n<1>\nrescue\n<2>\nelse\n<3>\nend>"
|
733
|
+
expect(wrap("begin\n1\nrescue\n2\nend")).to eq "<begin\n<1>\nrescue\n<2>\nend>"
|
734
|
+
expect(wrap("begin\n1\nend")).to eq "<begin\n<1>\nend>"
|
735
|
+
expect(wrap("begin\nend")).to eq "<begin\nend>"
|
736
|
+
expect(wrap("begin\n1\nensure\n2\nend")).to eq "<begin\n<1>\nensure\n<2>\nend>"
|
671
737
|
end
|
672
738
|
it 'does not wrap arguments to rescue' do
|
673
|
-
wrap("begin\nrescue\nrescue => a\nrescue SyntaxError\nrescue Exception => a\nelse\nensure\nend").
|
739
|
+
expect(wrap("begin\nrescue\nrescue => a\nrescue SyntaxError\nrescue Exception => a\nelse\nensure\nend")).to eq\
|
674
740
|
"<begin\nrescue\nrescue => a\nrescue SyntaxError\nrescue Exception => a\nelse\nensure\nend>"
|
675
741
|
end
|
676
742
|
it 'does not wrap retry' do
|
677
743
|
# in this case, it could wrap the retry
|
678
744
|
# but I don't know how to tell the difference between this and
|
679
745
|
# "loop { begin; retry; end }" so w/e
|
680
|
-
wrap("begin\nrescue\nretry\nend").
|
746
|
+
expect(wrap("begin\nrescue\nretry\nend")).to eq "<begin\nrescue\nretry\nend>"
|
681
747
|
end
|
682
748
|
end
|
683
749
|
|
@@ -686,19 +752,19 @@ describe SeeingIsBelieving::WrapExpressions do
|
|
686
752
|
# ignoring public/private/protected for now, b/c they're just methods, not keywords
|
687
753
|
describe 'class definitions' do
|
688
754
|
it 'does not wrap the class definition, does wrap the body' do
|
689
|
-
wrap("class A\n1\nend").
|
755
|
+
expect(wrap("class A\n1\nend")).to eq "class A\n<1>\nend"
|
690
756
|
end
|
691
757
|
|
692
758
|
it 'does not wrap the superclass definition' do
|
693
|
-
wrap("class A < B\nend").
|
759
|
+
expect(wrap("class A < B\nend")).to eq "class A < B\nend"
|
694
760
|
end
|
695
761
|
|
696
762
|
it 'wraps the rescue body' do
|
697
|
-
wrap("class A < B\n1\nrescue\n2\nend").
|
763
|
+
expect(wrap("class A < B\n1\nrescue\n2\nend")).to eq "class A < B\n<1>\nrescue\n<2>\nend"
|
698
764
|
end
|
699
765
|
|
700
766
|
it 'does not wrap the singleton class' do
|
701
|
-
wrap("class << self\n end").
|
767
|
+
expect(wrap("class << self\n end")).to eq "class << self\n end"
|
702
768
|
end
|
703
769
|
end
|
704
770
|
|
@@ -707,65 +773,63 @@ describe SeeingIsBelieving::WrapExpressions do
|
|
707
773
|
# ignoring public/private/protected for now, b/c they're just methods, not keywords
|
708
774
|
describe 'module definitions' do
|
709
775
|
it 'does not wrap the definition, does wrap the body' do
|
710
|
-
wrap("module A\n1\nend").
|
776
|
+
expect(wrap("module A\n1\nend")).to eq "module A\n<1>\nend"
|
711
777
|
end
|
712
778
|
it 'wraps the rescue portion' do
|
713
|
-
wrap("module A\n1\nrescue\n2\nend").
|
779
|
+
expect(wrap("module A\n1\nrescue\n2\nend")).to eq "module A\n<1>\nrescue\n<2>\nend"
|
714
780
|
end
|
715
781
|
end
|
716
782
|
|
717
783
|
describe 'method definitions' do
|
718
784
|
it 'does not wrap the definition or arguments' do
|
719
|
-
wrap("def a(b,c=1,*d,&e)\nend").
|
785
|
+
expect(wrap("def a(b,c=1,*d,&e)\nend")).to eq "def a(b,c=1,*d,&e)\nend"
|
720
786
|
end
|
721
787
|
|
722
788
|
it 'wraps the body' do
|
723
|
-
wrap("def a\n1\nend").
|
724
|
-
wrap("def a()\n1\nend").
|
789
|
+
expect(wrap("def a\n1\nend")).to eq "def a\n<1>\nend"
|
790
|
+
expect(wrap("def a()\n1\nend")).to eq "def a()\n<1>\nend"
|
725
791
|
end
|
726
792
|
|
727
793
|
it 'does not try to wrap singleton method definitions' do
|
728
|
-
wrap("def a.b\n1\nend").
|
729
|
-
wrap("def a.b()\n1\nend").
|
794
|
+
expect(wrap("def a.b\n1\nend")).to eq "def a.b\n<1>\nend"
|
795
|
+
expect(wrap("def a.b()\n1\nend")).to eq "def a.b()\n<1>\nend"
|
730
796
|
end
|
731
797
|
|
732
798
|
it 'wraps calls to yield' do
|
733
|
-
wrap("def a\nyield\nend").
|
799
|
+
expect(wrap("def a\nyield\nend")).to eq "def a\n<yield>\nend"
|
734
800
|
end
|
735
801
|
|
736
802
|
it 'wraps calls to super' do
|
737
|
-
wrap("def a\nsuper\nend").
|
738
|
-
wrap("def a\nsuper 1\nend").
|
803
|
+
expect(wrap("def a\nsuper\nend")).to eq "def a\n<super>\nend"
|
804
|
+
expect(wrap("def a\nsuper 1\nend")).to eq "def a\n<super 1>\nend"
|
739
805
|
end
|
740
806
|
|
741
807
|
it 'wraps the bodies of returns' do
|
742
|
-
wrap("def a\nreturn 1\nend").
|
808
|
+
expect(wrap("def a\nreturn 1\nend")).to eq "def a\nreturn <1>\nend"
|
743
809
|
end
|
744
810
|
|
745
811
|
it 'wraps the rescue and ensure portion' do
|
746
|
-
wrap("def a\n1\nrescue\n2\nend").
|
747
|
-
wrap("def a\n1\nrescue\n2\nensure\n3\nend").
|
748
|
-
wrap("def a\n1\nensure\n2\nend").
|
812
|
+
expect(wrap("def a\n1\nrescue\n2\nend")).to eq "def a\n<1>\nrescue\n<2>\nend"
|
813
|
+
expect(wrap("def a\n1\nrescue\n2\nensure\n3\nend")).to eq "def a\n<1>\nrescue\n<2>\nensure\n<3>\nend"
|
814
|
+
expect(wrap("def a\n1\nensure\n2\nend")).to eq "def a\n<1>\nensure\n<2>\nend"
|
749
815
|
end
|
750
816
|
end
|
751
817
|
|
752
818
|
describe 'lambdas' do
|
753
819
|
it 'wraps the lambda' do
|
754
|
-
wrap("lambda { }").
|
755
|
-
wrap("-> { }").
|
756
|
-
wrap("-> a, b { }").
|
757
|
-
wrap("-> {\n1\n}").
|
758
|
-
wrap("-> * { }").
|
820
|
+
expect(wrap("lambda { }")).to eq "<lambda { }>"
|
821
|
+
expect(wrap("-> { }")).to eq "<-> { }>"
|
822
|
+
expect(wrap("-> a, b { }")).to eq "<-> a, b { }>"
|
823
|
+
expect(wrap("-> {\n1\n}")).to eq "<-> {\n<1>\n}>"
|
824
|
+
expect(wrap("-> * { }")).to eq "<-> * { }>"
|
759
825
|
end
|
760
826
|
|
761
827
|
it 'wraps the full invocation' do
|
762
|
-
wrap("lambda { }.()").
|
763
|
-
wrap("-> { }.()").
|
764
|
-
wrap("-> a, b {\n1\n}.(1,\n2)").
|
765
|
-
wrap("-> a, b { }.call(1, 2)").
|
766
|
-
|
767
|
-
wrap("-> * { }()").should == "<-> * { }.()>"
|
768
|
-
end
|
828
|
+
expect(wrap("lambda { }.()")).to eq "<lambda { }.()>"
|
829
|
+
expect(wrap("-> { }.()")).to eq "<-> { }.()>"
|
830
|
+
expect(wrap("-> a, b {\n1\n}.(1,\n2)")).to eq "<-> a, b {\n<1>\n}.(<1>,\n2)>"
|
831
|
+
expect(wrap("-> a, b { }.call(1, 2)")).to eq "<-> a, b { }.call(1, 2)>"
|
832
|
+
expect(wrap("-> * { }.()")).to eq "<-> * { }.()>"
|
769
833
|
end
|
770
834
|
end
|
771
835
|
|
@@ -790,12 +854,11 @@ describe SeeingIsBelieving::WrapExpressions do
|
|
790
854
|
# which we could do with some meta, just replacing it with the literal when we parse it
|
791
855
|
# but still, moving this out of here will be really annoying, and no one is going to use it, so fuck it
|
792
856
|
it 'does not record them', not_implemented: true do
|
793
|
-
pending 'not implemented, and probably never will be'
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
end
|
857
|
+
pending 'not implemented, and probably never will be'
|
858
|
+
expect(wrap("BEGIN {}")).to eq "BEGIN {}"
|
859
|
+
expect(wrap("END {}")).to eq "END {}"
|
860
|
+
expect(wrap("BEGIN {\n123\n}")).to eq "BEGIN {\n<123>\n}"
|
861
|
+
expect(wrap("END {\n123\n}")).to eq "END {\n<123>\n}"
|
799
862
|
end
|
800
863
|
end
|
801
864
|
end
|