seeing_is_believing 3.0.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/features/flags.feature +39 -0
- data/features/regression.feature +154 -0
- data/features/xmpfilter-style.feature +57 -0
- data/lib/seeing_is_believing/binary/annotate_every_line.rb +11 -4
- data/lib/seeing_is_believing/binary/annotate_marked_lines.rb +11 -5
- data/lib/seeing_is_believing/binary/config.rb +9 -0
- data/lib/seeing_is_believing/binary/data_structures.rb +1 -0
- data/lib/seeing_is_believing/binary/interline_align.rb +57 -0
- data/lib/seeing_is_believing/customize_pp.rb +5 -0
- data/lib/seeing_is_believing/event_stream/consumer.rb +39 -43
- data/lib/seeing_is_believing/event_stream/producer.rb +24 -31
- data/lib/seeing_is_believing/safe.rb +93 -39
- data/lib/seeing_is_believing/the_matrix.rb +10 -10
- data/lib/seeing_is_believing/version.rb +1 -1
- data/lib/seeing_is_believing/wrap_expressions.rb +24 -5
- data/spec/binary/config_spec.rb +17 -2
- data/spec/event_stream_spec.rb +1 -0
- data/spec/seeing_is_believing_spec.rb +58 -53
- data/spec/spec_helper.rb +22 -0
- data/spec/spec_helper_spec.rb +16 -0
- data/spec/wrap_expressions_spec.rb +35 -0
- metadata +7 -3
data/spec/binary/config_spec.rb
CHANGED
@@ -220,8 +220,8 @@ RSpec.describe SeeingIsBelieving::Binary::Config do
|
|
220
220
|
expect(parse([]).lib_options.require_files).to eq [matrix_file]
|
221
221
|
end
|
222
222
|
|
223
|
-
it 'appends pp for xmpfilter style' do
|
224
|
-
expect(parse(['-x']).lib_options.require_files).to eq [matrix_file, 'pp']
|
223
|
+
it 'appends pp and our customizations for xmpfilter style' do
|
224
|
+
expect(parse(['-x']).lib_options.require_files).to eq [matrix_file, 'pp', 'seeing_is_believing/customize_pp']
|
225
225
|
end
|
226
226
|
|
227
227
|
specify '-r and --require set an error if not provided with a filename' do
|
@@ -563,6 +563,21 @@ RSpec.describe SeeingIsBelieving::Binary::Config do
|
|
563
563
|
end
|
564
564
|
|
565
565
|
|
566
|
+
describe 'align_results?' do
|
567
|
+
it 'defaults to true' do
|
568
|
+
expect(parse([]).annotator_options.interline_align?).to eq true
|
569
|
+
end
|
570
|
+
it 'can be turned on with --interline-align' do
|
571
|
+
expect(parse(['--interline-align'])).to_not have_error '--interline-align'
|
572
|
+
expect(parse(['--interline-align']).annotator_options.interline_align?).to eq true
|
573
|
+
end
|
574
|
+
it 'can be turned off with --no-interline-align' do
|
575
|
+
expect(parse(['--no-interline-align'])).to_not have_error '--no-interline-align'
|
576
|
+
expect(parse(['--no-interline-align']).annotator_options.interline_align?).to eq false
|
577
|
+
end
|
578
|
+
end
|
579
|
+
|
580
|
+
|
566
581
|
describe '.finalize' do
|
567
582
|
let(:stdin_data) { 'stdin data' }
|
568
583
|
let(:stdin) { object_double $stdin, read: stdin_data }
|
data/spec/event_stream_spec.rb
CHANGED
@@ -560,7 +560,7 @@ RSpec.describe SeeingIsBelieving do
|
|
560
560
|
|
561
561
|
describe 'fork' do
|
562
562
|
it 'records results from both parent and child, without double reporting items that may have been left in the queue at the time of forking' do
|
563
|
-
n =
|
563
|
+
n = 100
|
564
564
|
result = invoke <<-RUBY
|
565
565
|
n = #{n}
|
566
566
|
as = '0' * n; 0
|
@@ -674,16 +674,6 @@ RSpec.describe SeeingIsBelieving do
|
|
674
674
|
end').stderr).to eq ''
|
675
675
|
end
|
676
676
|
|
677
|
-
specify 'when File does not have sync=, <<, flush, puts, close' do
|
678
|
-
expect(invoke('class File
|
679
|
-
undef sync
|
680
|
-
undef <<
|
681
|
-
undef flush
|
682
|
-
undef puts
|
683
|
-
undef close
|
684
|
-
end').stderr).to eq ''
|
685
|
-
end
|
686
|
-
|
687
677
|
specify 'when Queue does not have <<, shift, and clear' do
|
688
678
|
expect(invoke('class Queue
|
689
679
|
undef <<
|
@@ -711,14 +701,19 @@ RSpec.describe SeeingIsBelieving do
|
|
711
701
|
end
|
712
702
|
|
713
703
|
specify 'when Fixnum does not have <, <<, next, ==, inspect, to_s' do
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
704
|
+
result = invoke('class Fixnum
|
705
|
+
undef <
|
706
|
+
undef <<
|
707
|
+
undef ==
|
708
|
+
def next
|
709
|
+
"redefining instead of undefing b/c it comes from Integer"
|
710
|
+
end
|
711
|
+
undef to_s
|
712
|
+
undef inspect
|
713
|
+
end
|
714
|
+
"a"')
|
715
|
+
expect(result.stderr).to eq ''
|
716
|
+
expect(result.to_a.last).to eq ['"a"']
|
722
717
|
end
|
723
718
|
|
724
719
|
specify 'when Hash does not have [], []=, fetch' do
|
@@ -754,15 +749,16 @@ RSpec.describe SeeingIsBelieving do
|
|
754
749
|
end').stderr).to eq ''
|
755
750
|
end
|
756
751
|
|
757
|
-
|
758
|
-
|
759
|
-
|
752
|
+
# defined? is a macro, not a method, otherwise I'd test that here
|
753
|
+
specify 'when Kernel does not have kind_of?' do
|
754
|
+
expect(invoke('module Kernel
|
760
755
|
undef kind_of?
|
761
|
-
end
|
756
|
+
end
|
757
|
+
1').to_a).to eq [[], [], ['nil'], ['1']]
|
762
758
|
end
|
763
759
|
|
764
760
|
specify 'when Enumerable does not have map' do
|
765
|
-
expect(invoke('
|
761
|
+
expect(invoke('module Enumerable
|
766
762
|
undef map
|
767
763
|
end
|
768
764
|
').stderr).to eq ''
|
@@ -780,15 +776,19 @@ RSpec.describe SeeingIsBelieving do
|
|
780
776
|
end
|
781
777
|
|
782
778
|
specify 'when Exception does not have message, class (can\'t get backtrace to work)' do
|
783
|
-
result = invoke('
|
784
|
-
|
785
|
-
|
786
|
-
|
779
|
+
result = invoke('begin
|
780
|
+
raise "hello"
|
781
|
+
ensure
|
782
|
+
class Exception
|
783
|
+
undef message
|
784
|
+
undef backtrace
|
785
|
+
def class; "totally the wrong thing" end
|
786
|
+
end
|
787
787
|
end
|
788
|
-
raise "hello"
|
789
788
|
')
|
790
789
|
expect(result.exception.message).to eq 'hello'
|
791
|
-
|
790
|
+
expect(result.exception.backtrace.length).to eq 1
|
791
|
+
expect(result.exception.backtrace[0]).to match /program\.rb:\d/
|
792
792
|
expect(result.exception.class_name).to eq 'RuntimeError'
|
793
793
|
end
|
794
794
|
|
@@ -801,6 +801,8 @@ RSpec.describe SeeingIsBelieving do
|
|
801
801
|
undef join
|
802
802
|
undef abort_on_exception
|
803
803
|
end
|
804
|
+
fork
|
805
|
+
1
|
804
806
|
').stderr).to eq ''
|
805
807
|
end
|
806
808
|
|
@@ -842,31 +844,34 @@ RSpec.describe SeeingIsBelieving do
|
|
842
844
|
').stderr).to eq ''
|
843
845
|
end
|
844
846
|
|
845
|
-
|
846
|
-
|
847
|
+
specify 'when UnboundMethod does not have bind' do
|
848
|
+
expect(invoke('class UnboundMethod
|
849
|
+
undef bind
|
850
|
+
end
|
851
|
+
').stderr).to eq ''
|
852
|
+
end
|
847
853
|
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
+
specify 'when Method does not have call' do
|
855
|
+
expect(invoke('class Method
|
856
|
+
undef call
|
857
|
+
end
|
858
|
+
').stderr).to eq ''
|
859
|
+
end
|
854
860
|
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
861
|
+
specify 'when Proc does not have call, to_proc' do
|
862
|
+
expect(invoke('class Proc
|
863
|
+
undef call
|
864
|
+
undef to_proc
|
865
|
+
end
|
866
|
+
').stderr).to eq ''
|
867
|
+
end
|
868
|
+
|
869
|
+
# Apparently it doesn't have a to_proc method, they must check to see if it's nil in the code that implements &
|
870
|
+
specify 'when nil does not have to_s' do
|
871
|
+
expect(invoke('class NilClass
|
872
|
+
undef to_s
|
873
|
+
end
|
874
|
+
').stderr).to eq ''
|
868
875
|
end
|
869
876
|
end
|
870
877
|
end
|
871
|
-
|
872
|
-
# all of them together
|
data/spec/spec_helper.rb
CHANGED
@@ -3,6 +3,28 @@ module SibSpecHelpers
|
|
3
3
|
pending message
|
4
4
|
raise message
|
5
5
|
end
|
6
|
+
|
7
|
+
def ruby_version
|
8
|
+
Version.new RUBY_VERSION
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
class Version
|
13
|
+
attr_reader :segments
|
14
|
+
include Comparable
|
15
|
+
def initialize(version_string)
|
16
|
+
@segments = version_string.scan(/\d+/).map(&:to_i)
|
17
|
+
end
|
18
|
+
def <=>(other)
|
19
|
+
other = Version.new other unless other.kind_of? Version
|
20
|
+
segments.zip(other.segments).each do |ours, theirs|
|
21
|
+
return 1 if theirs.nil? || theirs < ours
|
22
|
+
return -1 if ours < theirs
|
23
|
+
end
|
24
|
+
segments.length <=> other.segments.length
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
6
28
|
end
|
7
29
|
|
8
30
|
RSpec.configure do |c|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe SibSpecHelpers::Version do
|
4
|
+
let(:v231) { SibSpecHelpers::Version.new '2.3.1' }
|
5
|
+
example { expect(v231).to eq v231 }
|
6
|
+
example { expect(v231).to eq '2.3.1' }
|
7
|
+
example { expect(v231).to_not be < '2' }
|
8
|
+
example { expect(v231).to be < '3' }
|
9
|
+
example { expect(v231).to_not be < '2.2' }
|
10
|
+
example { expect(v231).to_not be < '2.3' }
|
11
|
+
example { expect(v231).to be < '2.4' }
|
12
|
+
example { expect(v231).to_not be < '2.3.0' }
|
13
|
+
example { expect(v231).to_not be < '2.3.1' }
|
14
|
+
example { expect(v231).to be < '2.3.2' }
|
15
|
+
example { expect(v231).to be < '2.3.1.0' }
|
16
|
+
end
|
@@ -637,6 +637,10 @@ RSpec.describe SeeingIsBelieving::WrapExpressions do
|
|
637
637
|
expect(heredoc_wrap "<<A\n123\nA").to eq "[{<<A}]\n123\nA"
|
638
638
|
expect(heredoc_wrap "<<-A\nA").to eq "[{<<-A}]\nA"
|
639
639
|
expect(heredoc_wrap "<<-A\n123\nA").to eq "[{<<-A}]\n123\nA"
|
640
|
+
if ruby_version >= '2.3'
|
641
|
+
expect(heredoc_wrap "<<~A\nA").to eq "[{<<~A}]\nA"
|
642
|
+
expect(heredoc_wrap "<<~A\n123\nA").to eq "[{<<~A}]\n123\nA"
|
643
|
+
end
|
640
644
|
expect(heredoc_wrap "1\n<<A\nA").to eq "[{1}\n{<<A}]\nA"
|
641
645
|
expect(heredoc_wrap "<<A + <<B\n1\nA\n2\nB").to eq "[{<<A + <<B}]\n1\nA\n2\nB"
|
642
646
|
expect(heredoc_wrap "<<A\n1\nA\n<<B\n2\nB").to eq "[{<<A}\n1\nA\n{<<B}]\n2\nB"
|
@@ -667,6 +671,12 @@ RSpec.describe SeeingIsBelieving::WrapExpressions do
|
|
667
671
|
expect(heredoc_wrap "<<A.whatever(<<B)\nA\nB").to eq "[{<<A.whatever(<<B)}]\nA\nB"
|
668
672
|
expect(heredoc_wrap "<<A.size()\nA").to eq "[{<<A.size()}]\nA"
|
669
673
|
end
|
674
|
+
|
675
|
+
it 'is not confused by external heredocs (backticks)' do
|
676
|
+
expect(heredoc_wrap "<<`A`\nA").to eq "[{<<`A`}]\nA"
|
677
|
+
expect(heredoc_wrap "<<-`A`\nA").to eq "[{<<-`A`}]\nA"
|
678
|
+
expect(heredoc_wrap "<<~`A`\nA").to eq "[{<<~`A`}]\nA" if ruby_version >= '2.3'
|
679
|
+
end
|
670
680
|
end
|
671
681
|
|
672
682
|
# raises can be safely ignored, they're just method invocations
|
@@ -805,6 +815,31 @@ RSpec.describe SeeingIsBelieving::WrapExpressions do
|
|
805
815
|
end
|
806
816
|
end
|
807
817
|
|
818
|
+
describe 'interpolation wraps the whole value and interpolated values' do
|
819
|
+
def self.assert_interpolates(name, code, expected)
|
820
|
+
example(name) { expect(wrap code).to eq expected }
|
821
|
+
end
|
822
|
+
|
823
|
+
assert_interpolates 'backtick syscall', "`a\#{\n1\n}\nb\n`", "<`a\#{\n<1>\n}\nb\n`>"
|
824
|
+
assert_interpolates 'slash regex', "/a\#{\n1\n}\nb\n/", "</a\#{\n<1>\n}\nb\n/>"
|
825
|
+
assert_interpolates 'double quoted string', "\"a\#{\n1\n}\nb\n\"", "<\"a\#{\n<1>\n}\nb\n\">"
|
826
|
+
assert_interpolates 'double quoted symbol', ":\"a\#{\n1\n}\nb\n\"", "<:\"a\#{\n<1>\n}\nb\n\">"
|
827
|
+
|
828
|
+
assert_interpolates 'symbol array with interpolation', "%I.a\#{\n1\n}\nb\n.", "<%I.a\#{\n<1>\n}\nb\n.>"
|
829
|
+
assert_interpolates '%x syscall', "%x.a\#{\n1\n}\nb\n.", "<%x.a\#{\n<1>\n}\nb\n.>"
|
830
|
+
assert_interpolates '% string', "%.a\#{\n1\n}\nb\n.", "<%.a\#{\n<1>\n}\nb\n.>"
|
831
|
+
assert_interpolates 'string array with interpolation', "%W.a\#{\n1\n}\nb\n.", "<%W.a\#{\n<1>\n}\nb\n.>"
|
832
|
+
assert_interpolates '%r regex', "%r.a\#{\n1\n}\nb\n.", "<%r.a\#{\n<1>\n}\nb\n.>"
|
833
|
+
assert_interpolates '%Q string', "%Q.a\#{\n1\n}\nb\n.", "<%Q.a\#{\n<1>\n}\nb\n.>"
|
834
|
+
|
835
|
+
assert_interpolates '%s symbol', "%s.a\#{\n1\n}\nb\n.", "<%s.a\#{\n1\n}\nb\n.>"
|
836
|
+
assert_interpolates 'single quoted string', "'a\#{\n1\n}\nb\n'", "<'a\#{\n1\n}\nb\n'>"
|
837
|
+
assert_interpolates 'single quoted symbol', ":'a\#{\n1\n}\nb\n'", "<:'a\#{\n1\n}\nb\n'>"
|
838
|
+
assert_interpolates 'symbol array without interpolation', "%i.a\#{\n1\n}\nb\n.", "<%i.a\#{\n1\n}\nb\n.>"
|
839
|
+
assert_interpolates '%q string without interpolation', "%q.a\#{\n1\n}\nb\n.", "<%q.a\#{\n1\n}\nb\n.>"
|
840
|
+
assert_interpolates 'string array without interpolation', "%w.a\#{\n1\n}\nb\n.", "<%w.a\#{\n1\n}\nb\n.>"
|
841
|
+
end
|
842
|
+
|
808
843
|
describe 'BEGIN/END' do
|
809
844
|
# not implemented b/c we cannot wrap around these either.
|
810
845
|
# So what does it mean to wrap around?
|
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: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Cheek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -161,9 +161,11 @@ files:
|
|
161
161
|
- lib/seeing_is_believing/binary/data_structures.rb
|
162
162
|
- lib/seeing_is_believing/binary/engine.rb
|
163
163
|
- lib/seeing_is_believing/binary/format_comment.rb
|
164
|
+
- lib/seeing_is_believing/binary/interline_align.rb
|
164
165
|
- lib/seeing_is_believing/binary/remove_annotations.rb
|
165
166
|
- lib/seeing_is_believing/binary/rewrite_comments.rb
|
166
167
|
- lib/seeing_is_believing/code.rb
|
168
|
+
- lib/seeing_is_believing/customize_pp.rb
|
167
169
|
- lib/seeing_is_believing/debugger.rb
|
168
170
|
- lib/seeing_is_believing/error.rb
|
169
171
|
- lib/seeing_is_believing/evaluate_by_moving_files.rb
|
@@ -200,6 +202,7 @@ files:
|
|
200
202
|
- spec/hash_struct_spec.rb
|
201
203
|
- spec/seeing_is_believing_spec.rb
|
202
204
|
- spec/spec_helper.rb
|
205
|
+
- spec/spec_helper_spec.rb
|
203
206
|
- spec/wrap_expressions_spec.rb
|
204
207
|
homepage: https://github.com/JoshCheek/seeing_is_believing
|
205
208
|
licenses:
|
@@ -261,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
261
264
|
version: '0'
|
262
265
|
requirements: []
|
263
266
|
rubyforge_project: seeing_is_believing
|
264
|
-
rubygems_version: 2.
|
267
|
+
rubygems_version: 2.6.8
|
265
268
|
signing_key:
|
266
269
|
specification_version: 4
|
267
270
|
summary: Records results of every line of code in your file
|
@@ -290,4 +293,5 @@ test_files:
|
|
290
293
|
- spec/hash_struct_spec.rb
|
291
294
|
- spec/seeing_is_believing_spec.rb
|
292
295
|
- spec/spec_helper.rb
|
296
|
+
- spec/spec_helper_spec.rb
|
293
297
|
- spec/wrap_expressions_spec.rb
|