1module ExceptionSpecs
2  class Exceptional < Exception; end
3
4  class Backtrace
5    def self.backtrace
6      begin
7        raise # If you move this line, update backtrace_spec.rb
8      rescue RuntimeError => e
9        e.backtrace
10      end
11    end
12
13    def self.backtrace_locations
14      begin
15        raise
16      rescue RuntimeError => e
17        e.backtrace_locations
18      end
19    end
20  end
21
22  class UnExceptional < Exception
23    def backtrace
24      nil
25    end
26    def message
27      nil
28    end
29  end
30
31  class ConstructorException < Exception
32
33    def initialize
34    end
35
36  end
37
38  class OverrideToS < RuntimeError
39    def to_s
40      "this is from #to_s"
41    end
42  end
43
44  class EmptyToS < RuntimeError
45    def to_s
46      ""
47    end
48  end
49
50  class InitializeException < StandardError
51    attr_reader :ivar
52
53    def initialize(message = nil)
54      super
55      @ivar = 1
56    end
57
58    def initialize_copy(other)
59      super
60      ScratchPad.record object_id
61    end
62  end
63
64  module ExceptionModule
65    def repr
66      1
67    end
68  end
69end
70
71module NoMethodErrorSpecs
72  class NoMethodErrorA; end
73
74  class NoMethodErrorB; end
75
76  class NoMethodErrorC;
77    protected
78    def a_protected_method;end
79    private
80    def a_private_method; end
81  end
82
83  class NoMethodErrorD; end
84
85  class InstanceException < Exception
86  end
87end
88
89class NameErrorSpecs
90  class ReceiverClass
91    def call_undefined_class_variable
92      @@doesnt_exist
93    end
94  end
95end
96