summaryrefslogtreecommitdiff
path: root/test/ruby/test_exception.rb
AgeCommit message (Collapse)Author
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.
2020-01-02Update tests for full keyword argument separationJeremy Evans
Notes: Merged: https://github.com/ruby/ruby/pull/2794
2019-12-31Split test_nomethod_error.rbNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/2800
2019-12-31Split test_name_error.rbNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/2800
2019-12-31Split test_frozen_error.rbNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/2800
2019-12-31Fix the exception to be raisedNobuyoshi Nakada
`NoMethodError` has been raised instead of `FrozenError`. Notes: Merged: https://github.com/ruby/ruby/pull/2800
2019-12-23Reword keyword arguments warning messages to convey these are deprecation ↵Marc-Andre Lafortune
warnings
2019-12-20Added `experimental` warning categoryNobuyoshi Nakada
[Feature #16420]
2019-12-20vm_args.c: rephrase the warning message of keyword argument separationYusuke Endoh
(old) test.rb:4: warning: The last argument is used as the keyword parameter test.rb:1: warning: for `foo' defined here; maybe ** should be added to the call? (new) test.rb:4: warning: The last argument is used as keyword parameters; maybe ** should be added to the call test.rb:1: warning: The called method `foo' is defined here
2019-12-20Makes the receiver to FrozenError.new a keyword parameterNobuyoshi Nakada
[Feature #16419]
2019-12-19Manage deprecation warnings about keyword argumentNobuyoshi Nakada
2019-12-13Add `Warning.[]` and `Warning.[]=`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/2739
2019-11-18Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans
This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby. Notes: Merged: https://github.com/ruby/ruby/pull/2476
2019-10-22test/ruby/test_exception typo fixMSP-Greg
2019-10-21DidYouMean can be an empty stub module [Bug #16263]Nobuyoshi Nakada
2019-10-21test_exception - fix with & w/o did_you_meanMSP-Greg
See Ruby issue 16263 Notes: Merged: https://github.com/ruby/ruby/pull/2577
2019-09-25Make rb_scan_args handle keywords more similar to Ruby methods (#2460)Jeremy Evans
Cfuncs that use rb_scan_args with the : entry suffer similar keyword argument separation issues that Ruby methods suffer if the cfuncs accept optional or variable arguments. This makes the following changes to : handling. * Treats as **kw, prompting keyword argument separation warnings if called with a positional hash. * Do not look for an option hash if empty keywords are provided. For backwards compatibility, treat an empty keyword splat as a empty mandatory positional hash argument, but emit a a warning, as this behavior will be removed in Ruby 3. The argument number check needs to be moved lower so it can correctly handle an empty positional argument being added. * If the last argument is nil and it is necessary to treat it as an option hash in order to make sure all arguments are processed, continue to treat the last argument as the option hash. Emit a warning in this case, as this behavior will be removed in Ruby 3. * If splitting the keyword hash into two hashes, issue a warning, as we will not be splitting hashes in Ruby 3. * If the keyword argument is required to fill a mandatory positional argument, continue to do so, but emit a warning as this behavior will be going away in Ruby 3. * If keyword arguments are provided and the last argument is not a hash, that indicates something wrong. This can happen if a cfunc is calling rb_scan_args multiple times, and providing arguments that were not passed to it from Ruby. Callers need to switch to the new rb_scan_args_kw function, which allows passing of whether keywords were provided. This commit fixes all warnings caused by the changes above. It switches some function calls to *_kw versions with appropriate kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS is used. If creating new arguments, RB_PASS_KEYWORDS is used if the last argument is a hash to be treated as keywords. In open_key_args in io.c, use rb_scan_args_kw. In this case, the arguments provided come from another C function, not Ruby. The last argument may or may not be a hash, so we can't set keyword argument mode. However, if it is a hash, we don't want to warn when treating it as keywords. In Ruby files, make sure to appropriately use keyword splats or literal keywords when calling Cfuncs that now issue keyword argument separation warnings through rb_scan_args. Also, make sure not to pass nil in place of an option hash. Work around Kernel#warn warnings due to problems in the Rubygems override of the method. There is an open pull request to fix these issues in Rubygems, but part of the Rubygems tests for their override fail on ruby-head due to rb_scan_args not recognizing empty keyword splats, which this commit fixes. Implementation wise, adding rb_scan_args_kw is kind of a pain, because rb_scan_args takes a variable number of arguments. In order to not duplicate all the code, the function internals need to be split into two functions taking a va_list, and to avoid passing in a ton of arguments, a single struct argument is used to handle the variables previously local to the function. Notes: Merged-By: jeremyevans <code@jeremyevans.net>
2019-09-02Do not clear backtrace in Exception#exceptionNobuyoshi Nakada
[Bug #15558]
2019-09-02Rewrote using assert_separatelyNobuyoshi Nakada
2019-07-15Removed duplicate highlightingNobuyoshi Nakada
2019-06-05error.c: avoid infinite recursion at inspecting the frozen objectNobuyoshi Nakada