From d2f2f9db511afc348a88f864b9f0b0ccfc59a8f1 Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Sat, 14 Dec 2019 21:48:32 +0900 Subject: Remove location info from `Exception#inspect` Because location info (file name and line number) is kept in the backtrace, it should not be kept in the result of `inspect` (and the exception object itself), I think. ### Example ```ruby # example.rb begin raise "err" rescue => e p e end ``` #### Before this patch: ``` $ bin/mruby example.rb example.rb:2: err (RuntimeError) ``` #### After this patch: ``` $ bin/mruby example.rb err (RuntimeError) ``` --- test/t/exception.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/t/exception.rb b/test/t/exception.rb index bdf277c1e..a6f69eef6 100644 --- a/test/t/exception.rb +++ b/test/t/exception.rb @@ -352,8 +352,10 @@ assert('Exception 19') do assert_equal [true, true], Class4Exception19.new.a end -assert('Exception#inspect without message') do +assert('Exception#inspect') do assert_equal "Exception", Exception.new.inspect + assert_equal "Exception", Exception.new("").inspect + assert_equal "error! (Exception)", Exception.new("error!").inspect end assert('Exception#backtrace') do -- cgit v1.2.3