summaryrefslogtreecommitdiff
path: root/test/testunit
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-21 03:56:45 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-21 03:56:45 +0000
commit923d3ea159d59bc355b19a74ba01723a0d16cd36 (patch)
treeb1ca6ff0ea8e8ac5dce1f5c96a03a8030acb25f7 /test/testunit
parentbda85cb021407ecf437891cd194e00e70669ca45 (diff)
* lib/runit, lib/rubyunit.rb, test/testunit/runit: removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/testunit')
-rw-r--r--test/testunit/runit/test_assert.rb402
-rw-r--r--test/testunit/runit/test_testcase.rb91
-rw-r--r--test/testunit/runit/test_testresult.rb144
-rw-r--r--test/testunit/runit/test_testsuite.rb49
4 files changed, 0 insertions, 686 deletions
diff --git a/test/testunit/runit/test_assert.rb b/test/testunit/runit/test_assert.rb
deleted file mode 100644
index a3e62b2b2d..0000000000
--- a/test/testunit/runit/test_assert.rb
+++ /dev/null
@@ -1,402 +0,0 @@
-# Author:: Masaki Suketa.
-# Adapted by:: Nathaniel Talbott.
-# Copyright:: Copyright (c) Masaki Suketa. All rights reserved.
-# Copyright:: Copyright (c) 2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'rubyunit'
-
-module RUNIT
- class TargetAssert
- include RUNIT::Assert
- end
-
- class TestAssert < RUNIT::TestCase
- def setup
- @assert = TargetAssert.new
- @e = nil
- end
-
- def test_assert
- sub_test_assert_pass(true)
- sub_test_assert_pass(TRUE)
- sub_test_assert_failure(false)
- sub_test_assert_failure(FALSE)
- sub_test_assert_failure(nil)
- sub_test_assert_pass("")
- sub_test_assert_pass("ok")
- sub_test_assert_pass(0)
- sub_test_assert_pass(1)
- end
-
- def test_assert_with_2_argument
- assert_no_exception {
- assert(true, "3")
- }
- assert_no_exception {
- assert(true)
- }
- end
-
- def test_assert_equal_float_0_1
- assert_proc = Proc.new {
- @assert.assert_equal_float(1.4, 1.35, 0.1)
- }
- sub_assert_pass(assert_proc)
- end
-
- def test_assert_equal_float_0_5
- assert_proc = Proc.new {
- @assert.assert_equal_float(1.4, 1.34, 0.5)
- }
- sub_assert_pass(assert_proc)
- end
-
- def test_assert_equal_float_0
- assert_proc = Proc.new {
- @assert.assert_equal_float(1.4, 1.4, 0)
- }
- sub_assert_pass(assert_proc)
- end
-
- def test_assert_equal_float_0_raise
- assert_proc = Proc.new {
- @assert.assert_equal_float(1.4, 1.34, 0)
- }
- sub_assert_raise_fail(assert_proc)
- end
-
- def test_assert_equal_float_0_01
- assert_proc = Proc.new {
- @assert.assert_equal_float(1.4, 1.35, 0.01)
- }
- sub_assert_raise_fail(assert_proc)
- end
-
- def test_assert_equal_float_0_001
- assert_proc = Proc.new {
- @assert.assert_equal_float(Math.sqrt(2), 1.414, 0.001)
- }
- sub_assert_pass(assert_proc)
- end
-
- def test_assert_equal_float_minus_1_0
- assert_proc = Proc.new {
- @assert.assert_equal_float(1.4, 1.35, -1.0)
- }
- sub_assert_raise_fail(assert_proc)
- end
-
- def test_assert_fail
- except = nil
- begin
- @assert.assert_fail("failure")
- rescue Exception
- except = $!
- end
- assert_not_nil(except)
- end
-
- def sub_test_assert_pass(obj)
- assert_proc = Proc.new {
- @assert.assert(obj)
- }
- sub_assert_pass(assert_proc)
- end
-
- def sub_test_assert_failure(obj)
- assert_proc = Proc.new {
- @assert.assert(obj)
- }
- sub_assert_raise_fail(assert_proc)
- end
-
- def test_assert_equal
- assert_proc = Proc.new {
- @assert.assert_equal(2, 2)
- }
- sub_assert_pass(assert_proc)
- assert_proc = Proc.new {
- @assert.assert_equal(2, 3)
- }
- sub_assert_raise_fail(assert_proc)
- end
-
- def test_assert_nil
- obj = nil
- assert_proc = Proc.new {
- @assert.assert_nil(obj)
- }
- sub_assert_pass(assert_proc)
- obj = 'string'
- sub_assert_raise_fail(assert_proc)
- end
-
- def test_assert_not_nil
- obj = 'string'
- assert_proc = Proc.new {
- @assert.assert_not_nil(obj)
- }
- sub_assert_pass(assert_proc)
-
- obj = nil
- sub_assert_raise_fail(assert_proc)
- end
-
- def test_assert_operator
- assert_proc = Proc.new {
- @assert.assert_operator(2, :<, 3)
- }
- sub_assert_pass(assert_proc)
- assert_proc = Proc.new {
- @assert.assert_operator(2, :>, 3)
- }
- sub_assert_raise_fail(assert_proc)
- end
-
- def test_assert_respond_to
- sub_test_assert_respond_to('string', 'sub', 'foo')
- sub_test_assert_respond_to('string', :sub, :foo)
- end
-
- def sub_test_assert_respond_to(obj, msg, dummy_msg)
- assert_proc = Proc.new {
- @assert.assert_respond_to(msg, obj)
- }
- sub_assert_pass(assert_proc)
- assert_proc = Proc.new {
- @assert.assert_respond_to(dummy_msg, obj)
- }
- sub_assert_raise_fail(assert_proc)
- end
-
- def test_assert_send
- assert_proc = Proc.new {
- ary = []
- @assert.assert_send ary, :empty?
- }
- sub_assert_pass(assert_proc)
- assert_proc = Proc.new {
- ary = [2,3]
- @assert.assert_send ary, :empty?
- }
- sub_assert_raise_fail(assert_proc)
- assert_proc = Proc.new {
- str = "abc"
- @assert.assert_send str, :sub!, "z", "y"
- }
- sub_assert_raise_fail(assert_proc)
- end
-
- def test_assert_kind_of
- assert_proc = Proc.new {
- @assert.assert_kind_of(String, "string")
- }
- sub_assert_pass(assert_proc)
- assert_proc = Proc.new {
- @assert.assert_kind_of(Regexp, "string")
- }
- sub_assert_raise_fail(assert_proc)
- end
-
- def test_assert_instance_of
- assert_proc = Proc.new {
- @assert.assert_instance_of(String, "string")
- }
- sub_assert_pass(assert_proc)
- assert_proc = Proc.new {
- @assert.assert_instance_of(Object, "string")
- }
- sub_assert_raise_fail(assert_proc)
- end
-
- def test_assert_match
- assert_proc = Proc.new{
- @assert.assert_match('foostring', /foo/)
- }
- sub_assert_pass(assert_proc)
- assert_proc = Proc.new {
- @assert.assert_match('barstring', /foo/)
- }
- sub_assert_raise_fail(assert_proc)
- match = @assert.assert_match('foostring', /foo/)
- assert_instance_of(MatchData, match)
- assert_equal('foo', match[0])
- end
-
- def test_assert_matches
- assert_proc = Proc.new{
- @assert.assert_matches('foostring', /foo/)
- }
- sub_assert_pass(assert_proc)
- assert_proc = Proc.new {
- @assert.assert_matches('barstring', /foo/)
- }
- sub_assert_raise_fail(assert_proc)
- end
-
- def test_assert_not_match
- assert_proc = Proc.new{
- @assert.assert_not_match('barstring', /foo/)
- }
- sub_assert_pass(assert_proc)
- assert_proc = Proc.new {
- @assert.assert_not_match('foostring', /foo/)
- }
- sub_assert_raise_fail(assert_proc)
- assert_proc = Proc.new {
- @assert.assert_not_match('foobarbaz', /ba.+/)
- }
- sub_assert_raise_fail(assert_proc)
- end
-
- def test_assert_same
- flag = false
- e = "foo"
- a = e
- assert_proc = Proc.new {@assert.assert_same(e, a)}
- sub_assert_pass(assert_proc)
-
- a = "foo"
- sub_assert_raise_fail(assert_proc)
- end
-
- def test_assert_exception
- assert_proc = Proc.new{
- @assert.assert_exception(IOError) {
- raise IOError
- }
- }
- sub_assert_pass(assert_proc)
-
- assert_proc = Proc.new{
- @assert.assert_exception(StandardError) {
- raise IOError
- }
- }
- sub_assert_raise_fail(assert_proc)
-
- assert_proc = Proc.new{
- @assert.assert_exception(IOError, "Exception") {
- raise StandardError
- }
- }
- sub_assert_raise_fail(assert_proc)
-
- assert_proc = Proc.new {
- @assert.assert_exception(StandardError) {
- "No Exception raised in this block"
- }
- }
- sub_assert_raise_fail(assert_proc)
-
- assert_proc = Proc.new {
- @assert.assert_exception(StandardError) {
- exit(33)
- }
- }
- sub_assert_raise_fail(assert_proc)
-
- t = @assert.assert_exception(IOError) {
- raise IOError
- }
- assert_instance_of(IOError, t)
- t = @assert.assert_exception(NameError) {
- non_existent_method
- }
- assert_instance_of(NameError, t)
- t = @assert.assert_exception(SystemExit) {
- exit(33)
- }
- assert_instance_of(SystemExit, t)
- end
-
- def test_assert_no_exception
- assert_proc = Proc.new{
- @assert.assert_no_exception(IOError, ArgumentError) {
- "No Exception raised in this block"
- }
- }
- sub_assert_pass(assert_proc)
-
- assert_proc = Proc.new{
- @assert.assert_no_exception(IOError, ArgumentError) {
- raise StandardError, "Standard Error raised"
- }
- }
- sub_assert_raise_error(assert_proc)
-
- assert_proc = Proc.new{
- @assert.assert_no_exception(IOError, ArgumentError) {
- raise ArgumentError, "Bad Argument"
- }
- }
- sub_assert_raise_fail(assert_proc)
-
- assert_proc = Proc.new{
- @assert.assert_no_exception {
- raise ArgumentError, "Bad Argument"
- }
- }
- sub_assert_raise_fail(assert_proc)
-
- assert_proc = Proc.new{
- @assert.assert_no_exception {
- raise NameError, "Bad Name"
- }
- }
- sub_assert_raise_fail(assert_proc)
- assert_proc = Proc.new {
- @assert.assert_no_exception {
- raise NoMemoryError
- }
- }
- sub_assert_raise_fail(assert_proc)
- end
-
- def sub_assert_pass(p)
- flag = false
- err = nil
- begin
- p.call
- flag = true
- rescue
- err = $!
- flag = false
- end
- assert(flag, err.to_s)
- end
-
- def sub_assert_raise_fail(p)
- flag = false
- err = nil
- begin
- p.call
- flag = false
- rescue RUNIT::AssertionFailedError
- flag = true
- err = $!
- rescue Exception
- flag = false
- err = $!
- end
- assert(flag, err.to_s)
- end
-
- def sub_assert_raise_error(p)
- flag = false
- err = nil
- begin
- p.call
- flag = false
- rescue RUNIT::AssertionFailedError
- flag = false
- err = $!
- rescue Exception
- flag = true
- err = $!
- end
- assert(flag, err.to_s)
- end
- end
-end
diff --git a/test/testunit/runit/test_testcase.rb b/test/testunit/runit/test_testcase.rb
deleted file mode 100644
index f57e0386e3..0000000000
--- a/test/testunit/runit/test_testcase.rb
+++ /dev/null
@@ -1,91 +0,0 @@
-# Author:: Masaki Suketa.
-# Adapted by:: Nathaniel Talbott.
-# Copyright:: Copyright (c) Masaki Suketa. All rights reserved.
-# Copyright:: Copyright (c) 2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'rubyunit'
-
-module RUNIT
- class DummyError < StandardError
- end
-
- class TestTestCase < RUNIT::TestCase
- def setup
- @dummy_testcase = Class.new(RUNIT::TestCase) do
- def self.name
- "DummyTestCase"
- end
-
- attr_reader :status, :dummy_called, :dummy2_called
-
- def initialize(*arg)
- super(*arg)
- @status = 0
- @dummy_called = false
- @dummy2_called = false
- end
-
- def setup
- @status = 1 if @status == 0
- end
-
- def test_dummy
- @status = 2 if @status == 1
- @dummy_called = true
- end
-
- def test_dummy2
- @status = 2 if @status == 1
- @dummy2_called = true
- raise DummyError
- end
-
- def teardown
- @status = 3 if @status == 2
- end
- end
-
- @test1 = @dummy_testcase.new('test_dummy')
- @test2 = @dummy_testcase.new('test_dummy2', 'TestCase')
- end
-
- def test_name
- assert_equal('DummyTestCase#test_dummy', @test1.name) # The second parameter to #initialize is ignored in emulation
- assert_equal('DummyTestCase#test_dummy2', @test2.name)
- end
-
- def test_run
- result = RUNIT::TestResult.new
- @test1.run(result)
- assert_equal(1, result.run_count)
- end
-
- def test_s_suite
- suite = @dummy_testcase.suite
- assert_instance_of(RUNIT::TestSuite, suite)
- assert_equal(2, suite.count_test_cases)
- end
-
- def test_teardown_err
- suite = Class.new(RUNIT::TestCase) do
- def test_foo
- assert(false)
- end
-
- def test_bar
- assert(true)
- end
-
- def teardown
- raise StandardError
- end
- end.suite
-
- result = RUNIT::TestResult.new
- suite.run(result)
- assert_equal(2, result.error_size)
- assert_equal(1, result.failure_size)
- end
- end
-end
diff --git a/test/testunit/runit/test_testresult.rb b/test/testunit/runit/test_testresult.rb
deleted file mode 100644
index 702b88d0c0..0000000000
--- a/test/testunit/runit/test_testresult.rb
+++ /dev/null
@@ -1,144 +0,0 @@
-# Author:: Masaki Suketa.
-# Adapted by:: Nathaniel Talbott.
-# Copyright:: Copyright (c) Masaki Suketa. All rights reserved.
-# Copyright:: Copyright (c) 2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'rubyunit'
-
-module RUNIT
- class TestTestResult < RUNIT::TestCase
- def setup
- @result = RUNIT::TestResult.new
-
- @normal_suite = Class::new(RUNIT::TestCase) do
- def test_1
- assert(true)
- assert(true)
- end
- end.suite
-
- @failure_suite = Class::new(RUNIT::TestCase) do
- def test_1
- assert(true)
- assert(false)
- end
- end.suite
-
- @error_suite = Class::new(RUNIT::TestCase) do
- def setup
- raise ScriptError
- end
- def test_1
- assert(true)
- end
- end.suite
-
- @multi_failure_suite = Class::new(RUNIT::TestCase) do
- def test1
- assert(false)
- end
- def test2
- assert(false)
- end
- def test3
- assert(false)
- end
- end.suite
-
- @with_error_suite = Class::new(RUNIT::TestCase) do
- def test1
- raise StandardError
- end
- end.suite
-
- @multi_error_suite = Class::new(RUNIT::TestCase) do
- def test1
- raise StandardError
- end
- def test2
- raise StandardError
- end
- def test3
- raise StandardError
- end
- end.suite
-
- @multi_suite = Class::new(RUNIT::TestCase) do
- def test_1
- assert(true)
- assert(true)
- end
- def test_2
- assert(true)
- end
- def test_3
- assert(true)
- assert(false)
- assert(true)
- end
- end.suite
- end
-
- def test_error_size
- @normal_suite.run(@result)
- assert_equal(0, @result.error_size)
- @with_error_suite.run(@result)
- assert_equal(1, @result.error_size)
- @multi_error_suite.run(@result)
- assert_equal(4, @result.error_size)
- end
-
- def test_errors
- @normal_suite.run(@result)
- assert_equal(0, @result.errors.size)
- end
-
- def test_failure_size
- @normal_suite.run(@result)
- assert_equal(0, @result.failure_size)
- @failure_suite.run(@result)
- assert_equal(1, @result.failure_size)
- @multi_failure_suite.run(@result)
- assert_equal(4, @result.failure_size)
- end
-
- def test_failures
- @normal_suite.run(@result)
- assert_equal(0, @result.failures.size)
- @failure_suite.run(@result)
- assert_equal(1, @result.failures.size)
- @multi_failure_suite.run(@result)
- assert_equal(4, @result.failures.size)
- end
-
- def test_run_no_exception
- assert_no_exception {
- @error_suite.run(@result)
- }
- end
-
- def test_run_asserts
- @normal_suite.run(@result)
- assert_equal(2, @result.run_asserts)
- end
-
- def test_run_asserts2
- @failure_suite.run(@result)
- assert_equal(2, @result.run_asserts)
- end
-
- def test_run_tests
- assert_equal(0, @result.run_tests)
- @normal_suite.run(@result)
- assert_equal(1, @result.run_tests)
- @multi_suite.run(@result)
- assert_equal(4, @result.run_tests)
- end
-
- def test_succeed?
- @normal_suite.run(@result)
- assert(@result.succeed?)
- end
- end
-end
diff --git a/test/testunit/runit/test_testsuite.rb b/test/testunit/runit/test_testsuite.rb
deleted file mode 100644
index 58702d3efe..0000000000
--- a/test/testunit/runit/test_testsuite.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-# Author:: Masaki Suketa.
-# Adapted by:: Nathaniel Talbott.
-# Copyright:: Copyright (c) Masaki Suketa. All rights reserved.
-# Copyright:: Copyright (c) 2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'rubyunit'
-
-module RUNIT
- class TestTestSuite < RUNIT::TestCase
- def setup
- @testsuite = RUNIT::TestSuite.new
- @dummy_test = Class.new(RUNIT::TestCase) do
- def test_foo
- end
- def test_bar
- end
- end
- @dummy_empty_test = Class.new(RUNIT::TestCase){}
- end
-
- def test_count_test_cases
- assert_equal(0, @testsuite.count_test_cases)
-
- @testsuite.add(@dummy_empty_test.suite)
- assert_equal(0, @testsuite.count_test_cases)
-
- @testsuite.add(@dummy_test.suite)
- assert_equal(2, @testsuite.count_test_cases)
-
- @testsuite.add(@dummy_test.suite)
- assert_equal(4, @testsuite.count_test_cases)
-
- dummytest_foo = @dummy_test.new('test_foo')
- @testsuite.add(dummytest_foo)
- assert_equal(5, @testsuite.count_test_cases)
- end
-
- def test_add
- @testsuite.add(@dummy_empty_test.suite)
- assert_equal(0, @testsuite.size)
- assert_equal(0, @testsuite.count_test_cases)
-
- @testsuite.add(@dummy_test.suite)
- assert_equal(2, @testsuite.size)
- assert_equal(2, @testsuite.count_test_cases)
- end
- end
-end