diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-01-06 14:07:06 -0800 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-01-06 14:07:06 -0800 |
| commit | 4258d7735beec9252bf6cb282fb704cb2cbe9ce9 (patch) | |
| tree | 1049b9591c820e4f4edcc3e1872d7798fefe4f4a /test | |
| parent | 101b617d24b3c25d0b5b36ab13ebf5336d167f50 (diff) | |
| parent | 280bad605e764d1caf59a3ee21b640e077b63d2f (diff) | |
| download | mruby-4258d7735beec9252bf6cb282fb704cb2cbe9ce9.tar.gz mruby-4258d7735beec9252bf6cb282fb704cb2cbe9ce9.zip | |
Merge pull request #698 from masuidrive/improve_mrbgems_test
improve mrbgems
Diffstat (limited to 'test')
| -rw-r--r-- | test/assert.rb | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/test/assert.rb b/test/assert.rb index 89e820a00..4fe95de9d 100644 --- a/test/assert.rb +++ b/test/assert.rb @@ -5,14 +5,13 @@ $asserts = [] $test_start = Time.now if Object.const_defined?(:Time) ## -# Print the assertion in a readable way -def print_assertion_string(str, iso) - print(str) - if(iso != '') - print(' [') - print(iso) - print(']') - end +# Create the assertion in a readable way +def assertion_string(err, str, iso=nil, e=nil) + msg = "#{err}#{str}" + msg += " [#{iso}]" if iso && iso != '' + msg += " => #{e.message}" if e + msg += " (mrbgems: #{GEMNAME})" if Object.const_defined?(:GEMNAME) + msg end ## @@ -26,7 +25,7 @@ end def assert(str = 'Assertion failed', iso = '') begin if(!yield) - $asserts.push(['Fail: ', str, iso]) + $asserts.push(assertion_string('Fail: ', str, iso)) $ko_test += 1 print('F') else @@ -34,7 +33,7 @@ def assert(str = 'Assertion failed', iso = '') print('.') end rescue Exception => e - $asserts.push(['Error: ', str, iso, e]) + $asserts.push(assertion_string('Error: ', str, iso, e)) $kill_test += 1 print('X') end @@ -45,14 +44,9 @@ end # which were reported broken. def report() print "\n" - $asserts.each do |err, str, iso, e| - print(err); - print_assertion_string(str, iso) - if e - print(" => ") - print(e.message) - end - print("\n") + + $asserts.each do |msg| + puts msg end $total_test = $ok_test.+($ko_test) |
