seeing_is_believing 2.0.0.beta1 → 2.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Readme.md +8 -20
- data/features/examples.feature +1 -3
- data/features/flags.feature +4 -12
- data/features/regression.feature +95 -1
- data/lib/seeing_is_believing.rb +17 -21
- data/lib/seeing_is_believing/binary.rb +3 -3
- data/lib/seeing_is_believing/binary/add_annotations.rb +86 -118
- data/lib/seeing_is_believing/binary/align_chunk.rb +22 -23
- data/lib/seeing_is_believing/binary/align_file.rb +10 -13
- data/lib/seeing_is_believing/binary/align_line.rb +0 -4
- data/lib/seeing_is_believing/binary/arg_parser.rb +11 -11
- data/lib/seeing_is_believing/binary/clean_body.rb +96 -0
- data/lib/seeing_is_believing/binary/comment_formatter.rb +55 -0
- data/lib/seeing_is_believing/binary/comment_lines.rb +37 -0
- data/lib/seeing_is_believing/binary/commentable_lines.rb +158 -0
- data/lib/seeing_is_believing/binary/rewrite_comments.rb +42 -0
- data/lib/seeing_is_believing/result.rb +2 -9
- data/lib/seeing_is_believing/the_matrix.rb +8 -8
- data/lib/seeing_is_believing/version.rb +1 -1
- data/lib/seeing_is_believing/{program_rewriter.rb → wrap_expressions.rb} +30 -22
- data/spec/binary/arg_parser_spec.rb +7 -7
- data/spec/binary/clean_body_spec.rb +217 -0
- data/spec/binary/comment_formatter_spec.rb +54 -0
- data/spec/binary/comment_lines_spec.rb +847 -0
- data/spec/binary/rewrite_comments_spec.rb +54 -0
- data/spec/seeing_is_believing_spec.rb +1 -2
- data/spec/{program_rewriter_spec.rb → wrap_expressions_spec.rb} +117 -40
- metadata +41 -56
- data/lib/seeing_is_believing/binary/line_formatter.rb +0 -47
- data/lib/seeing_is_believing/binary/remove_previous_annotations.rb +0 -75
- data/lib/seeing_is_believing/queue.rb +0 -55
- data/lib/seeing_is_believing/remove_inline_comments.rb +0 -46
- data/lib/seeing_is_believing/syntax_analyzer.rb +0 -61
- data/lib/seeing_is_believing/tracks_line_numbers_seen.rb +0 -19
- data/spec/binary/line_formatter_spec.rb +0 -53
- data/spec/binary/remove_previous_annotations_spec.rb +0 -198
- data/spec/queue_spec.rb +0 -80
- data/spec/syntax_analyzer_spec.rb +0 -56
data/spec/queue_spec.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
require 'seeing_is_believing/queue'
|
2
|
-
|
3
|
-
describe SeeingIsBelieving::Queue do
|
4
|
-
def queue_for(*values)
|
5
|
-
described_class.new { values.shift }
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'generates values from the block it is initialized with' do
|
9
|
-
queue = queue_for 1, 2
|
10
|
-
queue.dequeue.should == 1
|
11
|
-
queue.dequeue.should == 2
|
12
|
-
queue.dequeue.should == nil
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'can peek ahead' do
|
16
|
-
queue = queue_for 1, 2
|
17
|
-
queue.peek.should == 1
|
18
|
-
queue.peek.should == 1
|
19
|
-
queue.dequeue.should == 1
|
20
|
-
queue.dequeue.should == 2
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'considers a nil value to mean it is empty' do
|
24
|
-
queue = queue_for 1, 2
|
25
|
-
queue.should_not be_empty
|
26
|
-
queue.peek.should == 1
|
27
|
-
queue.should_not be_empty
|
28
|
-
queue.dequeue.should == 1
|
29
|
-
queue.should_not be_empty
|
30
|
-
queue.peek.should == 2
|
31
|
-
queue.should_not be_empty
|
32
|
-
queue.dequeue.should == 2
|
33
|
-
queue.should be_empty
|
34
|
-
queue.peek.should == nil
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'yields nil infinitely after the first time it is seen' do
|
38
|
-
queue = queue_for nil, 1
|
39
|
-
queue.should be_empty
|
40
|
-
queue.peek.should == nil
|
41
|
-
queue.dequeue.should == nil
|
42
|
-
queue.should be_empty
|
43
|
-
queue.peek.should == nil
|
44
|
-
queue.dequeue.should == nil
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'can (destructively) iterate over its items until it is empty' do
|
48
|
-
queue = queue_for *1..5
|
49
|
-
seen = []
|
50
|
-
queue.each { |i| seen << i }
|
51
|
-
seen.should == [*1..5]
|
52
|
-
queue.should be_empty
|
53
|
-
end
|
54
|
-
|
55
|
-
describe 'conditional iteration' do
|
56
|
-
it 'can iterate while a condition is met' do
|
57
|
-
queue = queue_for *1..5
|
58
|
-
seen = []
|
59
|
-
queue.while { |arg| arg < 4 }.each { |arg| seen << arg }
|
60
|
-
seen.should == [1, 2, 3]
|
61
|
-
queue.peek.should == 4
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'can iterate until a condition is met' do
|
65
|
-
queue = queue_for *1..5
|
66
|
-
seen = []
|
67
|
-
queue.until { |arg| arg == 4 }.each { |arg| seen << arg }
|
68
|
-
seen.should == [1, 2, 3]
|
69
|
-
queue.peek.should == 4
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'stops iterating when it hits the end of the queue' do
|
73
|
-
queue = queue_for *1..5
|
74
|
-
seen = []
|
75
|
-
queue.while { true }.each { |arg| seen << arg }
|
76
|
-
seen.should == [*1..5]
|
77
|
-
queue.should be_empty
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'seeing_is_believing'
|
2
|
-
|
3
|
-
describe SeeingIsBelieving::SyntaxAnalyzer do
|
4
|
-
it 'knows if the last line is a comment' do
|
5
|
-
is_comment = lambda { |code| described_class.ends_in_comment? code }
|
6
|
-
|
7
|
-
# true
|
8
|
-
is_comment['# whatev'].should be_true
|
9
|
-
is_comment['a # whatev'].should be_true
|
10
|
-
is_comment["a \n b # whatev"].should be_true
|
11
|
-
is_comment["=begin\n1\n=end"].should be_true
|
12
|
-
is_comment["# Transfer-Encoding: chunked"].should be_true
|
13
|
-
|
14
|
-
# false
|
15
|
-
is_comment['a'].should be_false
|
16
|
-
is_comment["a # whatev \n b"].should be_false
|
17
|
-
is_comment[""].should be_false
|
18
|
-
is_comment["=begin\n=end\n\n =end"].should be_false
|
19
|
-
pending "Fix comments to not be shit" do
|
20
|
-
is_comment[%'"\n\#{1}"'].should be_false
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'knows if it contains an unclosed comment' do
|
25
|
-
is_unclosed_comment = lambda { |code| described_class.unclosed_comment? code }
|
26
|
-
is_unclosed_comment["=begin"].should be_true
|
27
|
-
is_unclosed_comment["=begin\n"].should be_true
|
28
|
-
is_unclosed_comment["=begin\n1"].should be_true
|
29
|
-
is_unclosed_comment["1\n=begin\n1\n"].should be_true
|
30
|
-
is_unclosed_comment["1\n=begin\n1\n =end"].should be_true
|
31
|
-
is_unclosed_comment["1\n=begin\n1\n=end"].should be_false
|
32
|
-
is_unclosed_comment[" =begin"].should be_false
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'knows if the line begins a multiline comment' do
|
36
|
-
described_class.begins_multiline_comment?('=begin').should be_true
|
37
|
-
described_class.begins_multiline_comment?('=begins').should be_false
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'knows if the line ends a multiline comment' do
|
41
|
-
described_class.ends_multiline_comment?('=end').should be_true
|
42
|
-
described_class.ends_multiline_comment?('=ends').should be_false
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'knows when the line is a comment' do
|
46
|
-
described_class.line_is_comment?('# abc').should be_true
|
47
|
-
described_class.line_is_comment?(' # abc').should be_true
|
48
|
-
described_class.line_is_comment?('a # abc').should be_false
|
49
|
-
described_class.line_is_comment?('abc').should be_false
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'knows when a line opens the data segment' do
|
53
|
-
described_class.begins_data_segment?('__END__').should be_true
|
54
|
-
described_class.begins_data_segment?('__ENDS__').should be_false
|
55
|
-
end
|
56
|
-
end
|