summaryrefslogtreecommitdiff
path: root/test/ruby/test_exception.rb
AgeCommit message (Collapse)Author
2024-03-15Cover all warning categories by using `Warning.categories`Nobuyoshi Nakada
2024-03-15Test deprecation warning with `$;`Nobuyoshi Nakada
2024-03-14`Exception#set_backtrace` accept arrays of `Backtrace::Location`Jean Boussier
[Feature #13557] Setting the backtrace with an array of strings is lossy. The resulting exception will return nil on `#backtrace_locations`. By accepting an array of `Backtrace::Location` instance, we can rebuild a `Backtrace` instance and have a fully functioning Exception. Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
2024-02-22Skip under_gc_compact_stress on s390x (#10073)Takashi Kokubun
2024-02-15Do not include a backtick in error messages and backtracesYusuke Endoh
[Feature #16495]
2024-01-14Add test for `Errno` constantsNobuyoshi Nakada
2024-01-02Fix Exception#detailed_message for GC compactionPeter Zhu
Before this commit, the test fails with RGENGC_CHECK_MODE enabled: TestException#test_detailed_message_under_gc_compact_stress [test/ruby/test_exception.rb:1466]: <"\e[1mfoo (\e[1;4mRuntimeError\e[m\e[1m)\e[m\n" + "\e[1mbar\e[m\n" + "\e[1mbaz\e[m"> expected but was <"\e[1mfoo (\e[1;4mRuntimeError\e[m\e[1m)\e[m\n" + "\e[1m\x00\x00\x00\x00\x00\x00\x00\e[m">.
2023-08-03Remove --disable-gems for assert_separatelyPeter Zhu
assert_separately adds --disable=gems so we don't need to add --disable-gems when calling assert_separately. Notes: Merged: https://github.com/ruby/ruby/pull/8162
2023-07-24Use the caller location as default filename for eval family of methodsJean Boussier
[Feature #19755] Before (in /tmp/test.rb): ```ruby Object.class_eval("p __FILE__") # => "(eval)" ``` After: ```ruby Object.class_eval("p __FILE__") # => "(eval at /tmp/test.rb:1)" ``` This makes it much easier to track down generated code in case the author forgot to provide a filename argument. Notes: Merged: https://github.com/ruby/ruby/pull/8070
2023-04-10[Bug #19570] Propagate message encoding to decorated messageNobuyoshi Nakada
2023-02-27Prefer to use File.readlines instead of IO.readlinesHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/7387
2022-12-20[Bug #19242] Prohibit circular causes to be loadedNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6960
2022-12-01[Feature #19138] Add `SyntaxError#path`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6779
2022-11-22[Bug #19016] `SyntaxError` with parser error messagesNobuyoshi Nakada
Raise a `SyntaxError` with the parser error message, in the case reading from a file instead of the `-e` option or standard input. So syntax_suggest can get the message from the caught error. Notes: Merged: https://github.com/ruby/ruby/pull/6778
2022-11-22[Bug #19016] re-order error handling at cleanupNobuyoshi Nakada
Build and store the error message with `#detailed_message` before terminating all Ractors, then show the message later. Notes: Merged: https://github.com/ruby/ruby/pull/6778
2022-11-20[Bug #19016] Handle syntax error in main script like other errorsNobuyoshi Nakada
So that `SyntaxError#detailed_message` will be used also in the case exiting by such syntax error. Notes: Merged: https://github.com/ruby/ruby/pull/6771
2022-09-23Revert "Revert "error.c: Let Exception#inspect inspect its message""Yusuke Endoh
This reverts commit b9f030954a8a1572032f3548b39c5b8ac35792ce. [Bug #18170]
2022-09-10Enable deprecation warnings for test-allBenoit Daloze
* So deprecated methods/constants/functions are dealt with early, instead of many tests breaking suddenly when removing a deprecated method/constant/function. * Follows https://bugs.ruby-lang.org/issues/17591 Notes: Merged: https://github.com/ruby/ruby/pull/6321
2022-06-07Revert "error.c: Let Exception#inspect inspect its message"Yusuke Endoh
This reverts commit 9d927204e7b86eb00bfd07a060a6383139edf741. Notes: Merged: https://github.com/ruby/ruby/pull/5981
2022-06-07error.c: Let Exception#inspect inspect its messageYusuke Endoh
... only when the message string has a newline. `p StandardError.new("foo\nbar")` now prints `#<StandardError: "foo\nbar">' instead of: #<StandardError: bar> [Bug #18170] Notes: Merged: https://github.com/ruby/ruby/pull/4857
2022-03-18A positional Hash is not keyword arguments [Bug #18632]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5676
2022-02-22Add a test for Exception#detailed_messageYusuke Endoh
Notes: Merged: https://github.com/ruby/ruby/pull/5516
2022-02-22Do not escape error messageYusuke Endoh
[Feature #18367] Notes: Merged: https://github.com/ruby/ruby/pull/5516
2022-02-12test/ruby/test_exception.rb: prevent "assigned but unused variable"Yusuke Endoh
2022-02-05Fix TAG_THROW through require [Bug #18562]John Hawthorn
Previously this was being incorrectly swapped with TAG_RAISE in the next line. This would end up checking the T_IMEMO throw_data to the exception handling (which calls Module#===). This happened to not break existing tests because Module#=== returned false when klass is NULL. This commit handles throw from require correctly by jumping to the tag retaining the TAG_THROW state. Notes: Merged: https://github.com/ruby/ruby/pull/5513
2022-01-16Remove outdated skipsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5453
2022-01-16Use pend for old TODOsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5453
2022-01-04Don't segfault if Warning.warn is undefinedJeremy Evans
Check that there is a method entry for the method before passing it to rb_method_entry_arity. Fixes [Bug #18458] Notes: Merged: https://github.com/ruby/ruby/pull/5391
2022-01-04Use omit instead of skip: test/ruby/**/*.rbHiroshi SHIBATA
2021-12-28Removed deprecated Dir.exists? and File.exists?Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5352
2021-12-26Remove tainted and trusted featuresNobuyoshi Nakada
Already these had been announced to be removed in 3.2. Notes: Merged: https://github.com/ruby/ruby/pull/5348
2021-09-06Use Test::Unit::AssertionFailedError instead of MiniTest::Assertion for ↵Hiroshi SHIBATA
test-unit migration
2021-07-29Skip test_ensure_after_nomemoryerrorJeremy Evans
This test appears to cause failures in some environments.
2021-07-28Handle Timeout::Error instead of NoMemoryError in testJeremy Evans
Solaris 11 CI times out instead of raising NoMemoryError for large allocations, so it cannot test ensure after NoMemoryError.
2021-07-28Suppress "possibly useless use of * in void context" warningNobuyoshi Nakada
2021-07-27Fix infinite loop in ensure after NoMemoryErrorJeremy Evans
VM patch from wanabe. Test based on example from buzztaiki (Taiki Sugawara). Test fails when compiles with -DRUBY_DEBUG, as that can can use rb_bug instead of NoMemoryError, which doesn't allow testing this case. Test also fails on MingW, as RangeError is used instead of NoMemoryError. Skip the test in either case. Fixes [Bug #15779] Notes: Merged: https://github.com/ruby/ruby/pull/4577
2021-06-29Prefer qualified names under ThreadNobuyoshi Nakada
2021-05-21simple rescue+while+break should not use `throw`Koichi Sasada
609de71f043e8ba34f22b9993e444e2e5bb05709 fixes the issue by using `throw` insn if `ensure` is used. However, that patch introduce additional `throw` even if it is not needed. This patch solves the issue. This issue is pointed by @mame. Notes: Merged: https://github.com/ruby/ruby/pull/4507
2021-04-27test/ruby/test_exception.rb: suppress "warning: statement not reached"Yusuke Endoh
2021-04-22fix raise in exception with jumpKoichi Sasada
add_ensure_iseq() adds ensure block to the end of jump such as next/redo/return. However, if the rescue cause are in the body, this rescue catches the exception in ensure clause. iter do next rescue R ensure raise end In this case, R should not be executed, but executed without this patch. Fixes [Bug #13930] Fixes [Bug #16618] A part of tests are written by @jeremyevans https://github.com/ruby/ruby/pull/4291 Notes: Merged: https://github.com/ruby/ruby/pull/4399
2020-12-10Remove the uninitialized instance variable verbose mode warningJeremy Evans
This speeds up all instance variable access, even when not in verbose mode. Uninitialized instance variable warnings were rarely helpful, and resulted in slower code if you wanted to avoid warnings when run in verbose mode. Implements [Feature #17055] Notes: Merged: https://github.com/ruby/ruby/pull/3879
2020-12-08Supported category option in Warning#warnNobuyoshi Nakada
2020-12-02Revert "Removed deprecated Dir.exists? and File.exists?"Nobuyoshi Nakada
This reverts commit 1a5205536f0c0d6021450b11722919211847df86.
2020-12-02Removed deprecated Dir.exists? and File.exists?Nobuyoshi Nakada
2020-09-28Make Warning.warn accept only category keywordJeremy Evans
In general accepting arbitrary keywords is a bad idea unless you are delegating keywords or acting on arbitrary keywords. In this case, the category keyword is ignored, and it's less error prone to not ignore all keywords. Notes: Merged: https://github.com/ruby/ruby/pull/3508
2020-09-02Add category to `rb_warn_deprecated`eileencodes
PR https://github.com/ruby/ruby/pull/3418 added a category to `rb_warn_deprecated_to_remove` but not to `rb_warn_deprecated`. This adds the same code to `rb_warn_deprecated` so that those warnings also get a category. This change also adds tests for `rb_warn_deprecated` and updates the tests for `rb_warn_deprecated_to_remove` to have clearer names. I've fixed the call to `rb_method_entry` as we need to be using the instance method, not singleton. Feature: https://bugs.ruby-lang.org/issues/17122 Notes: Merged: https://github.com/ruby/ruby/pull/3505
2020-09-01Support passing a category to `Warning.warn`eileencodes
This change adds a `category` kwarg to make it easier to monkey patch `Warning.warn`. Warnings already have a category, but that warning isn't exposed. This implements a way to get the category so that warnings with a specific category, like deprecated, can be treated differently than other warnings in an application. The change here does an arity check on the method to support backwards compatibility for applications that may already have a warning monkey patch. For our usecase we want to `raise` for deprecation warnings in order to get the behavior for the next Ruby version. For example, now that we fixed all our warnings and deployed Ruby 2.7 to production, we want to be able to have deprecation warnings behave like they would in 3.0: raise an error. For other warnings, like uninialized constants, that behavior won't be removed from Ruby in the next version, so we don't need to raise errors. Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/3418
2020-07-15Fixed infinite loop at error in printing cause [Bug #17033]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3320
2020-04-21eval_error.c: default nil as "reverse" is now false [Feature #8661]Nobuyoshi Nakada
2020-01-29fix test cleanup.Koichi Sasada
should remove pathname.