[cairo-commit:00065] rcairo/rcairo [master] use test-unit gem.
null+rcairo at clear-code.com
null+rcairo at clear-code.com
Sat Sep 11 23:48:18 EDT 2010
Kouhei Sutou 2010-09-12 03:48:18 +0000 (Sun, 12 Sep 2010)
New Revision: 4144355655a12ad4671b13600de0f78159b5f69a
Log:
use test-unit gem.
Removed files:
test-unit/History.txt
test-unit/Manifest.txt
test-unit/README.txt
test-unit/Rakefile
test-unit/bin/testrb
test-unit/lib/test/unit.rb
test-unit/lib/test/unit/assertionfailederror.rb
test-unit/lib/test/unit/assertions.rb
test-unit/lib/test/unit/attribute.rb
test-unit/lib/test/unit/autorunner.rb
test-unit/lib/test/unit/collector.rb
test-unit/lib/test/unit/collector/descendant.rb
test-unit/lib/test/unit/collector/dir.rb
test-unit/lib/test/unit/collector/load.rb
test-unit/lib/test/unit/collector/objectspace.rb
test-unit/lib/test/unit/color.rb
test-unit/lib/test/unit/diff.rb
test-unit/lib/test/unit/error.rb
test-unit/lib/test/unit/exceptionhandler.rb
test-unit/lib/test/unit/failure.rb
test-unit/lib/test/unit/fixture.rb
test-unit/lib/test/unit/notification.rb
test-unit/lib/test/unit/omission.rb
test-unit/lib/test/unit/pending.rb
test-unit/lib/test/unit/priority.rb
test-unit/lib/test/unit/runner/console.rb
test-unit/lib/test/unit/runner/emacs.rb
test-unit/lib/test/unit/testcase.rb
test-unit/lib/test/unit/testresult.rb
test-unit/lib/test/unit/testsuite.rb
test-unit/lib/test/unit/ui/console/outputlevel.rb
test-unit/lib/test/unit/ui/console/testrunner.rb
test-unit/lib/test/unit/ui/emacs/testrunner.rb
test-unit/lib/test/unit/ui/testrunner.rb
test-unit/lib/test/unit/ui/testrunnermediator.rb
test-unit/lib/test/unit/ui/testrunnerutilities.rb
test-unit/lib/test/unit/util/backtracefilter.rb
test-unit/lib/test/unit/util/observable.rb
test-unit/lib/test/unit/util/procwrapper.rb
test-unit/lib/test/unit/version.rb
test-unit/sample/adder.rb
test-unit/sample/subtracter.rb
test-unit/sample/tc_adder.rb
test-unit/sample/tc_subtracter.rb
test-unit/sample/ts_examples.rb
test-unit/test/collector/test_descendant.rb
test-unit/test/collector/test_dir.rb
test-unit/test/collector/test_load.rb
test-unit/test/collector/test_objectspace.rb
test-unit/test/run-test.rb
test-unit/test/test_assertions.rb
test-unit/test/test_attribute.rb
test-unit/test/test_color.rb
test-unit/test/test_diff.rb
test-unit/test/test_emacs_runner.rb
test-unit/test/test_error.rb
test-unit/test/test_failure.rb
test-unit/test/test_fixture.rb
test-unit/test/test_notification.rb
test-unit/test/test_omission.rb
test-unit/test/test_pending.rb
test-unit/test/test_priority.rb
test-unit/test/test_testcase.rb
test-unit/test/test_testresult.rb
test-unit/test/test_testsuite.rb
test-unit/test/testunit_test_util.rb
test-unit/test/ui/test_testrunmediator.rb
test-unit/test/util/test_backtracefilter.rb
test-unit/test/util/test_observable.rb
test-unit/test/util/test_procwrapper.rb
Modified files:
test/run-test.rb
Deleted: test-unit/History.txt (+0 -32) 100644
===================================================================
--- test-unit/History.txt 2010-09-12 03:03:44 +0000 (a142f78)
+++ /dev/null
@@ -1,32 +0,0 @@
-=== 2.0.0 / 2008-06-18
-
-* 15 major enhancements
-
- * support startup/shutdown. (test case level setup/teardown)
- * support multiple setup/teardown.
- * support pending.
- * support omission.
- * support notification.
- * support colorize.
- * support diff.
- * support test attribute.
- * add assert_boolean.
- * add assert_true.
- * add assert_false.
- * add --priority-mode option.
- * don't use ObjectSpace to collect test cases.
- * make more customizable. (additional options, exception handling and so on)
- * improve Emacs integration.
-
-* 4 major changes
-
- * remove GTK+1 support.
- * split GTK+ runner as another gem.
- * split FOX runner as another gem.
- * split Tk runner as another gem.
-
-=== 1.2.3 / 2008-02-25
-
-* 1 major enhancement
-
- * Birthday (as a gem)!
Deleted: test-unit/Manifest.txt (+0 -70) 100644
===================================================================
--- test-unit/Manifest.txt 2010-09-12 03:03:44 +0000 (9d0f112)
+++ /dev/null
@@ -1,70 +0,0 @@
-History.txt
-Manifest.txt
-README.txt
-Rakefile
-bin/testrb
-lib/test/unit.rb
-lib/test/unit/assertionfailederror.rb
-lib/test/unit/assertions.rb
-lib/test/unit/attribute.rb
-lib/test/unit/autorunner.rb
-lib/test/unit/collector.rb
-lib/test/unit/collector/descendant.rb
-lib/test/unit/collector/dir.rb
-lib/test/unit/collector/load.rb
-lib/test/unit/collector/objectspace.rb
-lib/test/unit/color.rb
-lib/test/unit/diff.rb
-lib/test/unit/error.rb
-lib/test/unit/exceptionhandler.rb
-lib/test/unit/failure.rb
-lib/test/unit/fixture.rb
-lib/test/unit/notification.rb
-lib/test/unit/omission.rb
-lib/test/unit/pending.rb
-lib/test/unit/priority.rb
-lib/test/unit/runner/console.rb
-lib/test/unit/runner/emacs.rb
-lib/test/unit/testcase.rb
-lib/test/unit/testresult.rb
-lib/test/unit/testsuite.rb
-lib/test/unit/ui/console/outputlevel.rb
-lib/test/unit/ui/console/testrunner.rb
-lib/test/unit/ui/emacs/testrunner.rb
-lib/test/unit/ui/testrunner.rb
-lib/test/unit/ui/testrunnermediator.rb
-lib/test/unit/ui/testrunnerutilities.rb
-lib/test/unit/util/backtracefilter.rb
-lib/test/unit/util/observable.rb
-lib/test/unit/util/procwrapper.rb
-lib/test/unit/version.rb
-sample/adder.rb
-sample/subtracter.rb
-sample/tc_adder.rb
-sample/tc_subtracter.rb
-sample/ts_examples.rb
-test/collector/test_descendant.rb
-test/collector/test_dir.rb
-test/collector/test_load.rb
-test/collector/test_objectspace.rb
-test/run-test.rb
-test/test_assertions.rb
-test/test_attribute.rb
-test/test_color.rb
-test/test_diff.rb
-test/test_emacs_runner.rb
-test/test_error.rb
-test/test_failure.rb
-test/test_fixture.rb
-test/test_notification.rb
-test/test_omission.rb
-test/test_pending.rb
-test/test_priority.rb
-test/test_testcase.rb
-test/test_testresult.rb
-test/test_testsuite.rb
-test/testunit_test_util.rb
-test/ui/test_testrunmediator.rb
-test/util/test_backtracefilter.rb
-test/util/test_observable.rb
-test/util/test_procwrapper.rb
Deleted: test-unit/README.txt (+0 -32) 100644
===================================================================
--- test-unit/README.txt 2010-09-12 03:03:44 +0000 (2b58f1f)
+++ /dev/null
@@ -1,32 +0,0 @@
-= Test::Unit (Classic)
-
-* http://rubyforge.org/projects/test-unit/
-
-== DESCRIPTION:
-
-Test::Unit (Classic) - Nathaniel Talbott's originial test-unit,
-externalized from the ruby project as a gem (for tool developers).
-
-== FEATURES/PROBLEMS:
-
-* Test::Unit 1.2.3 is the original Test::Unit, taken
- straight from the ruby distribution. It is being
- distributed as a gem to allow tool builders to use it as a
- stand-alone package. (The test framework in ruby is going
- to radically change very soon).
-
-* DO NOT INSTALL THIS GEM unless you're active state or some other
- development tool provider! You don't need it.
-
-* Test::Unit 2.0.0 or later are extended versions of the
- original Test::Unit (== Tset::Unit 1.2.3).
-
-== INSTALL:
-
-* sudo gem install test-unit
-
-== LICENSE:
-
-(The Ruby License)
-
-This software is distributed under the same terms as ruby.
Deleted: test-unit/Rakefile (+0 -30) 100644
===================================================================
--- test-unit/Rakefile 2010-09-12 03:03:44 +0000 (2408ca6)
+++ /dev/null
@@ -1,30 +0,0 @@
-# -*- ruby -*-
-
-require 'rubygems'
-require 'hoe'
-require './lib/test/unit/version.rb'
-
-version = Test::Unit::VERSION
-ENV["VERSION"] = version
-Hoe.new('test-unit', version) do |p|
- p.developer('Kouhei Sutou', 'kou at cozmixng.org')
- p.developer('Ryan Davis', 'ryand-ruby at zenspider.com')
-
- # Ex-Parrot:
- # p.developer('Nathaniel Talbott', 'nathaniel at talbott.ws')
-end
-
-task :check_manifest => :clean_test_result
-
-task :clean_test_result do
- test_results = Dir.glob("**/.test-result")
- sh("rm", "-rf", *test_results) unless test_results.empty?
-end
-
-task :tag do
- message = "Released Test::Unit #{version}!"
- base = "svn+ssh://#{ENV['USER']}@rubyforge.org/var/svn/test-unit/"
- sh 'svn', 'copy', '-m', message, "#{base}trunk", "#{base}tags/#{version}"
-end
-
-# vim: syntax=Ruby
Deleted: test-unit/bin/testrb (+0 -5) 100755
===================================================================
--- test-unit/bin/testrb 2010-09-12 03:03:44 +0000 (ff49cb5)
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env ruby
-require 'test/unit'
-(r = Test::Unit::AutoRunner.new(true)).process_args(ARGV) or
- abort r.options.banner + " tests..."
-exit r.run
Deleted: test-unit/lib/test/unit.rb (+0 -280) 100644
===================================================================
--- test-unit/lib/test/unit.rb 2010-09-12 03:03:44 +0000 (b71f644)
+++ /dev/null
@@ -1,280 +0,0 @@
-require 'test/unit/testcase'
-require 'test/unit/autorunner'
-
-module Test # :nodoc:
- #
- # = Test::Unit - Ruby Unit Testing Framework
- #
- # == Introduction
- #
- # Unit testing is making waves all over the place, largely due to the
- # fact that it is a core practice of XP. While XP is great, unit testing
- # has been around for a long time and has always been a good idea. One
- # of the keys to good unit testing, though, is not just writing tests,
- # but having tests. What's the difference? Well, if you just _write_ a
- # test and throw it away, you have no guarantee that something won't
- # change later which breaks your code. If, on the other hand, you _have_
- # tests (obviously you have to write them first), and run them as often
- # as possible, you slowly build up a wall of things that cannot break
- # without you immediately knowing about it. This is when unit testing
- # hits its peak usefulness.
- #
- # Enter Test::Unit, a framework for unit testing in Ruby, helping you to
- # design, debug and evaluate your code by making it easy to write and
- # have tests for it.
- #
- #
- # == Notes
- #
- # Test::Unit has grown out of and superceded Lapidary.
- #
- #
- # == Feedback
- #
- # I like (and do my best to practice) XP, so I value early releases,
- # user feedback, and clean, simple, expressive code. There is always
- # room for improvement in everything I do, and Test::Unit is no
- # exception. Please, let me know what you think of Test::Unit as it
- # stands, and what you'd like to see expanded/changed/improved/etc. If
- # you find a bug, let me know ASAP; one good way to let me know what the
- # bug is is to submit a new test that catches it :-) Also, I'd love to
- # hear about any successes you have with Test::Unit, and any
- # documentation you might add will be greatly appreciated. My contact
- # info is below.
- #
- #
- # == Contact Information
- #
- # A lot of discussion happens about Ruby in general on the ruby-talk
- # mailing list (http://www.ruby-lang.org/en/ml.html), and you can ask
- # any questions you might have there. I monitor the list, as do many
- # other helpful Rubyists, and you're sure to get a quick answer. Of
- # course, you're also welcome to email me (Nathaniel Talbott) directly
- # at mailto:testunit at talbott.ws, and I'll do my best to help you out.
- #
- #
- # == Credits
- #
- # I'd like to thank...
- #
- # Matz, for a great language!
- #
- # Masaki Suketa, for his work on RubyUnit, which filled a vital need in
- # the Ruby world for a very long time. I'm also grateful for his help in
- # polishing Test::Unit and getting the RubyUnit compatibility layer
- # right. His graciousness in allowing Test::Unit to supercede RubyUnit
- # continues to be a challenge to me to be more willing to defer my own
- # rights.
- #
- # Ken McKinlay, for his interest and work on unit testing, and for his
- # willingness to dialog about it. He was also a great help in pointing
- # out some of the holes in the RubyUnit compatibility layer.
- #
- # Dave Thomas, for the original idea that led to the extremely simple
- # "require 'test/unit'", plus his code to improve it even more by
- # allowing the selection of tests from the command-line. Also, without
- # RDoc, the documentation for Test::Unit would stink a lot more than it
- # does now.
- #
- # Everyone who's helped out with bug reports, feature ideas,
- # encouragement to continue, etc. It's a real privilege to be a part of
- # the Ruby community.
- #
- # The guys at RoleModel Software, for putting up with me repeating, "But
- # this would be so much easier in Ruby!" whenever we're coding in Java.
- #
- # My Creator, for giving me life, and giving it more abundantly.
- #
- #
- # == License
- #
- # Test::Unit is copyright (c) 2000-2003 Nathaniel Talbott. It is free
- # software, and is distributed under the Ruby license. See the COPYING
- # file in the standard Ruby distribution for details.
- #
- #
- # == Warranty
- #
- # This software is provided "as is" and without any express or
- # implied warranties, including, without limitation, the implied
- # warranties of merchantibility and fitness for a particular
- # purpose.
- #
- #
- # == Author
- #
- # Nathaniel Talbott.
- # Copyright (c) 2000-2003, Nathaniel Talbott
- #
- # ----
- #
- # = Usage
- #
- # The general idea behind unit testing is that you write a _test_
- # _method_ that makes certain _assertions_ about your code, working
- # against a _test_ _fixture_. A bunch of these _test_ _methods_ are
- # bundled up into a _test_ _suite_ and can be run any time the
- # developer wants. The results of a run are gathered in a _test_
- # _result_ and displayed to the user through some UI. So, lets break
- # this down and see how Test::Unit provides each of these necessary
- # pieces.
- #
- #
- # == Assertions
- #
- # These are the heart of the framework. Think of an assertion as a
- # statement of expected outcome, i.e. "I assert that x should be equal
- # to y". If, when the assertion is executed, it turns out to be
- # correct, nothing happens, and life is good. If, on the other hand,
- # your assertion turns out to be false, an error is propagated with
- # pertinent information so that you can go back and make your
- # assertion succeed, and, once again, life is good. For an explanation
- # of the current assertions, see Test::Unit::Assertions.
- #
- #
- # == Test Method & Test Fixture
- #
- # Obviously, these assertions have to be called within a context that
- # knows about them and can do something meaningful with their
- # pass/fail value. Also, it's handy to collect a bunch of related
- # tests, each test represented by a method, into a common test class
- # that knows how to run them. The tests will be in a separate class
- # from the code they're testing for a couple of reasons. First of all,
- # it allows your code to stay uncluttered with test code, making it
- # easier to maintain. Second, it allows the tests to be stripped out
- # for deployment, since they're really there for you, the developer,
- # and your users don't need them. Third, and most importantly, it
- # allows you to set up a common test fixture for your tests to run
- # against.
- #
- # What's a test fixture? Well, tests do not live in a vacuum; rather,
- # they're run against the code they are testing. Often, a collection
- # of tests will run against a common set of data, also called a
- # fixture. If they're all bundled into the same test class, they can
- # all share the setting up and tearing down of that data, eliminating
- # unnecessary duplication and making it much easier to add related
- # tests.
- #
- # Test::Unit::TestCase wraps up a collection of test methods together
- # and allows you to easily set up and tear down the same test fixture
- # for each test. This is done by overriding #setup and/or #teardown,
- # which will be called before and after each test method that is
- # run. The TestCase also knows how to collect the results of your
- # assertions into a Test::Unit::TestResult, which can then be reported
- # back to you... but I'm getting ahead of myself. To write a test,
- # follow these steps:
- #
- # * Make sure Test::Unit is in your library path.
- # * require 'test/unit' in your test script.
- # * Create a class that subclasses Test::Unit::TestCase.
- # * Add a method that begins with "test" to your class.
- # * Make assertions in your test method.
- # * Optionally define #setup and/or #teardown to set up and/or tear
- # down your common test fixture.
- # * You can now run your test as you would any other Ruby
- # script... try it and see!
- #
- # A really simple test might look like this (#setup and #teardown are
- # commented out to indicate that they are completely optional):
- #
- # require 'test/unit'
- #
- # class TC_MyTest < Test::Unit::TestCase
- # # def setup
- # # end
- #
- # # def teardown
- # # end
- #
- # def test_fail
- # assert(false, 'Assertion was false.')
- # end
- # end
- #
- #
- # == Test Runners
- #
- # So, now you have this great test class, but you still need a way to
- # run it and view any failures that occur during the run. This is
- # where Test::Unit::UI::Console::TestRunner (and others, such as
- # Test::Unit::UI::GTK::TestRunner) comes into play. The console test
- # runner is automatically invoked for you if you require 'test/unit'
- # and simply run the file. To use another runner, or to manually
- # invoke a runner, simply call its run class method and pass in an
- # object that responds to the suite message with a
- # Test::Unit::TestSuite. This can be as simple as passing in your
- # TestCase class (which has a class suite method). It might look
- # something like this:
- #
- # require 'test/unit/ui/console/testrunner'
- # Test::Unit::UI::Console::TestRunner.run(TC_MyTest)
- #
- #
- # == Test Suite
- #
- # As more and more unit tests accumulate for a given project, it
- # becomes a real drag running them one at a time, and it also
- # introduces the potential to overlook a failing test because you
- # forget to run it. Suddenly it becomes very handy that the
- # TestRunners can take any object that returns a Test::Unit::TestSuite
- # in response to a suite method. The TestSuite can, in turn, contain
- # other TestSuites or individual tests (typically created by a
- # TestCase). In other words, you can easily wrap up a group of
- # TestCases and TestSuites like this:
- #
- # require 'test/unit/testsuite'
- # require 'tc_myfirsttests'
- # require 'tc_moretestsbyme'
- # require 'ts_anothersetoftests'
- #
- # class TS_MyTests
- # def self.suite
- # suite = Test::Unit::TestSuite.new
- # suite << TC_MyFirstTests.suite
- # suite << TC_MoreTestsByMe.suite
- # suite << TS_AnotherSetOfTests.suite
- # return suite
- # end
- # end
- # Test::Unit::UI::Console::TestRunner.run(TS_MyTests)
- #
- # Now, this is a bit cumbersome, so Test::Unit does a little bit more
- # for you, by wrapping these up automatically when you require
- # 'test/unit'. What does this mean? It means you could write the above
- # test case like this instead:
- #
- # require 'test/unit'
- # require 'tc_myfirsttests'
- # require 'tc_moretestsbyme'
- # require 'ts_anothersetoftests'
- #
- # Test::Unit is smart enough to find all the test cases existing in
- # the ObjectSpace and wrap them up into a suite for you. It then runs
- # the dynamic suite using the console TestRunner.
- #
- #
- # == Questions?
- #
- # I'd really like to get feedback from all levels of Ruby
- # practitioners about typos, grammatical errors, unclear statements,
- # missing points, etc., in this document (or any other).
- #
-
- module Unit
- # If set to false Test::Unit will not automatically run at exit.
- def self.run=(flag)
- @run = flag
- end
-
- # Automatically run tests at exit?
- def self.run?
- @run ||= false
- end
- end
-end
-
-at_exit do
- unless $! || Test::Unit.run?
- exit Test::Unit::AutoRunner.run
- end
-end
Deleted: test-unit/lib/test/unit/assertionfailederror.rb (+0 -14) 100644
===================================================================
--- test-unit/lib/test/unit/assertionfailederror.rb 2010-09-12 03:03:44 +0000 (a21e4b5)
+++ /dev/null
@@ -1,14 +0,0 @@
-#--
-#
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-module Test
- module Unit
-
- # Thrown by Test::Unit::Assertions when an assertion fails.
- class AssertionFailedError < StandardError
- end
- end
-end
Deleted: test-unit/lib/test/unit/assertions.rb (+0 -722) 100644
===================================================================
--- test-unit/lib/test/unit/assertions.rb 2010-09-12 03:03:44 +0000 (635d36a)
+++ /dev/null
@@ -1,722 +0,0 @@
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit/assertionfailederror'
-require 'test/unit/util/backtracefilter'
-require 'test/unit/diff'
-
-module Test
- module Unit
-
- ##
- # Test::Unit::Assertions contains the standard Test::Unit assertions.
- # Assertions is included in Test::Unit::TestCase.
- #
- # To include it in your own code and use its functionality, you simply
- # need to rescue Test::Unit::AssertionFailedError. Additionally you may
- # override add_assertion to get notified whenever an assertion is made.
- #
- # Notes:
- # * The message to each assertion, if given, will be propagated with the
- # failure.
- # * It is easy to add your own assertions based on assert_block().
- #
- # = Example Custom Assertion
- #
- # def deny(boolean, message = nil)
- # message = build_message message, '<?> is not false or nil.', boolean
- # assert_block message do
- # not boolean
- # end
- # end
-
- module Assertions
-
- ##
- # The assertion upon which all other assertions are based. Passes if the
- # block yields true.
- #
- # Example:
- # assert_block "Couldn't do the thing" do
- # do_the_thing
- # end
-
- public
- def assert_block(message="assert_block failed.") # :yields:
- _wrap_assertion do
- if (! yield)
- raise AssertionFailedError.new(message.to_s)
- end
- end
- end
-
- ##
- # Asserts that +boolean+ is not false or nil.
- #
- # Example:
- # assert [1, 2].include?(5)
-
- public
- def assert(boolean, message=nil)
- _wrap_assertion do
- assert_block("assert should not be called with a block.") { !block_given? }
- assert_block(build_message(message, "<?> is not true.", boolean)) { boolean }
- end
- end
-
- ##
- # Passes if +expected+ == +actual.
- #
- # Note that the ordering of arguments is important, since a helpful
- # error message is generated when this one fails that tells you the
- # values of expected and actual.
- #
- # Example:
- # assert_equal 'MY STRING', 'my string'.upcase
-
- public
- def assert_equal(expected, actual, message=nil)
- diff = AssertionMessage.delayed_literal do
- if !expected.is_a?(String) or !actual.is_a?(String)
- expected = AssertionMessage.convert(expected)
- actual = AssertionMessage.convert(actual)
- end
- diff = Diff.readable(expected, actual)
- if /^[-+]/ !~ diff
- diff = ""
- elsif /^[ ?]/ =~ diff or /(?:.*\n){2,}/ =~ diff
- diff = "\n\ndiff:\n#{diff}"
- else
- diff = ""
- end
- diff
- end
- full_message = build_message(message, <<EOT, expected, actual, diff)
-<?> expected but was
-<?>.?
-EOT
- assert_block(full_message) { expected == actual }
- end
-
- private
- def _check_exception_class(args) # :nodoc:
- args.partition do |klass|
- next if klass.instance_of?(Module)
- assert(Exception >= klass, "Should expect a class of exception, #{klass}")
- true
- end
- end
-
- private
- def _expected_exception?(actual_exception, exceptions, modules) # :nodoc:
- exceptions.include?(actual_exception.class) or
- modules.any? {|mod| actual_exception.is_a?(mod)}
- end
-
- ##
- # Passes if the block raises one of the given exceptions.
- #
- # Example:
- # assert_raise RuntimeError, LoadError do
- # raise 'Boom!!!'
- # end
-
- public
- def assert_raise(*args)
- _wrap_assertion do
- if Module === args.last
- message = ""
- else
- message = args.pop
- end
- exceptions, modules = _check_exception_class(args)
- expected = args.size == 1 ? args.first : args
- actual_exception = nil
- full_message = build_message(message, "<?> exception expected but none was thrown.", expected)
- assert_block(full_message) do
- begin
- yield
- rescue Exception => actual_exception
- break
- end
- false
- end
- full_message = build_message(message, "<?> exception expected but was\n?", expected, actual_exception)
- assert_block(full_message) {_expected_exception?(actual_exception, exceptions, modules)}
- actual_exception
- end
- end
-
- ##
- # Alias of assert_raise.
- #
- # Will be deprecated in 1.9, and removed in 2.0.
-
- public
- def assert_raises(*args, &block)
- assert_raise(*args, &block)
- end
-
- ##
- # Passes if +object+ .instance_of? +klass+
- #
- # Example:
- # assert_instance_of String, 'foo'
-
- public
- def assert_instance_of(klass, object, message="")
- _wrap_assertion do
- assert_equal(Class, klass.class, "assert_instance_of takes a Class as its first argument")
- full_message = build_message(message, <<EOT, object, klass, object.class)
-<?> expected to be an instance of
-<?> but was
-<?>.
-EOT
- assert_block(full_message){object.instance_of?(klass)}
- end
- end
-
- ##
- # Passes if +object+ is nil.
- #
- # Example:
- # assert_nil [1, 2].uniq!
-
- public
- def assert_nil(object, message="")
- full_message = build_message(message, <<EOT, object)
-<?> expected to be nil.
-EOT
- assert_block(full_message) { object.nil? }
- end
-
- ##
- # Passes if +object+ .kind_of? +klass+
- #
- # Example:
- # assert_kind_of Object, 'foo'
-
- public
- def assert_kind_of(klass, object, message="")
- _wrap_assertion do
- assert(klass.kind_of?(Module), "The first parameter to assert_kind_of should be a kind_of Module.")
- full_message = build_message(message, "<?>\nexpected to be kind_of\\?\n<?> but was\n<?>.", object, klass, object.class)
- assert_block(full_message){object.kind_of?(klass)}
- end
- end
-
- ##
- # Passes if +object+ .respond_to? +method+
- #
- # Example:
- # assert_respond_to 'bugbear', :slice
-
- public
- def assert_respond_to(object, method, message="")
- _wrap_assertion do
- full_message = build_message(nil, "<?>\ngiven as the method name argument to #assert_respond_to must be a Symbol or #respond_to\\?(:to_str).", method)
-
- assert_block(full_message) do
- method.kind_of?(Symbol) || method.respond_to?(:to_str)
- end
- full_message = build_message(message, <<EOT, object, object.class, method)
-<?>
-of type <?>
-expected to respond_to\\?<?>.
-EOT
- assert_block(full_message) { object.respond_to?(method) }
- end
- end
-
- ##
- # Passes if +string+ =~ +pattern+.
- #
- # Example:
- # assert_match(/\d+/, 'five, 6, seven')
-
- public
- def assert_match(pattern, string, message="")
- _wrap_assertion do
- pattern = case(pattern)
- when String
- Regexp.new(Regexp.escape(pattern))
- else
- pattern
- end
- full_message = build_message(message, "<?> expected to be =~\n<?>.", string, pattern)
- assert_block(full_message) { string =~ pattern }
- end
- end
-
- ##
- # Passes if +actual+ .equal? +expected+ (i.e. they are the same
- # instance).
- #
- # Example:
- # o = Object.new
- # assert_same o, o
-
- public
- def assert_same(expected, actual, message="")
- full_message = build_message(message, <<EOT, expected, expected.__id__, actual, actual.__id__)
-<?>
-with id <?> expected to be equal\\? to
-<?>
-with id <?>.
-EOT
- assert_block(full_message) { actual.equal?(expected) }
- end
-
- ##
- # Compares the +object1+ with +object2+ using +operator+.
- #
- # Passes if object1.__send__(operator, object2) is true.
- #
- # Example:
- # assert_operator 5, :>=, 4
-
- public
- def assert_operator(object1, operator, object2, message="")
- _wrap_assertion do
- full_message = build_message(nil, "<?>\ngiven as the operator for #assert_operator must be a Symbol or #respond_to\\?(:to_str).", operator)
- assert_block(full_message){operator.kind_of?(Symbol) || operator.respond_to?(:to_str)}
- full_message = build_message(message, <<EOT, object1, AssertionMessage.literal(operator), object2)
-<?> expected to be
-?
-<?>.
-EOT
- assert_block(full_message) { object1.__send__(operator, object2) }
- end
- end
-
- ##
- # Passes if block does not raise an exception.
- #
- # Example:
- # assert_nothing_raised do
- # [1, 2].uniq
- # end
-
- public
- def assert_nothing_raised(*args)
- _wrap_assertion do
- if Module === args.last
- message = ""
- else
- message = args.pop
- end
- exceptions, modules = _check_exception_class(args)
- begin
- yield
- rescue Exception => e
- if ((args.empty? && !e.instance_of?(AssertionFailedError)) ||
- _expected_exception?(e, exceptions, modules))
- assert_block(build_message(message, "Exception raised:\n?", e)){false}
- else
- raise
- end
- end
- nil
- end
- end
-
- ##
- # Flunk always fails.
- #
- # Example:
- # flunk 'Not done testing yet.'
-
- public
- def flunk(message="Flunked")
- assert_block(build_message(message)){false}
- end
-
- ##
- # Passes if ! +actual+ .equal? +expected+
- #
- # Example:
- # assert_not_same Object.new, Object.new
-
- public
- def assert_not_same(expected, actual, message="")
- full_message = build_message(message, <<EOT, expected, expected.__id__, actual, actual.__id__)
-<?>
-with id <?> expected to not be equal\\? to
-<?>
-with id <?>.
-EOT
- assert_block(full_message) { !actual.equal?(expected) }
- end
-
- ##
- # Passes if +expected+ != +actual+
- #
- # Example:
- # assert_not_equal 'some string', 5
-
- public
- def assert_not_equal(expected, actual, message="")
- full_message = build_message(message, "<?> expected to be != to\n<?>.", expected, actual)
- assert_block(full_message) { expected != actual }
- end
-
- ##
- # Passes if ! +object+ .nil?
- #
- # Example:
- # assert_not_nil '1 two 3'.sub!(/two/, '2')
-
- public
- def assert_not_nil(object, message="")
- full_message = build_message(message, "<?> expected to not be nil.", object)
- assert_block(full_message){!object.nil?}
- end
-
- ##
- # Passes if +regexp+ !~ +string+
- #
- # Example:
- # assert_no_match(/two/, 'one 2 three')
-
- public
- def assert_no_match(regexp, string, message="")
- _wrap_assertion do
- assert_instance_of(Regexp, regexp, "The first argument to assert_no_match should be a Regexp.")
- full_message = build_message(message, "<?> expected to not match\n<?>.", regexp, string)
- assert_block(full_message) { regexp !~ string }
- end
- end
-
- UncaughtThrow = {
- NameError => /^uncaught throw \`(.+)\'$/,
- ArgumentError => /^uncaught throw (.+)$/,
- ThreadError => /^uncaught throw \`(.+)\' in thread /
- } #`
-
- ##
- # Passes if the block throws +expected_object+
- #
- # Example:
- # assert_throws :done do
- # throw :done
- # end
-
- public
- def assert_throws(expected_object, message="", &proc)
- _wrap_assertion do
- begin
- catch([]) {}
- rescue TypeError
- assert_instance_of(Symbol, expected_object,
- "assert_throws expects the symbol that should be thrown for its first argument")
- end
- assert_block("Should have passed a block to assert_throws.") do
- block_given?
- end
- caught = true
- begin
- catch(expected_object) do
- proc.call
- caught = false
- end
- full_message = build_message(message,
- "<?> should have been thrown.",
- expected_object)
- assert_block(full_message) {caught}
- rescue NameError, ArgumentError, ThreadError => error
- raise unless UncaughtThrow[error.class] =~ error.message
- tag = $1
- tag = tag[1..-1].intern if tag[0, 1] == ":"
- full_message = build_message(message,
- "<?> expected to be thrown but\n" +
- "<?> was thrown.",
- expected_object, tag)
- flunk(full_message)
- end
- end
- end
-
- ##
- # Passes if block does not throw anything.
- #
- # Example:
- # assert_nothing_thrown do
- # [1, 2].uniq
- # end
-
- public
- def assert_nothing_thrown(message="", &proc)
- _wrap_assertion do
- assert(block_given?, "Should have passed a block to assert_nothing_thrown")
- begin
- proc.call
- rescue NameError, ArgumentError, ThreadError => error
- raise unless UncaughtThrow[error.class] =~ error.message
- tag = $1
- tag = tag[1..-1].intern if tag[0, 1] == ":"
- full_message = build_message(message,
- "<?> was thrown when nothing was expected",
- tag)
- flunk(full_message)
- end
- assert(true, "Expected nothing to be thrown")
- end
- end
-
- ##
- # Passes if +expected_float+ and +actual_float+ are equal
- # within +delta+ tolerance.
- #
- # Example:
- # assert_in_delta 0.05, (50000.0 / 10**6), 0.00001
-
- public
- def assert_in_delta(expected_float, actual_float, delta, message="")
- _wrap_assertion do
- {expected_float => "first float", actual_float => "second float", delta => "delta"}.each do |float, name|
- assert_respond_to(float, :to_f, "The arguments must respond to to_f; the #{name} did not")
- end
- assert_operator(delta, :>=, 0.0, "The delta should not be negative")
- full_message = build_message(message, <<EOT, expected_float, actual_float, delta)
-<?> and
-<?> expected to be within
-<?> of each other.
-EOT
- assert_block(full_message) { (expected_float.to_f - actual_float.to_f).abs <= delta.to_f }
- end
- end
-
- ##
- # Passes if the method send returns a true value.
- #
- # +send_array+ is composed of:
- # * A receiver
- # * A method
- # * Arguments to the method
- #
- # Example:
- # assert_send [[1, 2], :include?, 4]
-
- public
- def assert_send(send_array, message="")
- _wrap_assertion do
- assert_instance_of(Array, send_array, "assert_send requires an array of send information")
- assert(send_array.size >= 2, "assert_send requires at least a receiver and a message name")
- full_message = build_message(message, <<EOT, send_array[0], AssertionMessage.literal(send_array[1].to_s), send_array[2..-1])
-<?> expected to respond to
-<?(?)> with a true value.
-EOT
- assert_block(full_message) { send_array[0].__send__(send_array[1], *send_array[2..-1]) }
- end
- end
-
- ##
- # Passes if +actual+ is a boolean value.
- #
- # Example:
- # assert_boolean(true) # -> pass
- # assert_boolean(nil) # -> fail
- def assert_boolean(actual, message=nil)
- _wrap_assertion do
- assert_block(build_message(message,
- "<true> or <false> expected but was\n<?>",
- actual)) do
- [true, false].include?(actual)
- end
- end
- end
-
- ##
- # Passes if +actual+ is true.
- #
- # Example:
- # assert_true(true) # -> pass
- # assert_true(:true) # -> fail
- def assert_true(actual, message=nil)
- _wrap_assertion do
- assert_block(build_message(message,
- "<true> expected but was\n<?>",
- actual)) do
- actual == true
- end
- end
- end
-
- ##
- # Passes if +actual+ is false.
- #
- # Example:
- # assert_false(false) # -> pass
- # assert_false(nil) # -> fail
- def assert_false(actual, message=nil)
- _wrap_assertion do
- assert_block(build_message(message,
- "<false> expected but was\n<?>",
- actual)) do
- actual == false
- end
- end
- end
-
- ##
- # Builds a failure message. +head+ is added before the +template+ and
- # +arguments+ replaces the '?'s positionally in the template.
-
- public
- def build_message(head, template=nil, *arguments)
- template &&= template.chomp
- return AssertionMessage.new(head, template, arguments)
- end
-
- private
- def _wrap_assertion
- @_assertion_wrapped ||= false
- unless (@_assertion_wrapped)
- @_assertion_wrapped = true
- begin
- add_assertion
- return yield
- ensure
- @_assertion_wrapped = false
- end
- else
- return yield
- end
- end
-
- ##
- # Called whenever an assertion is made. Define this in classes that
- # include Test::Unit::Assertions to record assertion counts.
-
- private
- def add_assertion
- end
-
- ##
- # Select whether or not to use the pretty-printer. If this option is set
- # to false before any assertions are made, pp.rb will not be required.
-
- public
- def self.use_pp=(value)
- AssertionMessage.use_pp = value
- end
-
- # :stopdoc:
-
- class AssertionMessage
- @use_pp = true
- class << self
- attr_accessor :use_pp
-
- def literal(value)
- Literal.new(value)
- end
-
- def delayed_literal(&block)
- DelayedLiteral.new(block)
- end
-
- def convert(object)
- case object
- when Exception
- <<EOM.chop
-Class: <#{convert(object.class)}>
-Message: <#{convert(object.message)}>
----Backtrace---
-#{Util::BacktraceFilter.filter_backtrace(object.backtrace).join("\n")}
----------------
-EOM
- else
- if use_pp
- begin
- require 'pp' unless defined?(PP)
- return PP.pp(object, '').chomp
- rescue LoadError
- self.use_pp = false
- end
- end
- object.inspect
- end
- end
- end
-
- class Literal
- def initialize(value)
- @value = value
- end
-
- def inspect
- @value.to_s
- end
- end
-
- class DelayedLiteral
- def initialize(value)
- @value = value
- end
-
- def inspect
- @value.call.to_s
- end
- end
-
- class Template
- def self.create(string)
- parts = (string ? string.scan(/(?=[^\\])\?|(?:\\\?|[^\?])+/m) : [])
- self.new(parts)
- end
-
- attr_reader :count
-
- def initialize(parts)
- @parts = parts
- @count = parts.find_all{|e| e == '?'}.size
- end
-
- def result(parameters)
- raise "The number of parameters does not match the number of substitutions." if(parameters.size != count)
- params = parameters.dup
- @parts.collect{|e| e == '?' ? params.shift : e.gsub(/\\\?/m, '?')}.join('')
- end
- end
-
- include Util::BacktraceFilter
-
- def initialize(head, template_string, parameters)
- @head = head
- @template_string = template_string
- @parameters = parameters
- end
-
- def convert(object)
- self.class.convert(object)
- end
-
- def template
- @template ||= Template.create(@template_string)
- end
-
- def add_period(string)
- (string =~ /\.\Z/ ? string : string + '.')
- end
-
- def to_s
- message_parts = []
- if (@head)
- head = @head.to_s
- unless(head.empty?)
- message_parts << add_period(head)
- end
- end
- tail = template.result(@parameters.collect{|e| convert(e)})
- message_parts << tail unless(tail.empty?)
- message_parts.join("\n")
- end
- end
-
- # :startdoc:
-
- end
- end
-end
Deleted: test-unit/lib/test/unit/attribute.rb (+0 -125) 100644
===================================================================
--- test-unit/lib/test/unit/attribute.rb 2010-09-12 03:03:44 +0000 (35e362f)
+++ /dev/null
@@ -1,125 +0,0 @@
-module Test
- module Unit
- module Attribute
- class << self
- def included(base)
- base.extend(BaseClassMethods)
- base.extend(ClassMethods)
- end
- end
-
- module BaseClassMethods
- def attributes_table
- {}
- end
- end
-
- module ClassMethods
- def method_added(name)
- super
- return unless defined?(@current_attributes)
-
- attributes = {}
- kept_attributes = {}
- @current_attributes.each do |attribute_name, attribute|
- attributes[attribute_name] = attribute[:value]
- kept_attributes[attribute_name] = attribute if attribute[:keep]
- end
- set_attributes(name, attributes)
- @current_attributes = kept_attributes
- end
-
- def attribute(name, value, options={}, *method_names)
- unless options.is_a?(Hash)
- method_names << options
- options = {}
- end
- @current_attributes ||= {}
- if method_names.empty?
- @current_attributes[name] = options.merge(:value => value)
- else
- method_names.each do |method_name|
- set_attributes(method_name, {name => value})
- end
- end
- end
-
- def attributes_table
- @attributes_table ||= {}
- super.merge(@attributes_table)
- end
-
- def set_attributes(method_name, new_attributes)
- return if new_attributes.empty?
- method_name = normalize_method_name(method_name)
- @attributes_table ||= {}
- @attributes_table[method_name] ||= {}
- current_attributes = @attributes_table[method_name]
- new_attributes.each do |key, value|
- key = normalize_attribute_name(key)
- observers = attribute_observers(key) || []
- observers.each do |observer|
- observer.call(self,
- key,
- (attributes(method_name) || {})[key],
- value,
- method_name)
- end
- current_attributes[key] = value
- end
- end
-
- def attributes(method_name)
- method_name = normalize_method_name(method_name)
- attributes = attributes_table[method_name]
- ancestors[1..-1].each do |ancestor|
- if ancestor.is_a?(Class) and ancestor < Test::Unit::Attribute
- parent_attributes = ancestor.attributes(method_name)
- if attributes
- attributes = (parent_attributes || {}).merge(attributes)
- else
- attributes = parent_attributes
- end
- break
- end
- end
- attributes
- end
-
- def get_attribute(method_name, attribute_name)
- attribute_name = normalize_attribute_name(attribute_name)
- (attributes(method_name) || {})[attribute_name]
- end
-
- @@attribute_observers = {}
- def register_attribute_observer(attribute_name, observer=Proc.new)
- attribute_name = normalize_attribute_name(attribute_name)
- @@attribute_observers[attribute_name] ||= []
- @@attribute_observers[attribute_name] << observer
- end
-
- def attribute_observers(attribute_name)
- attribute_name = normalize_attribute_name(attribute_name)
- @@attribute_observers[attribute_name]
- end
-
- private
- def normalize_attribute_name(name)
- name.to_s
- end
-
- def normalize_method_name(name)
- name.to_s
- end
- end
-
- def attributes
- self.class.attributes(@method_name) || {}
- end
-
- def [](name)
- self.class.get_attribute(@method_name, name)
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/autorunner.rb (+0 -254) 100644
===================================================================
--- test-unit/lib/test/unit/autorunner.rb 2010-09-12 03:03:44 +0000 (974f444)
+++ /dev/null
@@ -1,254 +0,0 @@
-require 'test/unit'
-require 'optparse'
-
-module Test
- module Unit
- class AutoRunner
- RUNNERS = {}
- COLLECTORS = {}
- ADDITIONAL_OPTIONS = []
-
- class << self
- def register_runner(id, runner_builder=Proc.new)
- RUNNERS[id] = runner_builder
- end
-
- def register_collector(id, collector_builder=Proc.new)
- COLLECTORS[id] = collector_builder
- end
-
- def setup_option(option_builder=Proc.new)
- ADDITIONAL_OPTIONS << option_builder
- end
- end
-
- def self.run(force_standalone=false, default_dir=nil, argv=ARGV, &block)
- r = new(force_standalone || standalone?, &block)
- r.base = default_dir
- r.process_args(argv)
- r.run
- end
-
- def self.standalone?
- return false unless("-e" == $0)
- ObjectSpace.each_object(Class) do |klass|
- return false if(klass < TestCase)
- end
- true
- end
-
- register_collector(:descendant) do |auto_runner|
- require 'test/unit/collector/descendant'
- collector = Collector::Descendant.new
- collector.filter = auto_runner.filters
- collector.collect($0.sub(/\.rb\Z/, ''))
- end
-
- register_collector(:load) do |auto_runner|
- require 'test/unit/collector/load'
- collector = Collector::Load.new
- collector.patterns.concat(auto_runner.pattern) if auto_runner.pattern
- collector.excludes.concat(auto_runner.exclude) if auto_runner.exclude
- collector.base = auto_runner.base
- collector.filter = auto_runner.filters
- collector.collect(*auto_runner.to_run)
- end
-
- # deprecated
- register_collector(:object_space) do |auto_runner|
- require 'test/unit/collector/objectspace'
- c = Collector::ObjectSpace.new
- c.filter = auto_runner.filters
- c.collect($0.sub(/\.rb\Z/, ''))
- end
-
- # deprecated
- register_collector(:dir) do |auto_runner|
- require 'test/unit/collector/dir'
- c = Collector::Dir.new
- c.filter = auto_runner.filters
- c.pattern.concat(auto_runner.pattern) if auto_runner.pattern
- c.exclude.concat(auto_runner.exclude) if auto_runner.exclude
- c.base = auto_runner.base
- $:.push(auto_runner.base) if auto_runner.base
- c.collect(*(auto_runner.to_run.empty? ? ['.'] : auto_runner.to_run))
- end
-
- attr_reader :suite, :runner_options
- attr_accessor :filters, :to_run, :pattern, :exclude, :base, :workdir
- attr_writer :runner, :collector
-
- def initialize(standalone)
- Unit.run = true
- @standalone = standalone
- @runner = default_runner
- @collector = default_collector
- @filters = []
- @to_run = []
- @runner_options = {}
- @workdir = nil
- yield(self) if block_given?
- end
-
- def process_args(args = ARGV)
- begin
- options.order!(args) {|arg| @to_run << arg}
- rescue OptionParser::ParseError => e
- puts e
- puts options
- $! = nil
- abort
- else
- @filters << proc{false} unless(@filters.empty?)
- end
- not @to_run.empty?
- end
-
- def options
- @options ||= OptionParser.new do |o|
- o.banner = "Test::Unit automatic runner."
- o.banner << "\nUsage: #{$0} [options] [-- untouched arguments]"
-
- o.on
- o.on('-r', '--runner=RUNNER', RUNNERS,
- "Use the given RUNNER.",
- "(" + keyword_display(RUNNERS) + ")") do |r|
- @runner = r
- end
-
- if(@standalone)
- o.on('-b', '--basedir=DIR', "Base directory of test suites.") do |b|
- @base = b
- end
-
- o.on('-w', '--workdir=DIR', "Working directory to run tests.") do |w|
- @workdir = w
- end
-
- o.on('-a', '--add=TORUN', Array,
- "Add TORUN to the list of things to run;",
- "can be a file or a directory.") do |a|
- @to_run.concat(a)
- end
-
- @pattern = []
- o.on('-p', '--pattern=PATTERN', Regexp,
- "Match files to collect against PATTERN.") do |e|
- @pattern << e
- end
-
- @exclude = []
- o.on('-x', '--exclude=PATTERN', Regexp,
- "Ignore files to collect against PATTERN.") do |e|
- @exclude << e
- end
- end
-
- o.on('-n', '--name=NAME', String,
- "Runs tests matching NAME.",
- "(patterns may be used).") do |n|
- n = (%r{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n)
- case n
- when Regexp
- @filters << proc{|t| n =~ t.method_name ? true : nil}
- else
- @filters << proc{|t| n == t.method_name ? true : nil}
- end
- end
-
- o.on('-t', '--testcase=TESTCASE', String,
- "Runs tests in TestCases matching TESTCASE.",
- "(patterns may be used).") do |n|
- n = (%r{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n)
- case n
- when Regexp
- @filters << proc{|t| n =~ t.class.name ? true : nil}
- else
- @filters << proc{|t| n == t.class.name ? true : nil}
- end
- end
-
- priority_filter = Proc.new do |test|
- if @filters.size > 2
- nil
- else
- Priority::Checker.new(test).need_to_run? or nil
- end
- end
- o.on("--[no-]priority-mode",
- "Runs some tests based on their priority.") do |priority_mode|
- if priority_mode
- @filters |= [priority_filter]
- else
- @filters -= [priority_filter]
- end
- end
-
- o.on('-I', "--load-path=DIR[#{File::PATH_SEPARATOR}DIR...]",
- "Appends directory list to $LOAD_PATH.") do |dirs|
- $LOAD_PATH.concat(dirs.split(File::PATH_SEPARATOR))
- end
-
- ADDITIONAL_OPTIONS.each do |option_builder|
- option_builder.call(self, o)
- end
-
- o.on('--',
- "Stop processing options so that the",
- "remaining options will be passed to the",
- "test."){o.terminate}
-
- o.on('-h', '--help', 'Display this help.'){puts o; exit}
-
- o.on_tail
- o.on_tail('Deprecated options:')
-
- o.on_tail('--console', 'Console runner (use --runner).') do
- warn("Deprecated option (--console).")
- @runner = RUNNERS[:console]
- end
-
- if RUNNERS[:fox]
- o.on_tail('--fox', 'Fox runner (use --runner).') do
- warn("Deprecated option (--fox).")
- @runner = RUNNERS[:fox]
- end
- end
-
- o.on_tail
- end
- end
-
- def keyword_display(array)
- list = array.collect {|e, *| e.to_s}
- Array === array or list.sort!
- list.collect {|e| e.sub(/^(.)([A-Za-z]+)(?=\w*$)/, '\\1[\\2]')}.join(", ")
- end
-
- def run
- suite = @collector[self]
- return false if suite.nil?
- runner = @runner[self]
- return false if runner.nil?
- Dir.chdir(@workdir) if @workdir
- runner.run(suite, @runner_options).passed?
- end
-
- private
- def default_runner
- if ENV["EMACS"] == "t"
- RUNNERS[:emacs]
- else
- RUNNERS[:console]
- end
- end
-
- def default_collector
- COLLECTORS[@standalone ? :load : :descendant]
- end
- end
- end
-end
-
-require 'test/unit/runner/console'
-require 'test/unit/runner/emacs'
Deleted: test-unit/lib/test/unit/collector.rb (+0 -43) 100644
===================================================================
--- test-unit/lib/test/unit/collector.rb 2010-09-12 03:03:44 +0000 (9e9e654)
+++ /dev/null
@@ -1,43 +0,0 @@
-module Test
- module Unit
- module Collector
- def initialize
- @filters = []
- end
-
- def filter=(filters)
- @filters = case(filters)
- when Proc
- [filters]
- when Array
- filters
- end
- end
-
- def add_suite(destination, suite)
- to_delete = suite.tests.find_all{|t| !include?(t)}
- to_delete.each{|t| suite.delete(t)}
- destination << suite unless(suite.size == 0)
- end
-
- def include?(test)
- return true if(@filters.empty?)
- @filters.each do |filter|
- result = filter[test]
- if(result.nil?)
- next
- elsif(!result)
- return false
- else
- return true
- end
- end
- true
- end
-
- def sort(suites)
- suites.sort_by{|s| s.name}
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/collector/descendant.rb (+0 -23) 100644
===================================================================
--- test-unit/lib/test/unit/collector/descendant.rb 2010-09-12 03:03:44 +0000 (3ecad00)
+++ /dev/null
@@ -1,23 +0,0 @@
-require 'test/unit/collector'
-
-module Test
- module Unit
- module Collector
- class Descendant
- include Collector
-
- NAME = 'collected from the subclasses of TestCase'
-
- def collect(name=NAME)
- suite = TestSuite.new(name)
- sub_suites = []
- TestCase::DESCENDANTS.each do |descendant_test_case|
- add_suite(sub_suites, descendant_test_case.suite)
- end
- sort(sub_suites).each {|s| suite << s}
- suite
- end
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/collector/dir.rb (+0 -108) 100644
===================================================================
--- test-unit/lib/test/unit/collector/dir.rb 2010-09-12 03:03:44 +0000 (896008a)
+++ /dev/null
@@ -1,108 +0,0 @@
-require 'test/unit/testsuite'
-require 'test/unit/collector'
-
-module Test
- module Unit
- module Collector
- class Dir
- include Collector
-
- attr_reader :pattern, :exclude
- attr_accessor :base
-
- def initialize(dir=::Dir, file=::File, object_space=::ObjectSpace, req=nil)
- super()
- @dir = dir
- @file = file
- @object_space = object_space
- @req = req
- @pattern = [/\btest_.*\.rb\Z/m]
- @exclude = []
- @base = nil
- end
-
- def collect(*from)
- basedir = @base
- $:.push(basedir) if basedir
- if(from.empty?)
- recursive_collect('.', find_test_cases)
- elsif(from.size == 1)
- recursive_collect(from.first, find_test_cases)
- else
- suites = []
- from.each do |f|
- suite = recursive_collect(f, find_test_cases)
- suites << suite unless(suite.tests.empty?)
- end
- suite = TestSuite.new("[#{from.join(', ')}]")
- sort(suites).each{|s| suite << s}
- suite
- end
- ensure
- $:.delete_at($:.rindex(basedir)) if basedir
- end
-
- def find_test_cases(ignore=[])
- cases = []
- @object_space.each_object(Class) do |c|
- cases << c if(c < TestCase && !ignore.include?(c))
- end
- ignore.concat(cases)
- cases
- end
-
- def recursive_collect(name, already_gathered)
- sub_suites = []
- path = realdir(name)
- if @file.directory?(path)
- dir_name = name unless name == '.'
- @dir.entries(path).each do |e|
- next if(e == '.' || e == '..')
- e_name = dir_name ? @file.join(dir_name, e) : e
- if @file.directory?(realdir(e_name))
- next if /\A(?:CVS|\.svn)\z/ =~ e
- sub_suite = recursive_collect(e_name, already_gathered)
- sub_suites << sub_suite unless(sub_suite.empty?)
- else
- next if /~\z/ =~ e_name or /\A\.\#/ =~ e
- if @pattern and !@pattern.empty?
- next unless @pattern.any? {|pat| pat =~ e_name}
- end
- if @exclude and !@exclude.empty?
- next if @exclude.any? {|pat| pat =~ e_name}
- end
- collect_file(e_name, sub_suites, already_gathered)
- end
- end
- else
- collect_file(name, sub_suites, already_gathered)
- end
- suite = TestSuite.new(@file.basename(name))
- sort(sub_suites).each{|s| suite << s}
- suite
- end
-
- def collect_file(name, suites, already_gathered)
- dir = @file.dirname(@file.expand_path(name, @base))
- $:.unshift(dir)
- if(@req)
- @req.require(name)
- else
- require(name)
- end
- find_test_cases(already_gathered).each{|t| add_suite(suites, t.suite)}
- ensure
- $:.delete_at($:.rindex(dir)) if(dir)
- end
-
- def realdir(path)
- if @base
- @file.join(@base, path)
- else
- path
- end
- end
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/collector/load.rb (+0 -135) 100644
===================================================================
--- test-unit/lib/test/unit/collector/load.rb 2010-09-12 03:03:44 +0000 (3d07bc0)
+++ /dev/null
@@ -1,135 +0,0 @@
-require 'pathname'
-
-require 'test/unit/testsuite'
-require 'test/unit/collector'
-
-module Test
- module Unit
- module Collector
- class Load
- include Collector
-
- attr_reader :patterns, :excludes, :base
-
- def initialize
- super
- @system_excludes = [/~\z/, /\A\.\#/]
- @system_directory_excludes = [/\A(?:CVS|\.svn)\z/]
- @patterns = [/\Atest_.+\.rb\z/m]
- @excludes = []
- @base = nil
- end
-
- def base=(base)
- base = Pathname(base) unless base.nil?
- @base = base
- end
-
- def collect(*froms)
- add_load_path(@base) do
- froms = ["."] if froms.empty?
- test_suites = froms.collect do |from|
- test_suite = collect_recursive(from, find_test_cases)
- test_suite = nil if test_suite.tests.empty?
- test_suite
- end.compact
-
- if test_suites.size > 1
- test_suite = TestSuite.new("[#{froms.join(', ')}]")
- sort(test_suites).each do |sub_test_suite|
- test_suite << sub_test_suite
- end
- test_suite
- else
- test_suites.first
- end
- end
- end
-
- def find_test_cases(ignore=[])
- test_cases = []
- TestCase::DESCENDANTS.each do |test_case|
- test_cases << test_case unless ignore.include?(test_case)
- end
- ignore.concat(test_cases)
- test_cases
- end
-
- private
- def collect_recursive(name, already_gathered)
- sub_test_suites = []
-
- path = resolve_path(name)
- if path.directory?
- directories, files = path.children.partition do |child|
- child.directory?
- end
-
- files.each do |child|
- next if excluded_file?(child.basename.to_s)
- collect_file(child, sub_test_suites, already_gathered)
- end
-
- directories.each do |child|
- next if excluded_directory?(child.basename.to_s)
- sub_test_suite = collect_recursive(child, already_gathered)
- sub_test_suites << sub_test_suite unless sub_test_suite.empty?
- end
- else
- collect_file(path, sub_test_suites, already_gathered)
- end
-
- test_suite = TestSuite.new(path.basename.to_s)
- sort(sub_test_suites).each do |sub_test_suite|
- test_suite << sub_test_suite
- end
- test_suite
- end
-
- def collect_file(path, test_suites, already_gathered)
- add_load_path(path.expand_path.dirname) do
- require(path.to_s)
- find_test_cases(already_gathered).each do |test_case|
- add_suite(test_suites, test_case.suite)
- end
- end
- end
-
- def resolve_path(path)
- if @base
- @base + path
- else
- Pathname(path)
- end
- end
-
- def add_load_path(path)
- $LOAD_PATH.push(path.to_s) if path
- yield
- ensure
- $LOAD_PATH.delete_at($LOAD_PATH.rindex(path.to_s)) if path
- end
-
- def excluded_directory?(base)
- @system_directory_excludes.any? {|pattern| pattern =~ base}
- end
-
- def excluded_file?(base)
- return true if @system_excludes.any? {|pattern| pattern =~ base}
-
- patterns = @patterns || []
- unless patterns.empty?
- return true unless patterns.any? {|pattern| pattern =~ base}
- end
-
- excludes = @excludes || []
- unless excludes.empty?
- return true if excludes.any? {|pattern| pattern =~ base}
- end
-
- false
- end
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/collector/objectspace.rb (+0 -34) 100644
===================================================================
--- test-unit/lib/test/unit/collector/objectspace.rb 2010-09-12 03:03:44 +0000 (d1127a9)
+++ /dev/null
@@ -1,34 +0,0 @@
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit/collector'
-
-module Test
- module Unit
- module Collector
- class ObjectSpace
- include Collector
-
- NAME = 'collected from the ObjectSpace'
-
- def initialize(source=::ObjectSpace)
- super()
- @source = source
- end
-
- def collect(name=NAME)
- suite = TestSuite.new(name)
- sub_suites = []
- @source.each_object(Class) do |klass|
- if(Test::Unit::TestCase > klass)
- add_suite(sub_suites, klass.suite)
- end
- end
- sort(sub_suites).each{|s| suite << s}
- suite
- end
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/color.rb (+0 -61) 100644
===================================================================
--- test-unit/lib/test/unit/color.rb 2010-09-12 03:03:44 +0000 (435676f)
+++ /dev/null
@@ -1,61 +0,0 @@
-module Test
- module Unit
- class Color
- NAMES = ["black", "red", "green", "yellow",
- "blue", "magenta", "cyan", "white"]
- def initialize(name, options={})
- @name = name
- @foreground = options[:foreground]
- @foreground = true if @foreground.nil?
- @intensity = options[:intensity]
- @bold = options[:bold]
- @italic = options[:italic]
- @underline = options[:underline]
- end
-
- def sequence
- sequence = []
- if @name == "none"
- elsif @name == "reset"
- sequence << "0"
- else
- foreground_parameter = @foreground ? 3 : 4
- foreground_parameter += 6 if @intensity
- sequence << "#{foreground_parameter}#{NAMES.index(@name)}"
- end
- sequence << "1" if @bold
- sequence << "3" if @italic
- sequence << "4" if @underline
- sequence
- end
-
- def escape_sequence
- "\e[#{sequence.join(';')}m"
- end
-
- def +(other)
- MixColor.new([self, other])
- end
- end
-
- class MixColor
- def initialize(colors)
- @colors = colors
- end
-
- def sequence
- @colors.inject([]) do |result, color|
- result + color.sequence
- end
- end
-
- def escape_sequence
- "\e[#{sequence.join(';')}m"
- end
-
- def +(other)
- self.class.new([self, other])
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/diff.rb (+0 -524) 100644
===================================================================
--- test-unit/lib/test/unit/diff.rb 2010-09-12 03:03:44 +0000 (7e5e747)
+++ /dev/null
@@ -1,524 +0,0 @@
-# port of Python's difflib.
-
-module Test
- module Unit
- module Diff
- class SequenceMatcher
- def initialize(from, to, &junk_predicate)
- @from = from
- @to = to
- @junk_predicate = junk_predicate
- update_to_indexes
- end
-
- def longest_match(from_start, from_end, to_start, to_end)
- best_info = find_best_match_position(from_start, from_end,
- to_start, to_end)
- unless @junks.empty?
- args = [from_start, from_end, to_start, to_end]
- best_info = adjust_best_info_with_junk_predicate(false, best_info,
- *args)
- best_info = adjust_best_info_with_junk_predicate(true, best_info,
- *args)
- end
-
- best_info
- end
-
- def blocks
- @blocks ||= compute_blocks
- end
-
- def operations
- @operations ||= compute_operations
- end
-
- def grouped_operations(context_size=nil)
- context_size ||= 3
- _operations = operations
- _operations = [[:equal, 0, 0, 0, 0]] if _operations.empty?
- expand_edge_equal_operations!(_operations, context_size)
-
- group_window = context_size * 2
- groups = []
- group = []
- _operations.each do |tag, from_start, from_end, to_start, to_end|
- if tag == :equal and from_end - from_start > group_window
- group << [tag,
- from_start,
- [from_end, from_start + context_size].min,
- to_start,
- [to_end, to_start + context_size].min]
- groups << group
- group = []
- from_start = [from_start, from_end - context_size].max
- to_start = [to_start, to_end - context_size].max
- end
- group << [tag, from_start, from_end, to_start, to_end]
- end
- groups << group unless group.empty?
- groups
- end
-
- def ratio
- @ratio ||= compute_ratio
- end
-
- private
- def update_to_indexes
- @to_indexes = {}
- @junks = {}
- if @to.is_a?(String)
- each = " "[0].is_a?(Integer) ? :each_byte : :each_char
- else
- each = :each
- end
- i = 0
- @to.send(each) do |item|
- @to_indexes[item] ||= []
- @to_indexes[item] << i
- i += 1
- end
-
- return if @junk_predicate.nil?
- @to_indexes = @to_indexes.reject do |key, value|
- junk = @junk_predicate.call(key)
- @junks[key] = true if junk
- junk
- end
- end
-
- def find_best_match_position(from_start, from_end, to_start, to_end)
- best_from, best_to, best_size = from_start, to_start, 0
- sizes = {}
- from_start.upto(from_end) do |from_index|
- _sizes = {}
- (@to_indexes[@from[from_index]] || []).each do |to_index|
- next if to_index < to_start
- break if to_index > to_end
- size = _sizes[to_index] = (sizes[to_index - 1] || 0) + 1
- if size > best_size
- best_from = from_index - size + 1
- best_to = to_index - size + 1
- best_size = size
- end
- end
- sizes = _sizes
- end
- [best_from, best_to, best_size]
- end
-
- def adjust_best_info_with_junk_predicate(should_junk, best_info,
- from_start, from_end,
- to_start, to_end)
- best_from, best_to, best_size = best_info
- while best_from > from_start and best_to > to_start and
- (should_junk ?
- @junks.has_key?(@to[best_to - 1]) :
- !@junks.has_key?(@to[best_to - 1])) and
- @from[best_from - 1] == @to[best_to - 1]
- best_from -= 1
- best_to -= 1
- best_size += 1
- end
-
- while best_from + best_size < from_end and
- best_to + best_size < to_end and
- (should_junk ?
- @junks.has_key?(@to[best_to + best_size]) :
- !@junks.has_key?(@to[best_to + best_size])) and
- @from[best_from + best_size] == @to[best_to + best_size]
- best_size += 1
- end
-
- [best_from, best_to, best_size]
- end
-
- def matches
- @matches ||= compute_matches
- end
-
- def compute_matches
- matches = []
- queue = [[0, @from.size, 0, @to.size]]
- until queue.empty?
- from_start, from_end, to_start, to_end = queue.pop
- match = longest_match(from_start, from_end - 1, to_start, to_end - 1)
- match_from_index, match_to_index, size = match
- unless size.zero?
- if from_start < match_from_index and
- to_start < match_to_index
- queue.push([from_start, match_from_index,
- to_start, match_to_index])
- end
- matches << match
- if match_from_index + size < from_end and
- match_to_index + size < to_end
- queue.push([match_from_index + size, from_end,
- match_to_index + size, to_end])
- end
- end
- end
- matches.sort_by do |(from_index, to_index, match_size)|
- from_index
- end
- end
-
- def compute_blocks
- blocks = []
- current_from_index = current_to_index = current_size = 0
- matches.each do |from_index, to_index, size|
- if current_from_index + current_size == from_index and
- current_to_index + current_size == to_index
- current_size += size
- else
- unless current_size.zero?
- blocks << [current_from_index, current_to_index, current_size]
- end
- current_from_index = from_index
- current_to_index = to_index
- current_size = size
- end
- end
- unless current_size.zero?
- blocks << [current_from_index, current_to_index, current_size]
- end
-
- blocks << [@from.size, @to.size, 0]
- blocks
- end
-
- def compute_operations
- from_index = to_index = 0
- operations = []
- blocks.each do |match_from_index, match_to_index, size|
- tag = determine_tag(from_index, to_index,
- match_from_index, match_to_index)
- if tag != :equal
- operations << [tag,
- from_index, match_from_index,
- to_index, match_to_index]
- end
-
- from_index, to_index = match_from_index + size, match_to_index + size
- if size > 0
- operations << [:equal,
- match_from_index, from_index,
- match_to_index, to_index]
- end
- end
- operations
- end
-
- def compute_ratio
- matches = blocks.inject(0) {|result, block| result + block[-1]}
- length = @from.length + @to.length
- if length.zero?
- 1.0
- else
- 2.0 * matches / length
- end
- end
-
- def determine_tag(from_index, to_index,
- match_from_index, match_to_index)
- if from_index < match_from_index and to_index < match_to_index
- :replace
- elsif from_index < match_from_index
- :delete
- elsif to_index < match_to_index
- :insert
- else
- :equal
- end
- end
-
- def expand_edge_equal_operations!(_operations, context_size)
- tag, from_start, from_end, to_start, to_end = _operations[0]
- if tag == :equal
- _operations[0] = [tag,
- [from_start, from_end - context_size].max,
- from_end,
- [to_start, to_end - context_size].max,
- to_end]
- end
-
- tag, from_start, from_end, to_start, to_end = _operations[-1]
- if tag == :equal
- _operations[-1] = [tag,
- from_start,
- [from_end, from_start + context_size].min,
- to_start,
- [to_end, to_start + context_size].min]
- end
- end
- end
-
- class Differ
- def initialize(from, to)
- @from = from
- @to = to
- end
-
- private
- def tag(mark, contents)
- contents.collect {|content| "#{mark}#{content}"}
- end
- end
-
- class ReadableDiffer < Differ
- def diff(options={})
- result = []
- matcher = SequenceMatcher.new(@from, @to)
- matcher.operations.each do |args|
- tag, from_start, from_end, to_start, to_end = args
- case tag
- when :replace
- result.concat(diff_lines(from_start, from_end, to_start, to_end))
- when :delete
- result.concat(tag_deleted(@from[from_start...from_end]))
- when :insert
- result.concat(tag_inserted(@to[to_start...to_end]))
- when :equal
- result.concat(tag_equal(@from[from_start...from_end]))
- else
- raise "unknown tag: #{tag}"
- end
- end
- result
- end
-
- private
- def tag_deleted(contents)
- tag("- ", contents)
- end
-
- def tag_inserted(contents)
- tag("+ ", contents)
- end
-
- def tag_equal(contents)
- tag(" ", contents)
- end
-
- def tag_difference(contents)
- tag("? ", contents)
- end
-
- def find_diff_line_info(from_start, from_end, to_start, to_end)
- best_ratio = 0.74
- from_equal_index = to_equal_index = nil
- from_best_index = to_best_index = nil
-
- to_start.upto(to_end - 1) do |to_index|
- from_start.upto(from_end - 1) do |from_index|
- if @from[from_index] == @to[to_index]
- from_equal_index ||= from_index
- to_equal_index ||= to_index
- next
- end
-
- matcher = SequenceMatcher.new(@from[from_index], @to[to_index],
- &method(:space_character?))
- if matcher.ratio > best_ratio
- best_ratio = matcher.ratio
- from_best_index = from_index
- to_best_index = to_index
- end
- end
- end
-
- [best_ratio,
- from_equal_index, to_equal_index,
- from_best_index, to_best_index]
- end
-
- def diff_lines(from_start, from_end, to_start, to_end)
- cut_off = 0.75
-
- info = find_diff_line_info(from_start, from_end, to_start, to_end)
- best_ratio, from_equal_index, to_equal_index, *info = info
- from_best_index, to_best_index = info
-
- if best_ratio < cut_off
- if from_equal_index.nil?
- tagged_from = tag_deleted(@from[from_start...from_end])
- tagged_to = tag_inserted(@to[to_start...to_end])
- if to_end - to_start < from_end - from_start
- return tagged_to + tagged_from
- else
- return tagged_from + tagged_to
- end
- end
- from_best_index = from_equal_index
- to_best_index = to_equal_index
- best_ratio = 1.0
- end
-
- _diff_lines(from_start, from_best_index, to_start, to_best_index) +
- diff_line(@from[from_best_index], @to[to_best_index]) +
- _diff_lines(from_best_index + 1, from_end, to_best_index + 1, to_end)
- end
-
- def _diff_lines(from_start, from_end, to_start, to_end)
- if from_start < from_end
- if to_start < to_end
- diff_lines(from_start, from_end, to_start, to_end)
- else
- tag_deleted(@from[from_start...from_end])
- end
- else
- tag_inserted(@to[to_start...to_end])
- end
- end
-
- def diff_line(from_line, to_line)
- from_tags = ""
- to_tags = ""
- matcher = SequenceMatcher.new(from_line, to_line,
- &method(:space_character?))
- operations = matcher.operations
- operations.each do |tag, from_start, from_end, to_start, to_end|
- from_length = from_end - from_start
- to_length = to_end - to_start
- case tag
- when :replace
- from_tags << "^" * from_length
- to_tags << "^" * to_length
- when :delete
- from_tags << "-" * from_length
- when :insert
- to_tags << "+" * to_length
- when :equal
- from_tags << " " * from_length
- to_tags << " " * to_length
- else
- raise "unknown tag: #{tag}"
- end
- end
- format_diff_point(from_line, to_line, from_tags, to_tags)
- end
-
- def format_diff_point(from_line, to_line, from_tags, to_tags)
- common = [n_leading_characters(from_line, ?\t),
- n_leading_characters(to_line, ?\t)].min
- common = [common,
- n_leading_characters(from_tags[0, common], " "[0])].min
- from_tags = from_tags[common..-1].rstrip
- to_tags = to_tags[common..-1].rstrip
-
- result = tag_deleted([from_line])
- unless from_tags.empty?
- result.concat(tag_difference(["#{"\t" * common}#{from_tags}"]))
- end
- result.concat(tag_inserted([to_line]))
- unless to_tags.empty?
- result.concat(tag_difference(["#{"\t" * common}#{to_tags}"]))
- end
- result
- end
-
- def n_leading_characters(string, character)
- n = 0
- while string[n] == character
- n += 1
- end
- n
- end
-
- def space_character?(character)
- [" "[0], "\t"[0]].include?(character)
- end
- end
-
- class UnifiedDiffer < Differ
- def diff(options={})
- groups = SequenceMatcher.new(@from, @to).grouped_operations
- return [] if groups.empty?
- return [] if same_content?(groups)
-
- show_context = options[:show_context]
- show_context = true if show_context.nil?
- result = ["--- #{options[:from_label]}".rstrip,
- "+++ #{options[:to_label]}".rstrip]
- groups.each do |operations|
- result << format_summary(operations, show_context)
- operations.each do |args|
- operation_tag, from_start, from_end, to_start, to_end = args
- case operation_tag
- when :replace
- result.concat(tag("-", @from[from_start...from_end]))
- result.concat(tag("+", @to[to_start...to_end]))
- when :delete
- result.concat(tag("-", @from[from_start...from_end]))
- when :insert
- result.concat(tag("+", @to[to_start...to_end]))
- when :equal
- result.concat(tag(" ", @from[from_start...from_end]))
- end
- end
- end
- result
- end
-
- private
- def same_content?(groups)
- return false if groups.size != 1
- group = groups[0]
- return false if group.size != 1
- tag, from_start, from_end, to_start, to_end = group[0]
-
- tag == :equal and [from_start, from_end] == [to_start, to_end]
- end
-
- def format_summary(operations, show_context)
- _, first_from_start, _, first_to_start, _ = operations[0]
- _, _, last_from_end, _, last_to_end = operations[-1]
- summary = "@@ -%d,%d +%d,%d @@" % [first_from_start + 1,
- last_from_end - first_from_start,
- first_to_start + 1,
- last_to_end - first_to_start,]
- if show_context
- interesting_line = find_interesting_line(first_from_start,
- first_to_start,
- :define_line?)
- summary << " #{interesting_line}" if interesting_line
- end
- summary
- end
-
- def find_interesting_line(from_start, to_start, predicate)
- from_index = from_start
- to_index = to_start
- while from_index >= 0 or to_index >= 0
- [@from[from_index], @to[to_index]].each do |line|
- return line if line and send(predicate, line)
- end
-
- from_index -= 1
- to_index -= 1
- end
- nil
- end
-
- def define_line?(line)
- /\A(?:[_a-zA-Z$]|\s*(?:class|module|def)\b)/ =~ line
- end
- end
-
- module_function
- def readable(from, to, options={})
- diff(ReadableDiffer, from, to, options)
- end
-
- def unified(from, to, options={})
- diff(UnifiedDiffer, from, to, options)
- end
-
- def diff(differ_class, from, to, options={})
- differ = differ_class.new(from.split(/\r?\n/), to.split(/\r?\n/))
- differ.diff(options).join("\n")
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/error.rb (+0 -124) 100644
===================================================================
--- test-unit/lib/test/unit/error.rb 2010-09-12 03:03:44 +0000 (33844dd)
+++ /dev/null
@@ -1,124 +0,0 @@
-#--
-#
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit/util/backtracefilter'
-
-module Test
- module Unit
-
- # Encapsulates an error in a test. Created by
- # Test::Unit::TestCase when it rescues an exception thrown
- # during the processing of a test.
- class Error
- include Util::BacktraceFilter
-
- attr_reader(:test_name, :exception)
-
- SINGLE_CHARACTER = 'E'
- LABEL = "Error"
-
- # Creates a new Error with the given test_name and
- # exception.
- def initialize(test_name, exception)
- @test_name = test_name
- @exception = exception
- end
-
- # Returns a single character representation of an error.
- def single_character_display
- SINGLE_CHARACTER
- end
-
- def label
- LABEL
- end
-
- # Returns the message associated with the error.
- def message
- "#{@exception.class.name}: #{@exception.message}"
- end
-
- # Returns a brief version of the error description.
- def short_display
- "#@test_name: #{message.split("\n")[0]}"
- end
-
- # Returns a verbose version of the error description.
- def long_display
- backtrace_display = backtrace.join("\n ")
- "#{label}:\n#@test_name:\n#{message}\n #{backtrace_display}"
- end
-
- def backtrace
- filter_backtrace(@exception.backtrace)
- end
-
- # Overridden to return long_display.
- def to_s
- long_display
- end
- end
-
- module ErrorHandler
- class << self
- def included(base)
- base.exception_handler(:handle_all_exception)
- end
- end
-
- PASS_THROUGH_EXCEPTIONS = [NoMemoryError, SignalException, Interrupt,
- SystemExit]
- private
- def handle_all_exception(exception)
- case exception
- when *PASS_THROUGH_EXCEPTIONS
- false
- else
- problem_occurred
- add_error(exception)
- true
- end
- end
-
- def add_error(exception)
- current_result.add_error(Error.new(name, exception))
- end
- end
-
- module TestResultErrorSupport
- attr_reader :errors
-
- # Records a Test::Unit::Error.
- def add_error(error)
- @errors << error
- notify_fault(error)
- notify_changed
- end
-
- # Returns the number of errors this TestResult has
- # recorded.
- def error_count
- @errors.size
- end
-
- def error_occurred?
- not @errors.empty?
- end
-
- private
- def initialize_containers
- super
- @errors = []
- @summary_generators << :error_summary
- @problem_checkers << :error_occurred?
- end
-
- def error_summary
- "#{error_count} errors"
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/exceptionhandler.rb (+0 -39) 100644
===================================================================
--- test-unit/lib/test/unit/exceptionhandler.rb 2010-09-12 03:03:44 +0000 (8f21318)
+++ /dev/null
@@ -1,39 +0,0 @@
-module Test
- module Unit
- module ExceptionHandler
- @@exception_handlers = []
- class << self
- def exception_handlers
- @@exception_handlers
- end
-
- def included(base)
- base.extend(ClassMethods)
-
- observer = Proc.new do |test_case, _, _, value, method_name|
- if value
- @@exception_handlers.unshift(method_name)
- else
- @@exception_handlers -= [method_name]
- end
- end
- base.register_attribute_observer(:exception_handler, &observer)
- end
- end
-
- module ClassMethods
- def exception_handlers
- ExceptionHandler.exception_handlers
- end
-
- def exception_handler(*method_names)
- attribute(:exception_handler, true, *method_names)
- end
-
- def unregister_exception_handler(*method_names)
- attribute(:exception_handler, false, *method_names)
- end
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/failure.rb (+0 -110) 100644
===================================================================
--- test-unit/lib/test/unit/failure.rb 2010-09-12 03:03:44 +0000 (ccd71c2)
+++ /dev/null
@@ -1,110 +0,0 @@
-#--
-#
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-module Test
- module Unit
-
- # Encapsulates a test failure. Created by Test::Unit::TestCase
- # when an assertion fails.
- class Failure
- attr_reader :test_name, :location, :message
-
- SINGLE_CHARACTER = 'F'
- LABEL = "Failure"
-
- # Creates a new Failure with the given location and
- # message.
- def initialize(test_name, location, message)
- @test_name = test_name
- @location = location
- @message = message
- end
-
- # Returns a single character representation of a failure.
- def single_character_display
- SINGLE_CHARACTER
- end
-
- def label
- LABEL
- end
-
- # Returns a brief version of the error description.
- def short_display
- "#@test_name: #{@message.split("\n")[0]}"
- end
-
- # Returns a verbose version of the error description.
- def long_display
- if location.size == 1
- location_display = location[0].sub(/\A(.+:\d+).*/, ' [\\1]')
- else
- location_display = "\n [#{location.join("\n ")}]"
- end
- "#{label}:\n#@test_name#{location_display}:\n#@message"
- end
-
- # Overridden to return long_display.
- def to_s
- long_display
- end
- end
-
- module FailureHandler
- class << self
- def included(base)
- base.exception_handler(:handle_assertion_failed_error)
- end
- end
-
- private
- def handle_assertion_failed_error(exception)
- return false unless exception.is_a?(AssertionFailedError)
- problem_occurred
- add_failure(exception.message, exception.backtrace)
- true
- end
-
- def add_failure(message, backtrace)
- failure = Failure.new(name, filter_backtrace(backtrace), message)
- current_result.add_failure(failure)
- end
- end
-
- module TestResultFailureSupport
- attr_reader :failures
-
- # Records a Test::Unit::Failure.
- def add_failure(failure)
- @failures << failure
- notify_fault(failure)
- notify_changed
- end
-
- # Returns the number of failures this TestResult has
- # recorded.
- def failure_count
- @failures.size
- end
-
- def failure_occurred?
- not @failures.empty?
- end
-
- private
- def initialize_containers
- super
- @failures = []
- @summary_generators << :failure_summary
- @problem_checkers << :failure_occurred?
- end
-
- def failure_summary
- "#{failure_count} failures"
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/fixture.rb (+0 -185) 100644
===================================================================
--- test-unit/lib/test/unit/fixture.rb 2010-09-12 03:03:44 +0000 (f031026)
+++ /dev/null
@@ -1,185 +0,0 @@
-module Test
- module Unit
- module Fixture
- class << self
- def included(base)
- base.extend(ClassMethods)
-
- [:setup, :teardown].each do |fixture|
- observer = Proc.new do |test_case, _, _, value, method_name|
- if value.nil?
- test_case.send("unregister_#{fixture}_method", method_name)
- else
- test_case.send("register_#{fixture}_method", method_name,
- value)
- end
- end
- base.register_attribute_observer(fixture, &observer)
- end
- end
- end
-
- module ClassMethods
- def setup(*method_names)
- register_fixture(:setup, *method_names)
- end
-
- def unregister_setup(*method_names)
- unregister_fixture(:setup, *method_names)
- end
-
- def teardown(*method_names)
- register_fixture(:teardown, *method_names)
- end
-
- def unregister_teardown(*method_names)
- unregister_fixture(:teardown, *method_names)
- end
-
- def register_setup_method(method_name, options)
- register_fixture_method(:setup, method_name, options, :after, :append)
- end
-
- def unregister_setup_method(method_name)
- unregister_fixture_method(:setup, method_name)
- end
-
- def register_teardown_method(method_name, options)
- register_fixture_method(:teardown, method_name, options,
- :before, :prepend)
- end
-
- def unregister_teardown_method(method_name)
- unregister_fixture_method(:teardown, method_name)
- end
-
- def before_setup_methods
- collect_fixture_methods(:setup, :before)
- end
-
- def after_setup_methods
- collect_fixture_methods(:setup, :after)
- end
-
- def before_teardown_methods
- collect_fixture_methods(:teardown, :before)
- end
-
- def after_teardown_methods
- collect_fixture_methods(:teardown, :after)
- end
-
- private
- def register_fixture(fixture, *method_names)
- options = {}
- options = method_names.pop if method_names.last.is_a?(Hash)
- attribute(fixture, options, *method_names)
- end
-
- def unregister_fixture(fixture, *method_names)
- attribute(fixture, nil, *method_names)
- end
-
- def valid_register_fixture_options?(options)
- return true if options.empty?
- return false if options.size > 1
-
- key = options.keys.first
- [:before, :after].include?(key) and
- [:prepend, :append].include?(options[key])
- end
-
- def add_fixture_method_name(how, variable_name, method_name)
- unless self.instance_variable_defined?(variable_name)
- self.instance_variable_set(variable_name, [])
- end
- methods = self.instance_variable_get(variable_name)
-
- if how == :prepend
- methods = [method_name] | methods
- else
- methods = methods | [method_name]
- end
- self.instance_variable_set(variable_name, methods)
- end
-
- def registered_methods_variable_name(fixture, order)
- "@#{order}_#{fixture}_methods"
- end
-
- def unregistered_methods_variable_name(fixture)
- "@unregistered_#{fixture}_methods"
- end
-
- def register_fixture_method(fixture, method_name, options,
- default_order, default_how)
- unless valid_register_fixture_options?(options)
- message = "must be {:before => :prepend}, " +
- "{:before => :append}, {:after => :prepend} or " +
- "{:after => :append}: #{options.inspect}"
- raise ArgumentError, message
- end
-
- if options.empty?
- order, how = default_order, default_how
- else
- order, how = options.to_a.first
- end
- variable_name = registered_methods_variable_name(fixture, order)
- add_fixture_method_name(how, variable_name, method_name)
- end
-
- def unregister_fixture_method(fixture, method_name)
- variable_name = unregistered_methods_variable_name(fixture)
- add_fixture_method_name(:append, variable_name, method_name)
- end
-
- def collect_fixture_methods(fixture, order)
- methods_variable = registered_methods_variable_name(fixture, order)
- unregistered_methods_variable =
- unregistered_methods_variable_name(fixture)
-
- base_index = ancestors.index(Fixture)
- interested_ancestors = ancestors[0, base_index].reverse
- interested_ancestors.inject([]) do |result, ancestor|
- if ancestor.is_a?(Class)
- ancestor.class_eval do
- methods = []
- unregistered_methods = []
- if instance_variable_defined?(methods_variable)
- methods = instance_variable_get(methods_variable)
- end
- if instance_variable_defined?(unregistered_methods_variable)
- unregistered_methods =
- instance_variable_get(unregistered_methods_variable)
- end
- (result | methods) - unregistered_methods
- end
- else
- result
- end
- end
- end
- end
-
- private
- def run_fixture(fixture)
- [
- self.class.send("before_#{fixture}_methods"),
- fixture,
- self.class.send("after_#{fixture}_methods")
- ].flatten.each do |method_name|
- send(method_name) if respond_to?(method_name, true)
- end
- end
-
- def run_setup
- run_fixture(:setup)
- end
-
- def run_teardown
- run_fixture(:teardown)
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/notification.rb (+0 -125) 100644
===================================================================
--- test-unit/lib/test/unit/notification.rb 2010-09-12 03:03:44 +0000 (48ba3f6)
+++ /dev/null
@@ -1,125 +0,0 @@
-require 'test/unit/util/backtracefilter'
-
-module Test
- module Unit
- class Notification
- include Util::BacktraceFilter
- attr_reader :test_name, :location, :message
-
- SINGLE_CHARACTER = 'N'
- LABEL = "Notification"
-
- # Creates a new Notification with the given location and
- # message.
- def initialize(test_name, location, message)
- @test_name = test_name
- @location = location
- @message = message
- end
-
- # Returns a single character representation of a notification.
- def single_character_display
- SINGLE_CHARACTER
- end
-
- def label
- LABEL
- end
-
- # Returns a brief version of the error description.
- def short_display
- "#{@test_name}: #{@message.split("\n")[0]}"
- end
-
- # Returns a verbose version of the error description.
- def long_display
- backtrace = filter_backtrace(location).join("\n")
- "#{label}: #{@message}\n#{@test_name}\n#{backtrace}"
- end
-
- # Overridden to return long_display.
- def to_s
- long_display
- end
- end
-
- class NotifiedError < StandardError
- end
-
-
- module TestCaseNotificationSupport
- class << self
- def included(base)
- base.class_eval do
- include NotificationHandler
- end
- end
- end
-
- # Notify some information.
- #
- # Example:
- # def test_notification
- # notify("I'm here!")
- # # Reached here
- # notify("Special!") if special_case?
- # # Reached here too
- # end
- def notify(message, &block)
- notification = Notification.new(name, filter_backtrace(caller), message)
- add_notification(notification)
- end
-
- private
- def add_notification(notification)
- current_result.add_notification(notification)
- end
- end
-
- module NotificationHandler
- class << self
- def included(base)
- base.exception_handler(:handle_Notified_error)
- end
- end
-
- private
- def handle_Notified_error(exception)
- return false unless exception.is_a?(NotifiedError)
- notification = Notification.new(name,
- filter_backtrace(exception.backtrace),
- exception.message)
- add_notification(notification)
- true
- end
- end
-
- module TestResultNotificationSupport
- attr_reader :notifications
-
- # Records a Test::Unit::Notification.
- def add_notification(notification)
- @notifications << notification
- notify_fault(notification)
- notify_changed
- end
-
- # Returns the number of notifications this TestResult has
- # recorded.
- def notification_count
- @notifications.size
- end
-
- private
- def initialize_containers
- super
- @notifications = []
- @summary_generators << :notification_summary
- end
-
- def notification_summary
- "#{notification_count} notifications"
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/omission.rb (+0 -143) 100644
===================================================================
--- test-unit/lib/test/unit/omission.rb 2010-09-12 03:03:44 +0000 (e2187ba)
+++ /dev/null
@@ -1,143 +0,0 @@
-require 'test/unit/util/backtracefilter'
-
-module Test
- module Unit
- class Omission
- include Util::BacktraceFilter
- attr_reader :test_name, :location, :message
-
- SINGLE_CHARACTER = 'O'
- LABEL = "Omission"
-
- # Creates a new Omission with the given location and
- # message.
- def initialize(test_name, location, message)
- @test_name = test_name
- @location = location
- @message = message
- end
-
- # Returns a single character representation of a omission.
- def single_character_display
- SINGLE_CHARACTER
- end
-
- def label
- LABEL
- end
-
- # Returns a brief version of the error description.
- def short_display
- "#{@test_name}: #{@message.split("\n")[0]}"
- end
-
- # Returns a verbose version of the error description.
- def long_display
- backtrace = filter_backtrace(location).join("\n")
- "#{label}: #{@message}\n#{@test_name}\n#{backtrace}"
- end
-
- # Overridden to return long_display.
- def to_s
- long_display
- end
- end
-
- class OmittedError < StandardError
- end
-
-
- module TestCaseOmissionSupport
- class << self
- def included(base)
- base.class_eval do
- include OmissionHandler
- end
- end
- end
-
- # Omit the test of part of the test.
- #
- # Example:
- # def test_omission
- # omit
- # # Not reached here
- # end
- #
- # def test_omission_with_here
- # omit do
- # # Not ran here
- # end
- # # Reached here
- # end
- def omit(message=nil, &block)
- message ||= "omitted."
- if block_given?
- omission = Omission.new(name, filter_backtrace(caller), message)
- add_omission(omission)
- else
- raise OmittedError.new(message)
- end
- end
-
- def omit_if(condition, *args, &block)
- omit(*args, &block) if condition
- end
-
- def omit_unless(condition, *args, &block)
- omit(*args, &block) unless condition
- end
-
- private
- def add_omission(omission)
- current_result.add_omission(omission)
- end
- end
-
- module OmissionHandler
- class << self
- def included(base)
- base.exception_handler(:handle_omitted_error)
- end
- end
-
- private
- def handle_omitted_error(exception)
- return false unless exception.is_a?(OmittedError)
- omission = Omission.new(name,
- filter_backtrace(exception.backtrace),
- exception.message)
- add_omission(omission)
- true
- end
- end
-
- module TestResultOmissionSupport
- attr_reader :omissions
-
- # Records a Test::Unit::Omission.
- def add_omission(omission)
- @omissions << omission
- notify_fault(omission)
- notify_changed
- end
-
- # Returns the number of omissions this TestResult has
- # recorded.
- def omission_count
- @omissions.size
- end
-
- private
- def initialize_containers
- super
- @omissions = []
- @summary_generators << :omission_summary
- end
-
- def omission_summary
- "#{omission_count} omissions"
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/pending.rb (+0 -146) 100644
===================================================================
--- test-unit/lib/test/unit/pending.rb 2010-09-12 03:03:44 +0000 (bfc5ac0)
+++ /dev/null
@@ -1,146 +0,0 @@
-require 'test/unit/util/backtracefilter'
-
-module Test
- module Unit
- class Pending
- include Util::BacktraceFilter
- attr_reader :test_name, :location, :message
-
- SINGLE_CHARACTER = 'P'
- LABEL = "Pending"
-
- # Creates a new Pending with the given location and
- # message.
- def initialize(test_name, location, message)
- @test_name = test_name
- @location = location
- @message = message
- end
-
- # Returns a single character representation of a pending.
- def single_character_display
- SINGLE_CHARACTER
- end
-
- def label
- LABEL
- end
-
- # Returns a brief version of the error description.
- def short_display
- "#{@test_name}: #{@message.split("\n")[0]}"
- end
-
- # Returns a verbose version of the error description.
- def long_display
- backtrace = filter_backtrace(location).join("\n")
- "#{label}: #{@message}\n#{@test_name}\n#{backtrace}"
- end
-
- # Overridden to return long_display.
- def to_s
- long_display
- end
- end
-
- class PendedError < StandardError
- end
-
-
- module TestCasePendingSupport
- class << self
- def included(base)
- base.class_eval do
- include PendingHandler
- end
- end
- end
-
- # Marks the test or part of the test is pending.
- #
- # Example:
- # def test_pending
- # pend
- # # Not reached here
- # end
- #
- # def test_pending_with_here
- # pend do
- # # Ran here
- # # Fails if the block doesn't raise any error.
- # # Because it means the block is passed unexpectedly.
- # end
- # # Reached here
- # end
- def pend(message=nil, &block)
- message ||= "pended."
- if block_given?
- pending = nil
- begin
- yield
- rescue Exception
- pending = Pending.new(name, filter_backtrace(caller), message)
- add_pending(pending)
- end
- unless pending
- flunk("Pending block should not be passed: #{message}")
- end
- else
- raise PendedError.new(message)
- end
- end
-
- private
- def add_pending(pending)
- problem_occurred
- current_result.add_pending(pending)
- end
- end
-
- module PendingHandler
- class << self
- def included(base)
- base.exception_handler(:handle_pended_error)
- end
- end
-
- private
- def handle_pended_error(exception)
- return false unless exception.is_a?(PendedError)
- pending = Pending.new(name,
- filter_backtrace(exception.backtrace),
- exception.message)
- add_pending(pending)
- true
- end
- end
-
- module TestResultPendingSupport
- attr_reader :pendings
-
- # Records a Test::Unit::Pending.
- def add_pending(pending)
- @pendings << pending
- notify_fault(pending)
- notify_changed
- end
-
- # Returns the number of pendings this TestResult has
- # recorded.
- def pending_count
- @pendings.size
- end
-
- private
- def initialize_containers
- super
- @pendings = []
- @summary_generators << :pending_summary
- end
-
- def pending_summary
- "#{pending_count} pendings"
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/priority.rb (+0 -146) 100644
===================================================================
--- test-unit/lib/test/unit/priority.rb 2010-09-12 03:03:44 +0000 (f3b24b0)
+++ /dev/null
@@ -1,146 +0,0 @@
-require "fileutils"
-require "tmpdir"
-
-module Test
- module Unit
- module Priority
- class << self
- def included(base)
- base.extend(ClassMethods)
-
- base.class_eval do
- setup :priority_setup, :before => :prepend
- teardown :priority_teardown, :after => :append
- end
- end
- end
-
- class Checker
- class << self
- def have_priority?(name)
- singleton_class = (class << self; self; end)
- singleton_class.method_defined?(priority_check_method_name(name))
- end
-
- def need_to_run?(test)
- priority = test[:priority] || :normal
- if have_priority?(priority)
- send(priority_check_method_name(priority), test)
- else
- true
- end
- end
-
- def run_priority_must?(test)
- true
- end
-
- def run_priority_important?(test)
- rand > 0.1
- end
-
- def run_priority_high?(test)
- rand > 0.3
- end
-
- def run_priority_normal?(test)
- rand > 0.5
- end
-
- def run_priority_low?(test)
- rand > 0.75
- end
-
- def run_priority_never?(test)
- false
- end
-
- private
- def priority_check_method_name(priority_name)
- "run_priority_#{priority_name}?"
- end
- end
-
- attr_reader :test
- def initialize(test)
- @test = test
- end
-
- def setup
- FileUtils.rm_f(passed_file)
- end
-
- def teardown
- if @test.send(:passed?)
- FileUtils.touch(passed_file)
- else
- FileUtils.rm_f(passed_file)
- end
- end
-
- def need_to_run?
- !previous_test_success? or self.class.need_to_run?(@test)
- end
-
- private
- def previous_test_success?
- File.exist?(passed_file)
- end
-
- def result_dir
- components = [".test-result",
- @test.class.name || "AnonymousTestCase",
- @test.method_name.to_s]
- parent_directories = [File.dirname($0), Dir.pwd]
- if Process.respond_to?(:uid)
- parent_directories << File.join(Dir.tmpdir, Process.uid.to_s)
- end
- parent_directories.each do |parent_directory|
- dir = File.expand_path(File.join(parent_directory, *components))
- begin
- FileUtils.mkdir_p(dir)
- return dir
- rescue Errno::EACCES
- end
- end
-
- raise Errno::EACCES, parent_directories.join(", ")
- end
-
- def passed_file
- File.join(result_dir, "passed")
- end
-
- def escaped_method_name
- @method_name.to_s.gsub(/[!?=]$/) do |matched|
- case matched
- when "!"
- ".destructive"
- when "?"
- ".predicate"
- when "="
- ".equal"
- end
- end
- end
- end
-
- module ClassMethods
- def priority(name, *tests)
- unless Checker.have_priority?(name)
- raise ArgumentError, "unknown priority: #{name}"
- end
- attribute(:priority, name, {:keep => true}, *tests)
- end
- end
-
- def priority_setup
- Checker.new(self).setup
- end
-
- def priority_teardown
- Checker.new(self).teardown
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/runner/console.rb (+0 -46) 100644
===================================================================
--- test-unit/lib/test/unit/runner/console.rb 2010-09-12 03:03:44 +0000 (c3f3d53)
+++ /dev/null
@@ -1,46 +0,0 @@
-module Test
- module Unit
- AutoRunner.register_runner(:console) do |auto_runner|
- require 'test/unit/ui/console/testrunner'
- Test::Unit::UI::Console::TestRunner
- end
-
- AutoRunner.setup_option do |auto_runner, opts|
- require 'test/unit/ui/console/outputlevel'
-
- output_levels = [
- [:silent, UI::Console::OutputLevel::SILENT],
- [:progress, UI::Console::OutputLevel::PROGRESS_ONLY],
- [:normal, UI::Console::OutputLevel::NORMAL],
- [:verbose, UI::Console::OutputLevel::VERBOSE],
- ]
- opts.on('-v', '--verbose=[LEVEL]', output_levels,
- "Set the output level (default is verbose).",
- "(#{auto_runner.keyword_display(output_levels)})") do |level|
- level ||= output_levels.assoc(:verbose)[1]
- auto_runner.runner_options[:output_level] = level
- end
-
- use_color_options = [
- [:auto, :auto],
- ["-", false],
- ["no", false],
- ["false", false],
- ["+", true],
- ["yes", true],
- ["true", true],
- ]
- opts.on("--[no-]use-color=[auto]", use_color_options,
- "Use color output",
- "(default is auto") do |use_color|
- case use_color
- when nil
- use_color = true
- when :auto
- use_color = nil
- end
- auto_runner.runner_options[:use_color] = use_color
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/runner/emacs.rb (+0 -8) 100644
===================================================================
--- test-unit/lib/test/unit/runner/emacs.rb 2010-09-12 03:03:44 +0000 (c254657)
+++ /dev/null
@@ -1,8 +0,0 @@
-module Test
- module Unit
- AutoRunner.register_runner(:emacs) do |auto_runner|
- require 'test/unit/ui/emacs/testrunner'
- Test::Unit::UI::Emacs::TestRunner
- end
- end
-end
Deleted: test-unit/lib/test/unit/testcase.rb (+0 -281) 100644
===================================================================
--- test-unit/lib/test/unit/testcase.rb 2010-09-12 03:03:44 +0000 (134f4f9)
+++ /dev/null
@@ -1,281 +0,0 @@
-#--
-#
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit/attribute'
-require 'test/unit/fixture'
-require 'test/unit/exceptionhandler'
-require 'test/unit/assertions'
-require 'test/unit/failure'
-require 'test/unit/error'
-require 'test/unit/pending'
-require 'test/unit/omission'
-require 'test/unit/notification'
-require 'test/unit/priority'
-require 'test/unit/testsuite'
-require 'test/unit/assertionfailederror'
-require 'test/unit/util/backtracefilter'
-
-module Test
- module Unit
-
- # Ties everything together. If you subclass and add your own
- # test methods, it takes care of making them into tests and
- # wrapping those tests into a suite. It also does the
- # nitty-gritty of actually running an individual test and
- # collecting its results into a Test::Unit::TestResult object.
- #
- # You can run two hooks before/after a TestCase run.
- #
- # Example:
- # class TestMyClass < Test::Unit::TestCase
- # class << self
- # def startup
- # ...
- # end
- #
- # def shutdown
- # ...
- # end
- # end
- #
- # def setup
- # ...
- # end
- #
- # def teardown
- # ...
- # end
- #
- # def test_my_method1
- # ...
- # end
- #
- # def test_my_method2
- # ...
- # end
- # end
- #
- # Here is a call order:
- # * startup
- # * setup
- # * test_my_method1
- # * teardown
- # * setup
- # * test_my_method2
- # * teardown
- # * shutdown
- class TestCase
- include Attribute
- include Fixture
- include ExceptionHandler
- include ErrorHandler
- include FailureHandler
- include TestCasePendingSupport
- include TestCaseOmissionSupport
- include TestCaseNotificationSupport
- include Priority
- include Assertions
- include Util::BacktraceFilter
-
- STARTED = name + "::STARTED"
- FINISHED = name + "::FINISHED"
-
- DESCENDANTS = []
-
- class << self
- def inherited(sub_class)
- DESCENDANTS << sub_class
- end
-
- # Rolls up all of the test* methods in the fixture into
- # one suite, creating a new instance of the fixture for
- # each method.
- def suite
- method_names = public_instance_methods(true).collect {|name| name.to_s}
- tests = method_names.delete_if {|method_name| method_name !~ /^test./}
- suite = TestSuite.new(name, self)
- tests.sort.each do |test|
- catch(:invalid_test) do
- suite << new(test)
- end
- end
- if suite.empty?
- catch(:invalid_test) do
- suite << new("default_test")
- end
- end
- suite
- end
- end
-
- attr_reader :method_name
-
- # Creates a new instance of the fixture for running the
- # test represented by test_method_name.
- def initialize(test_method_name)
- throw :invalid_test unless respond_to?(test_method_name)
- throw :invalid_test if method(test_method_name).arity > 0
- @method_name = test_method_name
- @test_passed = true
- @interrupted = false
- end
-
- # Runs the individual test method represented by this
- # instance of the fixture, collecting statistics, failures
- # and errors in result.
- def run(result)
- begin
- @_result = result
- yield(STARTED, name)
- begin
- run_setup
- run_test
- rescue Exception
- @interrupted = true
- raise unless handle_exception($!)
- ensure
- begin
- run_teardown
- rescue Exception
- raise unless handle_exception($!)
- end
- end
- result.add_run
- yield(FINISHED, name)
- ensure
- @_result = nil
- end
- end
-
- # Called before every test method runs. Can be used
- # to set up fixture information.
- #
- # You can add additional setup tasks by the following
- # code:
- # class TestMyClass < Test::Unit::TestCase
- # def setup
- # ...
- # end
- #
- # setup
- # def my_setup1
- # ...
- # end
- #
- # setup
- # def my_setup2
- # ...
- # end
- #
- # def test_my_class
- # ...
- # end
- # end
- #
- # Here is a call order:
- # * setup
- # * my_setup1
- # * my_setup2
- # * test_my_class
- def setup
- end
-
- # Called after every test method runs. Can be used to tear
- # down fixture information.
- #
- # You can add additional teardown tasks by the following
- # code:
- # class TestMyClass < Test::Unit::TestCase
- # def teardown
- # ...
- # end
- #
- # teardown
- # def my_teardown1
- # ...
- # end
- #
- # teardown
- # def my_teardown2
- # ...
- # end
- #
- # def test_my_class
- # ...
- # end
- # end
- #
- # Here is a call order:
- # * test_my_class
- # * my_teardown2
- # * my_teardown1
- # * teardown
- def teardown
- end
-
- def default_test
- flunk("No tests were specified")
- end
-
- def size
- 1
- end
-
- # Returns a human-readable name for the specific test that
- # this instance of TestCase represents.
- def name
- "#{@method_name}(#{self.class.name})"
- end
-
- # Overridden to return #name.
- def to_s
- name
- end
-
- # It's handy to be able to compare TestCase instances.
- def ==(other)
- return false unless(other.kind_of?(self.class))
- return false unless(@method_name == other.method_name)
- self.class == other.class
- end
-
- def interrupted?
- @interrupted
- end
-
- private
- def current_result
- @_result
- end
-
- def run_test
- __send__(@method_name)
- end
-
- def handle_exception(exception)
- self.class.exception_handlers.each do |handler|
- return true if send(handler, exception)
- end
- false
- end
-
- # Returns whether this individual test passed or
- # not. Primarily for use in teardown so that artifacts
- # can be left behind if the test fails.
- def passed?
- @test_passed
- end
-
- def problem_occurred
- @test_passed = false
- end
-
- def add_assertion
- current_result.add_assertion
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/testresult.rb (+0 -89) 100644
===================================================================
--- test-unit/lib/test/unit/testresult.rb 2010-09-12 03:03:44 +0000 (1af27a0)
+++ /dev/null
@@ -1,89 +0,0 @@
-#--
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit/util/observable'
-require 'test/unit/failure'
-require 'test/unit/error'
-require 'test/unit/omission'
-require 'test/unit/pending'
-require 'test/unit/notification'
-
-module Test
- module Unit
- module NullResultContainerInitializer
- private
- def initialize_containers
- end
- end
-
- # Collects Test::Unit::Failure and Test::Unit::Error so that
- # they can be displayed to the user. To this end, observers
- # can be added to it, allowing the dynamic updating of, say, a
- # UI.
- class TestResult
- include Util::Observable
- include NullResultContainerInitializer
- include TestResultFailureSupport
- include TestResultErrorSupport
- include TestResultPendingSupport
- include TestResultOmissionSupport
- include TestResultNotificationSupport
-
- CHANGED = "CHANGED"
- FAULT = "FAULT"
-
- attr_reader :run_count, :assertion_count, :faults
-
- # Constructs a new, empty TestResult.
- def initialize
- @run_count, @assertion_count = 0, 0
- @summary_generators = []
- @problem_checkers = []
- @faults = []
- initialize_containers
- end
-
- # Records a test run.
- def add_run
- @run_count += 1
- notify_changed
- end
-
- # Records an individual assertion.
- def add_assertion
- @assertion_count += 1
- notify_changed
- end
-
- # Returns a string contain the recorded runs, assertions,
- # failures and errors in this TestResult.
- def summary
- ["#{run_count} tests",
- "#{assertion_count} assertions",
- *@summary_generators.collect {|generator| send(generator)}].join(", ")
- end
-
- def to_s
- summary
- end
-
- # Returns whether or not this TestResult represents
- # successful completion.
- def passed?
- @problem_checkers.all? {|checker| not send(checker)}
- end
-
- private
- def notify_changed
- notify_listeners(CHANGED, self)
- end
-
- def notify_fault(fault)
- @faults << fault
- notify_listeners(FAULT, fault)
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/testsuite.rb (+0 -110) 100644
===================================================================
--- test-unit/lib/test/unit/testsuite.rb 2010-09-12 03:03:44 +0000 (02a2ec3)
+++ /dev/null
@@ -1,110 +0,0 @@
-#--
-#
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit/error'
-
-module Test
- module Unit
-
- # A collection of tests which can be #run.
- #
- # Note: It is easy to confuse a TestSuite instance with
- # something that has a static suite method; I know because _I_
- # have trouble keeping them straight. Think of something that
- # has a suite method as simply providing a way to get a
- # meaningful TestSuite instance.
- class TestSuite
- attr_reader :name, :tests
-
- STARTED = name + "::STARTED"
- FINISHED = name + "::FINISHED"
-
- # Creates a new TestSuite with the given name.
- def initialize(name="Unnamed TestSuite", test_case=nil)
- @name = name
- @tests = []
- @test_case = test_case
- end
-
- # Runs the tests and/or suites contained in this
- # TestSuite.
- def run(result, &progress_block)
- yield(STARTED, name)
- run_startup(result)
- @tests.each do |test|
- test.run(result, &progress_block)
- end
- run_shutdown(result)
- yield(FINISHED, name)
- end
-
- # Adds the test to the suite.
- def <<(test)
- @tests << test
- self
- end
-
- def delete(test)
- @tests.delete(test)
- end
-
- # Retuns the rolled up number of tests in this suite;
- # i.e. if the suite contains other suites, it counts the
- # tests within those suites, not the suites themselves.
- def size
- total_size = 0
- @tests.each { |test| total_size += test.size }
- total_size
- end
-
- def empty?
- tests.empty?
- end
-
- # Overridden to return the name given the suite at
- # creation.
- def to_s
- @name
- end
-
- # It's handy to be able to compare TestSuite instances.
- def ==(other)
- return false unless(other.kind_of?(self.class))
- return false unless(@name == other.name)
- @tests == other.tests
- end
-
- private
- def run_startup(result)
- return if @test_case.nil? or !@test_case.respond_to?(:startup)
- begin
- @test_case.startup
- rescue Exception
- raise unless handle_exception($!, result)
- end
- end
-
- def run_shutdown(result)
- return if @test_case.nil? or !@test_case.respond_to?(:shutdown)
- begin
- @test_case.shutdown
- rescue Exception
- raise unless handle_exception($!, result)
- end
- end
-
- def handle_exception(exception, result)
- case exception
- when *ErrorHandler::PASS_THROUGH_EXCEPTIONS
- false
- else
- result.add_error(Error.new(@test_case.name, exception))
- true
- end
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/ui/console/outputlevel.rb (+0 -14) 100644
===================================================================
--- test-unit/lib/test/unit/ui/console/outputlevel.rb 2010-09-12 03:03:44 +0000 (67e5d9b)
+++ /dev/null
@@ -1,14 +0,0 @@
-module Test
- module Unit
- module UI
- module Console
- module OutputLevel
- SILENT = 0
- PROGRESS_ONLY = 1
- NORMAL = 2
- VERBOSE = 3
- end
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/ui/console/testrunner.rb (+0 -195) 100644
===================================================================
--- test-unit/lib/test/unit/ui/console/testrunner.rb 2010-09-12 03:03:44 +0000 (271a58d)
+++ /dev/null
@@ -1,195 +0,0 @@
-#--
-#
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit/color'
-require 'test/unit/ui/testrunner'
-require 'test/unit/ui/testrunnermediator'
-require 'test/unit/ui/console/outputlevel'
-
-module Test
- module Unit
- module UI
- module Console
-
- # Runs a Test::Unit::TestSuite on the console.
- class TestRunner < UI::TestRunner
- include OutputLevel
-
- COLOR_SCHEMES = {
- :default => {
- "success" => Color.new("green", :bold => true),
- "failure" => Color.new("red", :bold => true),
- "pending" => Color.new("magenta", :bold => true),
- "omission" => Color.new("blue", :bold => true),
- "notification" => Color.new("cyan", :bold => true),
- "error" => Color.new("yellow", :bold => true),
- },
- }
-
- # Creates a new TestRunner for running the passed
- # suite. If quiet_mode is true, the output while
- # running is limited to progress dots, errors and
- # failures, and the final result. io specifies
- # where runner output should go to; defaults to
- # STDOUT.
- def initialize(suite, options={})
- super
- @output_level = @options[:output_level] || NORMAL
- @output = @options[:output] || STDOUT
- @use_color = @options[:use_color]
- @use_color = guess_color_availability if @use_color.nil?
- @color_scheme = COLOR_SCHEMES[:default]
- @reset_color = Color.new("reset")
- @already_outputted = false
- @faults = []
- end
-
- # Begins the test run.
- def start
- setup_mediator
- attach_to_mediator
- return start_mediator
- end
-
- private
- def setup_mediator
- @mediator = create_mediator(@suite)
- output_setup_end
- end
-
- def output_setup_end
- suite_name = @suite.to_s
- suite_name = @suite.name if @suite.kind_of?(Module)
- output("Loaded suite #{suite_name}")
- end
-
- def create_mediator(suite)
- return TestRunnerMediator.new(suite)
- end
-
- def attach_to_mediator
- @mediator.add_listener(TestResult::FAULT, &method(:add_fault))
- @mediator.add_listener(TestRunnerMediator::STARTED, &method(:started))
- @mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished))
- @mediator.add_listener(TestCase::STARTED, &method(:test_started))
- @mediator.add_listener(TestCase::FINISHED, &method(:test_finished))
- end
-
- def start_mediator
- return @mediator.run_suite
- end
-
- def add_fault(fault)
- @faults << fault
- output_single(fault.single_character_display,
- fault_color(fault),
- PROGRESS_ONLY)
- @already_outputted = true
- end
-
- def started(result)
- @result = result
- output_started
- end
-
- def output_started
- output("Started")
- end
-
- def finished(elapsed_time)
- nl if output?(NORMAL) and !output?(VERBOSE)
- nl
- output("Finished in #{elapsed_time} seconds.")
- @faults.each_with_index do |fault, index|
- nl
- output_single("%3d) " % (index + 1))
- label, detail = format_fault(fault).split(/\r?\n/, 2)
- output(label, fault_color(fault))
- output(detail)
- end
- nl
- output(@result, result_color)
- end
-
- def format_fault(fault)
- fault.long_display
- end
-
- def test_started(name)
- output_single(name + ": ", nil, VERBOSE)
- end
-
- def test_finished(name)
- unless @already_outputted
- output_single(".", @color_scheme["success"], PROGRESS_ONLY)
- end
- nl(VERBOSE)
- @already_outputted = false
- end
-
- def nl(level=NORMAL)
- output("", nil, level)
- end
-
- def output(something, color=nil, level=NORMAL)
- return unless output?(level)
- output_single(something, color, level)
- @output.puts
- end
-
- def output_single(something, color=nil, level=NORMAL)
- return unless output?(level)
- if @use_color and color
- something = "%s%s%s" % [color.escape_sequence,
- something,
- @reset_color.escape_sequence]
- end
- @output.write(something)
- @output.flush
- end
-
- def output?(level)
- level <= @output_level
- end
-
- def fault_color(fault)
- @color_scheme[fault.class.name.split(/::/).last.downcase]
- end
-
- def result_color
- if @result.passed?
- if @result.pending_count > 0
- @color_scheme["pending"]
- elsif @result.omission_count > 0
- @color_scheme["omission"]
- elsif @result.notification_count > 0
- @color_scheme["notification"]
- else
- @color_scheme["success"]
- end
- elsif @result.error_count > 0
- @color_scheme["error"]
- elsif @result.failure_count > 0
- @color_scheme["failure"]
- end
- end
-
- def guess_color_availability
- return false unless @output.tty?
- term = ENV["TERM"]
- return true if term and (/term\z/ =~ term or term == "screen")
- return true if ENV["EMACS"] == "t"
- false
- end
- end
- end
- end
- end
-end
-
-if __FILE__ == $0
- Test::Unit::UI::Console::TestRunner.start_command_line_test
-end
Deleted: test-unit/lib/test/unit/ui/emacs/testrunner.rb (+0 -49) 100644
===================================================================
--- test-unit/lib/test/unit/ui/emacs/testrunner.rb 2010-09-12 03:03:44 +0000 (eed17a7)
+++ /dev/null
@@ -1,49 +0,0 @@
-require 'test/unit/ui/console/testrunner'
-
-module Test
- module Unit
- module UI
- module Emacs
- class TestRunner < Console::TestRunner
- private
- def output_setup_end
- end
-
- def output_started
- end
-
- def format_fault(fault)
- return super unless fault.respond_to?(:label)
- format_method_name = "format_fault_#{fault.label.downcase}"
- if respond_to?(format_method_name, true)
- send(format_method_name, fault)
- else
- super
- end
- end
-
- def format_fault_failure(failure)
- if failure.location.size == 1
- location = failure.location[0]
- location_display = location.sub(/\A(.+:\d+).*/, ' [\\1]')
- else
- location_display = "\n" + failure.location.join("\n")
- end
- result = "#{failure.label}:\n"
- result << "#{failure.test_name}#{location_display}:\n"
- result << failure.message
- result
- end
-
- def format_fault_error(error)
- result = "#{error.label}:\n"
- result << "#{error.test_name}:\n"
- result << "#{error.message}\n"
- result << error.backtrace.join("\n")
- result
- end
- end
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/ui/testrunner.rb (+0 -20) 100644
===================================================================
--- test-unit/lib/test/unit/ui/testrunner.rb 2010-09-12 03:03:44 +0000 (e872b03)
+++ /dev/null
@@ -1,20 +0,0 @@
-require 'test/unit/ui/testrunnerutilities'
-
-module Test
- module Unit
- module UI
- class TestRunner
- extend TestRunnerUtilities
-
- def initialize(suite, options={})
- if suite.respond_to?(:suite)
- @suite = suite.suite
- else
- @suite = suite
- end
- @options = options
- end
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/ui/testrunnermediator.rb (+0 -77) 100644
===================================================================
--- test-unit/lib/test/unit/ui/testrunnermediator.rb 2010-09-12 03:03:44 +0000 (7033f3b)
+++ /dev/null
@@ -1,77 +0,0 @@
-#--
-#
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit'
-require 'test/unit/util/observable'
-require 'test/unit/testresult'
-
-module Test
- module Unit
- module UI
-
- # Provides an interface to write any given UI against,
- # hopefully making it easy to write new UIs.
- class TestRunnerMediator
- RESET = name + "::RESET"
- STARTED = name + "::STARTED"
- FINISHED = name + "::FINISHED"
-
- include Util::Observable
-
- # Creates a new TestRunnerMediator initialized to run
- # the passed suite.
- def initialize(suite)
- @suite = suite
- end
-
- # Runs the suite the TestRunnerMediator was created
- # with.
- def run_suite
- Unit.run = true
-
- result = create_result
- result_listener = result.add_listener(TestResult::CHANGED) do |*args|
- notify_listeners(TestResult::CHANGED, *args)
- end
- fault_listener = result.add_listener(TestResult::FAULT) do |*args|
- notify_listeners(TestResult::FAULT, *args)
- end
-
- start_time = Time.now
- begin
- notify_listeners(RESET, @suite.size)
- notify_listeners(STARTED, result)
-
- @suite.run(result) do |channel, value|
- notify_listeners(channel, value)
- end
- ensure
- elapsed_time = Time.now - start_time
- result.remove_listener(TestResult::FAULT, fault_listener)
- result.remove_listener(TestResult::CHANGED, result_listener)
- notify_listeners(FINISHED, elapsed_time)
- end
-
- result
- end
-
- private
- # A factory method to create the result the mediator
- # should run with. Can be overridden by subclasses if
- # one wants to use a different result.
- def create_result
- TestResult.new
- end
-
- def measure_time
- begin_time = Time.now
- yield
- Time.now - begin_time
- end
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/ui/testrunnerutilities.rb (+0 -41) 100644
===================================================================
--- test-unit/lib/test/unit/ui/testrunnerutilities.rb 2010-09-12 03:03:44 +0000 (33d80fb)
+++ /dev/null
@@ -1,41 +0,0 @@
-#--
-#
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-module Test
- module Unit
- module UI
-
- # Provides some utilities common to most, if not all,
- # TestRunners.
- #
- #--
- #
- # Perhaps there ought to be a TestRunner superclass? There
- # seems to be a decent amount of shared code between test
- # runners.
-
- module TestRunnerUtilities
-
- # Creates a new TestRunner and runs the suite.
- def run(suite, options={})
- return new(suite, options).start
- end
-
- # Takes care of the ARGV parsing and suite
- # determination necessary for running one of the
- # TestRunners from the command line.
- def start_command_line_test
- if ARGV.empty?
- puts "You should supply the name of a test suite file to the runner"
- exit
- end
- require ARGV[0].gsub(/.+::/, '')
- new(eval(ARGV[0])).start
- end
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/util/backtracefilter.rb (+0 -41) 100644
===================================================================
--- test-unit/lib/test/unit/util/backtracefilter.rb 2010-09-12 03:03:44 +0000 (1ea8103)
+++ /dev/null
@@ -1,41 +0,0 @@
-module Test
- module Unit
- module Util
- module BacktraceFilter
- TESTUNIT_FILE_SEPARATORS = %r{[\\/:]}
- TESTUNIT_PREFIX = __FILE__.split(TESTUNIT_FILE_SEPARATORS)[0..-3]
- TESTUNIT_RB_FILE = /\.rb\Z/
-
- module_function
- def filter_backtrace(backtrace, prefix=nil)
- return ["No backtrace"] unless(backtrace)
- split_p = if(prefix)
- prefix.split(TESTUNIT_FILE_SEPARATORS)
- else
- TESTUNIT_PREFIX
- end
- match = proc do |e|
- split_e = e.split(TESTUNIT_FILE_SEPARATORS)[0, split_p.size]
- next false unless(split_e[0..-2] == split_p[0..-2])
- split_e[-1].sub(TESTUNIT_RB_FILE, '') == split_p[-1]
- end
- return backtrace unless(backtrace.detect(&match))
- found_prefix = false
- new_backtrace = backtrace.reverse.reject do |e|
- if(match[e])
- found_prefix = true
- true
- elsif(found_prefix)
- false
- else
- true
- end
- end.reverse
- new_backtrace = (new_backtrace.empty? ? backtrace : new_backtrace)
- new_backtrace = new_backtrace.reject(&match)
- new_backtrace.empty? ? backtrace : new_backtrace
- end
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/util/observable.rb (+0 -90) 100644
===================================================================
--- test-unit/lib/test/unit/util/observable.rb 2010-09-12 03:03:44 +0000 (3567d34)
+++ /dev/null
@@ -1,90 +0,0 @@
-#--
-#
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit/util/procwrapper'
-
-module Test
- module Unit
- module Util
-
- # This is a utility class that allows anything mixing
- # it in to notify a set of listeners about interesting
- # events.
- module Observable
- # We use this for defaults since nil might mean something
- NOTHING = "NOTHING/#{__id__}"
-
- # Adds the passed proc as a listener on the
- # channel indicated by channel_name. listener_key
- # is used to remove the listener later; if none is
- # specified, the proc itself is used.
- #
- # Whatever is used as the listener_key is
- # returned, making it very easy to use the proc
- # itself as the listener_key:
- #
- # listener = add_listener("Channel") { ... }
- # remove_listener("Channel", listener)
- def add_listener(channel_name, listener_key=NOTHING, &listener) # :yields: value
- unless(block_given?)
- raise ArgumentError.new("No callback was passed as a listener")
- end
-
- key = listener_key
- if (listener_key == NOTHING)
- listener_key = listener
- key = ProcWrapper.new(listener)
- end
-
- channels[channel_name] ||= {}
- channels[channel_name][key] = listener
- return listener_key
- end
-
- # Removes the listener indicated by listener_key
- # from the channel indicated by
- # channel_name. Returns the registered proc, or
- # nil if none was found.
- def remove_listener(channel_name, listener_key)
- channel = channels[channel_name]
- return nil unless (channel)
- key = listener_key
- if (listener_key.instance_of?(Proc))
- key = ProcWrapper.new(listener_key)
- end
- if (channel.has_key?(key))
- return channel.delete(key)
- end
- return nil
- end
-
- # Calls all the procs registered on the channel
- # indicated by channel_name. If value is
- # specified, it is passed in to the procs,
- # otherwise they are called with no arguments.
- #
- #--
- #
- # Perhaps this should be private? Would it ever
- # make sense for an external class to call this
- # method directly?
- def notify_listeners(channel_name, *arguments)
- channel = channels[channel_name]
- return 0 unless (channel)
- listeners = channel.values
- listeners.each { |listener| listener.call(*arguments) }
- return listeners.size
- end
-
- private
- def channels
- @channels ||= {}
- return @channels
- end
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/util/procwrapper.rb (+0 -48) 100644
===================================================================
--- test-unit/lib/test/unit/util/procwrapper.rb 2010-09-12 03:03:44 +0000 (ad72521)
+++ /dev/null
@@ -1,48 +0,0 @@
-#--
-#
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-module Test
- module Unit
- module Util
-
- # Allows the storage of a Proc passed through '&' in a
- # hash.
- #
- # Note: this may be inefficient, since the hash being
- # used is not necessarily very good. In Observable,
- # efficiency is not too important, since the hash is
- # only accessed when adding and removing listeners,
- # not when notifying.
-
- class ProcWrapper
-
- # Creates a new wrapper for a_proc.
- def initialize(a_proc)
- @a_proc = a_proc
- @hash = a_proc.inspect.sub(/^(#<#{a_proc.class}:)/){''}.sub(/(>)$/){''}.hex
- end
-
- def hash
- return @hash
- end
-
- def ==(other)
- case(other)
- when ProcWrapper
- return @a_proc == other.to_proc
- else
- return super
- end
- end
- alias :eql? :==
-
- def to_proc
- return @a_proc
- end
- end
- end
- end
-end
Deleted: test-unit/lib/test/unit/version.rb (+0 -7) 100644
===================================================================
--- test-unit/lib/test/unit/version.rb 2010-09-12 03:03:44 +0000 (9d65d76)
+++ /dev/null
@@ -1,7 +0,0 @@
-
-# HACK: quick and dirty to get integrated into the new project - ryan
-module Test
- module Unit
- VERSION = '2.0.1'
- end
-end
Deleted: test-unit/sample/adder.rb (+0 -13) 100644
===================================================================
--- test-unit/sample/adder.rb 2010-09-12 03:03:44 +0000 (aa5c88c)
+++ /dev/null
@@ -1,13 +0,0 @@
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-class Adder
- def initialize(number)
- @number = number
- end
- def add(number)
- return @number + number
- end
-end
-
Deleted: test-unit/sample/subtracter.rb (+0 -12) 100644
===================================================================
--- test-unit/sample/subtracter.rb 2010-09-12 03:03:44 +0000 (2c08247)
+++ /dev/null
@@ -1,12 +0,0 @@
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-class Subtracter
- def initialize(number)
- @number = number
- end
- def subtract(number)
- return @number - number
- end
-end
Deleted: test-unit/sample/tc_adder.rb (+0 -18) 100644
===================================================================
--- test-unit/sample/tc_adder.rb 2010-09-12 03:03:44 +0000 (8453beb)
+++ /dev/null
@@ -1,18 +0,0 @@
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit'
-require 'adder'
-
-class TC_Adder < Test::Unit::TestCase
- def setup
- @adder = Adder.new(5)
- end
- def test_add
- assert_equal(7, @adder.add(2), "Should have added correctly")
- end
- def teardown
- @adder = nil
- end
-end
Deleted: test-unit/sample/tc_subtracter.rb (+0 -18) 100644
===================================================================
--- test-unit/sample/tc_subtracter.rb 2010-09-12 03:03:44 +0000 (d2c8313)
+++ /dev/null
@@ -1,18 +0,0 @@
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit'
-require 'subtracter'
-
-class TC_Subtracter < Test::Unit::TestCase
- def setup
- @subtracter = Subtracter.new(5)
- end
- def test_subtract
- assert_equal(3, @subtracter.subtract(2), "Should have subtracted correctly")
- end
- def teardown
- @subtracter = nil
- end
-end
Deleted: test-unit/sample/ts_examples.rb (+0 -7) 100644
===================================================================
--- test-unit/sample/ts_examples.rb 2010-09-12 03:03:44 +0000 (3d24dd6)
+++ /dev/null
@@ -1,7 +0,0 @@
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit'
-require 'tc_adder'
-require 'tc_subtracter'
Deleted: test-unit/test/collector/test_descendant.rb (+0 -135) 100644
===================================================================
--- test-unit/test/collector/test_descendant.rb 2010-09-12 03:03:44 +0000 (6b6132e)
+++ /dev/null
@@ -1,135 +0,0 @@
-require 'test/unit'
-require 'test/unit/collector/descendant'
-
-class TestUnitCollectorDescendant < Test::Unit::TestCase
- def setup
- @previous_descendants = Test::Unit::TestCase::DESCENDANTS.dup
- Test::Unit::TestCase::DESCENDANTS.clear
-
- @test_case1 = Class.new(Test::Unit::TestCase) do
- def self.name
- "test-case1"
- end
-
- def test_1
- end
-
- def test_2
- end
- end
-
- @test_case2 = Class.new(Test::Unit::TestCase) do
- def self.name
- "test-case2"
- end
-
- def test_0
- end
- end
-
- @no_test_case = Class.new do
- def self.name
- "no-test-case"
- end
-
- def test_4
- end
- end
- end
-
- def teardown
- Test::Unit::TestCase::DESCENDANTS.replace(@previous_descendants)
- end
-
- def test_basic_collection
- assert_collect(full_suite("name"), "name")
-
- assert_collect(full_suite("name"), "name") do |collector|
- collector.filter = []
- end
- end
-
- def test_filtered_collection
- assert_collect(empty_suite) do |collector|
- collector.filter = Proc.new {false}
- end
-
- assert_collect(full_suite) do |collector|
- collector.filter = Proc.new {true}
- end
-
- assert_collect(full_suite) do |collector|
- collector.filter = Proc.new {nil}
- end
-
- assert_collect(empty_suite) do |collector|
- collector.filter = [Proc.new {false}, Proc.new {true}]
- end
-
- assert_collect(full_suite) do |collector|
- collector.filter = [Proc.new {true}, Proc.new {false}]
- end
-
- assert_collect(empty_suite) do |collector|
- collector.filter = [Proc.new {nil}, Proc.new {false}]
- end
-
- assert_collect(full_suite) do |collector|
- collector.filter = [Proc.new {nil}, Proc.new {true}]
- end
-
- expected = empty_suite
- suite1 = Test::Unit::TestSuite.new(@test_case1.name)
- suite1 << @test_case1.new("test_1")
- suite2 = Test::Unit::TestSuite.new(@test_case2.name)
- suite2 << @test_case2.new("test_0")
- expected << suite1 << suite2
- assert_collect(expected) do |collector|
- collector.filter = Proc.new do |test|
- ['test_1', 'test_0'].include?(test.method_name)
- end
- end
-
- expected = empty_suite
- suite1 = Test::Unit::TestSuite.new(@test_case1.name)
- suite1 << @test_case1.new("test_1")
- suite2 = Test::Unit::TestSuite.new(@test_case2.name)
- suite2 << @test_case2.new("test_0")
- expected << suite1 << suite2
- assert_collect(expected) do |collector|
- filters = [Proc.new {|test| test.method_name == 'test_1' ? true : nil},
- Proc.new {|test| test.method_name == 'test_0' ? true : nil},
- Proc.new {false}]
- collector.filter = filters
- end
- end
-
- private
- def assert_collect(expected, *collect_args)
- collector = Test::Unit::Collector::Descendant.new
- yield(collector) if block_given?
- assert_equal(expected, collector.send(:collect, *collect_args))
- end
-
- def default_name
- Test::Unit::Collector::Descendant::NAME
- end
-
- def empty_suite(name=nil)
- Test::Unit::TestSuite.new(name || default_name)
- end
-
- def full_suite(name=nil)
- sub_suite1 = Test::Unit::TestSuite.new(@test_case1.name)
- sub_suite1 << @test_case1.new('test_1')
- sub_suite1 << @test_case1.new('test_2')
-
- sub_suite2 = Test::Unit::TestSuite.new(@test_case2.name)
- sub_suite2 << @test_case2.new('test_0')
-
- suite = empty_suite(name)
- suite << sub_suite1
- suite << sub_suite2
- suite
- end
-end
Deleted: test-unit/test/collector/test_dir.rb (+0 -406) 100644
===================================================================
--- test-unit/test/collector/test_dir.rb 2010-09-12 03:03:44 +0000 (2de802c)
+++ /dev/null
@@ -1,406 +0,0 @@
-require 'test/unit'
-require 'test/unit/collector/dir'
-require 'pp'
-
-module Test
- module Unit
- module Collector
- class TestDir < TestCase
- class FileSystem
- class Directory
- def initialize(name, fs, parent=self, &block)
- @name = name
- @fs = fs
- @parent = parent
- @contents = {'.' => self, '..' => parent}
- instance_eval(&block) if(block)
- end
-
- def file(name, contents)
- @contents[name] = contents
- end
-
- def dir(name, &block)
- @contents[name] = self.class.new(name, @fs, self, &block)
- end
-
- def entries
- @contents.keys
- end
-
- def directory?(name)
- return true if(name.nil? || name.empty?)
- return false unless(@contents.include?(name))
- @contents[name].kind_of?(self.class)
- end
-
- def file?(name)
- return false unless(@contents.include?(name))
- !directory?(name)
- end
-
- def exist?(name)
- @contents.include?(name)
- end
-
- def [](name)
- raise Errno::ENOENT, name unless(@contents.include?(name))
- @contents[name]
- end
-
- def path_to(name=nil)
- if(!name)
- @parent.path_to(@name)
- elsif(@parent == self)
- @fs.join('/', name)
- else
- @fs.join(@parent.path_to(@name), name)
- end
- end
- end
-
- class ObjectSpace
- def initialize
- @objects = []
- end
-
- def each_object(klass, &block)
- @objects.find_all{|o| o.kind_of?(klass)}.each(&block)
- end
-
- def <<(object)
- @objects << object
- end
- end
-
- attr_reader :object_space
-
- def initialize(&block)
- @root = Directory.new('/', self, &block)
- @pwd = @root
- @object_space = ObjectSpace.new
- @required = []
- end
-
- def entries(dir)
- e = find(dir)
- require_directory(dir)
- e.entries
- end
-
- def directory?(name)
- return true if (base = basename(name)) == '/'
- e = find(dirname(name))
- return false unless(e)
- e.directory?(base)
- end
-
- def find(path)
- if(/\A\// =~ path)
- thing = @root
- else
- thing = @pwd
- end
- path.scan(/[^\/]+/) do |e|
- break thing = false unless(thing.kind_of?(Directory))
- thing = thing[e]
- end
- thing
- end
-
- def dirname(name)
- if (name = name.tr_s('/', '/')) == '/'
- name
- else
- name[%r"\A.+(?=/[^/]+/?\z)|\A/"] || "."
- end
- end
-
- def basename(name)
- name[%r"(\A/|[^/]+)/*\z", 1]
- end
-
- def split(name)
- [dirname(name), basename(name)]
- end
-
- def join(*parts)
- parts.join('/').gsub(%r{/+}, '/')
- end
-
- def file?(name)
- e = find(dirname(name))
- return false unless(e)
- e.file?(basename(name))
- end
-
- def pwd
- @pwd.path_to
- end
-
- def chdir(to)
- e = find(to)
- require_directory(to)
- @pwd = e
- end
-
- def expand_path(path, base = nil)
- until /\A\// =~ path
- base ||= pwd
- path = join(base, path)
- base = nil
- end
- path.gsub!(%r"(?:/\.)+(?=/)", '')
- nil while path.sub!(%r"/(?!\.\./)[^/]+/\.\.(?=/)", '')
- path.sub!(%r"\A(?:/\.\.)+(?=/)", '')
- path.sub!(%r"(?:\A(/)|/)\.\.?\z", '\1')
- path
- end
-
- def require_directory(path)
- raise Errno::ENOTDIR, path unless(directory?(path))
- end
-
- def require(file)
- return false if(@required.include?(file))
- begin
- e = find(file)
- rescue Errno::ENOENT => e
- if(/\.rb\Z/ =~ file)
- raise LoadError, file
- end
- e = find(file + '.rb')
- end
- @required << file
- @object_space << e
- true
- rescue Errno::ENOENT
- raise LoadError, file
- end
- end
-
- def test_dir
- inner_dir = nil
- dirs = FileSystem::Directory.new('/', nil) do
- file 'a', nil
- inner_dir = dir 'b'
- end
- assert_equal(inner_dir, dirs['b'])
- end
-
- def test_fs
- fs = FileSystem.new do
- file 'a', nil
- dir 'b'
- end
- assert_equal(['.', '..', 'a', 'b'].sort, fs.entries('/').sort)
- assert(fs.directory?('/'))
- assert(!fs.directory?('/a'))
- assert(!fs.directory?('/bogus'))
- assert(fs.file?('/a'))
- assert(!fs.file?('/'))
- assert(!fs.file?('/bogus'))
- assert(fs.directory?('/b'))
- assert(fs.file?('a'))
- assert(fs.directory?('b'))
- end
-
- def test_fs_sub
- fs = FileSystem.new do
- dir 'a' do
- file 'b', nil
- dir 'c' do
- file 'd', nil
- end
- end
- end
- assert(fs.file?('/a/b'))
- assert(!fs.file?('/a/b/c/d'))
- assert(fs.file?('/a/c/d'))
- end
-
- def test_fs_pwd
- fs = FileSystem.new do
- file 'a', nil
- dir 'b' do
- file 'c', nil
- dir 'd' do
- file 'e', nil
- end
- end
- end
- assert_equal('/', fs.pwd)
- assert_raises(Errno::ENOENT) do
- fs.chdir('bogus')
- end
- assert_raises(Errno::ENOTDIR) do
- fs.chdir('a')
- end
- fs.chdir('b')
- assert_equal('/b', fs.pwd)
- fs.chdir('d')
- assert_equal('/b/d', fs.pwd)
- fs.chdir('..')
- assert_equal('/b', fs.pwd)
- fs.chdir('..')
- assert_equal('/', fs.pwd)
- end
-
- def test_fs_entries
- fs = FileSystem.new do
- file 'a', nil
- dir 'b' do
- file 'c', nil
- file 'd', nil
- end
- file 'e', nil
- dir 'f' do
- file 'g', nil
- dir 'h' do
- file 'i', nil
- end
- end
- end
- assert_equal(['.', '..', 'a', 'b', 'e', 'f'], fs.entries('/').sort)
- assert_equal(['.', '..', 'a', 'b', 'e', 'f'], fs.entries('.').sort)
- assert_equal(['.', '..', 'a', 'b', 'e', 'f'], fs.entries('b/..').sort)
- assert_equal(['.', '..', 'c', 'd'], fs.entries('b').sort)
- assert_raises(Errno::ENOENT) do
- fs.entries('z')
- end
- assert_raises(Errno::ENOTDIR) do
- fs.entries('a')
- end
- fs.chdir('f')
- assert_equal(['.', '..', 'i'], fs.entries('h').sort)
- end
-
- class TestClass1
- end
- class TestClass2
- end
- def test_fs_require
- fs = FileSystem.new do
- file 'test_class1.rb', TestClass1
- dir 'dir' do
- file 'test_class2.rb', TestClass2
- end
- end
- c = []
- fs.object_space.each_object(Class) do |o|
- c << o
- end
- assert_equal([], c)
-
- assert_raises(LoadError) do
- fs.require('bogus')
- end
-
- assert(fs.require('test_class1.rb'))
- assert(!fs.require('test_class1.rb'))
- c = []
- fs.object_space.each_object(Class) do |o|
- c << o
- end
- assert_equal([TestClass1], c)
-
- fs.require('dir/test_class2')
- c = []
- fs.object_space.each_object(Class) do |o|
- c << o
- end
- assert_equal([TestClass1, TestClass2], c)
-
- c = []
- fs.object_space.each_object(Time) do |o|
- c << o
- end
- assert_equal([], c)
- end
-
- def setup
- @t1 = t1 = create_test(1)
- @t2 = t2 = create_test(2)
- @t3 = t3 = create_test(3)
- @t4 = t4 = create_test(4)
- @t5 = t5 = create_test(5)
- @t6 = t6 = create_test(6)
- fs = FileSystem.new do
- file 'test_1.rb', t1
- file 'test_2.rb', t2
- dir 'd1' do
- file 'test_3.rb', t3
- end
- file 't4.rb', t4
- dir 'd2' do
- file 'test_5', t5
- file 'test_6.rb', Time
- end
- file 't6.rb', t6
- end
- fs.require('t6')
- @c = Dir.new(fs, fs, fs.object_space, fs)
- end
-
- def create_test(name)
- t = Class.new(TestCase)
- t.class_eval <<-EOC
- def self.name
- "T\#{#{name}}"
- end
- def test_#{name}a
- end
- def test_#{name}b
- end
- EOC
- t
- end
-
- def test_simple_collect
- expected = TestSuite.new('d1')
- expected << (@t3.suite)
- assert_equal(expected, @c.collect('d1'))
- end
-
- def test_multilevel_collect
- expected = TestSuite.new('.')
- expected << @t1.suite << @t2.suite
- expected << (TestSuite.new('d1') << @t3.suite)
- assert_equal(expected, @c.collect)
- end
-
- def test_collect_file
- expected = TestSuite.new('test_1.rb')
- expected << @t1.suite
- assert_equal(expected, @c.collect('test_1.rb'))
-
- expected = TestSuite.new('t4.rb')
- expected << @t4.suite
- assert_equal(expected, @c.collect('t4.rb'))
- end
-
- def test_nil_pattern
- expected = TestSuite.new('d2')
- expected << @t5.suite
- @c.pattern.clear
- assert_equal(expected, @c.collect('d2'))
- end
-
- def test_filtering
- expected = TestSuite.new('.')
- expected << @t1.suite
- @c.filter = proc{|t| t.method_name == 'test_1a' || t.method_name == 'test_1b'}
- assert_equal(expected, @c.collect)
- end
-
- def test_collect_multi
- expected = TestSuite.new('[d1, d2]')
- expected << (TestSuite.new('d1') << @t3.suite)
- expected << (TestSuite.new('d2') << @t5.suite)
- @c.pattern.replace([/\btest_/])
- assert_equal(expected, @c.collect('d1', 'd2'))
- end
- end
- end
- end
-end
Deleted: test-unit/test/collector/test_load.rb (+0 -333) 100644
===================================================================
--- test-unit/test/collector/test_load.rb 2010-09-12 03:03:44 +0000 (051c764)
+++ /dev/null
@@ -1,333 +0,0 @@
-require 'tmpdir'
-require 'pathname'
-
-require 'test/unit'
-require 'test/unit/collector/load'
-
-class TestUnitCollectorLoad < Test::Unit::TestCase
- def setup
- @previous_descendants = Test::Unit::TestCase::DESCENDANTS.dup
- Test::Unit::TestCase::DESCENDANTS.clear
-
- @temporary_test_cases_module_name = "TempTestCases"
- ::Object.const_set(@temporary_test_cases_module_name, Module.new)
-
- @test_dir = Pathname(Dir.tmpdir) + "test-unit"
- @test_dir.rmtree if @test_dir.exist?
- @test_dir.mkpath
- end
-
- setup
- def setup_top_level_test_cases
- @test_case1 = @test_dir + "test_case1.rb"
- @test_case2 = @test_dir + "test_case2.rb"
- @no_load_test_case3 = @test_dir + "case3.rb"
-
- @test_case1.open("w") do |test_case|
- test_case.puts(<<-EOT)
-module #{@temporary_test_cases_module_name}
- class TestCase1 < Test::Unit::TestCase
- def test1_1
- end
-
- def test1_2
- end
- end
-end
-EOT
- end
-
- @test_case2.open("w") do |test_case|
- test_case.puts(<<-EOT)
-module #{@temporary_test_cases_module_name}
- class TestCase2 < Test::Unit::TestCase
- def test2
- end
- end
-end
-EOT
- end
-
- @no_load_test_case3.open("w") do |test_case|
- test_case.puts(<<-EOT)
-module #{@temporary_test_cases_module_name}
- class NoLoadTestCase3 < Test::Unit::TestCase
- def test3
- end
- end
-end
-EOT
- end
- end
-
- setup
- def setup_sub_level_test_cases
- @sub_test_dir = @test_dir + "sub"
- @sub_test_dir.mkpath
-
- @sub_test_case4 = @sub_test_dir + "test_case4.rb"
- @no_load_sub_test_case5 = @sub_test_dir + "case5.rb"
- @sub_test_case6 = @sub_test_dir + "test_case6.rb"
-
- @sub_test_case4.open("w") do |test_case|
- test_case.puts(<<-EOT)
-module #{@temporary_test_cases_module_name}
- class SubTestCase4 < Test::Unit::TestCase
- def test4_1
- end
-
- def test4_2
- end
- end
-end
-EOT
- end
-
- @no_load_sub_test_case5.open("w") do |test_case|
- test_case.puts(<<-EOT)
-module #{@temporary_test_cases_module_name}
- class NoLoadSubTestCase5 < Test::Unit::TestCase
- def test5_1
- end
-
- def test5_2
- end
- end
-end
-EOT
- end
-
- @sub_test_case6.open("w") do |test_case|
- test_case.puts(<<-EOT)
-module #{@temporary_test_cases_module_name}
- class SubTestCase6 < Test::Unit::TestCase
- def test6
- end
- end
-end
-EOT
- end
- end
-
- setup
- def setup_sub_level_test_cases2
- @sub2_test_dir = @test_dir + "sub2"
- @sub2_test_dir.mkpath
-
- @no_load_sub2_test_case7 = @sub2_test_dir + "case7.rb"
- @sub2_test_case8 = @sub2_test_dir + "test_case8.rb"
- @sub2_test_case9 = @sub2_test_dir + "test_case9.rb"
-
- @no_load_sub2_test_case7.open("w") do |test_case|
- test_case.puts(<<-EOT)
-module #{@temporary_test_cases_module_name}
- class NoLoadSub2TestCase7 < Test::Unit::TestCase
- def test7_1
- end
-
- def test7_2
- end
- end
-end
-EOT
- end
-
- @sub2_test_case8.open("w") do |test_case|
- test_case.puts(<<-EOT)
-module #{@temporary_test_cases_module_name}
- class Sub2TestCase8 < Test::Unit::TestCase
- def test8_1
- end
-
- def test8_2
- end
- end
-end
-EOT
- end
-
- @sub2_test_case9.open("w") do |test_case|
- test_case.puts(<<-EOT)
-module #{@temporary_test_cases_module_name}
- class Sub2TestCase9 < Test::Unit::TestCase
- def test9
- end
- end
-end
-EOT
- end
- end
-
- setup
- def setup_svn_test_cases
- @svn_test_dir = @test_dir + ".svn"
- @svn_test_dir.mkpath
-
- @svn_test_case10 = @svn_test_dir + "test_case10.rb"
-
- @svn_test_case10.open("w") do |test_case|
- test_case.puts(<<-EOT)
-module #{@temporary_test_cases_module_name}
- class SvnTestCase10 < Test::Unit::TestCase
- def test7
- end
- end
-end
-EOT
- end
- end
-
- setup
- def setup_sub_cvs_test_cases
- @sub_cvs_test_dir = @sub_test_dir + "CVS"
- @sub_cvs_test_dir.mkpath
-
- @sub_cvs_test_case11 = @sub_cvs_test_dir + "test_case11.rb"
-
- @sub_cvs_test_case11.open("w") do |test_case|
- test_case.puts(<<-EOT)
-module #{@temporary_test_cases_module_name}
- class SubCVSTestCase11 < Test::Unit::TestCase
- def test11
- end
- end
-end
-EOT
- end
- end
-
- def teardown
- @test_dir.rmtree if @test_dir.exist?
- ::Object.send(:remove_const, @temporary_test_cases_module_name)
- Test::Unit::TestCase::DESCENDANTS.replace(@previous_descendants)
- end
-
- def test_simple_collect
- assert_collect([:suite, {:name => @sub_test_dir.basename.to_s},
- [:suite, {:name => _test_case_name("SubTestCase4")},
- [:test, {:name => "test4_1"}],
- [:test, {:name => "test4_2"}]],
- [:suite, {:name => _test_case_name("SubTestCase6")},
- [:test, {:name => "test6"}]]],
- @sub_test_dir.to_s)
- end
-
- def test_multilevel_collect
- assert_collect([:suite, {:name => "."},
- [:suite, {:name => _test_case_name("TestCase1")},
- [:test, {:name => "test1_1"}],
- [:test, {:name => "test1_2"}]],
- [:suite, {:name => _test_case_name("TestCase2")},
- [:test, {:name => "test2"}]],
- [:suite, {:name => @sub_test_dir.basename.to_s},
- [:suite, {:name => _test_case_name("SubTestCase4")},
- [:test, {:name => "test4_1"}],
- [:test, {:name => "test4_2"}]],
- [:suite, {:name => _test_case_name("SubTestCase6")},
- [:test, {:name => "test6"}]]],
- [:suite, {:name => @sub2_test_dir.basename.to_s},
- [:suite, {:name => _test_case_name("Sub2TestCase8")},
- [:test, {:name => "test8_1"}],
- [:test, {:name => "test8_2"}]],
- [:suite, {:name => _test_case_name("Sub2TestCase9")},
- [:test, {:name => "test9"}]]]])
- end
-
- def test_collect_file
- assert_collect([:suite, {:name => @test_case1.basename.to_s},
- [:suite, {:name => _test_case_name("TestCase1")},
- [:test, {:name => "test1_1"}],
- [:test, {:name => "test1_2"}]]],
- @test_case1.to_s)
-
- assert_collect([:suite, {:name => @no_load_sub_test_case5.basename.to_s},
- [:suite, {:name => _test_case_name("NoLoadSubTestCase5")},
- [:test, {:name => "test5_1"}],
- [:test, {:name => "test5_2"}]]],
- @no_load_sub_test_case5.to_s)
- end
-
- def test_nil_pattern
- assert_collect([:suite, {:name => @sub_test_dir.basename.to_s},
- [:suite, {:name => _test_case_name("NoLoadSubTestCase5")},
- [:test, {:name => "test5_1"}],
- [:test, {:name => "test5_2"}]],
- [:suite, {:name => _test_case_name("SubTestCase4")},
- [:test, {:name => "test4_1"}],
- [:test, {:name => "test4_2"}]],
- [:suite, {:name => _test_case_name("SubTestCase6")},
- [:test, {:name => "test6"}]]],
- @sub_test_dir.to_s) do |collector|
- collector.patterns.clear
- end
- end
-
- def test_filtering
- assert_collect([:suite, {:name => "."},
- [:suite, {:name => _test_case_name("TestCase1")},
- [:test, {:name => "test1_1"}],
- [:test, {:name => "test1_2"}]]]) do |collector|
- collector.filter = Proc.new do |test|
- not /\Atest1/.match(test.method_name).nil?
- end
- end
- end
-
- def test_collect_multi
- test_dirs = [@sub_test_dir.to_s, @sub2_test_dir.to_s]
- assert_collect([:suite, {:name => "[#{test_dirs.join(', ')}]"},
- [:suite, {:name => @sub_test_dir.basename.to_s},
- [:suite, {:name => _test_case_name("SubTestCase4")},
- [:test, {:name => "test4_1"}],
- [:test, {:name => "test4_2"}]],
- [:suite, {:name => _test_case_name("SubTestCase6")},
- [:test, {:name => "test6"}]]],
- [:suite, {:name => @sub2_test_dir.basename.to_s},
- [:suite, {:name => _test_case_name("Sub2TestCase8")},
- [:test, {:name => "test8_1"}],
- [:test, {:name => "test8_2"}]],
- [:suite, {:name => _test_case_name("Sub2TestCase9")},
- [:test, {:name => "test9"}]]]],
- *test_dirs)
- end
-
- private
- def assert_collect(expected, *collect_args)
- keep_required_files do
- Dir.chdir(@test_dir.to_s) do
- collector = Test::Unit::Collector::Load.new
- yield(collector) if block_given?
- actual = inspect_test_object(collector.send(:collect, *collect_args))
- assert_equal(expected, actual)
- end
- end
- end
-
- def keep_required_files
- required_files = $".dup
- yield
- ensure
- $".replace(required_files)
- end
-
- def _test_case_name(test_case_class_name)
- "#{@temporary_test_cases_module_name}::#{test_case_class_name}"
- end
-
- def inspect_test_object(test_object)
- return nil if test_object.nil?
- case test_object
- when Test::Unit::TestSuite
- sub_tests = test_object.tests.collect do |test|
- inspect_test_object(test)
- end.sort_by do |type, attributes, *children|
- attributes[:name]
- end
- [:suite, {:name => test_object.name}, *sub_tests]
- when Test::Unit::TestCase
- [:test, {:name => test_object.method_name}]
- else
- raise "unexpected test object: #{test_object.inspect}"
- end
- end
-end
Deleted: test-unit/test/collector/test_objectspace.rb (+0 -98) 100644
===================================================================
--- test-unit/test/collector/test_objectspace.rb 2010-09-12 03:03:44 +0000 (a1532ff)
+++ /dev/null
@@ -1,98 +0,0 @@
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit'
-require 'test/unit/collector/objectspace'
-
-module Test
- module Unit
- module Collector
- class TC_ObjectSpace < TestCase
- def setup
- @tc1 = Class.new(TestCase) do
- def self.name
- "tc_1"
- end
- def test_1
- end
- def test_2
- end
- end
-
- @tc2 = Class.new(TestCase) do
- def self.name
- "tc_2"
- end
- def test_0
- end
- end
-
- @no_tc = Class.new do
- def test_4
- end
- end
-
- @object_space = {Class => [@tc1, @tc2, @no_tc], String => ['']}
- def @object_space.each_object(type)
- self[type].each{|item| yield(item) }
- end
-
- @c = ObjectSpace.new(@object_space)
- end
-
- def full_suite(name=ObjectSpace::NAME)
- expected = TestSuite.new(name)
- expected << (TestSuite.new(@tc1.name) << @tc1.new('test_1') << @tc1.new('test_2'))
- expected << (TestSuite.new(@tc2.name) << @tc2.new('test_0'))
- end
-
- def empty_suite
- TestSuite.new(ObjectSpace::NAME)
- end
-
- def test_basic_collection
- assert_equal(full_suite("name"), @c.collect("name"))
-
- @c.filter = []
- assert_equal(full_suite("name"), @c.collect("name"))
- end
-
- def test_filtered_collection
- @c.filter = proc{false}
- assert_equal(empty_suite, @c.collect)
-
- @c.filter = proc{true}
- assert_equal(full_suite, @c.collect)
-
- @c.filter = proc{nil}
- assert_equal(full_suite, @c.collect)
-
- @c.filter = [proc{false}, proc{true}]
- assert_equal(empty_suite, @c.collect)
-
- @c.filter = [proc{true}, proc{false}]
- assert_equal(full_suite, @c.collect)
-
- @c.filter = [proc{nil}, proc{false}]
- assert_equal(empty_suite, @c.collect)
-
- @c.filter = [proc{nil}, proc{true}]
- assert_equal(full_suite, @c.collect)
-
- expected = TestSuite.new(ObjectSpace::NAME)
- expected << (TestSuite.new(@tc1.name) << @tc1.new('test_1'))
- expected << (TestSuite.new(@tc2.name) << @tc2.new('test_0'))
- @c.filter = proc{|test| ['test_1', 'test_0'].include?(test.method_name)}
- assert_equal(expected, @c.collect)
-
- expected = TestSuite.new(ObjectSpace::NAME)
- expected << (TestSuite.new(@tc1.name) << @tc1.new('test_1'))
- expected << (TestSuite.new(@tc2.name) << @tc2.new('test_0'))
- @c.filter = [proc{|t| t.method_name == 'test_1' ? true : nil}, proc{|t| t.method_name == 'test_0' ? true : nil}, proc{false}]
- assert_equal(expected, @c.collect)
- end
- end
- end
- end
-end
Deleted: test-unit/test/run-test.rb (+0 -13) 100755
===================================================================
--- test-unit/test/run-test.rb 2010-09-12 03:03:44 +0000 (0f74347)
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/env ruby
-
-$VERBOSE = true
-
-base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
-lib_dir = File.join(base_dir, "lib")
-test_dir = File.join(base_dir, "test")
-
-$LOAD_PATH.unshift(lib_dir)
-
-require 'test/unit'
-
-exit Test::Unit::AutoRunner.run(true, test_dir)
Deleted: test-unit/test/test_assertions.rb (+0 -693) 100644
===================================================================
--- test-unit/test/test_assertions.rb 2010-09-12 03:03:44 +0000 (024c037)
+++ /dev/null
@@ -1,693 +0,0 @@
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit'
-
-module Test
- module Unit
- class TC_Assertions < TestCase
- def check(value, message="")
- add_assertion
- raise AssertionFailedError.new(message) unless value
- end
-
- def check_assertions(expect_fail, expected_message="",
- return_value_expected=false)
- @actual_assertion_count = 0
- failed = true
- actual_message = nil
- @catch_assertions = true
- return_value = nil
- begin
- return_value = yield
- failed = false
- rescue AssertionFailedError => error
- actual_message = error.message
- end
- @catch_assertions = false
-
- if expect_fail
- message = "Should have failed, but didn't"
- else
- message = "Should not have failed, but did with message\n" +
- "<#{actual_message}>"
- end
- check(expect_fail == failed, message)
-
- message = "Should have made one assertion but made\n" +
- "<#{@actual_assertion_count}>"
- check(1 == @actual_assertion_count, message)
-
- if expect_fail
- case expected_message
- when String
- check(actual_message == expected_message,
- "Should have the correct message.\n" +
- "<#{expected_message.inspect}> expected but was\n" +
- "<#{actual_message.inspect}>")
- when Regexp
- check(actual_message =~ expected_message,
- "The message should match correctly.\n" +
- "</#{expected_message.source}/> expected to match\n" +
- "<#{actual_message.inspect}>")
- else
- check(false,
- "Incorrect expected message type in assert_nothing_failed")
- end
- else
- if return_value_expected
- check(!return_value.nil?, "Should return a value")
- else
- check(return_value.nil?,
- "Should not return a value but returned <#{return_value}>")
- end
- end
-
- return_value
- end
-
- def check_nothing_fails(return_value_expected=false, &proc)
- check_assertions(false, "", return_value_expected, &proc)
- end
-
- def check_fails(expected_message="", &proc)
- check_assertions(true, expected_message, &proc)
- end
-
- def inspect_tag(tag)
- begin
- throw tag
- rescue NameError
- tag.to_s.inspect
- rescue ArgumentError
- tag.inspect
- end
- end
-
- def test_assert_block
- check_nothing_fails {
- assert_block {true}
- }
- check_nothing_fails {
- assert_block("successful assert_block") {true}
- }
- check_nothing_fails {
- assert_block("successful assert_block") {true}
- }
- check_fails("assert_block failed.") {
- assert_block {false}
- }
- check_fails("failed assert_block") {
- assert_block("failed assert_block") {false}
- }
- end
-
- def test_assert
- check_nothing_fails{assert("a")}
- check_nothing_fails{assert(true)}
- check_nothing_fails{assert(true, "successful assert")}
- check_fails("<nil> is not true."){assert(nil)}
- check_fails("<false> is not true."){assert(false)}
- check_fails("failed assert.\n<false> is not true."){assert(false, "failed assert")}
- end
-
- def test_assert_equal
- check_nothing_fails {
- assert_equal("string1", "string1")
- }
- check_nothing_fails {
- assert_equal( "string1", "string1", "successful assert_equal")
- }
- check_nothing_fails {
- assert_equal("string1", "string1", "successful assert_equal")
- }
-
- message = <<-EOM.chomp
-<"string1"> expected but was
-<"string2">.
-
-diff:
-- string1
-? ^
-+ string2
-? ^
-EOM
- check_fails(message) {
- assert_equal("string1", "string2")
- }
-
- message = <<-EOM.chomp
-failed assert_equal.
-<"string1"> expected but was
-<"string2">.
-
-diff:
-- string1
-? ^
-+ string2
-? ^
-EOM
- check_fails(message) {
- assert_equal("string1", "string2", "failed assert_equal")
- }
-
- message = <<-EOM.chomp
-<"111111"> expected but was
-<111111>.
-
-diff:
-- "111111"
-? - -
-+ 111111
-EOM
- check_fails(message) do
- assert_equal("111111", 111111)
- end
- end
-
- def test_assert_equal_for_too_small_difference
- message = <<-EOM.chomp
-<1> expected but was
-<2>.
-EOM
- check_fails(message) do
- assert_equal(1, 2)
- end
- end
-
- def test_assert_equal_for_same_inspected_objects
- now = Time.now
- now_without_usec = Time.at(now.to_i)
- message = <<-EOM.chomp
-<#{now.inspect}> expected but was
-<#{now.inspect}>.
-EOM
- check_fails(message) do
- assert_equal(now, now_without_usec)
- end
- end
-
- def test_assert_equal_with_multi_lines_result
- message = <<-EOM.chomp
-<#{"a\nb".inspect}> expected but was
-<#{"x".inspect}>.
-
-diff:
-+ x
-- a
-- b
-EOM
- check_fails(message) do
- assert_equal("a\nb", "x")
- end
- end
-
- def test_assert_raise
- return_value = nil
- check_nothing_fails(true) {
- return_value = assert_raise(RuntimeError) {
- raise "Error"
- }
- }
- check(return_value.kind_of?(Exception), "Should have returned the exception from a successful assert_raise")
- check(return_value.message == "Error", "Should have returned the correct exception from a successful assert_raise")
- check_nothing_fails(true) {
- assert_raise(ArgumentError, "successful assert_raise") {
- raise ArgumentError.new("Error")
- }
- }
- check_nothing_fails(true) {
- assert_raise(RuntimeError) {
- raise "Error"
- }
- }
- check_nothing_fails(true) {
- assert_raise(RuntimeError, "successful assert_raise") {
- raise "Error"
- }
- }
- check_fails("<RuntimeError> exception expected but none was thrown.") {
- assert_raise(RuntimeError) {
- 1 + 1
- }
- }
- check_fails(%r{\Afailed assert_raise.\n<ArgumentError> exception expected but was\nClass: <RuntimeError>\nMessage: <"Error">\n---Backtrace---\n.+\n---------------\Z}m) {
- assert_raise(ArgumentError, "failed assert_raise") {
- raise "Error"
- }
- }
- check_fails("Should expect a class of exception, Object.\n<false> is not true.") {
- assert_nothing_raised(Object) {
- 1 + 1
- }
- }
-
- exceptions = [ArgumentError, TypeError]
- modules = [Math, Comparable]
- rescues = exceptions + modules
- exceptions.each do |exc|
- check_nothing_fails(true) {
- return_value = assert_raise(*rescues) {
- raise exc, "Error"
- }
- }
- check(return_value.instance_of?(exc), "Should have returned #{exc} but was #{return_value.class}")
- check(return_value.message == "Error", "Should have returned the correct exception from a successful assert_raise")
- end
- modules.each do |mod|
- check_nothing_fails(true) {
- return_value = assert_raise(*rescues) {
- raise Exception.new("Error").extend(mod)
- }
- }
- check(mod === return_value, "Should have returned #{mod}")
- check(return_value.message == "Error", "Should have returned the correct exception from a successful assert_raise")
- end
- check_fails("<[ArgumentError, TypeError, Math, Comparable]> exception expected but none was thrown.") {
- assert_raise(*rescues) {
- 1 + 1
- }
- }
- check_fails(%r{\Afailed assert_raise.
-<\[ArgumentError, TypeError\]> exception expected but was
-Class: <RuntimeError>
-Message: <"Error">
----Backtrace---
-.+
----------------\Z}m) {
- assert_raise(ArgumentError, TypeError, "failed assert_raise") {
- raise "Error"
- }
- }
- end
-
- def test_assert_instance_of
- check_nothing_fails {
- assert_instance_of(String, "string")
- }
- check_nothing_fails {
- assert_instance_of(String, "string", "successful assert_instance_of")
- }
- check_nothing_fails {
- assert_instance_of(String, "string", "successful assert_instance_of")
- }
- check_fails(%Q{<"string"> expected to be an instance of\n<Hash> but was\n<String>.}) {
- assert_instance_of(Hash, "string")
- }
- check_fails(%Q{failed assert_instance_of.\n<"string"> expected to be an instance of\n<Hash> but was\n<String>.}) {
- assert_instance_of(Hash, "string", "failed assert_instance_of")
- }
- end
-
- def test_assert_nil
- check_nothing_fails {
- assert_nil(nil)
- }
- check_nothing_fails {
- assert_nil(nil, "successful assert_nil")
- }
- check_nothing_fails {
- assert_nil(nil, "successful assert_nil")
- }
- check_fails(%Q{<"string"> expected to be nil.}) {
- assert_nil("string")
- }
- check_fails(%Q{failed assert_nil.\n<"string"> expected to be nil.}) {
- assert_nil("string", "failed assert_nil")
- }
- end
-
- def test_assert_not_nil
- check_nothing_fails{assert_not_nil(false)}
- check_nothing_fails{assert_not_nil(false, "message")}
- check_fails("<nil> expected to not be nil."){assert_not_nil(nil)}
- check_fails("message.\n<nil> expected to not be nil.") {assert_not_nil(nil, "message")}
- end
-
- def test_assert_kind_of
- check_nothing_fails {
- assert_kind_of(Module, Array)
- }
- check_nothing_fails {
- assert_kind_of(Object, "string", "successful assert_kind_of")
- }
- check_nothing_fails {
- assert_kind_of(Object, "string", "successful assert_kind_of")
- }
- check_nothing_fails {
- assert_kind_of(Comparable, 1)
- }
- check_fails(%Q{<"string">\nexpected to be kind_of?\n<Class> but was\n<String>.}) {
- assert_kind_of(Class, "string")
- }
- check_fails(%Q{failed assert_kind_of.\n<"string">\nexpected to be kind_of?\n<Class> but was\n<String>.}) {
- assert_kind_of(Class, "string", "failed assert_kind_of")
- }
- end
-
- def test_assert_match
- check_nothing_fails {
- assert_match(/strin./, "string")
- }
- check_nothing_fails {
- assert_match("strin", "string")
- }
- check_nothing_fails {
- assert_match(/strin./, "string", "successful assert_match")
- }
- check_nothing_fails {
- assert_match(/strin./, "string", "successful assert_match")
- }
- check_fails(%Q{<"string"> expected to be =~\n</slin./>.}) {
- assert_match(/slin./, "string")
- }
- check_fails(%Q{<"string"> expected to be =~\n</strin\\./>.}) {
- assert_match("strin.", "string")
- }
- check_fails(%Q{failed assert_match.\n<"string"> expected to be =~\n</slin./>.}) {
- assert_match(/slin./, "string", "failed assert_match")
- }
- end
-
- def test_assert_same
- thing = "thing"
- check_nothing_fails {
- assert_same(thing, thing)
- }
- check_nothing_fails {
- assert_same(thing, thing, "successful assert_same")
- }
- check_nothing_fails {
- assert_same(thing, thing, "successful assert_same")
- }
- thing2 = "thing"
- check_fails(%Q{<"thing">\nwith id <#{thing.__id__}> expected to be equal? to\n<"thing">\nwith id <#{thing2.__id__}>.}) {
- assert_same(thing, thing2)
- }
- check_fails(%Q{failed assert_same.\n<"thing">\nwith id <#{thing.__id__}> expected to be equal? to\n<"thing">\nwith id <#{thing2.__id__}>.}) {
- assert_same(thing, thing2, "failed assert_same")
- }
- end
-
- def test_assert_nothing_raised
- check_nothing_fails {
- assert_nothing_raised {
- 1 + 1
- }
- }
- check_nothing_fails {
- assert_nothing_raised("successful assert_nothing_raised") {
- 1 + 1
- }
- }
- check_nothing_fails {
- assert_nothing_raised("successful assert_nothing_raised") {
- 1 + 1
- }
- }
- check_nothing_fails {
- begin
- assert_nothing_raised(RuntimeError, StandardError, Comparable, "successful assert_nothing_raised") {
- raise ZeroDivisionError.new("ArgumentError")
- }
- rescue ZeroDivisionError
- end
- }
- check_fails("Should expect a class of exception, Object.\n<false> is not true.") {
- assert_nothing_raised(Object) {
- 1 + 1
- }
- }
- check_fails(%r{\AException raised:\nClass: <RuntimeError>\nMessage: <"Error">\n---Backtrace---\n.+\n---------------\Z}m) {
- assert_nothing_raised {
- raise "Error"
- }
- }
- check_fails(%r{\Afailed assert_nothing_raised\.\nException raised:\nClass: <RuntimeError>\nMessage: <"Error">\n---Backtrace---\n.+\n---------------\Z}m) {
- assert_nothing_raised("failed assert_nothing_raised") {
- raise "Error"
- }
- }
- check_fails(%r{\AException raised:\nClass: <RuntimeError>\nMessage: <"Error">\n---Backtrace---\n.+\n---------------\Z}m) {
- assert_nothing_raised(StandardError, RuntimeError) {
- raise "Error"
- }
- }
- check_fails("Failure.") do
- assert_nothing_raised do
- flunk("Failure")
- end
- end
- end
-
- def test_flunk
- check_fails("Flunked.") {
- flunk
- }
- check_fails("flunk message.") {
- flunk("flunk message")
- }
- end
-
- def test_assert_not_same
- thing = "thing"
- thing2 = "thing"
- check_nothing_fails {
- assert_not_same(thing, thing2)
- }
- check_nothing_fails {
- assert_not_same(thing, thing2, "message")
- }
- check_fails(%Q{<"thing">\nwith id <#{thing.__id__}> expected to not be equal? to\n<"thing">\nwith id <#{thing.__id__}>.}) {
- assert_not_same(thing, thing)
- }
- check_fails(%Q{message.\n<"thing">\nwith id <#{thing.__id__}> expected to not be equal? to\n<"thing">\nwith id <#{thing.__id__}>.}) {
- assert_not_same(thing, thing, "message")
- }
- end
-
- def test_assert_not_equal
- check_nothing_fails {
- assert_not_equal("string1", "string2")
- }
- check_nothing_fails {
- assert_not_equal("string1", "string2", "message")
- }
- check_fails(%Q{<"string"> expected to be != to\n<"string">.}) {
- assert_not_equal("string", "string")
- }
- check_fails(%Q{message.\n<"string"> expected to be != to\n<"string">.}) {
- assert_not_equal("string", "string", "message")
- }
- end
-
- def test_assert_no_match
- check_nothing_fails{assert_no_match(/sling/, "string")}
- check_nothing_fails{assert_no_match(/sling/, "string", "message")}
- check_fails(%Q{The first argument to assert_no_match should be a Regexp.\n<"asdf"> expected to be an instance of\n<Regexp> but was\n<String>.}) do
- assert_no_match("asdf", "asdf")
- end
- check_fails(%Q{</string/> expected to not match\n<"string">.}) do
- assert_no_match(/string/, "string")
- end
- check_fails(%Q{message.\n</string/> expected to not match\n<"string">.}) do
- assert_no_match(/string/, "string", "message")
- end
- end
-
- def test_assert_throws
- check_nothing_fails do
- assert_throws(:thing, "message") do
- throw :thing
- end
- end
-
- tag = :thing2
- check_fails("message.\n" +
- "<:thing> expected to be thrown but\n" +
- "<#{inspect_tag(tag)}> was thrown.") do
- assert_throws(:thing, "message") do
- throw :thing2
- end
- end
- check_fails("message.\n" +
- "<:thing> should have been thrown.") do
- assert_throws(:thing, "message") do
- 1 + 1
- end
- end
- end
-
- def test_assert_nothing_thrown
- check_nothing_fails do
- assert_nothing_thrown("message") do
- 1 + 1
- end
- end
-
- tag = :thing
- inspected = inspect_tag(tag)
- check_fails("message.\n" +
- "<#{inspected}> was thrown when nothing was expected.") do
- assert_nothing_thrown("message") do
- throw tag
- end
- end
- end
-
- def test_assert_operator
- check_nothing_fails {
- assert_operator("thing", :==, "thing", "message")
- }
- check_fails(%Q{<0.15>\ngiven as the operator for #assert_operator must be a Symbol or #respond_to?(:to_str).}) do
- assert_operator("thing", 0.15, "thing")
- end
- check_fails(%Q{message.\n<"thing1"> expected to be\n==\n<"thing2">.}) {
- assert_operator("thing1", :==, "thing2", "message")
- }
- end
-
- def test_assert_respond_to
- check_nothing_fails {
- assert_respond_to("thing", :to_s, "message")
- }
- check_nothing_fails {
- assert_respond_to("thing", "to_s", "message")
- }
- check_fails("<0.15>\ngiven as the method name argument to #assert_respond_to must be a Symbol or #respond_to?(:to_str).") {
- assert_respond_to("thing", 0.15)
- }
- check_fails("message.\n<:symbol>\nof type <Symbol>\nexpected to respond_to?<:non_existent>.") {
- assert_respond_to(:symbol, :non_existent, "message")
- }
- end
-
- def test_assert_in_delta
- check_nothing_fails {
- assert_in_delta(1.4, 1.4, 0)
- }
- check_nothing_fails {
- assert_in_delta(0.5, 0.4, 0.1, "message")
- }
- check_nothing_fails {
- float_thing = Object.new
- def float_thing.to_f
- 0.2
- end
- assert_in_delta(0.1, float_thing, 0.1)
- }
- check_fails("message.\n<0.5> and\n<0.4> expected to be within\n<0.05> of each other.") {
- assert_in_delta(0.5, 0.4, 0.05, "message")
- }
- check_fails(%r{The arguments must respond to to_f; the first float did not\.\n<.+>\nof type <Object>\nexpected to respond_to\?<:to_f>.}) {
- assert_in_delta(Object.new, 0.4, 0.1)
- }
- check_fails("The delta should not be negative.\n<-0.1> expected to be\n>=\n<0.0>.") {
- assert_in_delta(0.5, 0.4, -0.1, "message")
- }
- end
-
- def test_assert_send
- object = Object.new
- class << object
- private
- def return_argument(argument, bogus)
- return argument
- end
- end
- check_nothing_fails {
- assert_send([object, :return_argument, true, "bogus"], "message")
- }
- check_fails(%r{\Amessage\.\n<.+> expected to respond to\n<return_argument\(\[false, "bogus"\]\)> with a true value.\Z}) {
- assert_send([object, :return_argument, false, "bogus"], "message")
- }
- end
-
- def test_condition_invariant
- object = Object.new
- def object.inspect
- @changed = true
- end
- def object.==(other)
- @changed ||= false
- return (!@changed)
- end
- check_nothing_fails do
- assert_equal(object, object, "message")
- end
- end
-
- def test_assert_boolean
- check_nothing_fails do
- assert_boolean(true)
- end
- check_nothing_fails do
- assert_boolean(false)
- end
-
- check_fails("<true> or <false> expected but was\n<1>") do
- assert_boolean(1)
- end
-
- check_fails("<true> or <false> expected but was\n<nil>") do
- assert_boolean(nil)
- end
-
- check_fails("message.\n<true> or <false> expected but was\n<\"XXX\">") do
- assert_boolean("XXX", "message")
- end
- end
-
- def test_assert_true
- check_nothing_fails do
- assert_true(true)
- end
-
- check_fails("<true> expected but was\n<false>") do
- assert_true(false)
- end
-
- check_fails("<true> expected but was\n<1>") do
- assert_true(1)
- end
-
- check_fails("message.\n<true> expected but was\n<nil>") do
- assert_true(nil, "message")
- end
- end
-
- def test_assert_false
- check_nothing_fails do
- assert_false(false)
- end
-
- check_fails("<false> expected but was\n<true>") do
- assert_false(true)
- end
-
- check_fails("<false> expected but was\n<nil>") do
- assert_false(nil)
- end
-
- check_fails("message.\n<false> expected but was\n<:false>") do
- assert_false(:false, "message")
- end
- end
-
- def add_failure(message, location=caller)
- unless @catch_assertions
- super
- end
- end
-
- def add_assertion
- if @catch_assertions
- @actual_assertion_count += 1
- else
- super
- end
- end
- end
- end
-end
Deleted: test-unit/test/test_attribute.rb (+0 -86) 100644
===================================================================
--- test-unit/test/test_attribute.rb 2010-09-12 03:03:44 +0000 (f6e2836)
+++ /dev/null
@@ -1,86 +0,0 @@
-class TestUnitAttribute < Test::Unit::TestCase
- class TestStack < Test::Unit::TestCase
- class << self
- def suite
- Test::Unit::TestSuite.new(name)
- end
- end
-
- class Stack
- def initialize
- @data = []
- end
-
- def push(data)
- @data.push(data)
- end
-
- def peek
- @data[-2]
- end
-
- def empty?
- @data.empty?
- end
-
- def size
- @data.size + 11
- end
- end
-
- def setup
- @stack = Stack.new
- end
-
- attribute :category, :accessor
- def test_peek
- @stack.push(1)
- @stack.push(2)
- assert_equal(2, @stack.peek)
- end
-
- attribute :bug, 1234
- def test_bug_1234
- assert_equal(0, @stack.size)
- end
-
- def test_no_attributes
- assert(@stack.empty?)
- @stack.push(1)
- assert(!@stack.empty?)
- assert_equal(1, @stack.size)
- end
- end
-
- def test_set_attributes
- test_for_accessor_category = TestStack.new("test_peek")
- assert_equal({"category" => :accessor},
- test_for_accessor_category.attributes)
-
- test_for_bug_1234 = TestStack.new("test_bug_1234")
- assert_equal({"bug" => 1234}, test_for_bug_1234.attributes)
-
- test_no_attributes = TestStack.new("test_no_attributes")
- assert_equal({}, test_no_attributes.attributes)
- end
-
- def test_callback
- changed_attributes = []
- observer = Proc.new do |test_case, key, old_value, value, method_name|
- changed_attributes << [test_case, key, old_value, value, method_name]
- end
-
- test_case = Class.new(TestStack) do
- register_attribute_observer(:bug, &observer)
- attribute("bug", 9876, "test_bug_1234")
- attribute(:description, "Test for peek", "test_peek")
- attribute(:bug, 29, "test_peek")
- end
-
- assert_equal([
- [test_case, "bug", 1234, 9876, "test_bug_1234"],
- [test_case, "bug", nil, 29, "test_peek"],
- ],
- changed_attributes)
- end
-end
Deleted: test-unit/test/test_color.rb (+0 -37) 100644
===================================================================
--- test-unit/test/test_color.rb 2010-09-12 03:03:44 +0000 (6aa990a)
+++ /dev/null
@@ -1,37 +0,0 @@
-class TestUnitColor < Test::Unit::TestCase
- def test_color_escape_sequence
- assert_escape_sequence(["31"], color("red"))
- assert_escape_sequence(["32", "1"], color("green", :bold => true))
- assert_escape_sequence(["0"], color("reset"))
- assert_escape_sequence(["45"], color("magenta", :foreground => false))
- end
-
- def test_mix_color_escape_sequence
- assert_escape_sequence(["34", "1"],
- mix_color([color("blue"),
- color("none", :bold => true)]))
- assert_escape_sequence(["34", "1", "4"],
- mix_color([color("blue"),
- color("none", :bold => true)]) +
- color("none", :underline => true))
- assert_escape_sequence(["34", "1", "4"],
- color("blue") +
- color("none", :bold => true) +
- color("none", :underline => true))
- end
-
- private
- def color(name, options={})
- Test::Unit::Color.new(name, options)
- end
-
- def mix_color(colors)
- Test::Unit::MixColor.new(colors)
- end
-
- def assert_escape_sequence(expected, color)
- assert_equal(expected, color.sequence)
- assert_match(/\e\[(?:\d+;)*\d+m/, color.escape_sequence)
- assert_equal(expected, color.escape_sequence[2..-2].split(";"))
- end
-end
Deleted: test-unit/test/test_diff.rb (+0 -477) 100644
===================================================================
--- test-unit/test/test_diff.rb 2010-09-12 03:03:44 +0000 (164c9d4)
+++ /dev/null
@@ -1,477 +0,0 @@
-class TestUnitDiff < Test::Unit::TestCase
- def test_to_indexes
- assert_to_indexes({"abc def" => [0, 2], "abc" => [1]},
- ["abc def", "abc", "abc def"])
-
- assert_to_indexes({?a => [0, 3], ?b => [1], ?c => [2], ?d => [4]},
- "abcad")
-
- assert_to_indexes({
- ?1 => [0, 35],
- ?t => [2, 5, 16],
- ?e => [3, 14, 31, 38],
- ?s => [4, 6, 12, 13, 20, 32, 44],
- ?, => [7, 21, 33],
- ?0 => [9, 23],
- ?a => [11, 26],
- ?r => [15, 30],
- ?i => [17, 27, 41],
- ?o => [18],
- ?n => [19, 39, 42],
- ?f => [25],
- ?l => [28],
- ?u => [29],
- ?p => [37],
- ?d => [40],
- ?g => [43],
- },
- "1 tests, 0 assertions, 0 failures, 1 pendings") do |x|
- x == " "[0]
- end
- end
-
- def test_longest_match
- assert_longest_match([0, 1, 3],
- %w(b c d), %w(a b c d x y z),
- 0, 2, 0, 7)
- assert_longest_match([1, 2, 2],
- %w(b c d), %w(a b c d x y z),
- 1, 2, 0, 6)
- assert_longest_match([0, 0, 0],
- %w(a b), %w(c),
- 0, 1, 0, 0)
- assert_longest_match([1, 0, 2],
- %w(q a b x c d), %w(a b y c d f),
- 0, 5, 0, 5)
- assert_longest_match([4, 3, 2],
- %w(q a b x c d), %w(a b y c d f),
- 3, 5, 2, 5)
-
- assert_longest_match([1, 0, 2], "qabxcd", "abycdf", 0, 5, 0, 5)
- assert_longest_match([0, 0, 1], "efg", "eg", 0, 2, 0, 1)
- assert_longest_match([2, 1, 1], "efg", "eg", 1, 2, 1, 1)
- end
-
- def test_longest_match_with_junk_predicate
- assert_longest_match([0, 4, 5], " abcd", "abcd abcd", 0, 4, 0, 8)
- assert_longest_match([1, 0, 4], " abcd", "abcd abcd", 0, 4, 0, 8) do |x|
- x == ' '[0]
- end
- end
-
- def test_matches
- assert_matches([[0, 0, 2],
- [3, 2, 2]],
- %w(a b x c d), %w(a b c d))
- assert_matches([[1, 0, 2],
- [4, 3, 2]],
- %w(q a b x c d), %w(a b y c d f))
-
- assert_matches([[1, 0, 2],
- [4, 3, 2]],
- "qabxcd", "abycdf")
- assert_matches([[0, 0, 1],
- [2, 1, 1]],
- "efg", "eg")
- end
-
- def test_matches_with_junk_predicate
- assert_matches([[0, 0, 23],
- [24, 24, 11],
- [36, 36, 9]],
- "1 tests, 0 assertions, 1 failures, 0 pendings",
- "1 tests, 0 assertions, 0 failures, 1 pendings")
-
- assert_matches([[0, 0, 1],
- [1, 1, 8],
- [9, 9, 1],
- [10, 10, 13],
- [24, 24, 11],
- [36, 36, 9]],
- "1 tests, 0 assertions, 1 failures, 0 pendings",
- "1 tests, 0 assertions, 0 failures, 1 pendings") do |x|
- x == " "[0]
- end
- end
-
- def test_blocks
- assert_blocks([[0, 0, 2],
- [3, 2, 2],
- [5, 4, 0]],
- %w(a b x c d), %w(a b c d))
- assert_blocks([[1, 0, 2],
- [4, 3, 2],
- [6, 6, 0]],
- %w(q a b x c d), %w(a b y c d f))
-
- assert_blocks([[1, 0, 2],
- [4, 3, 2],
- [6, 6, 0]],
- "qabxcd", "abycdf")
- assert_blocks([[0, 0, 1],
- [2, 1, 1],
- [3, 2, 0]],
- "efg", "eg")
- end
-
- def test_blocks_with_junk_predicate
- assert_blocks([[0, 0, 23],
- [24, 24, 11],
- [36, 36, 9],
- [45, 45, 0]],
- "1 tests, 0 assertions, 1 failures, 0 pendings",
- "1 tests, 0 assertions, 0 failures, 1 pendings") do |x|
- x == " "[0]
- end
- end
-
- def test_operations
- assert_operations([], %w(), %w())
-
- assert_operations([[:delete, 0, 1, 0, 0],
- [:equal, 1, 3, 0, 2],
- [:replace, 3, 4, 2, 3],
- [:equal, 4, 6, 3, 5],
- [:insert, 6, 6, 5, 6]],
- %w(q a b x c d), %w(a b y c d f))
-
- assert_operations([[:delete, 0, 1, 0, 0],
- [:equal, 1, 3, 0, 2],
- [:replace, 3, 4, 2, 3],
- [:equal, 4, 6, 3, 5],
- [:insert, 6, 6, 5, 6]],
- "qabxcd", "abycdf")
-
- assert_operations([[:equal, 0, 23, 0, 23],
- [:replace, 23, 24, 23, 24],
- [:equal, 24, 35, 24, 35],
- [:replace, 35, 36, 35, 36],
- [:equal, 36, 45, 36, 45]],
- "1 tests, 0 assertions, 1 failures, 0 pendings",
- "1 tests, 0 assertions, 0 failures, 1 pendings")
-
- assert_operations([[:equal, 0, 23, 0, 23],
- [:replace, 23, 24, 23, 24],
- [:equal, 24, 35, 24, 35],
- [:replace, 35, 36, 35, 36],
- [:equal, 36, 45, 36, 45]],
- "1 tests, 0 assertions, 1 failures, 0 pendings",
- "1 tests, 0 assertions, 0 failures, 1 pendings") do |x|
- x == " "[0]
- end
- end
-
- def test_grouped_operations
- assert_grouped_operations([[[:equal, 0, 0, 0, 0]]],
- %w(),
- %w())
-
- assert_grouped_operations([[[:equal, 0, 3, 0, 3]]],
- %w(a b c),
- %w(a b c))
-
- assert_grouped_operations([[[:equal, 0, 1, 0, 1],
- [:replace, 1, 2, 1, 2],
- [:equal, 2, 5, 2, 5]],
- [[:equal, 8, 11, 8, 11],
- [:replace, 11, 12, 11, 12],
- [:equal, 12, 13, 12, 13],
- [:delete, 13, 16, 13, 13],
- [:equal, 16, 17, 13, 14],
- [:replace, 17, 18, 14, 15],
- [:equal, 18, 20, 15, 17]]],
- %w(1 2 3 4 5 6 7 8 9 a b c d e f g h i j k),
- %w(1 i 3 4 5 6 7 8 9 a b cX d h iX j k))
- end
-
- def test_ratio
- assert_ratio(0.75, "abcd", "bcde")
- assert_ratio(0.80, "efg", "eg")
- end
-
- def test_same_contents_readable_diff
- assert_readable_diff(" aaa", ["aaa"], ["aaa"])
- assert_readable_diff(" aaa\n" \
- " bbb",
- ["aaa", "bbb"], ["aaa", "bbb"])
- end
-
- def test_deleted_readable_diff
- assert_readable_diff(" aaa\n" \
- "- bbb",
- ["aaa", "bbb"], ["aaa"])
- assert_readable_diff(" aaa\n" \
- "- bbb\n" \
- "- ccc\n" \
- "- ddd",
- ["aaa", "bbb", "ccc", "ddd"], ["aaa"])
- end
-
- def test_inserted_readable_diff
- assert_readable_diff(" aaa\n" \
- "+ bbb\n" \
- "+ ccc\n" \
- "+ ddd",
- ["aaa"], ["aaa", "bbb", "ccc", "ddd"])
- end
-
- def test_replace_readable_diff
- assert_readable_diff(" aaa\n" \
- "- bbb\n" \
- "+ BbB\n" \
- " ccc\n" \
- "- ddd\n" \
- "- efg\n" \
- "? -\n" \
- "+ eg",
- ["aaa", "bbb", "ccc", "ddd", "efg"],
- ["aaa", "BbB", "ccc", "eg"])
-
- assert_readable_diff("- abcd xyz abc\n" \
- "? -\n" \
- "+ abcd abcd xyz abc\n" \
- "? +++++",
- [" abcd xyz abc"],
- ["abcd abcd xyz abc"])
- end
-
- def test_difference_readable_diff
- assert_readable_diff("- 1 tests, 0 assertions, 1 failures, 0 pendings\n" \
- "? ^ ^\n" \
- "+ 1 tests, 0 assertions, 0 failures, 1 pendings\n" \
- "? ^ ^",
- ["1 tests, 0 assertions, 1 failures, 0 pendings"],
- ["1 tests, 0 assertions, 0 failures, 1 pendings"])
- end
-
- def test_complex_readable_diff
- assert_readable_diff(" aaa\n" \
- "- bbb\n" \
- "- ccc\n" \
- "+ \n" \
- "+ # \n" \
- " ddd",
- ["aaa", "bbb", "ccc", "ddd"],
- ["aaa", "", " # ", "ddd"])
-
- assert_readable_diff("- one1\n" \
- "? ^\n" \
- "+ ore1\n" \
- "? ^\n" \
- "- two2\n" \
- "- three3\n" \
- "? - -\n" \
- "+ tree\n" \
- "+ emu",
- ["one1", "two2", "three3"],
- ["ore1", "tree", "emu"])
- end
-
- def test_empty_readable_diff
- assert_readable_diff("", [""], [""])
- end
-
- def test_unified_diff
- assert_unified_diff("",
- ["one", "two", "three"],
- ["one", "two", "three"],
- "content 1",
- "content 2")
-
- assert_unified_diff("--- Original Sat Jan 26 23:30:50 1991\n" \
- "+++ Current Fri Jun 06 10:20:52 2003\n" \
- "@@ -1,4 +1,4 @@\n" \
- "+zero\n" \
- " one\n" \
- "-two\n" \
- "-three\n" \
- "+tree\n" \
- " four",
- ["one", "two", "three", "four"],
- ["zero", "one", "tree", "four"],
- "Original Sat Jan 26 23:30:50 1991",
- "Current Fri Jun 06 10:20:52 2003",
- :show_context => false)
-
- from = File.read(__FILE__).split(/\n/)
- to = from.dup
- target_line = __LINE__
- to[target_line - 1, 1] = []
- context = " def test_unified_diff"
- summary = "@@ -#{target_line - 3},7 +#{target_line - 3},6 @@ #{context}"
- assert_unified_diff((["--- revision 10",
- "+++ revision 11",
- summary] +
- from[target_line - 4, 3].collect {|line| " #{line}"} +
- ["-#{from[target_line - 1]}"] +
- from[target_line, 3].collect {|line| " #{line}"}
- ).join("\n"),
- from, to,
- "revision 10",
- "revision 11")
- end
-
- def test_empty_unified_diff
- assert_unified_diff("", [""], [""], "From", "To")
- assert_unified_diff("", [], [], "From", "To")
- end
-
- def test_diff_lines
- assert_diff_lines(["- ddd",
- "- efg",
- "? -",
- "+ eg"],
- ["aaa", "bbb", "ccc", "ddd", "efg"],
- ["aaa", "BbB", "ccc", "eg"],
- 3, 5, 3, 4)
- end
-
- def test_diff_line
- assert_diff_line(["- abcDefghiJkl",
- "? ^ ^ ^",
- "+ abcdefGhijkl",
- "? ^ ^ ^"],
- "abcDefghiJkl",
- "abcdefGhijkl")
-
- assert_diff_line(["- bcDefghiJklx",
- "? ^ ^ ^ -",
- "+ abcdefGhijkl",
- "? + ^ ^ ^"],
- "bcDefghiJklx",
- "abcdefGhijkl")
- end
-
- def test_empty_diff_line
- assert_diff_line(["- ",
- "+ "],
- "", "")
- end
-
- def test_format_diff_point
- assert_format_diff_point(["- \tabcDefghiJkl",
- "? \t ^ ^ ^",
- "+ \t\tabcdefGhijkl",
- "? \t ^ ^ ^"],
- "\tabcDefghiJkl",
- "\t\tabcdefGhijkl",
- " ^ ^ ^ ",
- "+ ^ ^ ^ ")
- assert_format_diff_point(["- efg",
- "? ^",
- "+ eg"],
- "efg",
- "eg",
- " ^",
- "")
- end
-
- def test_interesting_line
- from = ["class X",
- " def find(x=0)",
- " body",
- " end",
- "end"]
- to = ["def xxx",
- " raise 'not call me'",
- "end"]
- assert_interesting_line(" def find(x=0)",
- from, to,
- 2, 1)
- assert_interesting_line("def xxx",
- from, to,
- 2, 0)
- assert_interesting_line("class X",
- from, to,
- 0, 0)
- end
-
- private
- def assert_to_indexes(expected, to, &junk_predicate)
- matcher = Test::Unit::Diff::SequenceMatcher.new([""], to, &junk_predicate)
- assert_equal(expected, matcher.instance_variable_get("@to_indexes"))
- end
-
- def assert_find_best_match_position(expected, from, to,
- from_start, from_end,
- to_start, to_end, &junk_predicate)
- matcher = Test::Unit::Diff::SequenceMatcher.new(from, to, &junk_predicate)
- assert_equal(expected, matcher.send(:find_best_match_position,
- from_start, from_end,
- to_start, to_end))
- end
-
- def assert_longest_match(expected, from, to,
- from_start, from_end,
- to_start, to_end, &junk_predicate)
- matcher = Test::Unit::Diff::SequenceMatcher.new(from, to, &junk_predicate)
- assert_equal(expected, matcher.longest_match(from_start, from_end,
- to_start, to_end))
- end
-
- def assert_matches(expected, from, to, &junk_predicate)
- matcher = Test::Unit::Diff::SequenceMatcher.new(from, to, &junk_predicate)
- assert_equal(expected, matcher.send(:matches))
- end
-
- def assert_blocks(expected, from, to, &junk_predicate)
- matcher = Test::Unit::Diff::SequenceMatcher.new(from, to, &junk_predicate)
- assert_equal(expected, matcher.blocks)
- end
-
- def assert_operations(expected, from, to, &junk_predicate)
- matcher = Test::Unit::Diff::SequenceMatcher.new(from, to, &junk_predicate)
- assert_equal(expected, matcher.operations)
- end
-
- def assert_grouped_operations(expected, from, to)
- matcher = Test::Unit::Diff::SequenceMatcher.new(from, to)
- assert_equal(expected, matcher.grouped_operations)
- end
-
- def assert_ratio(expected, from, to)
- matcher = Test::Unit::Diff::SequenceMatcher.new(from, to)
- assert_in_delta(expected, 0.001, matcher.ratio)
- end
-
- def assert_readable_diff(expected, from, to)
- assert_equal(expected,
- Test::Unit::Diff.readable(from.join("\n"), to.join("\n")))
- end
-
- def assert_unified_diff(expected, from, to, from_label, to_label, options={})
- options = options.merge(:from_label => from_label,
- :to_label => to_label)
- assert_equal(expected,
- Test::Unit::Diff.unified(from.join("\n"), to.join("\n"),
- options))
- end
-
- def assert_diff_lines(expected, from, to,
- from_start, from_end,
- to_start, to_end)
- differ = Test::Unit::Diff::ReadableDiffer.new(from, to)
- assert_equal(expected, differ.send(:diff_lines,
- from_start, from_end,
- to_start, to_end))
- end
-
- def assert_diff_line(expected, from_line, to_line)
- differ = Test::Unit::Diff::ReadableDiffer.new([""], [""])
- assert_equal(expected, differ.send(:diff_line, from_line, to_line))
- end
-
- def assert_format_diff_point(expected, from_line, to_line, from_tags, to_tags)
- differ = Test::Unit::Diff::ReadableDiffer.new([""], [""])
- assert_equal(expected, differ.send(:format_diff_point,
- from_line, to_line,
- from_tags, to_tags))
- end
-
- def assert_interesting_line(expected, from, to, from_start, to_start)
- differ = Test::Unit::Diff::UnifiedDiffer.new(from, to)
- assert_equal(expected, differ.send(:find_interesting_line,
- from_start, to_start,
- :define_line?))
- end
-end
Deleted: test-unit/test/test_emacs_runner.rb (+0 -60) 100644
===================================================================
--- test-unit/test/test_emacs_runner.rb 2010-09-12 03:03:44 +0000 (412c8cc)
+++ /dev/null
@@ -1,60 +0,0 @@
-require 'test/unit'
-require 'test/unit/ui/emacs/testrunner'
-
-class TestUnitEmacsRunner < Test::Unit::TestCase
- def test_format_failure_with_a_location
- runner = create_runner
- test_name = "test_failure"
- file = "/home/user/test_xxx.rb"
- line = "3"
- info = "in `xxx'"
- location = "#{file}:#{line}: #{info}"
- message = "FAIL!!!"
- failure = Test::Unit::Failure.new(test_name, [location], message)
- assert_equal(<<-EOM.chomp, runner.send(:format_fault, failure))
-Failure:
-#{test_name} [#{file}:#{line}]:
-#{message}
-EOM
- end
-
- def test_format_failure_with_locations
- runner = create_runner
- test_name = "test_failure"
- locations = ["/home/user/test_xxx.rb:3: in `xxx'",
- "/home/user/yyy/test_yyy.rb:999: in `yyy'",
- "/home/user/xyz/zzz.rb:29: in `zzz'"]
- message = "Many backtrace!!!"
- failure = Test::Unit::Failure.new(test_name, locations, message)
- assert_equal(<<-EOM.chomp, runner.send(:format_fault, failure))
-Failure:
-#{test_name}
-#{locations.join("\n")}:
-#{message}
-EOM
- end
-
- def test_format_error
- runner = create_runner
- test_name = "test_error"
- message = "Error Message!!!"
- backtrace = ["/home/user/test_xxx.rb:3: in `xxx'",
- "/home/user/yyy/test_yyy.rb:999: in `yyy'",
- "/home/user/xyz/zzz.rb:29: in `zzz'"]
- exception = RuntimeError.new(message)
- exception.set_backtrace(backtrace)
- error = Test::Unit::Error.new(test_name, exception)
- assert_equal(<<-EOM.chomp, runner.send(:format_fault, error))
-Error:
-#{test_name}:
-#{exception.class.name}: #{message}
-#{backtrace.join("\n")}
-EOM
- end
-
- private
- def create_runner(suite=nil)
- suite ||= Test::Unit::TestSuite.new
- Test::Unit::UI::Emacs::TestRunner.new(suite)
- end
-end
Deleted: test-unit/test/test_error.rb (+0 -26) 100644
===================================================================
--- test-unit/test/test_error.rb 2010-09-12 03:03:44 +0000 (56b275b)
+++ /dev/null
@@ -1,26 +0,0 @@
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit'
-
-module Test
- module Unit
- class TC_Error < TestCase
- TF_Exception = Struct.new('TF_Exception', :message, :backtrace)
- def test_display
- ex = TF_Exception.new("message1\nmessage2", ['line1', 'line2'])
- e = Error.new("name", ex)
- assert_equal("name: #{TF_Exception.name}: message1", e.short_display)
- assert_equal(<<EOM.strip, e.long_display)
-Error:
-name:
-Struct::TF_Exception: message1
-message2
- line1
- line2
-EOM
- end
- end
- end
-end
Deleted: test-unit/test/test_failure.rb (+0 -33) 100644
===================================================================
--- test-unit/test/test_failure.rb 2010-09-12 03:03:44 +0000 (164f942)
+++ /dev/null
@@ -1,33 +0,0 @@
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2003 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit'
-require 'test/unit/failure'
-
-module Test::Unit
- class TestFailure < TestCase
- def test_display
- f = Failure.new("name", [%q{location:1 in 'l'}], "message1\nmessage2")
- assert_equal("name: message1", f.short_display)
- assert_equal(<<EOM.strip, f.long_display)
-Failure:
-name [location:1]:
-message1
-message2
-EOM
-
- f = Failure.new("name", [%q{location1:2 in 'l1'}, 'location2:1', %q{location3:3 in 'l3'}], "message1\nmessage2")
- assert_equal("name: message1", f.short_display)
- assert_equal(<<EOM.strip, f.long_display)
-Failure:
-name
- [location1:2 in 'l1'
- location2:1
- location3:3 in 'l3']:
-message1
-message2
-EOM
- end
- end
-end
Deleted: test-unit/test/test_fixture.rb (+0 -252) 100644
===================================================================
--- test-unit/test/test_fixture.rb 2010-09-12 03:03:44 +0000 (25e7343)
+++ /dev/null
@@ -1,252 +0,0 @@
-class TestUnitFixture < Test::Unit::TestCase
- module EmptyModule
- end
-
- def test_setup_without_option
- test_case = assert_setup([:setup,
- :custom_setup_method0,
- :custom_setup_method1,
- :custom_setup_method3],
- [])
- assert_inherited_setup([:setup,
- :custom_setup_method0,
- :custom_setup_method1,
- :custom_setup_method3],
- test_case)
- assert_inherited_setup([:setup], nil)
- end
-
- def test_setup_with_before_option
- test_case = assert_setup([:custom_setup_method3,
- :custom_setup_method0,
- :custom_setup_method1,
- :setup],
- [[{:before => :append}],
- [{:before => :append}],
- [{:before => :prepend}],
- [{:before => :prepend}]])
- assert_inherited_setup([:custom_setup_method3,
- :custom_setup_method0,
- :custom_setup_method1,
- :setup],
- test_case)
- assert_inherited_setup([:setup], nil)
- end
-
- def test_setup_with_after_option
- test_case = assert_setup([:setup,
- :custom_setup_method3,
- :custom_setup_method0,
- :custom_setup_method1],
- [[{:after => :append}],
- [{:after => :append}],
- [{:after => :prepend}],
- [{:after => :prepend}]])
- assert_inherited_setup([:setup,
- :custom_setup_method3,
- :custom_setup_method0,
- :custom_setup_method1],
- test_case)
- assert_inherited_setup([:setup], nil)
- end
-
- def test_setup_with_invalid_option
- assert_invalid_setup_option(:unknown => true)
- assert_invalid_setup_option(:before => :unknown)
- assert_invalid_setup_option(:after => :unknown)
- end
-
- def test_teardown_without_option
- test_case = assert_teardown([:custom_teardown_method3,
- :custom_teardown_method1,
- :custom_teardown_method0,
- :teardown],
- [])
- assert_inherited_teardown([:custom_teardown_method3,
- :custom_teardown_method1,
- :custom_teardown_method0,
- :teardown],
- test_case)
- assert_inherited_teardown([:teardown], nil)
- end
-
- def test_teardown_with_before_option
- test_case = assert_teardown([:custom_teardown_method3,
- :custom_teardown_method0,
- :custom_teardown_method1,
- :teardown],
- [[{:before => :append}],
- [{:before => :append}],
- [{:before => :prepend}],
- [{:before => :prepend}]])
- assert_inherited_teardown([:custom_teardown_method3,
- :custom_teardown_method0,
- :custom_teardown_method1,
- :teardown],
- test_case)
- assert_inherited_teardown([:teardown], nil)
- end
-
- def test_teardown_with_after_option
- test_case = assert_teardown([:teardown,
- :custom_teardown_method3,
- :custom_teardown_method0,
- :custom_teardown_method1],
- [[{:after => :append}],
- [{:after => :append}],
- [{:after => :prepend}],
- [{:after => :prepend}]])
- assert_inherited_teardown([:teardown,
- :custom_teardown_method3,
- :custom_teardown_method0,
- :custom_teardown_method1],
- test_case)
- assert_inherited_teardown([:teardown], nil)
- end
-
- def test_teardown_with_invalid_option
- assert_invalid_teardown_option(:unknown => true)
- assert_invalid_teardown_option(:before => :unknown)
- assert_invalid_teardown_option(:after => :unknown)
- end
-
- private
- def assert_setup_customizable(expected, parent, options)
- called = []
- test_case = Class.new(parent || Test::Unit::TestCase) do
- yield(self, :before) if block_given?
-
- @@called = called
- def setup
- @@called << :setup
- end
-
- setup(*(options[0] || [])) if options
- def custom_setup_method0
- @@called << :custom_setup_method0
- end
-
- def custom_setup_method1
- @@called << :custom_setup_method1
- end
- setup(*[:custom_setup_method1, *(options[1] || [])]) if options
-
- setup(*(options[2] || [])) if options
- def custom_setup_method2
- @@called << :custom_setup_method2
- end
- unregister_setup(:custom_setup_method2) if options
-
- setup(*(options[3] || [])) if options
- def custom_setup_method3
- @@called << :custom_setup_method3
- end
-
- def test_nothing
- end
-
- yield(self, :after) if block_given?
- end
-
- test_case.new("test_nothing").run(Test::Unit::TestResult.new) {}
- assert_equal(expected, called)
- test_case
- end
-
- def assert_setup(expected, options)
- _test_case = assert_setup_customizable(expected, nil, options)
- assert_setup_customizable(expected, nil, options) do |test_case, tag|
- test_case.send(:include, EmptyModule) if tag == :before
- end
- _test_case
- end
-
- def assert_inherited_setup(expected, parent)
- _test_case = assert_setup_customizable(expected, parent, nil)
- assert_setup_customizable(expected, parent, nil) do |test_case, tag|
- test_case.send(:include, EmptyModule) if tag == :before
- end
- _test_case
- end
-
- def assert_teardown_customizable(expected, parent, options)
- called = []
- test_case = Class.new(parent || Test::Unit::TestCase) do
- yield(self, :before) if block_given?
-
- @@called = called
- def teardown
- @@called << :teardown
- end
-
- teardown(*(options[0] || [])) if options
- def custom_teardown_method0
- @@called << :custom_teardown_method0
- end
-
- def custom_teardown_method1
- @@called << :custom_teardown_method1
- end
- teardown(*[:custom_teardown_method1, *(options[1] || [])]) if options
-
- teardown(*(options[2] || [])) if options
- def custom_teardown_method2
- @@called << :custom_teardown_method2
- end
- unregister_teardown(:custom_teardown_method2) if options
-
- teardown(*(options[3] || [])) if options
- def custom_teardown_method3
- @@called << :custom_teardown_method3
- end
-
- def test_nothing
- end
-
- yield(self, :after) if block_given?
- end
-
- test_case.new("test_nothing").run(Test::Unit::TestResult.new) {}
- assert_equal(expected, called)
- test_case
- end
-
- def assert_teardown(expected, options)
- assert_teardown_customizable(expected, nil, options)
- assert_teardown_customizable(expected, nil, options) do |test_case, tag|
- test_case.send(:include, EmptyModule) if tag == :before
- end
- end
-
- def assert_inherited_teardown(expected, parent)
- assert_teardown_customizable(expected, parent, nil)
- assert_teardown_customizable(expected, parent, nil) do |test_case, tag|
- test_case.send(:include, EmptyModule) if tag == :before
- end
- end
-
- def assert_invalid_option(fixture_type, option)
- exception = assert_raise(ArgumentError) do
- Class.new(Test::Unit::TestCase) do
- def test_nothing
- end
-
- send(fixture_type, option)
- def fixture
- end
- end
- end
- assert_equal("must be {:before => :prepend}, {:before => :append}, " +
- "{:after => :prepend} or {:after => :append}" +
- ": #{option.inspect}",
- exception.message)
- end
-
- def assert_invalid_setup_option(option)
- assert_invalid_option(:setup, option)
- end
-
- def assert_invalid_teardown_option(option)
- assert_invalid_option(:teardown, option)
- end
-end
Deleted: test-unit/test/test_notification.rb (+0 -33) 100644
===================================================================
--- test-unit/test/test_notification.rb 2010-09-12 03:03:44 +0000 (7a85ddb)
+++ /dev/null
@@ -1,33 +0,0 @@
-require 'test/unit'
-require 'testunit_test_util'
-
-class TestNotification < Test::Unit::TestCase
- include TestUnitTestUtil
-
- class TestCase < Test::Unit::TestCase
- class << self
- def suite
- Test::Unit::TestSuite.new(name)
- end
- end
-
- def test_notify
- notify("1st notify")
- notify("2nd notify. Reach here.")
- end
- end
-
- def test_notify
- result = _run_test("test_notify")
- assert_equal("1 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, " \
- "0 omissions, 2 notifications",
- result.to_s)
- assert_fault_messages(["1st notify", "2nd notify. Reach here."],
- result.notifications)
- end
-
- private
- def _run_test(name)
- super(TestCase, name)
- end
-end
Deleted: test-unit/test/test_omission.rb (+0 -81) 100644
===================================================================
--- test-unit/test/test_omission.rb 2010-09-12 03:03:44 +0000 (bdafedc)
+++ /dev/null
@@ -1,81 +0,0 @@
-require 'test/unit'
-require 'testunit_test_util'
-
-class TestUnitOmission < Test::Unit::TestCase
- include TestUnitTestUtil
-
- class TestCase < Test::Unit::TestCase
- class << self
- def suite
- Test::Unit::TestSuite.new(name)
- end
- end
-
- def test_omit
- omit("1st omit")
- omit("2nd omit. Should not be reached here.")
- assert(true, "Should not be reached here too.")
- end
-
- def test_omit_with_condition
- omit_if(false, "Never omit.")
- omit_unless(true, "Never omit too.")
- omit_if(true, "Should omit.")
- omit("The last omit. Should not be reached here.")
- end
-
- def test_omit_with_block
- omit("Omit block") do
- flunk("Should not be reached here.")
- end
- assert(true, "Should be reached here.")
- end
-
- def test_omit_with_block_and_condition
- omit_if(false, "Never omit.") do
- assert(true, "Should be reached here.")
- end
- omit_if(true, "Should omit.") do
- flunk("Never reached here.")
- end
- assert(true, "Should be reached here too.")
- end
- end
-
- def test_omit
- result = _run_test("test_omit")
- assert_equal("1 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, " \
- "1 omissions, 0 notifications",
- result.to_s)
- assert_fault_messages(["1st omit"], result.omissions)
- end
-
- def test_omit_with_condition
- result = _run_test("test_omit_with_condition")
- assert_equal("1 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, " \
- "1 omissions, 0 notifications",
- result.to_s)
- assert_fault_messages(["Should omit."], result.omissions)
- end
-
- def test_omit_with_block
- result = _run_test("test_omit_with_block")
- assert_equal("1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, " \
- "1 omissions, 0 notifications",
- result.to_s)
- assert_fault_messages(["Omit block"], result.omissions)
- end
-
- def test_omit_with_condition_and_block
- result = _run_test("test_omit_with_block_and_condition")
- assert_equal("1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, " \
- "1 omissions, 0 notifications",
- result.to_s)
- assert_fault_messages(["Should omit."], result.omissions)
- end
-
- private
- def _run_test(name)
- super(TestCase, name)
- end
-end
Deleted: test-unit/test/test_pending.rb (+0 -70) 100644
===================================================================
--- test-unit/test/test_pending.rb 2010-09-12 03:03:44 +0000 (de1bc27)
+++ /dev/null
@@ -1,70 +0,0 @@
-require 'test/unit'
-require 'testunit_test_util'
-
-class TestUnitPending < Test::Unit::TestCase
- include TestUnitTestUtil
-
- class TestCase < Test::Unit::TestCase
- class << self
- def suite
- Test::Unit::TestSuite.new(name)
- end
- end
-
- def test_pend
- pend("1st pend")
- pend("2nd pend. Should not be reached here.")
- assert(true, "Should not be reached here too.")
- end
-
- def test_pend_with_failure_in_block
- pend("Wait a minute") do
- raise "Not implemented yet"
- end
- assert(true, "Reached here.")
- end
-
- def test_pend_with_no_failure_in_block
- pend("Wait a minute") do
- "Nothing raised"
- end
- assert(true, "Not reached here.")
- end
- end
-
- def test_pend
- test = nil
- result = _run_test("test_pend") {|t| test = t}
- assert_equal("1 tests, 0 assertions, 0 failures, 0 errors, 1 pendings, " \
- "0 omissions, 0 notifications",
- result.to_s)
- assert_fault_messages(["1st pend"], result.pendings)
- assert_true(test.interrupted?)
- end
-
- def test_pend_with_failure_in_block
- test = nil
- result = _run_test("test_pend_with_failure_in_block") {|t| test = t}
- assert_equal("1 tests, 1 assertions, 0 failures, 0 errors, 1 pendings, " \
- "0 omissions, 0 notifications",
- result.to_s)
- assert_fault_messages(["Wait a minute"], result.pendings)
- assert_false(test.interrupted?)
- end
-
- def test_pend_with_no_failure_in_block
- test = nil
- result = _run_test("test_pend_with_no_failure_in_block") {|t| test = t}
- assert_equal("1 tests, 1 assertions, 1 failures, 0 errors, 0 pendings, " \
- "0 omissions, 0 notifications",
- result.to_s)
- assert_fault_messages(["Pending block should not be passed: Wait a minute."],
- result.failures)
- assert_true(test.interrupted?)
- end
-
- private
- def _run_test(name, &block)
- super(TestCase, name, &block)
- end
-end
Deleted: test-unit/test/test_priority.rb (+0 -89) 100644
===================================================================
--- test-unit/test/test_priority.rb 2010-09-12 03:03:44 +0000 (5b3a8b9)
+++ /dev/null
@@ -1,89 +0,0 @@
-require 'test/unit'
-
-class TestUnitPriority < Test::Unit::TestCase
- class TestCase < Test::Unit::TestCase
- class << self
- def suite
- Test::Unit::TestSuite.new(name)
- end
- end
-
- priority :must
- def test_must
- assert(true)
- end
-
- def test_must_inherited
- assert(true)
- end
-
- priority :important
- def test_important
- assert(true)
- end
-
- def test_important_inherited
- assert(true)
- end
-
- priority :high
- def test_high
- assert(true)
- end
-
- def test_high_inherited
- assert(true)
- end
-
- priority :normal
- def test_normal
- assert(true)
- end
-
- def test_normal_inherited
- assert(true)
- end
-
- priority :low
- def test_low
- assert(true)
- end
-
- def test_low_inherited
- assert(true)
- end
-
- priority :never
- def test_never
- assert(true)
- end
-
- def test_never_inherited
- assert(true)
- end
- end
-
- def test_priority
- assert_priority("must", 1.0, 0.0001)
- assert_priority("important", 0.9, 0.09)
- assert_priority("high", 0.70, 0.1)
- assert_priority("normal", 0.5, 0.1)
- assert_priority("low", 0.25, 0.1)
- assert_priority("never", 0.0, 0.0001)
- end
-
- def assert_priority(priority, expected, delta)
- assert_need_to_run("test_#{priority}", expected, delta)
- assert_need_to_run("test_#{priority}_inherited", expected, delta)
- end
-
- def assert_need_to_run(test_name, expected, delta)
- test = TestCase.new(test_name)
- n = 1000
- n_need_to_run = 0
- n.times do |i|
- n_need_to_run +=1 if Test::Unit::Priority::Checker.need_to_run?(test)
- end
- assert_in_delta(expected, n_need_to_run.to_f / n, delta)
- end
-end
Deleted: test-unit/test/test_testcase.rb (+0 -430) 100644
===================================================================
--- test-unit/test/test_testcase.rb 2010-09-12 03:03:44 +0000 (6c7c46a)
+++ /dev/null
@@ -1,430 +0,0 @@
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit'
-
-module Test
- module Unit
- class TC_TestCase < TestCase
- def test_creation
- tc = Class.new(TestCase) do
- def test_with_arguments(arg1, arg2)
- end
- end
-
- caught = true
- catch(:invalid_test) do
- tc.new(:test_with_arguments)
- caught = false
- end
- check("Should have caught an invalid test when there are arguments", caught)
-
- caught = true
- catch(:invalid_test) do
- tc.new(:non_existent_test)
- caught = false
- end
- check("Should have caught an invalid test when the method does not exist", caught)
- end
-
- def setup
- @tc_failure_error = Class.new(TestCase) do
- def test_failure
- assert_block("failure") { false }
- end
- def test_error
- 1 / 0
- end
- def test_nested_failure
- nested
- end
- def nested
- assert_block("nested"){false}
- end
- def return_passed?
- return passed?
- end
- end
-
- def @tc_failure_error.name
- "TC_FailureError"
- end
- end
-
- def test_add_failed_assertion
- test_case = @tc_failure_error.new(:test_failure)
- check("passed? should start out true", test_case.return_passed?)
- result = TestResult.new
- called = false
- result.add_listener(TestResult::FAULT) {
- | fault |
- check("Should have a Failure", fault.instance_of?(Failure))
- check("The Failure should have the correct message", "failure" == fault.message)
- check("The Failure should have the correct test_name (was <#{fault.test_name}>)", fault.test_name == "test_failure(TC_FailureError)")
- r = /\A.*#{Regexp.escape(File.basename(__FILE__))}:\d+:in `test_failure'\Z/
-
- location = fault.location
- check("The location should be an array", location.kind_of?(Array))
- check("The location should have two lines (was: <#{location.inspect}>)", location.size == 2)
- check("The Failure should have the correct location (was <#{location[0].inspect}>, expected <#{r.inspect}>)", r =~ location[0])
- called = true
- }
- progress = []
- test_case.run(result) { |*arguments| progress << arguments }
- check("The failure should have triggered the listener", called)
- check("The failure should have set passed?", !test_case.return_passed?)
- check("The progress block should have been updated correctly", [[TestCase::STARTED, test_case.name], [TestCase::FINISHED, test_case.name]] == progress)
- end
-
- def test_add_failure_nested
- test_case = @tc_failure_error.new(:test_nested_failure)
- check("passed? should start out true", test_case.return_passed?)
-
- result = TestResult.new
- called = false
- result.add_listener(TestResult::FAULT) {
- | fault |
- check("Should have a Failure", fault.instance_of?(Failure))
- check("The Failure should have the correct message", "nested" == fault.message)
- check("The Failure should have the correct test_name (was <#{fault.test_name}>)", fault.test_name == "test_nested_failure(TC_FailureError)")
- r =
-
- location = fault.location
- check("The location should be an array", location.kind_of?(Array))
- check("The location should have the correct number of lines (was: <#{location.inspect}>)", location.size == 3)
- check("The Failure should have the correct location (was <#{location[0].inspect}>)", /\A.*#{Regexp.escape(File.basename(__FILE__))}:\d+:in `nested'\Z/ =~ location[0])
- check("The Failure should have the correct location (was <#{location[1].inspect}>)", /\A.*#{Regexp.escape(File.basename(__FILE__))}:\d+:in `test_nested_failure'\Z/ =~ location[1])
- called = true
- }
- test_case.run(result){}
- check("The failure should have triggered the listener", called)
- end
-
- def test_add_error
- test_case = @tc_failure_error.new(:test_error)
- check("passed? should start out true", test_case.return_passed?)
- result = TestResult.new
- called = false
- result.add_listener(TestResult::FAULT) {
- | fault |
- check("Should have a TestError", fault.instance_of?(Error))
- check("The Error should have the correct message", "ZeroDivisionError: divided by 0" == fault.message)
- check("The Error should have the correct test_name", "test_error(TC_FailureError)" == fault.test_name)
- check("The Error should have the correct exception", fault.exception.instance_of?(ZeroDivisionError))
- called = true
- }
- test_case.run(result) {}
- check("The error should have triggered the listener", called)
- check("The error should have set passed?", !test_case.return_passed?)
- end
-
- def test_no_tests
- suite = TestCase.suite
- check("Should have a test suite", suite.instance_of?(TestSuite))
- check("Should have one test", suite.size == 1)
- check("Should have the default test", suite.tests.first.name == "default_test(Test::Unit::TestCase)")
-
- result = TestResult.new
- suite.run(result) {}
- check("Should have had one test run", result.run_count == 1)
- check("Should have had one test failure", result.failure_count == 1)
- check("Should have had no errors", result.error_count == 0)
- end
-
- def test_suite
- tc = Class.new(TestCase) do
- def test_succeed
- assert_block {true}
- end
- def test_fail
- assert_block {false}
- end
- def test_error
- 1/0
- end
- def dont_run
- assert_block {true}
- end
- def test_dont_run(argument)
- assert_block {true}
- end
- def test
- assert_block {true}
- end
- end
-
- suite = tc.suite
- check("Should have a test suite", suite.instance_of?(TestSuite))
- check("Should have three tests", suite.size == 3)
-
- result = TestResult.new
- suite.run(result) {}
- check("Should have had three test runs", result.run_count == 3)
- check("Should have had one test failure", result.failure_count == 1)
- check("Should have had one test error", result.error_count == 1)
- end
-
-
- def test_setup_teardown
- tc = Class.new(TestCase) do
- attr_reader(:setup_called, :teardown_called)
- def initialize(test)
- super(test)
- @setup_called = false
- @teardown_called = false
- end
- def setup
- @setup_called = true
- end
- def teardown
- @teardown_called = true
- end
- def test_succeed
- assert_block {true}
- end
- def test_fail
- assert_block {false}
- end
- def test_error
- raise "Error!"
- end
- end
- result = TestResult.new
-
- test = tc.new(:test_succeed)
- test.run(result) {}
- check("Should have called setup the correct number of times", test.setup_called)
- check("Should have called teardown the correct number of times", test.teardown_called)
-
- test = tc.new(:test_fail)
- test.run(result) {}
- check("Should have called setup the correct number of times", test.setup_called)
- check("Should have called teardown the correct number of times", test.teardown_called)
-
- test = tc.new(:test_error)
- test.run(result) {}
- check("Should have called setup the correct number of times", test.setup_called)
- check("Should have called teardown the correct number of times", test.teardown_called)
-
- check("Should have had two test runs", result.run_count == 3)
- check("Should have had a test failure", result.failure_count == 1)
- check("Should have had a test error", result.error_count == 1)
- end
-
- def test_assertion_failed_not_called
- tc = Class.new(TestCase) do
- def test_thing
- raise AssertionFailedError.new
- end
- end
-
- suite = tc.suite
- check("Should have one test", suite.size == 1)
- result = TestResult.new
- suite.run(result) {}
- check("Should have had one test run", result.run_count == 1)
- check("Should have had one assertion failure", result.failure_count == 1)
- check("Should not have any assertion errors but had #{result.error_count}", result.error_count == 0)
- end
-
- def test_equality
- tc1 = Class.new(TestCase) do
- def test_1
- end
- def test_2
- end
- end
-
- tc2 = Class.new(TestCase) do
- def test_1
- end
- end
-
- test1 = tc1.new('test_1')
- test2 = tc1.new('test_1')
- check("Should be equal", test1 == test2)
- check("Should be equal", test2 == test1)
-
- test1 = tc1.new('test_2')
- check("Should not be equal", test1 != test2)
- check("Should not be equal", test2 != test1)
-
- test2 = tc1.new('test_2')
- check("Should be equal", test1 == test2)
- check("Should be equal", test2 == test1)
-
- test1 = tc1.new('test_1')
- test2 = tc2.new('test_1')
- check("Should not be equal", test1 != test2)
- check("Should not be equal", test2 != test1)
-
-
- check("Should not be equal", test1 != Object.new)
- check("Should not be equal", Object.new != test1)
- end
-
- def test_re_raise_exception
- test_case = Class.new(TestCase) do
- def test_raise_interrupt
- raise Interrupt
- end
- end
-
- test = test_case.new("test_raise_interrupt")
- begin
- test.run(TestResult.new) {}
- check("Should not be reached", false)
- rescue Exception
- check("Interrupt exception should be re-raised", $!.class == Interrupt)
- end
- end
-
- def test_startup_shutdown
- called = []
- test_case = Class.new(TestCase) do
- @@called = called
- class << self
- def startup
- @@called << :startup
- end
-
- def shutdown
- @@called << :shutdown
- end
- end
-
- def setup
- @@called << :setup
- end
-
- def teardown
- @@called << :teardown
- end
-
- def test1
- end
-
- def test2
- end
- end
-
- test_suite = test_case.suite
- test_suite.run(TestResult.new) {}
- check("startup/shutdown should be called once per test case" +
- ": #{called.inspect}",
- called == [:startup,
- :setup, :teardown,
- :setup, :teardown,
- :shutdown])
- end
-
- def test_error_on_startup
- test_case = Class.new(TestCase) do
- class << self
- def startup
- raise "from startup"
- end
- end
-
- def test_nothing
- end
- end
-
- test_suite = test_case.suite
- result = TestResult.new
- test_suite.run(result) {}
- check("Should record an error on startup: #{result}",
- result.error_count == 1)
- end
-
- def test_pass_through_error_on_startup
- test_case = Class.new(TestCase) do
- class << self
- def startup
- raise Interrupt
- end
- end
-
- def test_nothing
- end
- end
-
- test_suite = test_case.suite
- begin
- test_suite.run(TestResult.new) {}
- check("Should not be reached", false)
- rescue Exception
- check("Interrupt should be passed through: #{$!}",
- Interrupt === $!)
- end
- end
-
- def test_error_on_shutdown
- test_case = Class.new(TestCase) do
- class << self
- def shutdown
- raise "from shutdown"
- end
- end
-
- def test_nothing
- end
- end
-
- test_suite = test_case.suite
- result = TestResult.new
- test_suite.run(result) {}
- check("Should record an error on shutdown: #{result}",
- result.error_count == 1)
- end
-
- def test_pass_through_error_on_shutdown
- test_case = Class.new(TestCase) do
- class << self
- def shutdown
- raise Interrupt
- end
- end
-
- def test_nothing
- end
- end
-
- test_suite = test_case.suite
- begin
- test_suite.run(TestResult.new) {}
- check("Should not be reached", false)
- rescue Exception
- check("Interrupt should be passed through: #{$!}",
- Interrupt === $!)
- end
- end
-
- def test_interrupted
- test_case = Class.new(TestCase) do
- def test_fail
- flunk
- end
-
- def test_nothing
- end
- end
-
- failed_test = test_case.new(:test_fail)
- failed_test.run(TestResult.new) {}
- check("Should be interrupted", failed_test.interrupted?)
-
- success_test = test_case.new(:test_nothing)
- success_test.run(TestResult.new) {}
- check("Should not be interrupted", !success_test.interrupted?)
- end
-
- private
- def check(message, passed)
- add_assertion
- raise AssertionFailedError.new(message) unless passed
- end
- end
- end
-end
Deleted: test-unit/test/test_testresult.rb (+0 -113) 100644
===================================================================
--- test-unit/test/test_testresult.rb 2010-09-12 03:03:44 +0000 (889179e)
+++ /dev/null
@@ -1,113 +0,0 @@
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit/testcase'
-require 'test/unit/testresult'
-
-module Test
- module Unit
- class TC_TestResult < TestCase
- def setup
- @my_result = TestResult.new
- @my_result.add_assertion()
- @failure = "failure"
- @my_result.add_failure(@failure)
- @error = "error"
- @my_result.add_error(@error)
- end
-
- def test_result_changed_notification
- called1 = false
- @my_result.add_listener(TestResult::CHANGED) do |result|
- assert_equal(@my_result, result)
- called1 = true
- end
- @my_result.add_assertion
- assert_true(called1)
-
- called1, called2 = false, false
- @my_result.add_listener(TestResult::CHANGED) do |result|
- assert_equal(@my_result, result)
- called2 = true
- end
- @my_result.add_assertion
- assert_equal([true, true], [called1, called2])
-
- called1, called2 = false, false
- @my_result.add_failure("")
- assert_equal([true, true], [called1, called2])
-
- called1, called2 = false, false
- @my_result.add_error("")
- assert_equal([true, true], [called1, called2])
-
- called1, called2 = false, false
- @my_result.add_run
- assert_equal([true, true], [called1, called2])
- end
-
- def test_fault_notification
- called1 = false
- fault = "fault"
- @my_result.add_listener(TestResult::FAULT) do |passed_fault|
- assert_equal(fault, passed_fault)
- called1 = true
- end
-
- @my_result.add_assertion
- assert_false(called1)
-
- @my_result.add_failure(fault)
- assert_true(called1)
-
- called1, called2 = false, false
- @my_result.add_listener(TestResult::FAULT) do |passed_fault|
- assert_equal(fault, passed_fault)
- called2 = true
- end
-
- @my_result.add_assertion
- assert_equal([false, false], [called1, called2])
-
- called1, called2 = false, false
- @my_result.add_failure(fault)
- assert_equal([true, true], [called1, called2])
-
- called1, called2 = false, false
- @my_result.add_error(fault)
- assert_equal([true, true], [called1, called2])
-
- called1, called2 = false, false
- @my_result.add_run
- assert_equal([false, false], [called1, called2])
- end
-
- def test_passed?
- result = TestResult.new
- assert_true(result.passed?)
-
- result.add_assertion
- assert_true(result.passed?)
-
- result.add_run
- assert_true(result.passed?)
-
- result.add_failure("")
- assert_false(result.passed?)
-
- result = TestResult.new
- result.add_error("")
- assert_false(result.passed?)
- end
-
- def test_faults
- assert_equal([@failure, @error], @my_result.faults)
-
- notification = "notification"
- @my_result.add_notification(notification)
- assert_equal([@failure, @error, notification], @my_result.faults)
- end
- end
- end
-end
Deleted: test-unit/test/test_testsuite.rb (+0 -129) 100644
===================================================================
--- test-unit/test/test_testsuite.rb 2010-09-12 03:03:44 +0000 (5f6631d)
+++ /dev/null
@@ -1,129 +0,0 @@
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit'
-
-module Test
- module Unit
- class TC_TestSuite < TestCase
- def setup
- @testcase1 = Class.new(TestCase) do
- def test_succeed1
- assert_block { true }
- end
- def test_fail
- assert_block { false }
- end
- end
-
- @testcase2 = Class.new(TestCase) do
- def test_succeed2
- assert_block { true }
- end
- def test_error
- raise
- end
- end
- end
-
- def test_add
- s = TestSuite.new
- assert_equal(s, s << self.class.new("test_add"))
- end
-
- def test_delete
- s = TestSuite.new
- t1 = self.class.new("test_delete")
- s << t1
- t2 = self.class.new("test_add")
- s << t2
- assert_equal(t1, s.delete(t1))
- assert_nil(s.delete(t1))
- assert_equal(TestSuite.new << t2, s)
- end
-
- def test_size
- suite = TestSuite.new
- suite2 = TestSuite.new
- suite2 << self.class.new("test_size")
- suite << suite2
- suite << self.class.new("test_size")
- assert_equal(2, suite.size, "The count should be correct")
- end
-
- def test_run
- progress = []
- suite = @testcase1.suite
- result = TestResult.new
- suite.run(result) { |*values| progress << values }
-
- assert_equal(2, result.run_count, "Should have had four test runs")
- assert_equal(1, result.failure_count, "Should have had one test failure")
- assert_equal(0, result.error_count, "Should have had one test error")
- assert_equal([[TestSuite::STARTED, suite.name],
- [TestCase::STARTED, "test_fail(#{suite.name})"],
- [TestCase::FINISHED, "test_fail(#{suite.name})"],
- [TestCase::STARTED, "test_succeed1(#{suite.name})"],
- [TestCase::FINISHED, "test_succeed1(#{suite.name})"],
- [TestSuite::FINISHED, suite.name]],
- progress, "Should have had the correct progress")
-
- suite = TestSuite.new
- suite << @testcase1.suite
- suite << @testcase2.suite
- result = TestResult.new
- progress = []
- suite.run(result) { |*values| progress << values }
-
- assert_equal(4, result.run_count, "Should have had four test runs")
- assert_equal(1, result.failure_count, "Should have had one test failure")
- assert_equal(1, result.error_count, "Should have had one test error")
- assert_equal(14, progress.size, "Should have had the correct number of progress calls")
- end
-
- def test_empty?
- assert(TestSuite.new.empty?, "A new test suite should be empty?")
- assert(!@testcase2.suite.empty?, "A test suite with tests should not be empty")
- end
-
- def test_equality
- suite1 = TestSuite.new
- suite2 = TestSuite.new
- assert_equal(suite1, suite2)
- assert_equal(suite2, suite1)
-
- suite1 = TestSuite.new('name')
- assert_not_equal(suite1, suite2)
- assert_not_equal(suite2, suite1)
-
- suite2 = TestSuite.new('name')
- assert_equal(suite1, suite2)
- assert_equal(suite2, suite1)
-
- suite1 << 'test'
- assert_not_equal(suite1, suite2)
- assert_not_equal(suite2, suite1)
-
- suite2 << 'test'
- assert_equal(suite1, suite2)
- assert_equal(suite2, suite1)
-
- suite2 = Object.new
- class << suite2
- def name
- 'name'
- end
- def tests
- ['test']
- end
- end
- assert_not_equal(suite1, suite2)
- assert_not_equal(suite2, suite1)
-
- assert_not_equal(suite1, Object.new)
- assert_not_equal(Object.new, suite1)
- end
- end
- end
-end
Deleted: test-unit/test/testunit_test_util.rb (+0 -14) 100644
===================================================================
--- test-unit/test/testunit_test_util.rb 2010-09-12 03:03:44 +0000 (33527b9)
+++ /dev/null
@@ -1,14 +0,0 @@
-module TestUnitTestUtil
- private
- def assert_fault_messages(expected, faults)
- assert_equal(expected, faults.collect {|fault| fault.message})
- end
-
- def _run_test(test_case, name)
- result = Test::Unit::TestResult.new
- test = test_case.new(name)
- yield(test) if block_given?
- test.run(result) {}
- result
- end
-end
Deleted: test-unit/test/ui/test_testrunmediator.rb (+0 -20) 100644
===================================================================
--- test-unit/test/ui/test_testrunmediator.rb 2010-09-12 03:03:44 +0000 (332a843)
+++ /dev/null
@@ -1,20 +0,0 @@
-require 'test/unit/ui/testrunnermediator'
-
-class TestUnitUIMediator < Test::Unit::TestCase
- def test_run_suite_with_interrupt_exception
- test_case = Class.new(Test::Unit::TestCase) do
- def test_raise_interrupt
- raise Interrupt
- end
- end
- mediator = Test::Unit::UI::TestRunnerMediator.new(test_case.suite)
- finished = false
- mediator.add_listener(Test::Unit::UI::TestRunnerMediator::FINISHED) do
- finished = true
- end
- assert_raise(Interrupt) do
- mediator.run_suite
- end
- assert(finished)
- end
-end
Deleted: test-unit/test/util/test_backtracefilter.rb (+0 -41) 100644
===================================================================
--- test-unit/test/util/test_backtracefilter.rb 2010-09-12 03:03:44 +0000 (d4e40ea)
+++ /dev/null
@@ -1,41 +0,0 @@
-require 'test/unit'
-
-require 'test/unit/util/backtracefilter'
-
-module Test::Unit::Util
- class TestBacktraceFilter < Test::Unit::TestCase
- include BacktraceFilter
-
- def test_filter_backtrace
- backtrace = [%q{C:\some\old\path/test/unit/assertions.rb:44:in 'assert'},
- %q{tc_thing.rb:4:in 'a'},
- %q{tc_thing.rb:4:in 'test_stuff'},
- %q{C:\some\old\path/test/unit/testcase.rb:44:in 'send'},
- %q{C:\some\old\path\test\unit\testcase.rb:44:in 'run'},
- %q{C:\some\old\path\test\unit.rb:44:in 'run'},
- %q{tc_thing.rb:3}]
- assert_equal(backtrace[1..2], filter_backtrace(backtrace, %q{C:\some\old\path\test\unit}), "Should filter out all TestUnit-specific lines")
-
-backtrace = [%q{tc_thing.rb:4:in 'a'},
- %q{tc_thing.rb:4:in 'test_stuff'},
- %q{tc_thing.rb:3}]
- assert_equal(backtrace, filter_backtrace(backtrace, %q{C:\some\old\path\test\unit}), "Shouldn't filter too much")
-
- backtrace = [%q{C:\some\old\path/test/unit/assertions.rb:44:in 'assert'},
- %q{tc_thing.rb:4:in 'a'},
- %q{tc_thing.rb:4:in 'test_stuff'},
- %q{tc_thing.rb:3}]
- assert_equal(backtrace[1..3], filter_backtrace(backtrace, %q{C:\some\old\path\test\unit}), "Should filter out all TestUnit-specific lines")
-
- backtrace = [%q{C:\some\old\path/test/unit/assertions.rb:44:in 'assert'},
- %q{C:\some\old\path/test/unit/testcase.rb:44:in 'send'},
- %q{C:\some\old\path\test\unit\testcase.rb:44:in 'run'},
- %q{C:\some\old\path\test\unit.rb:44:in 'run'}]
- assert_equal(backtrace, filter_backtrace(backtrace, %q{C:\some\old\path\test\unit}), "Should filter out all TestUnit-specific lines")
- end
-
- def test_nil_backtrace
- assert_equal(["No backtrace"], filter_backtrace(nil))
- end
- end
-end
Deleted: test-unit/test/util/test_observable.rb (+0 -102) 100644
===================================================================
--- test-unit/test/util/test_observable.rb 2010-09-12 03:03:44 +0000 (6cd1018)
+++ /dev/null
@@ -1,102 +0,0 @@
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit/util/observable'
-
-module Test
- module Unit
- module Util
- class TC_Observable < TestCase
-
- class TF_Observable
- include Observable
- end
-
- def setup
- @observable = TF_Observable.new
- end
-
- def test_simple_observation
- assert_raises(ArgumentError, "add_listener should throw an exception if no callback is supplied") do
- @observable.add_listener(:property, "a")
- end
-
- heard = false
- callback = proc { heard = true }
- assert_equal("a", @observable.add_listener(:property, "a", &callback), "add_listener should return the listener that was added")
-
- count = 0
- @observable.instance_eval do
- count = notify_listeners(:property)
- end
- assert_equal(1, count, "notify_listeners should have returned the number of listeners that were notified")
- assert(heard, "Should have heard the property changed")
-
- heard = false
- assert_equal(callback, @observable.remove_listener(:property, "a"), "remove_listener should return the callback")
-
- count = 1
- @observable.instance_eval do
- count = notify_listeners(:property)
- end
- assert_equal(0, count, "notify_listeners should have returned the number of listeners that were notified")
- assert(!heard, "Should not have heard the property change")
- end
-
- def test_value_observation
- value = nil
- @observable.add_listener(:property, "a") do |passed_value|
- value = passed_value
- end
- count = 0
- @observable.instance_eval do
- count = notify_listeners(:property, "stuff")
- end
- assert_equal(1, count, "Should have update the correct number of listeners")
- assert_equal("stuff", value, "Should have received the value as an argument to the listener")
- end
-
- def test_multiple_value_observation
- values = []
- @observable.add_listener(:property, "a") do |first_value, second_value|
- values = [first_value, second_value]
- end
- count = 0
- @observable.instance_eval do
- count = notify_listeners(:property, "stuff", "more stuff")
- end
- assert_equal(1, count, "Should have update the correct number of listeners")
- assert_equal(["stuff", "more stuff"], values, "Should have received the value as an argument to the listener")
- end
-
- def test_add_remove_with_default_listener
- assert_raises(ArgumentError, "add_listener should throw an exception if no callback is supplied") do
- @observable.add_listener(:property)
- end
-
- heard = false
- callback = proc { heard = true }
- assert_equal(callback, @observable.add_listener(:property, &callback), "add_listener should return the listener that was added")
-
- count = 0
- @observable.instance_eval do
- count = notify_listeners(:property)
- end
- assert_equal(1, count, "notify_listeners should have returned the number of listeners that were notified")
- assert(heard, "Should have heard the property changed")
-
- heard = false
- assert_equal(callback, @observable.remove_listener(:property, callback), "remove_listener should return the callback")
-
- count = 1
- @observable.instance_eval do
- count = notify_listeners(:property)
- end
- assert_equal(0, count, "notify_listeners should have returned the number of listeners that were notified")
- assert(!heard, "Should not have heard the property change")
- end
- end
- end
- end
-end
Deleted: test-unit/test/util/test_procwrapper.rb (+0 -36) 100644
===================================================================
--- test-unit/test/util/test_procwrapper.rb 2010-09-12 03:03:44 +0000 (3e552c7)
+++ /dev/null
@@ -1,36 +0,0 @@
-# Author:: Nathaniel Talbott.
-# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
-# License:: Ruby license.
-
-require 'test/unit'
-require 'test/unit/util/procwrapper'
-
-module Test
- module Unit
- module Util
- class TC_ProcWrapper < TestCase
- def munge_proc(&a_proc)
- return a_proc
- end
- def setup
- @original = proc {}
- @munged = munge_proc(&@original)
- @wrapped_original = ProcWrapper.new(@original)
- @wrapped_munged = ProcWrapper.new(@munged)
- end
- def test_wrapping
- assert_same(@original, @wrapped_original.to_proc, "The wrapper should return what was wrapped")
- end
- def test_hashing
-
- assert_equal(@wrapped_original.hash, @wrapped_munged.hash, "The original and munged should have the same hash when wrapped")
- assert_equal(@wrapped_original, @wrapped_munged, "The wrappers should be equivalent")
-
- a_hash = {@wrapped_original => @original}
- assert(a_hash[@wrapped_original], "Should be able to access the wrapper in the hash")
- assert_equal(a_hash[@wrapped_original], @original, "Should be able to access the wrapper in the hash")
- end
- end
- end
- end
-end
Modified: test/run-test.rb (+2 -3)
===================================================================
--- test/run-test.rb 2010-09-12 03:03:44 +0000 (92058da)
+++ test/run-test.rb 2010-09-12 03:48:18 +0000 (98afe63)
@@ -1,7 +1,6 @@
#!/usr/bin/env ruby
base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
-test_unit_dir = File.join(base_dir, "test-unit", "lib")
ext_dir = File.join(base_dir, "ext", "cairo")
lib_dir = File.join(base_dir, "lib")
test_dir = File.join(base_dir, "test")
@@ -12,8 +11,8 @@ if system("which make > /dev/null")
end
end
-$LOAD_PATH.unshift(test_unit_dir)
-
+require 'rubygems'
+gem 'test-unit'
require 'test/unit'
$LOAD_PATH.unshift(base_dir)
More information about the cairo-commit
mailing list