diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/assert.rb | 18 | ||||
| -rw-r--r-- | test/mrbtest.rake | 17 | ||||
| -rw-r--r-- | test/t/hash.rb | 1 |
3 files changed, 35 insertions, 1 deletions
diff --git a/test/assert.rb b/test/assert.rb index d2d865649..1e9a781d6 100644 --- a/test/assert.rb +++ b/test/assert.rb @@ -174,6 +174,24 @@ def assert_raise(*exp) ret end +def assert_nothing_raised(*exp) + ret = true + if $mrbtest_assert + $mrbtest_assert_idx += 1 + msg = exp.last.class == String ? exp.pop : "" + begin + yield + rescue Exception => e + msg = "#{msg} exception raised." + diff = " Class: <#{e.class}>\n" + + " Message: #{e.message}" + $mrbtest_assert.push([$mrbtest_assert_idx, msg, diff]) + ret = false + end + end + ret +end + ## # Fails unless +obj+ is a kind of +cls+. def assert_kind_of(cls, obj, msg = nil) diff --git a/test/mrbtest.rake b/test/mrbtest.rake index 35495889e..1c52eafbd 100644 --- a/test/mrbtest.rake +++ b/test/mrbtest.rake @@ -12,9 +12,11 @@ MRuby.each_target do ass_lib = ass_c.ext(exts.object) mrbtest_lib = libfile("#{current_build_dir}/mrbtest") - file mrbtest_lib => [mlib, ass_lib, gems.map(&:test_objs), gems.map { |g| g.test_rbireps.ext(exts.object) }].flatten do |t| + gem_test_files = gems.select { |g| g.run_test_in_other_mrb_state? }.map { |g| g.test_rbireps.ext(exts.object) } + file mrbtest_lib => [mlib, ass_lib, gems.map(&:test_objs), gem_test_files].flatten do |t| archiver.run t.name, t.prerequisites end + file mrbtest_lib => "#{build_dir}/test/no_mrb_open_test.o" unless build_mrbtest_lib_only? driver_obj = objfile("#{current_build_dir}/driver") @@ -41,15 +43,28 @@ MRuby.each_target do _pp "GEN", "*.rb", "#{clib.relative_path}" FileUtils.mkdir_p File.dirname(clib) open(clib, 'w') do |f| + f.puts %Q[/*] + f.puts %Q[ * This file contains a list of all] + f.puts %Q[ * test functions.] + f.puts %Q[ *] + f.puts %Q[ * IMPORTANT:] + f.puts %Q[ * This file was generated!] + f.puts %Q[ * All manual changes will get lost.] + f.puts %Q[ */] + f.puts %Q[] f.puts IO.read(init) mrbc.run f, mrbs, 'mrbtest_irep' gems.each do |g| + next unless g.run_test_in_other_mrb_state? f.puts %Q[void GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb_state *mrb);] end + f.puts %Q[void no_mrb_open_mrbgem_test(mrb_state *mrb);] f.puts %Q[void mrbgemtest_init(mrb_state* mrb) {] gems.each do |g| + next unless g.run_test_in_other_mrb_state? f.puts %Q[ GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb);] end + f.puts %Q[ no_mrb_open_mrbgem_test(mrb);] f.puts %Q[}] end end diff --git a/test/t/hash.rb b/test/t/hash.rb index 92bc223b6..e7d5e8f74 100644 --- a/test/t/hash.rb +++ b/test/t/hash.rb @@ -12,6 +12,7 @@ end assert('Hash#==', '15.2.13.4.1') do assert_true({ 'abc' => 'abc' } == { 'abc' => 'abc' }) assert_false({ 'abc' => 'abc' } == { 'cba' => 'cba' }) + assert_true({ :equal => 1 } == { :equal => 1.0 }) end assert('Hash#[]', '15.2.13.4.2') do |
