seeing_is_believing 0.0.21 → 0.0.22

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b04673605b79a81c7e47cd26c98a9b10fba50193
4
- data.tar.gz: 3e98d95b8e19b3aca8087584218f21bfe7492e68
3
+ metadata.gz: 4b8af587001dcce44e111c4611d49e476e6d0248
4
+ data.tar.gz: 969a7c9d9fdb9dc658c7c8c18a9805da7a2baedd
5
5
  SHA512:
6
- metadata.gz: 12d197241dabb6a700cfd2b241d2c88a1713d0ee2dc3ae3de359ea8364fdb9718758784ac5e7ca25a92137c23c14a486c440b9e5ec9fabda8899b0ce992ae733
7
- data.tar.gz: 0da562f2291215aea0710cd1bd99575041d6de741c11cfdca692b2392645669e06d96e6441301cf216474c81f489896810758024919ff686879c80078140bbf3
6
+ metadata.gz: cb909d18af0d797c8236c53015a430f5bf7bf45b7c625a4986488b89bb8df8500220fc0208270ce9e44bb556f38f6b79356e71c8f4c2445a0126cf4697a67501
7
+ data.tar.gz: b72db4437845c50df7d5c948b2fa73d0397e7cbcf493600eeb953c612ec93cc6d0f759a6503504e89f642e619c21a231df8ca51c11fbc7e68d28aeab7c7f320f
data/Readme.md CHANGED
@@ -83,6 +83,12 @@ Rubygems is allowing pushes again, but if it goes back down, you can install lik
83
83
  $ cd ..
84
84
  $ rm -rf "./seeing_is_believing"
85
85
 
86
+ Sublime Text 2 Integration
87
+ ==========================
88
+
89
+ See [sublime-text-2-seeing-is-believing](https://github.com/JoshCheek/sublime-text-2-seeing-is-believing).
90
+
91
+
86
92
  TextMate Integration
87
93
  ====================
88
94
 
@@ -138,6 +144,7 @@ Todo
138
144
  * Don't blow up on "a\\\n.b"
139
145
  * Record results with "a\n.b.\nc"
140
146
  * Record results with "a + \n b"
147
+ * a\n.b(\n.c\n) will blow up, need to make sure that joining it with the next line is valid ruby
141
148
  * 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
142
149
 
143
150
  License
@@ -82,3 +82,9 @@ Feature: Running the binary unsuccessfully
82
82
  m
83
83
  """
84
84
 
85
+ Scenario: Total Fucking Failure
86
+ Given the file "sib_will_utterly_die.rb" "BEGIN {}"
87
+ When I run "seeing_is_believing sib_will_utterly_die.rb"
88
+ Then stderr is not empty
89
+ And the exit status is 2
90
+ And stdout is empty
@@ -7,5 +7,6 @@ When("I run '$command'") { |command| @last_exec
7
7
  Then(/^(stderr|stdout) is:$/) { |stream_name, output| @last_executed.send(stream_name).chomp.should == eval_curlies(output) }
8
8
  Then(/^(stderr|stdout) is ["'](.*?)["']$/) { |stream_name, output| @last_executed.send(stream_name).chomp.should == eval_curlies(output) }
9
9
  Then(/^(stderr|stdout) is empty$/) { |stream_name| @last_executed.send(stream_name).should == '' }
10
+ Then(/^(stderr|stdout) is not empty$/) { |stream_name| @last_executed.send(stream_name).chomp.should_not be_empty }
10
11
  Then(/^(stderr|stdout) includes "([^"]*)"$/) { |stream_name, content| @last_executed.send(stream_name).should include eval_curlies(content) }
11
12
  Then('the exit status is $status') { |status| @last_executed.exitstatus.to_s.should == status }
@@ -10,7 +10,7 @@ class SeeingIsBelieving
10
10
  DISPLAYABLE_ERROR_STATUS = 1 # e.g. there was an error, but the output is legit (we can display exceptions)
11
11
  NONDISPLAYABLE_ERROR_STATUS = 2 # e.g. an error like incorrect invocation or syntax that can't be displayed in the input program
12
12
 
13
- attr_accessor :argv, :stdin, :stdout, :stderr, :timeout_error
13
+ attr_accessor :argv, :stdin, :stdout, :stderr, :timeout_error, :unexpected_exception
14
14
 
15
15
  def initialize(argv, stdin, stdout, stderr)
16
16
  self.argv = argv
@@ -20,16 +20,17 @@ class SeeingIsBelieving
20
20
  end
21
21
 
22
22
  def call
23
- @exitstatus ||= if flags_have_errors? then print_errors ; NONDISPLAYABLE_ERROR_STATUS
24
- elsif should_print_help? then print_help ; SUCCESS_STATUS
25
- elsif should_print_version? then print_version ; SUCCESS_STATUS
26
- elsif has_filename? && file_dne? then print_file_dne ; NONDISPLAYABLE_ERROR_STATUS
27
- elsif should_clean? then print_cleaned_program ; SUCCESS_STATUS
28
- elsif invalid_syntax? then print_syntax_error ; NONDISPLAYABLE_ERROR_STATUS
29
- elsif program_timedout? then print_timeout_error ; NONDISPLAYABLE_ERROR_STATUS
30
- else print_program ; (results.has_exception? ?
31
- DISPLAYABLE_ERROR_STATUS :
32
- SUCCESS_STATUS)
23
+ @exitstatus ||= if flags_have_errors? then print_errors ; NONDISPLAYABLE_ERROR_STATUS
24
+ elsif should_print_help? then print_help ; SUCCESS_STATUS
25
+ elsif should_print_version? then print_version ; SUCCESS_STATUS
26
+ elsif has_filename? && file_dne? then print_file_dne ; NONDISPLAYABLE_ERROR_STATUS
27
+ elsif should_clean? then print_cleaned_program ; SUCCESS_STATUS
28
+ elsif invalid_syntax? then print_syntax_error ; NONDISPLAYABLE_ERROR_STATUS
29
+ elsif program_timedout? then print_timeout_error ; NONDISPLAYABLE_ERROR_STATUS
30
+ elsif something_blew_up? then print_unexpected_error ; NONDISPLAYABLE_ERROR_STATUS
31
+ else print_program ; (results.has_exception? ?
32
+ DISPLAYABLE_ERROR_STATUS :
33
+ SUCCESS_STATUS)
33
34
  end
34
35
  end
35
36
 
@@ -65,6 +66,16 @@ class SeeingIsBelieving
65
66
  timeout: flags[:timeout]
66
67
  rescue Timeout::Error
67
68
  self.timeout_error = true
69
+ rescue Exception
70
+ self.unexpected_exception = $!
71
+ end
72
+
73
+ def something_blew_up?
74
+ !!unexpected_exception
75
+ end
76
+
77
+ def print_unexpected_error
78
+ stderr.puts unexpected_exception.class, unexpected_exception.message
68
79
  end
69
80
 
70
81
  def printer
@@ -44,6 +44,8 @@ class SeeingIsBelieving
44
44
  evaluate_file
45
45
  fail unless exitstatus.success?
46
46
  deserialize_result
47
+ # Okay, really, I should wrap this in another exception and raise it on up,
48
+ # but for now, I'm feeling a little lazy and am not going to do it
47
49
  rescue Exception
48
50
  notify_user_of_error if error_implies_bug_in_sib? $!
49
51
  raise $!
@@ -159,7 +159,7 @@ class SeeingIsBelieving
159
159
  # this is conspicuosuly inferior, but I can't figure out how to actually parse it
160
160
  # see: http://www.ruby-forum.com/topic/4409633
161
161
  def self.void_value_expression?(code)
162
- /(^|\s)(?:return|next|redo|retry|break).*?\n?\z/ =~ code
162
+ /(^|\s)(?:return|next|redo|retry|break)([^\w\n]|\n?\z).*?\n?\z/ =~ code
163
163
  end
164
164
 
165
165
  # HERE DOCS
@@ -1,3 +1,3 @@
1
1
  class SeeingIsBelieving
2
- VERSION = '0.0.21'
2
+ VERSION = '0.0.22'
3
3
  end
@@ -189,7 +189,7 @@ describe SeeingIsBelieving do
189
189
  DOC
190
190
  end
191
191
 
192
- it 'does not try to record the keyword retry' do
192
+ it 'does not try to record the keyword retry', t2:true do
193
193
  values_for(<<-DOC).should == [[], [], [], ['nil']]
194
194
  def meth
195
195
  rescue
@@ -172,7 +172,9 @@ describe SeeingIsBelieving::SyntaxAnalyzer do
172
172
  end
173
173
 
174
174
  shared_examples_for 'void_value_expression?' do |keyword|
175
- it "returns true when the expression ends in #{keyword}" do
175
+ it "`#{keyword}` returns true when the expression ends in #{keyword}", t:true do
176
+ described_class.void_value_expression?("#{keyword}").should be_true
177
+ described_class.void_value_expression?("#{keyword}(1)").should be_true
176
178
  described_class.void_value_expression?("#{keyword} 1").should be_true
177
179
  described_class.void_value_expression?("#{keyword} 1\n").should be_true
178
180
  described_class.void_value_expression?("#{keyword} 1 if true").should be_true
@@ -183,6 +185,8 @@ describe SeeingIsBelieving::SyntaxAnalyzer do
183
185
  described_class.void_value_expression?("def a\n#{keyword} 1\nend").should be_false
184
186
  described_class.void_value_expression?("-> {\n#{keyword} 1\n}").should be_false
185
187
  described_class.void_value_expression?("Proc.new {\n#{keyword} 1\n}").should be_false
188
+ described_class.void_value_expression?("#{keyword}_something").should be_false
189
+ described_class.void_value_expression?("def a\n#{keyword}\nend").should be_false
186
190
  end
187
191
 
188
192
  it "doesn't work because the return and next keyword evaluators are insufficient regexps" do
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.21
4
+ version: 0.0.22
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-28 00:00:00.000000000 Z
11
+ date: 2013-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake