Commit graph

16692 commits

Author SHA1 Message Date
Jeremy Evans
58adb1636b [ruby/net-http] Update the content-length heading when decoding bodies
Previously, the content-encoding header was removed and the body
was modified, but the content-length header was not modified,
resulting in the content-length header not matching the body
length.

Fixes [Bug #16672]

a7cb30124c
2022-04-02 02:49:21 +09:00
Jeremy Evans
d1d48cb690 Revert "Raise RuntimeError if Kernel#binding is called from a non-Ruby frame"
This reverts commit 343ea9967e.

This causes an assertion failure with -DRUBY_DEBUG=1 -DRGENGC_CHECK_MODE=2
2022-04-01 07:22:49 -07:00
Nobuyoshi Nakada
d8189ed23f
Return only captured range in MatchData [Bug #18670] 2022-03-31 18:01:15 +09:00
Yusuke Endoh
ddd83e8462 test/date/test_date_parse.rb: relax the time limit
The timeout was very strict for weak CI machines like qemu-riscv.
Due to the additional overhead for Regexp.timeout=, it started failing
on such machines.

20220330T200018Z.fail.html.gz
```
  1) Error:
TestDateParse#test__parse_too_long_year:
Timeout::Error: execution expired
```
2022-03-31 12:52:16 +09:00
Yusuke Endoh
c499a4c28a re.c: stop a wrong warning of "flags ignored" on Regexp.new(//)
[Bug #18669]
2022-03-31 10:07:09 +09:00
Jeremy Evans
fbaadd1cfe
Do not autosplat array in block call just because keywords accepted
If the block only accepts a single positional argument plus keywords,
then do not autosplat.  Still autosplat if the block accepts more
than one positional argument in addition to keywords.

Autosplatting a single positional argument plus keywords made sense
in Ruby 2, since a final positional hash could be used as keywords,
but it does not make sense in Ruby 3.

Fixes [Bug #18633]
2022-03-30 11:03:56 -07:00
Yusuke Endoh
2ade40276b re.c: raise Regexp::TimeoutError instead of RuntimeError 2022-03-30 16:50:46 +09:00
Yusuke Endoh
ce87bb8bd6 re.c: Add timeout keyword for Regexp.new and Regexp#timeout 2022-03-30 16:50:46 +09:00
Yusuke Endoh
ffc3b37f96 re.c: Add Regexp.timeout= and Regexp.timeout
[Feature #17837]
2022-03-30 16:50:46 +09:00
Jeremy Evans
3c6a0033e3 Avoid trace events in implementation of TracePoint#enable
This is more backwards compatible, and should fix issues with
power_assert.

Unfortunately, it requires using a sentinel value as the default
value of target_thread, instead of the more natural expression
used in the original approach.
2022-03-29 18:14:33 -07:00
Jeremy Evans
9c1d32a7ad Make TracePoint#enable with block target current thread by default
If TracePoint#enable is passed a block, it previously started
the trace on all threads.  This changes it to trace only the
current thread by default.  To limit the scope of the change,
the current thread is only used by default if target and
target_line are both nil.  You can pass target_thread: nil
to enable tracing on all threads, to get the previous
default behavior.

Fixes [Bug #16889]
2022-03-29 18:14:33 -07:00
Jeremy Evans
6d3f447aec Fix multiplex backreferencs near end of string in regexp match
Idea from Jirka Marsik.

Fixes [Bug #18631]
2022-03-29 15:29:15 -07:00
Jeremy Evans
173a6b6a80 Make define_singleton_method always define a public method
In very unlikely cases, it could previously define a non-public method
starting in Ruby 2.1.

Fixes [Bug #18561]
2022-03-29 12:10:13 -07:00
Jemma Issroff
87123c4fc7 Refactor test_dump_all to make assertions about the contents of the dumped hash 2022-03-29 08:21:10 -07:00
Nobuyoshi Nakada
69967ee64e
Revert "Finer-grained inline constant cache invalidation"
This reverts commits for [Feature #18589]:
* 8008fb7352
  "Update formatting per feedback"
* 8f6eaca2e1
  "Delete ID from constant cache table if it becomes empty on ISEQ free"
* 629908586b
  "Finer-grained inline constant cache invalidation"

MSWin builds on AppVeyor have been crashing since the merger.
2022-03-25 20:29:09 +09:00
Jeremy Evans
343ea9967e Raise RuntimeError if Kernel#binding is called from a non-Ruby frame
Check whether the current or previous frame is a Ruby frame in
call_trace_func before attempting to create a binding for the frame.

Fixes [Bug #18487]

Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2022-03-24 12:31:07 -07:00
Kevin Newton
629908586b Finer-grained inline constant cache invalidation
Current behavior - caches depend on a global counter. All constant mutations cause caches to be invalidated.

```ruby
class A
  B = 1
end

def foo
  A::B # inline cache depends on global counter
end

foo # populate inline cache
foo # hit inline cache

C = 1 # global counter increments, all caches are invalidated

foo # misses inline cache due to `C = 1`
```

Proposed behavior - caches depend on name components. Only constant mutations with corresponding names will invalidate the cache.

```ruby
class A
  B = 1
end

def foo
  A::B # inline cache depends constants named "A" and "B"
end

foo # populate inline cache
foo # hit inline cache

C = 1 # caches that depend on the name "C" are invalidated

foo # hits inline cache because IC only depends on "A" and "B"
```

Examples of breaking the new cache:

```ruby
module C
  # Breaks `foo` cache because "A" constant is set and the cache in foo depends
  # on "A" and "B"
  class A; end
end

B = 1
```

We expect the new cache scheme to be invalidated less often because names aren't frequently reused. With the cache being invalidated less, we can rely on its stability more to keep our constant references fast and reduce the need to throw away generated code in YJIT.
2022-03-24 09:14:38 -07:00
David Rodríguez
d9dd88a686 [rubygems/rubygems] Avoid crash in test teardown
If an exception happens during test `setup` method, the `teardown`
method will still be run for cleaning up, but if some other errors
occurs then, it will hide the original error.

This is happening sometimes in CI where restoring original gem hooks is
failing because the error in `setup` happened before the variable
holding the original hooks was initialized.

This commit moves initialization of `@orig_hooks` to the beginning of
the `setup` method to avoid this issue.

8524d2b74d
2022-03-24 07:34:29 +09:00
Jeremy Evans
8f1c69f27c Raise ArgumentError when calling Enumberable#inject without block or arguments
Previously, this would work as expected if the enumerable contained
0 or 1 element, and would raise LocalJumpError otherwise. That
inconsistent behavior is likely to lead to bugs.

Fixes [Bug #18635]
2022-03-23 07:55:49 -07:00
Nobuyoshi Nakada
92ef73a918 [ruby/rdoc] Expand the enclosing tree of the current file
f9f90ef2ff
2022-03-22 01:32:13 +09:00
Nobuyoshi Nakada
dafe5c1323 [ruby/rdoc] Fold files in the page directory
b7b4cdab6c
2022-03-22 01:32:12 +09:00
Nobuyoshi Nakada
034c09776d [ruby/rdoc] Add test_generate_page
c870284163
2022-03-22 01:32:11 +09:00
Nobuyoshi Nakada
fafa40997e
Make a dedecated assertion to clarify failed assertions 2022-03-19 14:33:04 +09:00
Shugo Maeda
1107839a7f Add String#bytesplice 2022-03-18 11:51:03 +09:00
Jeremy Evans
b6804d62f8 Make Proc#parameters support lambda keyword for returning parameters as if lambda
This makes it easier to use Proc#parameters to build wrappers.

Implements [Feature #15357]
2022-03-17 11:52:02 -07:00
Nobuyoshi Nakada
4fdb10e65e
A positional Hash is not keyword arguments [Bug #18632] 2022-03-18 00:35:02 +09:00
Nobuyoshi Nakada
e660b934b9
A positional Hash is not keyword arguments [Bug #18632] 2022-03-17 20:53:41 +09:00
Nobuyoshi Nakada
acbc2bdd30
Update the test for [Feature #18615] 2022-03-17 15:07:18 +09:00
Martin Dürst
151208a19b Revert "Fix version check to use Emoji version for emoji-variation-sequences.txt"
This reverts commit 48f1e8c5d8.
2022-03-16 15:18:30 +09:00
Martin Dürst
e85547ae81 Revert "Allow .0 version mismatch to pass the tests"
This reverts commit fc6e4ce62b.
2022-03-16 15:17:30 +09:00
Nobuyoshi Nakada
ebcbca96fb [ruby/rdoc] Fix full name of known class
Properly set the name of `File::Constants`, which is the only name
with a namespace in `RDoc::KNOWN_CLASSES`, and fixes longstanding bug
that `File::Constants` becomes `File::File::Constants`.

When it is generated by `rb_file_const` in dir.c, `name` is set to the
qualified name as same as `full_name`, and generated in the normal way
in file.c later, already set `full_name` is cleared and `name` will be
constructed from the enclosing namespace and the `name`.  It will
results in duplicated namespace, `File::File::Constants`.

3a8d6df562
2022-03-16 15:05:41 +09:00
Koichi Sasada
fc6e4ce62b Allow .0 version mismatch to pass the tests
With `make update-unicode`, some tests failed with the following error
due to header mismatch.

* `RbConfig::CONFIG['UNICODE_EMOJI_VERSION']` => 14.0
* the header line is `# emoji-variation-sequences-14.0.0.txt`

So the last `.0` is mismatch.
This patch allows additional `.0` in the header line.

Please revert this patch when a correct patach is merged.

```
  1) Error:
TestEmojiBreaks#test_embedded_emoji:
RuntimeError: File Name Mismatch: line: # emoji-variation-sequences-14.0.0.txt, expected filename: emoji-variation-sequences.txt
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:88:in `block (2 levels) in read_data'
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:82:in `foreach'
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:82:in `block in read_data'
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:79:in `each'
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:79:in `read_data'
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:111:in `all_tests'
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:127:in `test_embedded_emoji'
  2) Error:
TestEmojiBreaks#test_mixed_emoji:
RuntimeError: File Name Mismatch: line: # emoji-variation-sequences-14.0.0.txt, expected filename: emoji-variation-sequences.txt
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:88:in `block (2 levels) in read_data'
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:82:in `foreach'
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:82:in `block in read_data'
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:79:in `each'
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:79:in `read_data'
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:111:in `all_tests'
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:139:in `test_mixed_emoji'
  3) Error:
TestEmojiBreaks#test_single_emoji:
RuntimeError: File Name Mismatch: line: # emoji-variation-sequences-14.0.0.txt, expected filename: emoji-variation-sequences.txt
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:88:in `block (2 levels) in read_data'
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:82:in `foreach'
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:82:in `block in read_data'
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:79:in `each'
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:79:in `read_data'
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:111:in `all_tests'
    /tmp/ruby/v3/src/trunk/test/ruby/enc/test_emoji_breaks.rb:117:in `test_single_emoji'
```
2022-03-16 11:30:37 +09:00
Martin Dürst
48f1e8c5d8 Fix version check to use Emoji version for emoji-variation-sequences.txt 2022-03-16 08:46:04 +09:00
Nobuyoshi Nakada
976431d9ed [ruby/rdoc] Fold class and module index
4c7c46fcc4
2022-03-14 14:48:12 +09:00
Kazuhiro NISHIYAMA
3c59913a05
Fix failures
http://ci.rvm.jp/results/trunk-no-mjit@phosphorus-docker/3870646
```
  1) Error:
	TestEmojiBreaks#test_single_emoji:
	RuntimeError: File Name Mismatch: line: # emoji-variation-sequences-14.0.0.txt, expected filename: emoji-variation-sequences.txt
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:84:in `block (2 levels) in read_data'
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:82:in `foreach'
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:82:in `block in read_data'
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:79:in `each'
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:79:in `read_data'
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:105:in `all_tests'
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:111:in `test_single_emoji'
	  2) Error:
	TestEmojiBreaks#test_mixed_emoji:
	RuntimeError: File Name Mismatch: line: # emoji-variation-sequences-14.0.0.txt, expected filename: emoji-variation-sequences.txt
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:84:in `block (2 levels) in read_data'
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:82:in `foreach'
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:82:in `block in read_data'
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:79:in `each'
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:79:in `read_data'
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:105:in `all_tests'
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:133:in `test_mixed_emoji'
	  3) Error:
	TestEmojiBreaks#test_embedded_emoji:
	RuntimeError: File Name Mismatch: line: # emoji-variation-sequences-14.0.0.txt, expected filename: emoji-variation-sequences.txt
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:84:in `block (2 levels) in read_data'
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:82:in `foreach'
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:82:in `block in read_data'
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:79:in `each'
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:79:in `read_data'
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:105:in `all_tests'
	    /tmp/ruby/v3/src/trunk-no-mjit/test/ruby/enc/test_emoji_breaks.rb:121:in `test_embedded_emoji'
	make: *** [uncommon.mk:823: yes-test-all] Error 3
```
2022-03-14 08:57:06 +09:00
Martin Dürst
8f59482f5d add some tests for Unicode Version 14.0.0 2022-03-13 09:19:52 +09:00
John Hawthorn
83fabfccf5 Add test for protected methods on module included 2022-03-11 10:36:19 -08:00
Jeremy Evans
0c6e24d102 Fix visibility of alias of zsuper methods
This was broken by 71c746379d.

Fixes [Bug #18600]
2022-03-10 08:35:26 -08:00
Peter Zhu
f62f913132 [ruby/rdoc] Support crossref of methods with multiple arguments
For example, consider the following markup:

  C1#m(a, b)

Before this patch, it generated this HTML:

  <p><a href=\"C1.html#method-i-m\"><code>C1#m</code></a>(a, b)</p>

Which places the method arguments outside of the link.

Now it generates this HTML:

  <a href=\"C1.html#method-i-m\"><code>C1#m(a, b)</code></a>

05a2b2222b
2022-03-09 23:38:45 +09:00
Yusuke Endoh
bfc697f1e2 test/io/console/test_io_console.rb: parens needed 2022-03-08 17:40:02 +09:00
Yusuke Endoh
17e09f033c Skip three tests on FreeBSD 13
Some tests that use signals frequently fail randomly on FreeBSD 13.
Maybe something around signals has changed in FreeBSD 13.
This change skips them tentatively.
2022-03-08 16:06:37 +09:00
Ladislav Gallay
e1391bf96f [ruby/ostruct] Fix class and method as attribute names
7258535073
2022-03-07 20:08:22 +09:00
Nobuyoshi Nakada
f07f476518
Exclude binstubs tests
When relative loading is enabled, the executable ruby is expected
installed at the same directory as the binstub.
2022-03-02 18:37:53 +09:00
Peter Zhu
fb724a887a Show embed status of array when len is 0 in objspace dump 2022-03-01 10:55:53 -05:00
Benoit Daloze
a0e3da9ecc Fix race in TestThread#test_thread_status_in_trap
* If the sleep is not enough to run the rest of the logic the process
  would be exited early, e.g., before the signal handler can run.
2022-03-01 16:49:23 +01:00
Nobuyoshi Nakada
8780f15fd7 [ruby/date] Use assert_deprecated_warn
c55004715a
2022-02-25 20:39:47 +09:00
Nobuyoshi Nakada
bb22bc76b0 [ruby/date] Deprecate the unintentional ability to parse Symbol
d57818f3b3
2022-02-25 19:57:50 +09:00
Nobuyoshi Nakada
d4f32b6b7b [ruby/date] Scale timeouts
2889698e2f
2022-02-25 19:52:33 +09:00
Nobuyoshi Nakada
4933d7fe56 [ruby/date] Update tests
5a138afce9
2022-02-25 19:52:32 +09:00
Nobuyoshi Nakada
b5c2a0840f [ruby/date] Anchor at beginning of numbers
https://hackerone.com/reports/1254844

2f7814cc22
2022-02-25 19:52:31 +09:00