summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/mmapt.rb15
-rw-r--r--tests/runit_.rb44
2 files changed, 49 insertions, 10 deletions
diff --git a/tests/mmapt.rb b/tests/mmapt.rb
index a7a049c..c6a1fdc 100644
--- a/tests/mmapt.rb
+++ b/tests/mmapt.rb
@@ -2,17 +2,12 @@
$LOAD_PATH.unshift *%w{.. . tests}
require 'mmap'
require 'ftools'
-begin
- require 'test/unit'
- Inh = Test::Unit
-rescue LoadError
- require 'runit/testcase'
- require 'runit/cui/testrunner'
- Inh = RUNIT
-end
+require 'runit_'
$mmap, $str = nil, nil
+Inh = defined?(RUNIT) ? RUNIT : Test::Unit
+
class TestMmap < Inh::TestCase
def internal_init
$mmap.unmap if $mmap
@@ -70,7 +65,7 @@ class TestMmap < Inh::TestCase
eval "$mmap#{access}"
rescue IndexError, RangeError
else
- assert_fail("*must* fail with IndexError")
+ flunk("*must* fail with IndexError")
end
else
eval "$mmap#{access}"
@@ -114,7 +109,7 @@ class TestMmap < Inh::TestCase
eval "$mmap#{access}"
rescue IndexError, RangeError
else
- assert_fail("*must* fail with IndexError")
+ flunk("*must* fail with IndexError")
end
else
eval "$mmap#{access}"
diff --git a/tests/runit_.rb b/tests/runit_.rb
new file mode 100644
index 0000000..0479592
--- /dev/null
+++ b/tests/runit_.rb
@@ -0,0 +1,44 @@
+begin
+ require 'test/unit'
+rescue LoadError
+ require 'runit/testcase'
+ require 'runit/cui/testrunner'
+
+ module RUNIT
+ module Assert
+ def assert_raises(error, message = nil)
+ begin
+ yield
+ rescue error
+ assert(true, message)
+ rescue
+ assert_fail("must fail with #{error} : #{string}")
+ else
+ assert_fail("*must* fail : #{string}")
+ end
+ end
+ def flunk(message = "")
+ assert_fail(message)
+ end
+ end
+ end
+end
+
+
+if RUBY_VERSION > "1.7"
+ class Array
+ alias indices select
+ end
+ class Hash
+ alias indexes select
+ end
+ module BDB
+ class Common
+ alias indexes select
+ end
+
+ class Recnum
+ alias indices select
+ end
+ end
+end