diff options
| author | Daniel Bovensiepen <[email protected]> | 2013-01-08 10:07:55 +0800 |
|---|---|---|
| committer | Daniel Bovensiepen <[email protected]> | 2013-01-08 10:07:55 +0800 |
| commit | a096dc9e3b01f4fc31fc1f910e254813884a776e (patch) | |
| tree | cd353be9cb1df5e009d130ceabfcd627e7fb34a7 /test/assert.rb | |
| parent | af75d8de2ca6b3eda97c588334b15920e856a53b (diff) | |
| parent | 8c31c2006be7afa8da1fd01180955b108aee868c (diff) | |
| download | mruby-a096dc9e3b01f4fc31fc1f910e254813884a776e.tar.gz mruby-a096dc9e3b01f4fc31fc1f910e254813884a776e.zip | |
Merge remote-tracking branch 'mruby/master' into array-clear
Diffstat (limited to 'test/assert.rb')
| -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) |
