seeing_is_believing 0.0.20 → 0.0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +8 -3
- data/features/examples.feature +4 -10
- data/features/regression.feature +7 -0
- data/lib/seeing_is_believing/evaluate_by_moving_files.rb +1 -1
- data/lib/seeing_is_believing/expression_list.rb +7 -1
- data/lib/seeing_is_believing/version.rb +1 -1
- data/spec/expression_list_spec.rb +27 -8
- data/spec/seeing_is_believing_spec.rb +21 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b04673605b79a81c7e47cd26c98a9b10fba50193
|
4
|
+
data.tar.gz: 3e98d95b8e19b3aca8087584218f21bfe7492e68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12d197241dabb6a700cfd2b241d2c88a1713d0ee2dc3ae3de359ea8364fdb9718758784ac5e7ca25a92137c23c14a486c440b9e5ec9fabda8899b0ce992ae733
|
7
|
+
data.tar.gz: 0da562f2291215aea0710cd1bd99575041d6de741c11cfdca692b2392645669e06d96e6441301cf216474c81f489896810758024919ff686879c80078140bbf3
|
data/Readme.md
CHANGED
@@ -130,10 +130,15 @@ Known Issues
|
|
130
130
|
|
131
131
|
* `BEGIN/END` breaks things and I probably won't take the time to fix it, becuase it's nontrivial and its really meant for command-line scripts, but there is currently a cuke for it
|
132
132
|
* Heredocs aren't recorded. It might actually be possible if the ExpressionList were to get smarter
|
133
|
-
* Return statements and other control-flow changing keywords (next/break/redo/retry) are dealt with poorly, causing some situations where you could capture and display a value to not capture
|
134
133
|
* errors come out really shitty if you're calling them from another program like TextMate, would be better to put a line in that shows where the error is.
|
135
|
-
*
|
136
|
-
|
134
|
+
* "1\\\n.even?" just fucks everything
|
135
|
+
|
136
|
+
Todo
|
137
|
+
====
|
138
|
+
* Don't blow up on "a\\\n.b"
|
139
|
+
* Record results with "a\n.b.\nc"
|
140
|
+
* Record results with "a + \n b"
|
141
|
+
* Refactor ExpressionList/SeeingIsBelieving to store lines in an array instead of as a string, so everyone doesn't magically need to know when to chomp
|
137
142
|
|
138
143
|
License
|
139
144
|
=======
|
data/features/examples.feature
CHANGED
@@ -42,6 +42,7 @@ Feature: Running the binary successfully
|
|
42
42
|
# method invocation that occurs entirely on the next line
|
43
43
|
[*1..10]
|
44
44
|
.select(&:even?)
|
45
|
+
.map { |n| n * 2 }
|
45
46
|
|
46
47
|
# mutliple levels of nesting
|
47
48
|
class User
|
@@ -93,8 +94,9 @@ Feature: Running the binary successfully
|
|
93
94
|
HERE
|
94
95
|
|
95
96
|
# method invocation that occurs entirely on the next line
|
96
|
-
[*1..10]
|
97
|
-
.select(&:even?)
|
97
|
+
[*1..10] # => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
98
|
+
.select(&:even?) # => [2, 4, 6, 8, 10]
|
99
|
+
.map { |n| n * 2 } # => [4, 8, 12, 16, 20]
|
98
100
|
|
99
101
|
# mutliple levels of nesting
|
100
102
|
class User
|
@@ -254,11 +256,3 @@ Feature: Running the binary successfully
|
|
254
256
|
Then stderr is empty
|
255
257
|
And the exit status is 0
|
256
258
|
And stdout is "1 + 1 # => 2"
|
257
|
-
|
258
|
-
Scenario: Regression: A program containing a single comment
|
259
|
-
Given I have the stdin content "# single comment"
|
260
|
-
When I run "seeing_is_believing"
|
261
|
-
Then stderr is empty
|
262
|
-
And the exit status is 0
|
263
|
-
And stdout is "# single comment"
|
264
|
-
|
data/features/regression.feature
CHANGED
@@ -3,6 +3,13 @@ Feature:
|
|
3
3
|
As the dev who wrote SeeingIsBelieving
|
4
4
|
I want to have tests on those bugs that I found and could not have predicted
|
5
5
|
|
6
|
+
Scenario: A program containing a single comment
|
7
|
+
Given I have the stdin content "# single comment"
|
8
|
+
When I run "seeing_is_believing"
|
9
|
+
Then stderr is empty
|
10
|
+
And the exit status is 0
|
11
|
+
And stdout is "# single comment"
|
12
|
+
|
6
13
|
Scenario: No method error just fucks everything
|
7
14
|
Given the file "no_method_error.rb":
|
8
15
|
"""
|
@@ -133,7 +133,7 @@ class SeeingIsBelieving
|
|
133
133
|
end
|
134
134
|
|
135
135
|
def notify_user_of_error
|
136
|
-
error_stream.puts "It blew up
|
136
|
+
error_stream.puts "It blew up because SeeingIsBelieving isn't good enough >.<"
|
137
137
|
error_stream.puts "Please log an issue at: https://github.com/JoshCheek/seeing_is_believing/issues"
|
138
138
|
error_stream.puts
|
139
139
|
error_stream.puts "Program: #{program.inspect}"
|
@@ -29,7 +29,13 @@ class SeeingIsBelieving
|
|
29
29
|
pending_expression = generate
|
30
30
|
debug { "GENERATED: #{pending_expression.expression.inspect}, ADDING IT TO #{inspected_expressions expressions}" }
|
31
31
|
expressions << pending_expression
|
32
|
-
|
32
|
+
|
33
|
+
expression = reduce expressions, offset
|
34
|
+
|
35
|
+
if next_line_modifies_current?
|
36
|
+
expressions << PendingExpression.new(expression.chomp, []) # chomp b/c on_complete callback prob adds newline, but we do to when joining
|
37
|
+
end
|
38
|
+
|
33
39
|
offset += 1
|
34
40
|
end until expressions.empty?
|
35
41
|
return expression, offset
|
@@ -181,19 +181,38 @@ describe SeeingIsBelieving::ExpressionList do
|
|
181
181
|
example "example: method invocations on next line" do
|
182
182
|
# example 1: consume the expression with lines after
|
183
183
|
list = list_for ['a', '.b', ' .c', 'irrelevant'] do |*expressions, offset|
|
184
|
-
|
185
|
-
|
186
|
-
|
184
|
+
flat_expressions = expressions.flatten.join('')
|
185
|
+
case offset
|
186
|
+
when 0
|
187
|
+
flat_expressions.should == 'a'
|
188
|
+
'A'
|
189
|
+
when 1
|
190
|
+
flat_expressions.should == 'A.b'
|
191
|
+
'A.B'
|
192
|
+
when 2
|
193
|
+
flat_expressions.should == 'A.B .c'
|
194
|
+
'A.B.C'
|
195
|
+
else
|
196
|
+
raise "O.o"
|
197
|
+
end
|
187
198
|
end
|
188
|
-
list.call.should == ['
|
199
|
+
list.call.should == ['A.B.C', 3]
|
189
200
|
|
190
201
|
# example 2: consume the expression with no lines after
|
191
202
|
list = list_for ['a', '.b'] do |*expressions, offset|
|
192
|
-
|
193
|
-
|
194
|
-
|
203
|
+
flat_expressions = expressions.flatten.join('')
|
204
|
+
case offset
|
205
|
+
when 0
|
206
|
+
flat_expressions.should == 'a'
|
207
|
+
'A'
|
208
|
+
when 1
|
209
|
+
flat_expressions.should == 'A.b'
|
210
|
+
'A.B'
|
211
|
+
else
|
212
|
+
raise "O.o"
|
213
|
+
end
|
195
214
|
end
|
196
|
-
list.call.should == ['
|
215
|
+
list.call.should == ['A.B', 2]
|
197
216
|
end
|
198
217
|
|
199
218
|
example "example: smoke test debug option" do
|
@@ -269,8 +269,8 @@ describe SeeingIsBelieving do
|
|
269
269
|
end
|
270
270
|
|
271
271
|
it 'can deal with methods that are invoked entirely on the next line' do
|
272
|
-
values_for("1\n.even?").should == [[], ['false']]
|
273
|
-
values_for("1\n.even?\n__END__").should == [[], ['false']]
|
272
|
+
values_for("1\n.even?").should == [['1'], ['false']]
|
273
|
+
values_for("1\n.even?\n__END__").should == [['1'], ['false']]
|
274
274
|
end
|
275
275
|
|
276
276
|
it 'does not record leading comments' do
|
@@ -284,4 +284,23 @@ describe SeeingIsBelieving do
|
|
284
284
|
expect { invoke "sleep 0.2", timeout: 0.1 }.to raise_error Timeout::Error
|
285
285
|
end
|
286
286
|
|
287
|
+
it 'can record the middle of a chain of calls', t:true do
|
288
|
+
values_for("[*1..5]
|
289
|
+
.select(&:even?)
|
290
|
+
.map { |n| n * 3 }").should == [['[1, 2, 3, 4, 5]'],
|
291
|
+
['[2, 4]'],
|
292
|
+
['[6, 12]']]
|
293
|
+
# values_for("[*1..5]
|
294
|
+
# .select(&:even)
|
295
|
+
# .map { |n| n * 2 }.
|
296
|
+
# map { |n| n / 2 }\
|
297
|
+
# .map { |n| n * 3 }").should == [['[1, 2, 3, 4, 5]'],
|
298
|
+
# ['[2, 4]'],
|
299
|
+
# ['[4, 8]'],
|
300
|
+
# ['[2, 4]'],
|
301
|
+
# ['[6, 12]']]
|
302
|
+
# values_for("1 +\n2").should == [['1'], ['3']]
|
303
|
+
# values_for("1\\\n+ 2").should == [['1'], ['3']]
|
304
|
+
end
|
305
|
+
|
287
306
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seeing_is_believing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Cheek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|