Commit graph

16692 commits

Author SHA1 Message Date
Stan Lo
0aa50a03b1 [ruby/irb] Provide more useful message when
`IRB::Inspector#inspect_value` errors
(https://github.com/ruby/irb/pull/511)

**Before**

```
irb(main):001:0> c = Cat.new "foo"
(Object doesn't support #inspect)
=>
```

**After**

```
irb(main):001:0> c = Cat.new "foo"
An error occurred when inspecting the object: #<NoMethodError: undefined method `is_a?' for foo:Cat

      if obj.is_a?(String)
            ^^^^^^>
Result of Kernel#inspect: #<Cat:0x0000000109090d80 @name="foo">
=>
```
2023-02-27 11:07:19 +00:00
tomoya ishida
4f611df3f7 [ruby/reline] Fix wrong indent number in prompt. whole_lines has
duplicated line.
(https://github.com/ruby/reline/pull/460)

* whole_lines should consider prev_line_index, and must not duplicate last_line

* Add test for lines passed to dynamic prompt proc

* Refactor whole_lines parameters used in test helper

* Remove whole_line's arguments
2023-02-27 10:21:30 +00:00
Hiroshi SHIBATA
db0a4c8923 Prefer to use File.foreach instead of IO.foreach 2023-02-27 18:49:18 +09:00
Hiroshi SHIBATA
d3d8cd304f Prefer to use File.readlines instead of IO.readlines 2023-02-27 18:49:18 +09:00
tomoya ishida
92ed8e6f3f [ruby/reline] Fix the cause of test_yamatanooroti randomly failing
(https://github.com/ruby/reline/pull/474)

* Add repeated input-delete test that fails on HEAD

* Use raw mode while readmultiline
2023-02-27 08:44:02 +00:00
Yusuke Endoh
b6704201a3 Add all-ruby-quine as a sample code
This sample code works on all release versions of Ruby, from Ruby 0.49.
2023-02-27 11:20:42 +09:00
Samuel Williams
57bc3f2f46
Add IO::Buffer.string for efficient string creation. (#7364) 2023-02-25 18:40:26 +13:00
Alan Wu
132934b82b
YJIT: Generate Block::entry_exit with block entry PC
Previously, when Block::entry_exit is requested from any instruction
that is not the first one in the block, we generated the exit with an
incorrect PC. We should always be using the PC for the entry of the
block for Block::entry_exit.

It was a simple typo. The bug was [introduced][1] while we were
refactoring to use the current backend. Later, we had a chance to spot
this issue while [preparing][2] to enable unused variable warnings, but
didn't spot the issue.

Fixes [Bug #19463]

[1]: 27fcab995e
[2]: 31461c7e0e
2023-02-24 16:18:53 -05:00
Peter Zhu
3e09822407 Fix incorrect line numbers in GC hook
If the previous instruction is not a leaf instruction, then the PC was
incremented before the instruction was ran (meaning the currently
executing instruction is actually the previous instruction), so we
should not increment the PC otherwise we will calculate the source
line for the next instruction.

This bug can be reproduced in the following script:

```
require "objspace"

ObjectSpace.trace_object_allocations_start
a =

  1.0 / 0.0
p [ObjectSpace.allocation_sourceline(a), ObjectSpace.allocation_sourcefile(a)]
```

Which outputs: [4, "test.rb"]

This is incorrect because the object was allocated on line 10 and not
line 4. The behaviour is correct when we use a leaf instruction (e.g.
if we replaced `1.0 / 0.0` with `"hello"`), then the output is:
[10, "test.rb"].

[Bug #19456]
2023-02-24 14:10:09 -05:00
Stan Lo
07403de5a8 [ruby/irb] Cleanup completion tests
(https://github.com/ruby/irb/pull/520)

* Remove redundant completion test

The test case was introduced to guard an old implementation, which relied
on `Module#name`. Commit:

8827d18274

However, the current implementation has avoided calling `Module#name`
completely, so the test case is no longer necessary. Commit:

88311ce3c8

* Remove unnecessary pend
2023-02-24 13:34:40 +00:00
Akinori MUSHA
5d5ff6e5ed [ruby/set] Set#merge does not take keyword arguments as a Hash
ca1c9532a9
2023-02-24 11:48:08 +00:00
Akinori MUSHA
454ac4cbb2 [ruby/set] Set#merge takes many enumerable objects like Hash#merge! does
becaca994d
2023-02-24 11:48:07 +00:00
Jean Boussier
2a5354e593 Implement ObjectSpace::WeakKeyMap basic allocator
[Feature #18498]
2023-02-23 16:01:57 +01:00
Nobuyoshi Nakada
b112ae9971
Skip failing test on MSWin 2023-02-22 22:14:26 +09:00
Samuel Giddins
6232e1b9c0 [rubygems/rubygems] Skip extension test on jruby
38ee82c297
2023-02-22 08:42:21 +00:00
Samuel Giddins
151ae9790f [rubygems/rubygems] Better teardown
5fa0ebf09b
2023-02-22 08:42:20 +00:00
Samuel Giddins
a17b1b19b1 [rubygems/rubygems] Always join with a string
Gem.path_separator can also be a regexp...

7e6e56a5f3
2023-02-22 08:42:20 +00:00
Samuel Giddins
616a7e1f6c [rubygems/rubygems] Nil out Gem.configuration after tests
3135ad91d4
2023-02-22 08:42:19 +00:00
Samuel Giddins
ae5deb1ebc [rubygems/rubygems] Use assert_raise instead of assert_raises
For ruby-core compat

c8f85c91a8
2023-02-22 08:42:19 +00:00
Samuel Giddins
931db21208 [rubygems/rubygems] Add tests covering pre-releases for gem exec
f6877c29b9
2023-02-22 08:42:18 +00:00
Samuel Giddins
80bfa1b30a [rubygems/rubygems] Fix resetting env in gem exec, and make sure it is set for gem exec gem
13a6dd4992
2023-02-22 08:42:18 +00:00
Samuel Giddins
2dd9698350 [rubygems/rubygems] Allow gem exec gem
a767f7b9be
2023-02-22 08:42:17 +00:00
Samuel Giddins
47d4f73ee7 [rubygems/rubygems] Remove platform option for gem exec
Also fix native extensions that load dependencies

a06f9870c7
2023-02-22 08:42:17 +00:00
Samuel Giddins
612ebd10c0 [rubygems/rubygems] Ensure dependencies are updated by default when running gem exec
664f3e1e5f
2023-02-22 08:42:16 +00:00
Samuel Giddins
d81be0609b [rubygems/rubygems] Add specs for gem exec
3078e5834e
2023-02-22 08:42:16 +00:00
Hiroshi SHIBATA
015bf5c461
Removed accidentally commits with ruby/readline-ext
Partly reverted 1ddda4c0d7
2023-02-22 10:20:20 +09:00
Hiroshi SHIBATA
fc59b58715 [ruby/readline-ext] test_readline.rb only needs EnvUtil
9245965ecd
2023-02-22 01:18:26 +00:00
Hiroshi SHIBATA
088919065e [ruby/readline-ext] Omit some tests with macOS platform
efe2be6e4c
2023-02-22 01:18:25 +00:00
Hiroshi SHIBATA
1ddda4c0d7 [ruby/readline-ext] Import EnvUtils and related test libraries
f034697a48
2023-02-22 01:18:25 +00:00
Stan Lo
50e77b6a9c [ruby/irb] Improve RubyLex's tests
(https://github.com/ruby/irb/pull/484)

* Improve assert_indenting helper

Instead of putting assertions inside the `auto_indent` block, we
can just make `auto_indent` return the calculated space count, and use
it for assertion outside of the `auto_indent` block call.

This simplifies the setup code and makes the intention easier to
understand.

* Introduce assert_row_indenting helper

1. Helper users shouldn't need to write 2 assertions for the current and
   the next line's indentation.
2. With this new approach, we can generate clearer error message for
   both cases:

When the current line's space count doesn't match

```
  Incorrect spaces calculation for line:

  ```
> def each_top_level_statement
  ```

  All lines:

  ```
  def each_top_level_statement
  ```

<0> expected but was
<nil>
```

When the next line's space count doesn't match

```
  Incorrect spaces calculation for line after the current line:

  ```
  def each_top_level_statement
>
  ```

  All lines:

  ```
  def each_top_level_statement
  ```

<3> expected but was
<2>
```

* Replace assert_indenting with assert_row_indenting
2023-02-21 19:38:09 +00:00
Peter Zhu
93ac7405b8 Add marking and sweeping time to GC.stat
There is a `time` key in GC.stat that gives us the total time spent in
GC. However, we don't know what proportion of the time is spent between
marking and sweeping. This makes it difficult to tune the GC as we're
not sure where to focus our efforts on.

This PR adds keys `marking_time` and `sweeping_time` to GC.stat for the
time spent marking and sweeping, in milliseconds.

[Feature #19437]
2023-02-21 08:05:31 -05:00
Charles Oliver Nutter
4c7726516c [ruby/strscan] Mask out this test on JRuby/Windows
See https://github.com/jruby/jruby/issues/7644 for the root issue,
which will require fixes to JRuby's regular expression engine,
JOni.

29a65abff2
2023-02-21 19:31:39 +09:00
Sutou Kouhei
76a4cdfb02 [ruby/strscan] test: Run test more with fixed anchor mode
(https://github.com/ruby/strscan/pull/60)

fix https://github.com/ruby/strscan/pull/56
2023-02-21 19:31:38 +09:00
OKURA Masafumi
260bc7cdfa [ruby/strscan] Add test case to test_string
(https://github.com/ruby/strscan/pull/58)

`string` returns the original string after `scan` is called. Current
test doesn't check this behavior and now it's covered.
2023-02-21 19:31:38 +09:00
Sutou Kouhei
a350ef9f7a [ruby/csv] test: use mailing list ID instead of unavailable URL
04862ccf87
2023-02-21 19:31:29 +09:00
Vivek Bharath Akupatni
2ac1efc0f3 [ruby/csv] Use https links instead of http
(https://github.com/ruby/csv/pull/274)

e2a06929a8
2023-02-21 19:31:29 +09:00
Hiroshi SHIBATA
38fa8eb4cb Merge rubygems/bundler master
Pick from e9304aed7e
2023-02-21 19:28:12 +09:00
dependabot[bot]
ba2bd6d0f1 [rubygems/rubygems] Bump rb-sys
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.64 to 0.9.65.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.64...v0.9.65)

---
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-02-21 10:05:41 +00:00
Yusuke Endoh
6384f7981c Prevent "warning: ambiguity between regexp and two divisions"
20230221T031004Z.log.html.gz
```
/home/chkbuild/chkbuild/tmp/build/20230221T031004Z/ruby/test/rubygems/test_gem_ext_cargo_builder.rb:90: warning: ambiguity between regexp and two divisions: wrap regexp in parentheses or add a space after `/' operator
```
2023-02-21 13:46:11 +09:00
Takashi Kokubun
ecd0cdaf82
YJIT: Fix assertion for partially mapped last pages (#7337)
Follows up [Bug #19400]
2023-02-20 09:06:09 -08:00
Yusuke Endoh
8f868a1a65 Update some tests for the new message format of NoMethodError 2023-02-20 10:33:06 +09:00
Eric Wong
924ab1b7fd test/readline/test_readline.rb: skip a test x86_64-linux-(x32|i[3-6]86)
I run a 32-bit (x86) userspace on a 64-bit kernel to save memory
and this test fails for the same reason it does on pure 32-bit
platforms.

Followup-to: 6cf7c0a48f (test/readline/test_readline.rb: skip a test on i686-linux, 2021-11-09)
2023-02-19 22:39:28 +00:00
Yusuke Endoh
29f88b9fea [ruby/error_highlight] Support the new message format of NameError in Ruby 3.3
https://bugs.ruby-lang.org/issues/18285
https://github.com/ruby/ruby/pull/6950

a7c2da052e
2023-02-19 10:29:56 +00:00
Yusuke Endoh
4dc2cb3c1a [ruby/did_you_mean] Support the new message format of NameError in
Ruby 3.3
(https://github.com/ruby/did_you_mean/pull/184)

This change accepts the following change of the message of NameError in
a test.

https://bugs.ruby-lang.org/issues/18285#note-37

```
old: undefined method `sizee' for #<File:...>
new: undefined method `sizee' for an instance of File
```
2023-02-19 07:10:47 +00:00
Maciej Rzasa
36e3d46d35 [ruby/bigdecimal] Handle correctly #remainder with infinity. Fixes
https://github.com/ruby/bigdecimal/pull/187

4b8572d452
2023-02-17 17:46:27 +00:00
Nobuyoshi Nakada
dd28c55a7c
[Bug#19445] Fix keyword splat in enumerator
Extracted arguments do not have keyword hash to splat.
2023-02-17 10:57:22 +09:00
Alan Wu
a4b7ec1229 YJIT: Fix false assumption that String#+@ => ::String
Could return a subclass.

[Bug #19444]
2023-02-16 18:50:42 -05:00
Alan Wu
c178926fbe YJIT: jit_prepare_routine_call() for String#+@ missing
We saw SEGVs due to this when running with StackProf, which needs a
correct PC for RUBY_INTERNAL_EVENT_NEWOBJ, the same event used for
ObjectSpace allocation tracing.

[Bug #19444]
2023-02-16 18:50:42 -05:00
Haldun Bayhantopcu
0b4b2cd1ee Fix removing ivars from clases and modules.
Co-authored-by: Adam Hess <hparker@github.com>
2023-02-15 15:43:46 -08:00
Benoit Daloze
70d84a5f3d [ruby/timeout] Simplify test
db017da726
2023-02-15 19:25:05 +00:00