Skip to content
Browse files

skip form testcases for test data that are not legal ruby

detect illegals by passing each one to eval and detect SyntaxError
prepending something to each case which makes it have no side-effects
but, drop error messages to stderr eval normally prints on bad input
  • Loading branch information...
1 parent 38f589f commit 05239231958b764614e226c8222ec65091dc3bcf @calebc calebc committed Jun 6, 2011
Showing with 11 additions and 0 deletions.
  1. +11 −0 test/test_form.rb
View
11 test/test_form.rb
@@ -38,8 +38,19 @@ def setup
warn "some form tests disabled; set SLOW to enable them" unless SLOW
warn "some Macro.expand tests disabled; set SLOW to enable them" unless SLOW
+ nullfile= File.open(File.exist?( "/dev/null" )? "/dev/null" : "dev_null","w")
+
EXAMPLES.uniq.each_with_index{|x,i|
next if /__END__/===x
+ begin
+ #old_VERBOSE=$VERBOSE;$VERBOSE=false
+ oldSTDERR=STDERR.dup; STDERR.reopen(nullfile)
+ catch(:foo){ eval "BEGIN{throw :foo};"+x }
+ rescue SyntaxError
+ next
+ #ensure $VERBOSE=old_VERBOSE
+ ensure STDERR.reopen(oldSTDERR)
+ end
if / \^[^\s]/===x #and x.size>1000
while x['^']
warn "disabling tests of '#{x[/^.*\^.*$/]}'"

0 comments on commit 0523923

Please sign in to comment.
Something went wrong with that request. Please try again.