diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/t/exception.rb | 18 | ||||
| -rw-r--r-- | test/t/kernel.rb | 34 | ||||
| -rw-r--r-- | test/t/module.rb | 12 |
3 files changed, 56 insertions, 8 deletions
diff --git a/test/t/exception.rb b/test/t/exception.rb index 186ac2892..8aa07e813 100644 --- a/test/t/exception.rb +++ b/test/t/exception.rb @@ -295,7 +295,7 @@ end assert('Exception 17') do r=begin - raise "a" # StandardError + raise "a" # RuntimeError rescue ArgumentError 1 rescue StandardError @@ -365,13 +365,21 @@ assert('Exception#backtrace') do end assert('Raise in ensure') do - - assert_raise(RuntimeError) do + assert_raise(ArgumentError) do begin - raise "" + raise "" # RuntimeError ensure - raise "" + raise ArgumentError end end +end +assert('Raise in rescue') do + assert_raise(ArgumentError) do + begin + raise "" # RuntimeError + rescue + raise ArgumentError + end + end end diff --git a/test/t/kernel.rb b/test/t/kernel.rb index ebcc37129..427d71e36 100644 --- a/test/t/kernel.rb +++ b/test/t/kernel.rb @@ -437,6 +437,26 @@ assert('Kernel#raise', '15.3.1.3.40') do end end +assert('Kernel#remove_instance_variable', '15.3.1.3.41') do + class Test4RemoveInstanceVar + attr_reader :var + def initialize + @var = 99 + end + def remove + remove_instance_variable(:@var) + end + end + + tri = Test4RemoveInstanceVar.new + assert_equal 99, tri.var + tri.remove + assert_equal nil, tri.var + assert_raise NameError do + tri.remove + end +end + # Kernel#require is defined in mruby-require. '15.3.1.3.42' assert('Kernel#respond_to?', '15.3.1.3.43') do @@ -487,6 +507,20 @@ assert('Kernel#to_s', '15.3.1.3.46') do assert_equal to_s.class, String end +assert('Kernel.local_variables', '15.3.1.2.7') do + a, b = 0, 1 + a += b + + vars = Kernel.local_variables.sort + assert_equal [:a, :b, :vars], vars + + Proc.new { + c = 2 + vars = Kernel.local_variables.sort + assert_equal [:a, :b, :c, :vars], vars + }.call +end + assert('Kernel#!=') do str1 = "hello" str2 = str1 diff --git a/test/t/module.rb b/test/t/module.rb index 585774a4b..806824b70 100644 --- a/test/t/module.rb +++ b/test/t/module.rb @@ -254,7 +254,7 @@ assert('Module#const_get', '15.2.2.4.21') do assert_equal 42, Test4ConstGet.const_get(:Const4Test4ConstGet) end -assert('Module.const_missing', '15.2.2.4.22') do +assert('Module#const_missing', '15.2.2.4.22') do module Test4ConstMissing def self.const_missing(sym) 42 # the answer to everything @@ -273,7 +273,7 @@ assert('Module#const_get', '15.2.2.4.23') do assert_equal 23, Test4ConstSet.const_get(:Const4Test4ConstSet) end -assert('Module.constants', '15.2.2.4.24') do +assert('Module#constants', '15.2.2.4.24') do $n = [] module TestA C = 1 @@ -340,6 +340,12 @@ assert('Module#included_modules', '15.2.2.4.30') do assert_true r.include?(Test4includedModules) end +assert('Module#initialize', '15.2.2.4.31') do + assert_kind_of Module, Module.new + mod = Module.new { def hello; "hello"; end } + assert_equal [:hello], mod.instance_methods +end + assert('Module#instance_methods', '15.2.2.4.33') do module Test4InstanceMethodsA def method1() end @@ -444,7 +450,7 @@ assert('Module#remove_method', '15.2.2.4.41') do assert_false Test4RemoveMethod::Child.instance_methods(false).include? :hello end -assert('Module.undef_method', '15.2.2.4.42') do +assert('Module#undef_method', '15.2.2.4.42') do module Test4UndefMethod class Parent def hello |
