Commit graph

16692 commits

Author SHA1 Message Date
Samuel Williams
f5ea43a2e6
More coverage tests & specs. (#7171)
* Add spec for eval and line coverage.

* Add test for main file coverage.
2023-01-22 13:49:13 +13:00
tompng
76e3d853ab [ruby/reline] Add autoindent test for indent after bracket and newline
3f3da7d0e2
2023-01-20 13:40:16 +00:00
Nobuyoshi Nakada
53cd5796c5 [rubygems/rubygems] Clean test output
The output from the command is mixed in this test, even when
successful.
Use the output as a part of the message on failure instead.

960509a133
2023-01-20 10:39:57 +00:00
Shugo Maeda
cce3960964 [Feature #19314] Add new arguments of String#bytesplice
bytesplice(index, length, str, str_index, str_length) -> string
  bytesplice(range, str, str_range) -> string

In these forms, the content of +self+ is replaced by str.byteslice(str_index, str_length) or str.byteslice(str_range); however the substring of +str+ is not allocated as a new string.
2023-01-20 18:02:37 +09:00
Peter Zhu
0949cd7107 [ci skip] Add ticket label to test 2023-01-19 16:26:32 -05:00
lukeg
f66804e6f7 don't allow setting class variable on module that's frozen [Bug #19341] 2023-01-19 16:25:20 -05:00
Shugo Maeda
f7b72462aa
String#bytesplice should return self
In Feature #19314, we concluded that the return value of String#bytesplice
should be changed from the source string to the receiver, because the source
string is useless and confusing when extra arguments are added.

This change should be included in Ruby 3.2.1.
2023-01-19 17:13:07 +09:00
Samuel Williams
edd00697a8
Test some missing coverage too. (#7041) 2023-01-19 11:59:51 +13:00
tompng
976d72a9f5 [ruby/reline] Add scrollbar scroll-to-bottom test and fix existing scrollbar rendeing test
268e02b155
2023-01-18 14:49:28 +00:00
tomoya ishida
2d7e639549 [ruby/reline] multiline_repl do not need to depend on RubyLex
(https://github.com/ruby/reline/pull/502)

* multiline_repl do not need to depend on RubyLex

* Add auto indent test
2023-01-18 05:28:18 +00:00
Kaíque Kandy Koga
46066d0b96
Change ArgumentError message when Comparable#clamp receives min value higher than max value 2023-01-17 21:25:11 -08:00
dependabot[bot]
9399352a43 [rubygems/rubygems] Bump rb-sys in /test/rubygems/test_gem_ext_cargo_builder/custom_name
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.54 to 0.9.56.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.54...v0.9.56)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-17 09:57:05 +00:00
Peter Zhu
ed6fbb79e1 Fix crash when defining ivars on special constants
[Bug #19339]
2023-01-17 04:51:15 -05:00
dependabot[bot]
d7af0f6082 [rubygems/rubygems] Bump rb-sys
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.54 to 0.9.56.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.54...v0.9.56)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-17 07:19:03 +00:00
Nobuyoshi Nakada
71ce7e1825
[Bug #19335] Integer#remainder should respect #coerce (#7120)
Also `Numeric#remainder` should.
2023-01-15 13:03:27 +09:00
HASUMI Hitoshi
5b26f76ad9 [ruby/reline] Correspond to refactored RubyLex
(https://github.com/ruby/reline/pull/498)

* Correspond to refactored RubyLex

ref: https://github.com/ruby/irb/pull/503

* Fix test_yamatanooroti
2023-01-14 09:19:41 +00:00
Stan Lo
cb9b885e78 [ruby/irb] Store context in RubyLex
Some background for this refactor:

1. Through a RubyLex instance's lifetime, the context passed to its methods
   should be the same.
   Given that `Context` is only initialised in `Irb#initialize`,
   this should be true.

2. When `RubyLex` is initialised, the context object should be accessible.
   This is also true in all 3 of `RubyLex.new`'s invocations.

With the above observations, we should be able to store the context in `RubyLex`
as an instance variable. And doing so will make `RubyLex`'s instance methods
easier to use and maintain.

5c8d3df2df
2023-01-14 09:19:09 +00:00
Matt Valentine-House
bb5fddd070 Remove MIN_PRE_ALLOC_SIZE from Strings.
This optimisation is no longer helpful now that we use VWA to allocate
strings in larger size pools where they can be embedded.
2023-01-13 10:31:35 -05:00
Yusuke Endoh
94d6d6d93f [ruby/error_highlight] Identify which node in Foo::Bar::Baz causes a NameError
In Ruby 3.2 or later, a nested constant access like `Foo::Bar::Baz` is
compiled to one instruction by the optimization https://github.com/ruby/ruby/pull/6187

We try to spot which sub-node caues a NameError in question based on the
constant name. We will give up if the same constant name is accessed in
a nested access (`Foo::Foo`).

Fixes https://github.com/ruby/error_highlight/pull/31

0a4db7da0a
2023-01-13 08:25:09 +00:00
Nobuyoshi Nakada
5b36fefc4e
Skip time-related assertions on /dev/null 2023-01-13 12:26:16 +09:00
Koichi Sasada
2e7bceb34e Do not use VM stack for splat arg on cfunc
On the cfunc methods, if a splat argument is given, all array elements
are expanded on the VM stack and it can cause SystemStackError.
The idea to avoid it is making a hidden array to contain all parameters
and use this array as an argv.

This patch is reviesed version of https://github.com/ruby/ruby/pull/6816
The main change is all changes are closed around calling cfunc logic.

Fixes [Bug #4040]

Co-authored-by: Jeremy Evans <code@jeremyevans.net>
2023-01-13 09:30:29 +09:00
Stan Lo
207f8d0027 [ruby/irb] Avoid calling private methods on the main object
(https://github.com/ruby/irb/pull/498)

When the main object is frozen, `IRB` wraps a `SimpleDelegator` around it.
But because `SimpleDelegator` doesn't delegate private methods, methods like
`require_relative` or `const_get` would cause error, which are needed for
lazily loading commands.

This commit works around this limitation by avoiding those private method calls
when setting up command execution.
2023-01-12 11:49:16 +00:00
Jean Boussier
a8537eae2a [ruby/mutex_m] Avoid anonymous eval
It makes it hard to locate code when profiling etc.

8760ab19ec
2023-01-12 05:41:59 +00:00
tomoya ishida
0abb4b6348 [ruby/reline] Pass unmodifined lines(that does not include escape
sequence) to check_multiline_prompt
(https://github.com/ruby/reline/pull/458)

* pass unmodified lines to check_multiline_prompt

* Add test to check that output modified by output_modifier_proc is not passed to prompt_proc
2023-01-12 00:14:53 +00:00
Jean Boussier
bcdc058e50 [ruby/racc] Get rid of anonymous eval calls
Things declared in anonymous eval are always annoying to locate.
(profilers, etc)

f304205256
2023-01-12 07:52:29 +09:00
Masataka Pocke Kuwabara
11e15b4d48 [ruby/racc] Make racc Ractor compatible
1948de9d1d
2023-01-12 07:52:25 +09:00
Stan Lo
c693dfd7ef [ruby/irb] Drop unused arguments in RubyLex
(https://github.com/ruby/irb/pull/504)

* Simplify `RubyLex#set_prompt`

It's optional argument is never used by any caller.

* Remove the optional `p` argument from `RubyLex#set_input`

The argument is only used in a test case, which can be easily replaced by
a block argument.
2023-01-11 21:26:18 +00:00
Benoit Daloze
6abe20e87b Remove Encoding#replicate 2023-01-11 13:41:41 +01:00
Phillip Hellewell
d831b1d5ce [ruby/reline] Reset IOGate in test_reset
331c1094ef
2023-01-11 11:38:51 +00:00
Phillip Hellewell
4222083cbd [ruby/reline] Change IOGate back to GeneralIO
Staying with ANSI can cause side effects with other tests.

ba36067802
2023-01-11 11:38:50 +00:00
Jean Boussier
3161fd4372 [ruby/psych] Get rid of anonymous eval calls
Things declared in anonymous eval are always annoying to locate.

38871ad4e5
2023-01-11 10:08:13 +00:00
Koichi Sasada
8c2b6926d2 Skip unfixed assertion about objspace/dump_all
```
{"address":"0x7f8c03e9fcf0", "type":"STRING", "shape_id":10, "slot_size":40, "class":"0x7f8c00dbed98", "frozen":true, "embedded":true, "fstring":true, "bytesize":5, "value":"TEST2", "encoding":"US-ASCII", "coderange":"7bit", "memsize":40, "flags":{"wb_protected":true}}
{"address":"0x7f8c03e9ffc0", "type":"STRING", "shape_id":0, "slot_size":40, "class":"0x7f8c00dbed98", "embedded":true, "bytesize":5, "value":"TEST2", "encoding":"US-ASCII", "coderange":"7bit", "memsize":40, "flags":{"wb_protected":true}}
{"address":"0x7f8c03e487c0", "type":"STRING", "shape_id":0, "slot_size":40, "class":"0x7f8c00dbed98", "embedded":true, "bytesize":5, "value":"TEST2", "encoding":"UTF-8", "coderange":"unknown", "file":"-", "line":4, "method":"dump_my_heap_please", "generation":1, "memsize":40, "flags":{"wb_protected":true}}
  1) Failure:
TestObjSpace#test_dump_all [/tmp/ruby/src/trunk-gc-asserts/test/objspace/test_objspace.rb:622]:
number of strings.
<2> expected but was
<3>.
```

This failure only occurred on a ruby built with `DEFS=\"-DRGENGC_CHECK_MODE=2\""`
and only on a specific machine (Docker container) and difficult to reproduce,
so skip this failure to check other failures.
2023-01-11 18:09:48 +09:00
Alan Wu
aeddc19340
YJIT: Save PC and SP before calling leaf builtins (#7090)
Previously, we did not update `cfp->sp` before calling the C function of
ISEQs marked with `Primitive.attr! "inline"` (leaf builtins). This
caused the GC to miss temporary values on the stack in case the function
allocates and triggers a GC run. Right now, there is only a few leaf
builtins in numeric.rb on Integer methods such as `Integer#~`. Since
these methods only allocate when operating on big numbers, we missed
this issue.

Fix by saving PC and SP before calling the functions -- our usual
protocol for calling C functions that may allocate on the GC heap.

[Bug #19316]
2023-01-10 11:11:10 -05:00
Phillip Hellewell
97f8f2c470 [ruby/reline] Add key binding for Delete
603eacee22
2023-01-10 12:18:14 +00:00
Hiroshi SHIBATA
a43f1d90c2 Merge RubyGems and Bundler master
from 0635c1423d
2023-01-10 15:53:07 +09:00
dependabot[bot]
97d52a8ea2 [rubygems/rubygems] Bump rb-sys
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.53 to 0.9.54.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.53...v0.9.54)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-10 02:20:54 +00:00
dependabot[bot]
93b2de8278 [rubygems/rubygems] Bump rb-sys in /test/rubygems/test_gem_ext_cargo_builder/custom_name
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.53 to 0.9.54.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.53...v0.9.54)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-09 18:43:03 +00:00
Peter Zhu
2ad081f799 Assert that resizing arrays will re-embed them 2023-01-09 08:49:29 -05:00
Peter Zhu
682b45d489 Assert that resizing objects will re-embed them 2023-01-09 08:49:29 -05:00
Peter Zhu
3be2acfafd Fix re-embedding of strings during compaction
The reference updating code for strings is not re-embedding strings
because the code is incorrectly wrapped inside of a
`if (STR_SHARED_P(obj))` clause. Shared strings can't be re-embedded
so this ends up being a no-op. This means that strings can be moved to a
large size pool during compaction, but won't be re-embedded, which would
waste the space.
2023-01-09 08:49:29 -05:00
Nobuyoshi Nakada
9d078fe477 [ruby/zlib] Fix the test broken in older versions
fc89ff9ef0
2023-01-09 09:58:43 +00:00
Nobuyoshi Nakada
1cdf8ab07b
[Bug #19323] Raise RangeError instead of integer overflow 2023-01-08 20:54:48 +09:00
Nobuyoshi Nakada
cee5beab1d [Bug #19312] Return end-of-input at __END__ 2023-01-06 13:13:07 +01:00
yui-knk
979dd02e2f Check if the argument is Thread::Backtrace::Location object
[Bug #19262]
2023-01-06 09:22:09 +09:00
Peter Zhu
2056c0a7c6 Add embedded status to dumps of T_OBJECT
This commit adds `"embedded":true` in ObjectSpace.dump for T_OBJECTs
that are embedded.
2023-01-05 16:00:36 -05:00
Benoit Daloze
03dd37775a Raise an ArgumentError for unknown pack/unpack directive
* [Bug #19150]
2023-01-05 19:05:03 +01:00
Stan Lo
f9148d1580 [ruby/irb] Group command test cases with class
(https://github.com/ruby/irb/pull/491)

Currently, IRB has 35 test cases for 10 non-debugging commands, with the
rest 10 commands untested. So in the long-term, it could have around 70
test cases for all existing commands.

With this number of test cases, I think it's easier to manage them by grouping
them in classes (by command).
2023-01-05 13:06:23 +00:00
Peter Zhu
837ef8911c Fix crash in TracePoint c_call for removed method
trace_arg->id is the ID of the original method of an aliased method. If
the original method is removed, then the lookup will fail. We should use
trace_arg->called_id instead, which is the ID of the aliased method.

Fixes [Bug #19305]
2023-01-04 14:59:40 -05:00
Alan Wu
43ff0c2c48 YJIT: Fix yield into block with >=30 locals on ARM
It's a register spill issue. Fix by moving the Qnil fill snippet to
after registers are released.

[Bug #19299]
2023-01-03 16:17:50 -05:00
Matt Valentine-House
0dc989d031 Fix Error in GC Compaction specs
Previously if any of the tests that move objects between size pools
failed to move anything, then the call to stats.dig would return `nil`
which would then cause assert_operator to error.

This should be a test Failure, rather than an Error so this commit uses
a default value of 0 if stats.dig fails to find a key.

Also refactor object movement tests to use stats.dig, rather than :[]
2023-01-03 08:47:48 -05:00