Sha256: b26efd8d31e7464fb994247ca1f522baa8f05d0b39b2f90d737547ac830544c4
Contents?: true
Size: 1.68 KB
Versions: 2
Compression:
Stored size: 1.68 KB
Contents
# # Testing OpenWFE # # John Mettraux at openwfe.org # require 'tmpdir' require 'test/unit' #require 'openwfe/utils' require 'openwfe/util/safe' class SafelyTest < Test::Unit::TestCase #def setup #end #def teardown #end 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 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) 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 dotest3 (instance, code, level) begin if instance OpenWFE::instance_eval_safely(instance, code, level) else OpenWFE::eval_safely(code, level) end rescue Exception => e return e end nil end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
openwferu-0.9.6 | test/safely_test.rb |
openwferu-0.9.7 | test/safely_test.rb |