File: testException3.rb

package info (click to toggle)
jruby 1.5.1-1
  • links: PTS, VCS
  • area: non-free
  • in suites: squeeze
  • size: 46,252 kB
  • ctags: 72,039
  • sloc: ruby: 398,155; java: 169,482; yacc: 3,782; xml: 2,469; ansic: 415; sh: 279; makefile: 78; tcl: 40
file content (31 lines) | stat: -rw-r--r-- 780 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'test/unit'

class TC_Exception_Status_InstanceMethod < Test::Unit::TestCase
   def setup
      @err = nil
      begin; exit(99); rescue SystemExit => @err; end
   end

   def test_status_basic
      assert_respond_to(@err, :status)
      assert_nothing_raised{ @err.status }
      assert_kind_of(Fixnum, @err.status)
   end

   def test_status
      assert_equal(99, @err.status)
      begin; exit(-1); rescue SystemExit => @err; end
      assert_equal(-1, @err.status)
   end
   
   # Only the SystemExit class implements this method
   def test_status_expected_errors
      assert_raise(ArgumentError){ @err.status(99) }
      begin; 1/0; rescue Exception => @err; end
      assert_raise(NoMethodError){ @err.status }
   end

   def teardown
      @err = nil
   end
end