test/safely_test.rb in openwferu-0.9.7 vs test/safely_test.rb in openwferu-0.9.8

- old
+ new

@@ -3,11 +3,12 @@ # Testing OpenWFE # # John Mettraux at openwfe.org # -require 'tmpdir' +require 'tempfile' + require 'test/unit' #require 'openwfe/utils' require 'openwfe/util/safe' @@ -17,59 +18,48 @@ #end #def teardown #end - def test_safely_0 + #def test_safely_0 + # assert_not_nil dotest("print ''", 4) + # assert_not_nil dotest2("print ''", 4) + # assert_nil dotest("print ''", 2) + # assert_nil dotest2("print ''", 2) + #end - assert_not_nil dotest("print ''", 4) - assert_not_nil dotest2("print ''", 4) - - assert_nil dotest("print ''", 2) - assert_nil dotest2("print ''", 2) - end - def test_safely_1 + assert_not_nil dotest3(STDOUT, "self.print ''", 4) assert_nil dotest3(STDOUT, "self.print ''", 2) + assert_not_nil dotest3(nil, "print ''", 4) assert_nil dotest3(nil, "print ''", 2) end protected - def dotest (code, level) + #def dotest (code, level) + # tf = Tempfile.new "safely_test_temp.rb" + # tf.puts code + # tf.close + # e = nil + # begin + # OpenWFE::load_safely(tf.path, level) + # rescue Exception => e + # end + # File.delete(tf.path) + # e + #end - fname = "#{Dir.tmpdir}/safely_test_temp.rb" - - File.open fname, "w" do |f| - f.puts code - end - - e = nil - - begin - OpenWFE::load_safely(fname, level) - rescue Exception => e - end - - File.delete(fname) - - #puts OpenWFE::exception_to_s(e) if e - - e - end - - def dotest2 (code, level) - - begin - OpenWFE::load_eval_safely(code, level) - rescue Exception => e - return e - end - - nil - end + #def dotest2 (code, level) + # begin + # OpenWFE::load_eval_safely(code, level) + # rescue Exception => e + # return e + # end + # nil + #end def dotest3 (instance, code, level) begin if instance