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
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'seeing_is_believing/binary/rewrite_comments'
|
2
|
+
|
3
|
+
describe SeeingIsBelieving::Binary::RewriteComments do
|
4
|
+
def call(code, &block)
|
5
|
+
described_class.call code, &block
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'ignores multiline comments' do
|
9
|
+
seen = []
|
10
|
+
call("123\n=begin\n456\n=end\n789") do |*args|
|
11
|
+
seen << args
|
12
|
+
args[-2..-1]
|
13
|
+
end
|
14
|
+
seen.should == []
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'yields the line_number, line upto the whitespace, whitespace, and comment' do
|
18
|
+
seen = []
|
19
|
+
call("# c1\n"\
|
20
|
+
"123 # c2 # x\n"\
|
21
|
+
"n456\n"\
|
22
|
+
" \t # c3\n"\
|
23
|
+
"%Q{\n"\
|
24
|
+
" 1}#c4\n"\
|
25
|
+
"# c5") do |*args|
|
26
|
+
seen << args
|
27
|
+
args[-2..-1]
|
28
|
+
end
|
29
|
+
seen.should == [
|
30
|
+
[1, "", "", "# c1"],
|
31
|
+
[2, "123", " ", "# c2 # x"],
|
32
|
+
[4, "", " \t ", "# c3"],
|
33
|
+
[6, " 1}", "", "#c4"],
|
34
|
+
[7, "", "", "# c5"],
|
35
|
+
]
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'rewrites the whitespace and comment with the whitespace and comment that are returned' do
|
39
|
+
rewritten = call("# c1\n"\
|
40
|
+
"123 #c2\n"\
|
41
|
+
"n456\n"\
|
42
|
+
" \t # c3\n"\
|
43
|
+
"%Q{\n"\
|
44
|
+
" 1}#c4") do |line_number, *|
|
45
|
+
["NEW_WHITESPACE#{line_number}", "--COMMENT-#{line_number}--"]
|
46
|
+
end
|
47
|
+
rewritten.should == "NEW_WHITESPACE1--COMMENT-1--\n"\
|
48
|
+
"123NEW_WHITESPACE2--COMMENT-2--\n"\
|
49
|
+
"n456\n"\
|
50
|
+
"NEW_WHITESPACE4--COMMENT-4--\n"\
|
51
|
+
"%Q{\n"\
|
52
|
+
" 1}NEW_WHITESPACE6--COMMENT-6--"
|
53
|
+
end
|
54
|
+
end
|
@@ -309,12 +309,11 @@ describe SeeingIsBelieving do
|
|
309
309
|
debugger.to_s.should include "\nbegin;" # there is more, but we're just interested in showing that it wound up in the stream
|
310
310
|
end
|
311
311
|
|
312
|
-
it 'prints the result'
|
312
|
+
it 'prints the result' do
|
313
313
|
call
|
314
314
|
debugger.to_s.should include "RESULT:"
|
315
315
|
debugger.to_s.should include '1=>#<SIB:Line["1"] no exception>'
|
316
316
|
end
|
317
317
|
# should ProgramRewriter have some debug options?
|
318
318
|
end
|
319
|
-
|
320
319
|
end
|
@@ -1,33 +1,62 @@
|
|
1
|
-
require 'seeing_is_believing/
|
1
|
+
require 'seeing_is_believing/wrap_expressions'
|
2
2
|
|
3
|
-
# eventually make this not
|
3
|
+
# eventually make this not wrap BEGIN and END
|
4
4
|
# but for now, leave it b/c it's convenient to be able to make it blow up
|
5
5
|
# Probably replace this with some macro like __INVALID_SYNTAX__ that blows it up :)
|
6
6
|
|
7
|
-
describe SeeingIsBelieving::
|
7
|
+
describe SeeingIsBelieving::WrapExpressions do
|
8
8
|
def wrap(code)
|
9
9
|
described_class.call code,
|
10
10
|
before_each: -> * { '<' },
|
11
11
|
after_each: -> * { '>' }
|
12
12
|
end
|
13
13
|
|
14
|
-
# when we get to 2.0 syntax:
|
15
|
-
# example 'ah' do
|
16
|
-
# wrap '-> { }.()'
|
17
|
-
# end
|
18
|
-
|
19
14
|
it 'raises a SyntaxError if the program is invalid' do
|
20
15
|
expect { wrap '+' }.to raise_error SyntaxError
|
21
16
|
end
|
22
17
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
18
|
+
describe 'wrapping the body' do
|
19
|
+
let(:options) { { before_all: "[",
|
20
|
+
after_all: "]",
|
21
|
+
before_each: -> * { '<' },
|
22
|
+
after_each: -> * { '>' } } }
|
23
|
+
|
24
|
+
it 'wraps the entire body, ignoring leading comments and the data segment' do
|
25
|
+
described_class.call("#comment\nA\n__END__\n1", options).should == "#comment\n[<A>]\n__END__\n1"
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'does nothing when there are only comments' do
|
29
|
+
described_class.call("# abc", options).should == "# abc"
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'comes in before trailing comments' do
|
33
|
+
described_class.call("1# abc", options).should == "[<1>]# abc"
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'fucking heredocs' do
|
37
|
+
example 'single heredoc' do
|
38
|
+
described_class.call("<<A\nA", options).should == "[<<<A>]\nA"
|
39
|
+
end
|
40
|
+
|
41
|
+
example 'multiple heredocs' do
|
42
|
+
# a stupid implementatnio issue from hacking around heredocs
|
43
|
+
# causes the toplevel begin to wrap the whole file.
|
44
|
+
# It's fine b/c it is ultimately the same, but that's why it's
|
45
|
+
# "[<<<<A>\nA\n<<B>]\nB"
|
46
|
+
# instead of
|
47
|
+
# "[<<<A>\nA\n<<<B>]\nB"
|
48
|
+
described_class.call("<<A\nA\n<<B\nB", options).should == "[<<<<A>\nA\n<<B>]\nB"
|
49
|
+
end
|
50
|
+
|
51
|
+
example 'heredocs as targets and arguments to methods' do
|
52
|
+
described_class.call("<<A.size 1\nA", options).should == "[<<<A.size 1>]\nA"
|
53
|
+
described_class.call("<<A.size\nA", options).should == "[<<<A.size>]\nA"
|
54
|
+
described_class.call("<<A.size()\nA", options).should == "[<<<A.size()>]\nA"
|
55
|
+
described_class.call("a.size <<A\nA", options).should == "[<a.size <<A>]\nA"
|
56
|
+
described_class.call("<<A.size <<B\nA\nB", options).should == "[<<<A.size <<B>]\nA\nB"
|
57
|
+
described_class.call("<<A.size(<<B)\nA\nB", options).should == "[<<<A.size(<<B)>]\nA\nB"
|
58
|
+
end
|
59
|
+
end
|
31
60
|
end
|
32
61
|
|
33
62
|
it 'passes the current line number to the before_each and after_each wrappers' do
|
@@ -296,6 +325,7 @@ describe SeeingIsBelieving::ProgramReWriter do
|
|
296
325
|
wrap("a=1").should == "<a=1>"
|
297
326
|
wrap("a.b=1").should == "<a.b=1>"
|
298
327
|
wrap("A=1").should == "<A=1>"
|
328
|
+
wrap("::A=1").should == "<::A=1>"
|
299
329
|
wrap("A::B=1").should == "<A::B=1>"
|
300
330
|
wrap("@a=1").should == "<@a=1>"
|
301
331
|
wrap("@@a=1").should == "<@@a=1>"
|
@@ -303,6 +333,7 @@ describe SeeingIsBelieving::ProgramReWriter do
|
|
303
333
|
end
|
304
334
|
|
305
335
|
it 'wraps multiple assignments' do
|
336
|
+
wrap("a,b=c").should == "<a,b=c>"
|
306
337
|
wrap("a,b=1,2").should == "<a,b=1,2>"
|
307
338
|
wrap("a,b.c=1,2").should == "<a,b.c=1,2>"
|
308
339
|
wrap("a,B=1,2").should == "<a,B=1,2>"
|
@@ -310,6 +341,8 @@ describe SeeingIsBelieving::ProgramReWriter do
|
|
310
341
|
wrap("a,@b=1,2").should == "<a,@b=1,2>"
|
311
342
|
wrap("a,@@b=1,2").should == "<a,@@b=1,2>"
|
312
343
|
wrap("a,$b=1,2").should == "<a,$b=1,2>"
|
344
|
+
wrap("a, b = x.()").should == "<a, b = x.()>"
|
345
|
+
wrap("a, b = c\n.d,\ne\n.f").should == "<a, b = <<c>\n.d>,\n<e>\n.f>"
|
313
346
|
end
|
314
347
|
|
315
348
|
it 'wraps multiple assignment on each line' do
|
@@ -343,6 +376,15 @@ describe SeeingIsBelieving::ProgramReWriter do
|
|
343
376
|
wrap("a &&= 1").should == "<a &&= 1>"
|
344
377
|
wrap("a[1] = 2").should == "<a[1] = 2>"
|
345
378
|
wrap("a[1] ||= 2").should == "<a[1] ||= 2>"
|
379
|
+
wrap("@a ||= 123").should == "<@a ||= 123>"
|
380
|
+
wrap("$a ||= 123").should == "<$a ||= 123>"
|
381
|
+
wrap("@@a ||= 123").should == "<@@a ||= 123>"
|
382
|
+
wrap("B ||= 123").should == "<B ||= 123>"
|
383
|
+
wrap("@a ||= begin\n123\nend").should == "<@a ||= begin\n<123>\nend>"
|
384
|
+
wrap("$a ||= begin\n123\nend").should == "<$a ||= begin\n<123>\nend>"
|
385
|
+
wrap("@@a ||= begin\n123\nend").should == "<@@a ||= begin\n<123>\nend>"
|
386
|
+
wrap("B ||= begin\n123\nend").should == "<B ||= begin\n<123>\nend>"
|
387
|
+
wrap("::B ||= begin\n123\nend").should == "<::B ||= begin\n<123>\nend>"
|
346
388
|
end
|
347
389
|
|
348
390
|
it 'wraps arguments in the assignment' do
|
@@ -399,7 +441,7 @@ describe SeeingIsBelieving::ProgramReWriter do
|
|
399
441
|
wrap("case\nwhen 2, 3 then\n4\n5\nend").should == "<case\nwhen 2, 3 then\n<4>\n<5>\nend>"
|
400
442
|
end
|
401
443
|
|
402
|
-
it 'does not
|
444
|
+
it 'does not wrap if the last value in any portion is a void value expression' do
|
403
445
|
wrap("def a\nif true\nreturn 1\nend\nend").should == "def a\nif <true>\nreturn <1>\nend\nend"
|
404
446
|
wrap("def a\nif true\n1\nelse\nreturn 2\nend\nend").should == "def a\nif <true>\n<1>\nelse\nreturn <2>\nend\nend"
|
405
447
|
wrap("def a\nif true\n1\nelsif true\n2\nelse\nreturn 3\nend\nend").should == "def a\nif <true>\n<1>\nelsif <true>\n<2>\nelse\nreturn <3>\nend\nend"
|
@@ -476,13 +518,17 @@ describe SeeingIsBelieving::ProgramReWriter do
|
|
476
518
|
end
|
477
519
|
|
478
520
|
describe 'array literals' do
|
479
|
-
it '
|
521
|
+
it 'wraps the array and each element that is on its own line' do
|
480
522
|
wrap("[1]").should == "<[1]>"
|
481
523
|
wrap("[1,\n2,\n]").should == "<[<1>,\n<2>,\n]>"
|
482
524
|
wrap("[1, 2,\n]").should == "<[1, <2>,\n]>"
|
483
525
|
end
|
484
526
|
|
485
|
-
it 'does not
|
527
|
+
it 'does not wrap magic arrays' do
|
528
|
+
wrap("%w[\n1\n]").should == "<%w[\n1\n]>"
|
529
|
+
end
|
530
|
+
|
531
|
+
it 'does not wrap splat elements' do
|
486
532
|
wrap("[1,\n*2..3,\n4\n]").should == "<[<1>,\n*2..3,\n<4>\n]>"
|
487
533
|
end
|
488
534
|
end
|
@@ -498,14 +544,14 @@ describe SeeingIsBelieving::ProgramReWriter do
|
|
498
544
|
wrap("%r'a'").should == "<%r'a'>"
|
499
545
|
end
|
500
546
|
|
501
|
-
it '
|
547
|
+
it 'wraps regexes that span mulitple lines' do
|
502
548
|
wrap("/a\nb/").should == "</a\nb/>"
|
503
549
|
wrap("/a\nb/i").should == "</a\nb/i>"
|
504
550
|
end
|
505
551
|
|
506
|
-
# eventually it would be nice if it
|
552
|
+
# eventually it would be nice if it wraped the interpolated portion,
|
507
553
|
# when the end of the line was not back inside the regexp
|
508
|
-
it '
|
554
|
+
it 'wraps regexes with interpolation, but not the interpolated portion' do
|
509
555
|
wrap("/a\#{1}/").should == "</a\#{1}/>"
|
510
556
|
wrap("/a\n\#{1}\nb/").should == "</a\n\#{1}\nb/>"
|
511
557
|
wrap("/a\n\#{1\n}b/").should == "</a\n\#{1\n}b/>"
|
@@ -513,31 +559,31 @@ describe SeeingIsBelieving::ProgramReWriter do
|
|
513
559
|
end
|
514
560
|
|
515
561
|
describe 'string literals (except heredocs)' do
|
516
|
-
it '
|
562
|
+
it 'wraps single and double quoted strings' do
|
517
563
|
wrap("'a'").should == "<'a'>"
|
518
564
|
wrap('"a"').should == '<"a">'
|
519
565
|
end
|
520
566
|
|
521
|
-
it '
|
567
|
+
it 'wraps strings with %, %Q, and %q' do
|
522
568
|
wrap("%'a'").should == "<%'a'>"
|
523
569
|
wrap("%q'a'").should == "<%q'a'>"
|
524
570
|
wrap("%Q'a'").should == "<%Q'a'>"
|
525
571
|
end
|
526
572
|
|
527
|
-
it '
|
573
|
+
it 'wraps strings that span mulitple lines' do
|
528
574
|
wrap("'a\nb'").should == "<'a\nb'>"
|
529
575
|
wrap(%'"a\nb"').should == %'<"a\nb">'
|
530
576
|
end
|
531
577
|
|
532
|
-
# eventually it would be nice if it
|
578
|
+
# eventually it would be nice if it wraped the interpolated portion,
|
533
579
|
# when the end of the line was not back inside the string
|
534
|
-
it '
|
580
|
+
it 'wraps strings with interpolation, but not the interpolated portion' do
|
535
581
|
wrap('"a#{1}"').should == '<"a#{1}">'
|
536
582
|
wrap(%'"a\n\#{1}\nb"').should == %'<"a\n\#{1}\nb">'
|
537
583
|
wrap(%'"a\n\#{1\n}b"').should == %'<"a\n\#{1\n}b">'
|
538
584
|
end
|
539
585
|
|
540
|
-
it '
|
586
|
+
it 'wraps %, %q, %Q' do
|
541
587
|
wrap('%(A)').should == '<%(A)>'
|
542
588
|
wrap('%.A.').should == '<%.A.>'
|
543
589
|
wrap('%q(A)').should == '<%q(A)>'
|
@@ -545,10 +591,16 @@ describe SeeingIsBelieving::ProgramReWriter do
|
|
545
591
|
wrap('%Q(A)').should == '<%Q(A)>'
|
546
592
|
wrap('%Q.A.').should == '<%Q.A.>'
|
547
593
|
end
|
594
|
+
|
595
|
+
it 'wraps heredocs with call defined on them (edge cases on edge cases *sigh*)' do
|
596
|
+
pending "just don't care this much right now, hopefully it will magically be fixed when new parser is released" do
|
597
|
+
wrap("<<HERE.()\na\nHERE").should == "<<<HERE.()>\na\nHERE"
|
598
|
+
end
|
599
|
+
end
|
548
600
|
end
|
549
601
|
|
550
602
|
describe 'heredocs' do
|
551
|
-
it '
|
603
|
+
it 'wraps heredocs on their first line' do
|
552
604
|
wrap("<<A\nA").should == "<<<A>\nA"
|
553
605
|
wrap("<<A\n123\nA").should == "<<<A>\n123\nA"
|
554
606
|
wrap("<<-A\nA").should == "<<<-A>\nA"
|
@@ -556,12 +608,10 @@ describe SeeingIsBelieving::ProgramReWriter do
|
|
556
608
|
wrap("1\n<<A\nA").should == "<<1>\n<<A>\nA"
|
557
609
|
wrap("<<A + <<B\n1\nA\n2\nB").should == "<<<A + <<B>\n1\nA\n2\nB"
|
558
610
|
wrap("<<A\n1\nA\n<<B\n2\nB").should == "<<<<A>\n1\nA\n<<B>\n2\nB"
|
559
|
-
|
560
|
-
wrap("puts <<A\nA\nputs <<B\nB").should == "<<puts <<A>\nA\nputs <<B>\nB"
|
561
|
-
end
|
611
|
+
wrap("puts <<A\nA\nputs <<B\nB").should == "<puts <<A>\nA\n<puts <<B>\nB"
|
562
612
|
end
|
563
613
|
|
564
|
-
it "
|
614
|
+
it "wraps methods that wrap heredocs, even whent hey don't have parentheses" do
|
565
615
|
wrap("a(<<HERE)\nHERE").should == "<a(<<HERE)>\nHERE"
|
566
616
|
wrap("a <<HERE\nHERE").should == "<a <<HERE>\nHERE"
|
567
617
|
wrap("a 1, <<HERE\nHERE").should == "<a 1, <<HERE>\nHERE"
|
@@ -570,15 +620,16 @@ describe SeeingIsBelieving::ProgramReWriter do
|
|
570
620
|
wrap("a.b 1,\n2,\n<<HERE\nHERE").should == "<a.b <1>,\n<2>,\n<<HERE>\nHERE"
|
571
621
|
end
|
572
622
|
|
573
|
-
it "
|
623
|
+
it "wraps assignments whose value is a heredoc" do
|
574
624
|
wrap("a=<<A\nA").should == "<a=<<A>\nA"
|
575
625
|
wrap("a,b=<<A,<<B\nA\nB").should == "<a,b=<<A,<<B>\nA\nB"
|
576
626
|
wrap("a,b=1,<<B\nB").should == "<a,b=1,<<B>\nB"
|
577
627
|
wrap("a,b=<<A,1\nA").should == "<a,b=<<A,1>\nA"
|
578
628
|
end
|
579
629
|
|
580
|
-
it '
|
630
|
+
it 'wraps methods tacked onto the end of heredocs' do
|
581
631
|
wrap("<<A.size\nA").should == "<<<A.size>\nA"
|
632
|
+
wrap("<<A.size 1\nA").should == "<<<A.size 1>\nA"
|
582
633
|
wrap("<<A.whatever <<B\nA\nB").should == "<<<A.whatever <<B>\nA\nB"
|
583
634
|
wrap("<<A.whatever(<<B)\nA\nB").should == "<<<A.whatever(<<B)>\nA\nB"
|
584
635
|
wrap("<<A.size()\nA").should == "<<<A.size()>\nA"
|
@@ -609,15 +660,19 @@ describe SeeingIsBelieving::ProgramReWriter do
|
|
609
660
|
wrap("begin\nend").should == "<begin\nend>"
|
610
661
|
wrap("begin\n1\nensure\n2\nend").should == "<begin\n<1>\nensure\n<2>\nend>"
|
611
662
|
end
|
612
|
-
it 'does not
|
613
|
-
|
663
|
+
it 'does not wrap arguments to rescue' do
|
664
|
+
wrap("begin\nrescue\nrescue => a\nrescue SyntaxError\nrescue Exception => a\nelse\nensure\nend").should ==
|
665
|
+
"<begin\nrescue\nrescue => a\nrescue SyntaxError\nrescue Exception => a\nelse\nensure\nend>"
|
666
|
+
end
|
667
|
+
it 'does not wrap retry' do
|
668
|
+
# in this case, it could wrap the retry
|
614
669
|
# but I don't know how to tell the difference between this and
|
615
670
|
# "loop { begin; retry; end }" so w/e
|
616
671
|
wrap("begin\nrescue\nretry\nend").should == "<begin\nrescue\nretry\nend>"
|
617
672
|
end
|
618
673
|
end
|
619
674
|
|
620
|
-
# eventually, don't wrap these b/c they're spammy, but can be annoying since they can be accidentally
|
675
|
+
# eventually, don't wrap these b/c they're spammy, but can be annoying since they can be accidentally wraped
|
621
676
|
# by e.g. a begin/end
|
622
677
|
# ignoring public/private/protected for now, b/c they're just methods, not keywords
|
623
678
|
describe 'class definitions' do
|
@@ -638,7 +693,7 @@ describe SeeingIsBelieving::ProgramReWriter do
|
|
638
693
|
end
|
639
694
|
end
|
640
695
|
|
641
|
-
# eventually, don't wrap these b/c they're spammy, but can be annoying since they can be accidentally
|
696
|
+
# eventually, don't wrap these b/c they're spammy, but can be annoying since they can be accidentally wraped
|
642
697
|
# by e.g. a begin/end
|
643
698
|
# ignoring public/private/protected for now, b/c they're just methods, not keywords
|
644
699
|
describe 'module definitions' do
|
@@ -660,7 +715,7 @@ describe SeeingIsBelieving::ProgramReWriter do
|
|
660
715
|
wrap("def a()\n1\nend").should == "def a()\n<1>\nend"
|
661
716
|
end
|
662
717
|
|
663
|
-
it 'does not try to
|
718
|
+
it 'does not try to wrap singleton method definitions' do
|
664
719
|
wrap("def a.b\n1\nend").should == "def a.b\n<1>\nend"
|
665
720
|
wrap("def a.b()\n1\nend").should == "def a.b()\n<1>\nend"
|
666
721
|
end
|
@@ -684,4 +739,26 @@ describe SeeingIsBelieving::ProgramReWriter do
|
|
684
739
|
wrap("def a\n1\nensure\n2\nend").should == "def a\n<1>\nensure\n<2>\nend"
|
685
740
|
end
|
686
741
|
end
|
742
|
+
|
743
|
+
describe 'lambdas' do
|
744
|
+
it 'wraps the lambda' do
|
745
|
+
wrap("lambda { }").should == "<lambda { }>"
|
746
|
+
wrap("-> { }").should == "<-> { }>"
|
747
|
+
wrap("-> a, b { }").should == "<-> a, b { }>"
|
748
|
+
wrap("-> {\n1\n}").should == "<-> {\n<1>\n}>"
|
749
|
+
pending "Parser doesn't parse this https://github.com/whitequark/parser/issues/103" do
|
750
|
+
wrap("-> * { }").should == "<-> * { }>"
|
751
|
+
end
|
752
|
+
end
|
753
|
+
|
754
|
+
it 'wraps the full invocation' do
|
755
|
+
wrap("lambda { }.()").should == "<lambda { }.()>"
|
756
|
+
wrap("-> { }.()").should == "<-> { }.()>"
|
757
|
+
wrap("-> a, b {\n1\n}.(1,\n2)").should == "<-> a, b {\n<1>\n}.(<1>,\n2)>"
|
758
|
+
wrap("-> a, b { }.call(1, 2)").should == "<-> a, b { }.call(1, 2)>"
|
759
|
+
pending "Parser doesn't parse this https://github.com/whitequark/parser/issues/103" do
|
760
|
+
wrap("-> * { }()").should == "<-> * { }.()>"
|
761
|
+
end
|
762
|
+
end
|
763
|
+
end
|
687
764
|
end
|
metadata
CHANGED
@@ -1,112 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seeing_is_believing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 2.0.0.beta1
|
4
|
+
version: 2.0.0.beta2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Josh Cheek
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
|
14
|
+
name: parser
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 2.0.0.pre6
|
20
|
-
none: false
|
21
|
-
name: parser
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
23
|
requirements:
|
26
24
|
- - ~>
|
27
25
|
- !ruby/object:Gem::Version
|
28
26
|
version: 2.0.0.pre6
|
29
|
-
none: false
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
|
-
|
28
|
+
name: haiti
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
32
30
|
requirements:
|
33
31
|
- - ~>
|
34
32
|
- !ruby/object:Gem::Version
|
35
33
|
version: 0.0.3
|
36
|
-
none: false
|
37
|
-
name: haiti
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
37
|
requirements:
|
42
38
|
- - ~>
|
43
39
|
- !ruby/object:Gem::Version
|
44
40
|
version: 0.0.3
|
45
|
-
none: false
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
|
-
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
48
44
|
requirements:
|
49
45
|
- - ~>
|
50
46
|
- !ruby/object:Gem::Version
|
51
47
|
version: 10.0.3
|
52
|
-
none: false
|
53
|
-
name: rake
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
|
-
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
52
|
- - ~>
|
59
53
|
- !ruby/object:Gem::Version
|
60
54
|
version: 10.0.3
|
61
|
-
none: false
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
|
-
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
64
58
|
requirements:
|
65
59
|
- - ~>
|
66
60
|
- !ruby/object:Gem::Version
|
67
61
|
version: 2.12.0
|
68
|
-
none: false
|
69
|
-
name: rspec
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
|
-
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
65
|
requirements:
|
74
66
|
- - ~>
|
75
67
|
- !ruby/object:Gem::Version
|
76
68
|
version: 2.12.0
|
77
|
-
none: false
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
|
-
|
70
|
+
name: cucumber
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
80
72
|
requirements:
|
81
73
|
- - ~>
|
82
74
|
- !ruby/object:Gem::Version
|
83
75
|
version: 1.2.1
|
84
|
-
none: false
|
85
|
-
name: cucumber
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
|
-
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
79
|
requirements:
|
90
80
|
- - ~>
|
91
81
|
- !ruby/object:Gem::Version
|
92
82
|
version: 1.2.1
|
93
|
-
none: false
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
|
-
|
84
|
+
name: ichannel
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
96
86
|
requirements:
|
97
87
|
- - ~>
|
98
88
|
- !ruby/object:Gem::Version
|
99
89
|
version: 5.1.1
|
100
|
-
none: false
|
101
|
-
name: ichannel
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
|
-
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
93
|
requirements:
|
106
94
|
- - ~>
|
107
95
|
- !ruby/object:Gem::Version
|
108
96
|
version: 5.1.1
|
109
|
-
none: false
|
110
97
|
description: Records the results of every line of code in your file (intended to be
|
111
98
|
like xmpfilter), inspired by Bret Victor's JavaScript example in his talk "Inventing
|
112
99
|
on Principle"
|
@@ -135,59 +122,57 @@ files:
|
|
135
122
|
- lib/seeing_is_believing/binary/align_file.rb
|
136
123
|
- lib/seeing_is_believing/binary/align_line.rb
|
137
124
|
- lib/seeing_is_believing/binary/arg_parser.rb
|
138
|
-
- lib/seeing_is_believing/binary/
|
139
|
-
- lib/seeing_is_believing/binary/
|
125
|
+
- lib/seeing_is_believing/binary/clean_body.rb
|
126
|
+
- lib/seeing_is_believing/binary/comment_formatter.rb
|
127
|
+
- lib/seeing_is_believing/binary/comment_lines.rb
|
128
|
+
- lib/seeing_is_believing/binary/commentable_lines.rb
|
129
|
+
- lib/seeing_is_believing/binary/rewrite_comments.rb
|
140
130
|
- lib/seeing_is_believing/debugger.rb
|
141
131
|
- lib/seeing_is_believing/error.rb
|
142
132
|
- lib/seeing_is_believing/evaluate_by_moving_files.rb
|
143
133
|
- lib/seeing_is_believing/hard_core_ensure.rb
|
144
134
|
- lib/seeing_is_believing/has_exception.rb
|
145
135
|
- lib/seeing_is_believing/line.rb
|
146
|
-
- lib/seeing_is_believing/program_rewriter.rb
|
147
|
-
- lib/seeing_is_believing/queue.rb
|
148
|
-
- lib/seeing_is_believing/remove_inline_comments.rb
|
149
136
|
- lib/seeing_is_believing/result.rb
|
150
|
-
- lib/seeing_is_believing/syntax_analyzer.rb
|
151
137
|
- lib/seeing_is_believing/the_matrix.rb
|
152
|
-
- lib/seeing_is_believing/tracks_line_numbers_seen.rb
|
153
138
|
- lib/seeing_is_believing/version.rb
|
139
|
+
- lib/seeing_is_believing/wrap_expressions.rb
|
154
140
|
- seeing_is_believing.gemspec
|
155
141
|
- spec/binary/arg_parser_spec.rb
|
156
|
-
- spec/binary/
|
157
|
-
- spec/binary/
|
142
|
+
- spec/binary/clean_body_spec.rb
|
143
|
+
- spec/binary/comment_formatter_spec.rb
|
144
|
+
- spec/binary/comment_lines_spec.rb
|
145
|
+
- spec/binary/rewrite_comments_spec.rb
|
158
146
|
- spec/debugger_spec.rb
|
159
147
|
- spec/evaluate_by_moving_files_spec.rb
|
160
148
|
- spec/hard_core_ensure_spec.rb
|
161
149
|
- spec/line_spec.rb
|
162
|
-
- spec/program_rewriter_spec.rb
|
163
|
-
- spec/queue_spec.rb
|
164
150
|
- spec/seeing_is_believing_spec.rb
|
165
|
-
- spec/
|
151
|
+
- spec/wrap_expressions_spec.rb
|
166
152
|
- textmate-integration.png
|
167
153
|
homepage: https://github.com/JoshCheek/seeing_is_believing
|
168
154
|
licenses:
|
169
155
|
- WTFPL
|
156
|
+
metadata: {}
|
170
157
|
post_install_message:
|
171
158
|
rdoc_options: []
|
172
159
|
require_paths:
|
173
160
|
- lib
|
174
161
|
required_ruby_version: !ruby/object:Gem::Requirement
|
175
162
|
requirements:
|
176
|
-
- -
|
163
|
+
- - '>='
|
177
164
|
- !ruby/object:Gem::Version
|
178
165
|
version: '0'
|
179
|
-
none: false
|
180
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
167
|
requirements:
|
182
|
-
- -
|
168
|
+
- - '>'
|
183
169
|
- !ruby/object:Gem::Version
|
184
170
|
version: 1.3.1
|
185
|
-
none: false
|
186
171
|
requirements: []
|
187
172
|
rubyforge_project: seeing_is_believing
|
188
|
-
rubygems_version:
|
173
|
+
rubygems_version: 2.0.5
|
189
174
|
signing_key:
|
190
|
-
specification_version:
|
175
|
+
specification_version: 4
|
191
176
|
summary: Records results of every line of code in your file
|
192
177
|
test_files:
|
193
178
|
- features/errors.feature
|
@@ -196,14 +181,14 @@ test_files:
|
|
196
181
|
- features/regression.feature
|
197
182
|
- features/support/env.rb
|
198
183
|
- spec/binary/arg_parser_spec.rb
|
199
|
-
- spec/binary/
|
200
|
-
- spec/binary/
|
184
|
+
- spec/binary/clean_body_spec.rb
|
185
|
+
- spec/binary/comment_formatter_spec.rb
|
186
|
+
- spec/binary/comment_lines_spec.rb
|
187
|
+
- spec/binary/rewrite_comments_spec.rb
|
201
188
|
- spec/debugger_spec.rb
|
202
189
|
- spec/evaluate_by_moving_files_spec.rb
|
203
190
|
- spec/hard_core_ensure_spec.rb
|
204
191
|
- spec/line_spec.rb
|
205
|
-
- spec/program_rewriter_spec.rb
|
206
|
-
- spec/queue_spec.rb
|
207
192
|
- spec/seeing_is_believing_spec.rb
|
208
|
-
- spec/
|
193
|
+
- spec/wrap_expressions_spec.rb
|
209
194
|
has_rdoc:
|