mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* test/testunit/*: Added.
* lib/test/unit.rb: Documentation update. * lib/test/unit/ui/console/testrunner.rb (TestRunner#initialize): Ditto. * lib/test/unit.rb: Factored out an ObjectSpace collector. * lib/test/unit/collector/objectspace.rb: Ditto. * sample/testunit/*: Added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									50cd24f1cf
								
							
						
					
					
						commit
						65fe176ea4
					
				
					 17 changed files with 1448 additions and 24 deletions
				
			
		
							
								
								
									
										13
									
								
								sample/testunit/adder.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								sample/testunit/adder.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
# 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
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										12
									
								
								sample/testunit/subtracter.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								sample/testunit/subtracter.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,12 @@
 | 
			
		|||
# 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
 | 
			
		||||
							
								
								
									
										18
									
								
								sample/testunit/tc_adder.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								sample/testunit/tc_adder.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,18 @@
 | 
			
		|||
# 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
 | 
			
		||||
							
								
								
									
										18
									
								
								sample/testunit/tc_subtracter.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								sample/testunit/tc_subtracter.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,18 @@
 | 
			
		|||
# 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
 | 
			
		||||
							
								
								
									
										7
									
								
								sample/testunit/ts_examples.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								sample/testunit/ts_examples.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,7 @@
 | 
			
		|||
# 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'
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue