Commit graph

1255 commits

Author SHA1 Message Date
Nobuyoshi Nakada
94df8a0cae Postpone spec of eszett with ignore case in look behind 2024-12-24 17:50:01 +09:00
Nobuyoshi Nakada
bf5f8ecef1
[Bug #20978] Use ruby_bug instead of ruby_version_is 2024-12-23 19:21:46 +09:00
Nobuyoshi Nakada
adad97a031
[Bug #20978] Stringize Fiber storage keys 2024-12-23 18:16:28 +09:00
Nobuyoshi Nakada
99d5e6ab7a
Suppress WIN32OLE deprecation warnings for the time being 2024-12-22 22:10:02 +09:00
Andrew Konchin
d5abcae435 Fix formatting of spec/ruby/optional/capi/ext/hash_spec.c 2024-12-10 14:38:52 +01:00
Andrew Konchin
de5df203bc Update to ruby/spec@9f10222 2024-12-10 14:38:52 +01:00
Kazuhiro NISHIYAMA
bbcb094e2d Socket#connect may be raise ECONNREFUSED
On my environment with `sudo ufw default reject outgoing`,
outgoing packets are filtered without allow rules.
2024-12-03 13:56:26 +09:00
John Hawthorn
f1dda5ed01 Warn when redefining __id__ as well as object_id
[Feature #20912]
2024-11-29 20:41:00 -08:00
Hiroshi SHIBATA
b85425493a Omit flaky example with Windows platform
3330566428

```
  IO#wait [events, timeout] passed changes thread status to 'sleep' when waits for WRITABLE event FAILED
  Expected false == "sleep"
  to be truthy but was false
  D:/a/ruby/ruby/src/spec/ruby/library/io-wait/wait_spec.rb:99:in 'block (3 levels) in <top (required)>'
  D:/a/ruby/ruby/src/spec/ruby/library/io-wait/wait_spec.rb:8:in '<top (required)>'
```
2024-11-21 19:16:27 +09:00
Nobuyoshi Nakada
9c777f282f
[Bug #20900] Warn deprecated constant when removing 2024-11-19 12:43:38 +09:00
Matt Valentine-House
ee290c94a3 Include the currently active GC in RUBY_DESCRIPTION
This will add +MOD_GC to the version string and Ruby description when
Ruby is compiled with shared gc support.

When shared GC support is compiled in and a GC module has been loaded
using RUBY_GC_LIBRARY, the version string will include the name of
the currently active GC as reported by the rb_gc_active_gc_name function
in the form

+MOD_GC[gc_name]

[Feature #20794]
2024-11-14 10:46:36 +00:00
Jean byroot Boussier
6deeec5d45
Mark strings returned by Symbol#to_s as chilled (#12065)
* Use FL_USER0 for ELTS_SHARED

This makes space in RString for two bits for chilled strings.

* Mark strings returned by `Symbol#to_s` as chilled

[Feature #20350]

`STR_CHILLED` now spans on two user flags. If one bit is set it
marks a chilled string literal, if it's the other it marks a
`Symbol#to_s` chilled string.

Since it's not possible, and doesn't make much sense to include
debug info when `--debug-frozen-string-literal` is set, we can't
include allocation source, but we can safely include the symbol
name in the warning message, making it much easier to find the source
of the issue.

Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>

---------

Co-authored-by: Étienne Barrié <etienne.barrie@gmail.com>
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2024-11-13 09:20:00 -05:00
Yusuke Endoh
45cd4a8296 Do not round a**b to infinity
... instead, just calculate the value unless it is too big.
Also, this change raises an ArgumentError if it is expected to exceed
16 GB in a 64-bit environment.

(It is possible to calculate it straightforward, but it would likely be
out-of-memory, so I didn't think it would make sense.)

[Feature #20811]
2024-11-08 19:48:56 +09:00
Benoit Daloze
6385a28c33 Quarantine unreliable spec
* See discussion on https://github.com/ruby/spec/pull/1210
2024-11-07 13:47:43 +01:00
Yusuke Endoh
7c893c8d6b Loosen the criteria for timing checks of Kernel#sleep
The test was too flaky
2024-11-07 10:18:48 +09:00
Benoit Daloze
fdc82cca83 Update to ruby/spec@54c391e 2024-11-06 21:58:28 +01:00
Hiroshi SHIBATA
a2dd471d9e
macOS 15 is the stable version today 2024-11-06 15:45:32 +09:00
Nobuyoshi Nakada
18c3e2d9f1
Assert newly added warning in JSON.load 2024-11-06 12:58:21 +09:00
Takashi Kokubun
478e0fc710
YJIT: Replace Array#each only when YJIT is enabled (#11955)
* YJIT: Replace Array#each only when YJIT is enabled

* Add comments about BUILTIN_ATTR_C_TRACE

* Make Ruby Array#each available with --yjit as well

* Fix all paths that expect a C location

* Use method_basic_definition_p to detect patches

* Copy a comment about C_TRACE flag to compilers

* Rephrase a comment about add_yjit_hook

* Give METHOD_ENTRY_BASIC flag to Array#each

* Add --yjit-c-builtin option

* Allow inconsistent source_location in test-spec

* Refactor a check of BUILTIN_ATTR_C_TRACE

* Set METHOD_ENTRY_BASIC without touching vm->running
2024-11-04 11:14:28 -05:00
Jean Boussier
a6c4a842db Harden the ObjectSpace.memsize_of spec
[Bug #20803]

`abc` is used a lot across the ruby spec suite, if another test runs before
this spec is loaded and create this symbol dynamically (`"abc".to_sym`)
the spec will fail.

So it's preferable to use a symbol name that is very unlikely to be
used elsewhere to avoid flakes.
2024-10-23 16:04:28 +02:00
Étienne Barrié
257f78fb67 Show where mutated chilled strings were allocated
[Feature #20205]

The warning now suggests running with --debug-frozen-string-literal:

```
test.rb:3: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
```

When using --debug-frozen-string-literal, the location where the string
was created is shown:

```
test.rb:3: warning: literal string will be frozen in the future
test.rb:1: info: the string was created here
```

When resurrecting strings and debug mode is not enabled, the overhead is a simple FL_TEST_RAW.
When mutating chilled strings and deprecation warnings are not enabled,
the overhead is a simple warning category enabled check.

Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2024-10-21 12:33:02 +02:00
Nobuyoshi Nakada
d58ec11945
[Bug #20797] Yet another test 2024-10-15 14:52:17 +09:00
Nobuyoshi Nakada
9611c619ac
[Bug #20797] Check seconds in UTC offset as well as minutes 2024-10-14 13:55:55 +09:00
Samuel Williams
ad5641fd34
Support IO#timeout for rsock_connect. (#11880) 2024-10-12 10:08:34 +13:00
Nobuyoshi Nakada
d17edf3a17
[Bug #20705] Update strtod implementation
The absence of either the integer or fractional part should be
allowed.
2024-10-05 23:29:42 +09:00
Samuel Williams
c33cb9a586
Update io_spec.c to use rb_io_maybe_wait* if possible. (#11792) 2024-10-04 07:35:57 +00:00
Samuel Williams
c878843b2c
Better handling of timeout in rb_io_maybe_wait_*. (#9531) 2024-10-04 19:36:06 +13:00
tompng
c94815bab7 Update spec/ruby/ for colon-style hash inspect 2024-10-03 18:47:09 +09:00
Hiroshi SHIBATA
3ebc85e240
Define RactorLocalSingleton on .mspec.constants 2024-10-01 18:41:38 +09:00
Hiroshi SHIBATA
d109c7c620
Temporary disabled RactorLocalSingleton from constant leak check. 2024-10-01 18:32:40 +09:00
Samuel Williams
4c3727c6ac Add anonymous module name spec. 2024-09-23 14:23:58 +02:00
Jeremy Evans
8dc0d2904a Update exception message in string_for_symbol
This is a static function only called in two places (rb_to_id and
rb_to_symbol), and in both places, both symbols and strings are
allowed.  This makes the error message consistent with rb_check_id
and rb_check_symbol.

Fixes [Bug #20607]
2024-09-18 21:29:07 -07:00
Hiroshi SHIBATA
95f08f2b7f
Skip failing examples related with d81b0588bb 2024-09-17 15:44:18 +09:00
Jean Boussier
16f241f0aa Implement String#append_as_bytes(String | Integer, ...)
[Feature #20594]

A handy method to construct a string out of multiple chunks.

Contrary to `String#concat`, it doesn't do any encoding negociation,
and simply append the content as bytes regardless of whether this
result in a broken string or not.

It's the caller responsibility to check for `String#valid_encoding?`
in cases where it's needed.

When passed integers, only the lower byte is considered, like in
`String#setbyte`.
2024-09-09 15:04:51 +02:00
Jean Boussier
bc85c8d852 Implement Array#fetch_values
[Feature #20702]

Works the same way than `Hash#fetch_values` for for array.
2024-09-06 12:40:32 +02:00
Jean Boussier
57e3fc32ea Move Time#xmlschema in core and optimize it
[Feature #20707]

Converting Time into RFC3339 / ISO8601 representation is an significant
hotspot for applications that serialize data in JSON, XML or other formats.

By moving it into core we can optimize it much further than what `strftime` will
allow.

```
compare-ruby: ruby 3.4.0dev (2024-08-29T13:11:40Z master 6b08a50a62) +YJIT [arm64-darwin23]
built-ruby: ruby 3.4.0dev (2024-08-30T13:17:32Z native-xmlschema 34041ff71f) +YJIT [arm64-darwin23]
warming up......

|                        |compare-ruby|built-ruby|
|:-----------------------|-----------:|---------:|
|time.xmlschema          |      1.087M|    5.190M|
|                        |           -|     4.78x|
|utc_time.xmlschema      |      1.464M|    6.848M|
|                        |           -|     4.68x|
|time.xmlschema(6)       |    859.960k|    4.646M|
|                        |           -|     5.40x|
|utc_time.xmlschema(6)   |      1.080M|    5.917M|
|                        |           -|     5.48x|
|time.xmlschema(9)       |    893.909k|    4.668M|
|                        |           -|     5.22x|
|utc_time.xmlschema(9)   |      1.056M|    5.707M|
|                        |           -|     5.40x|
```
2024-09-05 19:23:12 +02:00
zverok
245ed2fc89 Range#step: restore legacy behavior for String ranges 2024-09-03 16:21:42 +09:00
Victor Shepelev
d450f9d6a2
Make Range#step to consistently use + for iteration (#7444)
Make Range#step to consistently use + for iteration [Feature #18368]

Previously, non-numerics expected step to be integer,
and iterated with begin#succ, skipping over step value
steps. Since this commit, numeric and non-numeric iteration
behaves the same way, by using + operator.
2024-08-18 13:15:18 +03:00
Alan Wu
d08e55141e Make Integer#round spec work regardless of pointer size
The spec is actually testing a behaviour stemming from NUM2INT(), and
since `sizeof(long)>=sizeof(int)`, `min_long-1` always makes NUM2INT()
raise `RangeError`.
2024-07-24 18:20:30 +02:00
Alan Wu
fbb981b9f8 Stop depending on Integer#size to return sizeof(long)
There is no guarantee that Integer#size will continue to return
`sizeof(long)` for small integers.

Use the `l!` specifier for Array#pack instead. It is a public
interface that has a direct relationship with the `long` type.
2024-07-24 18:20:30 +02:00
Alan Wu
12e6cf77ef Add "c_long_size" guard, supplanting "wordsize" and stop using Integer#size
What a "word" is when talking about sizes is confusing because it's a
highly overloaded term. Intel, Microsoft, and GDB are just a few vendors
that have their own definition of what a "word" is. Specs that used the
"wordsize" guard actually were mostly testing for the size of the C
`long` fundamental type, so rename the guard for clarity.

Also, get the size of `long` directly from RbConfig instead of guessing
using Integer#size. Integer#size is not guaranteed to have anything to
do with the `long` type.
2024-07-24 18:20:30 +02:00
Hiroshi SHIBATA
e0f40dc9b0
Split URI::Parser examples with RFC2396 and RFC3986
Prepare for https://github.com/ruby/uri/pull/107
2024-07-18 12:42:36 +09:00
Nobuyoshi Nakada
278bbd7b45 Revert pending EVENT_RETURN tests
* "Allow ambiguosity of `return` line"
  65b991bc85
* "Move to test/.excludes-prism"
  3b4ff810d2
* "Pending `EVENT_RETURN` settracefunc tests with Prism"
  a7f33c99c6
2024-07-17 14:06:11 -04:00
Hiroshi SHIBATA
371055979f Pend some tests because these are not working with macOS 15 beta and Xcode 16 beta 2024-07-12 13:38:22 +09:00
Jean Boussier
3de0e343e2 Do not warn about extra format argument when passed as keywords
[Bug #20593]

It's fairly common to use `format` to interpolate a number of values
into a user provided strings.

The arguments not matching are a problem when they are positional,
but when they are named, it's absolutely fine and we shouldn't
emit a warning.
2024-07-11 07:39:50 +02:00
Jean Boussier
9594db0cf2 Implement Hash.new(capacity:)
[Feature #19236]

When building a large hash, pre-allocating it with enough
capacity can save many re-hashes and significantly improve
performance.

```
/opt/rubies/3.3.0/bin/ruby --disable=gems -rrubygems -I./benchmark/lib ./benchmark/benchmark-driver/exe/benchmark-driver \
	            --executables="compare-ruby::../miniruby-master -I.ext/common --disable-gem" \
	            --executables="built-ruby::./miniruby --disable-gem" \
	            --output=markdown --output-compare -v $(find ./benchmark -maxdepth 1 -name 'hash_new' -o -name '*hash_new*.yml' -o -name '*hash_new*.rb' | sort)
compare-ruby: ruby 3.4.0dev (2024-03-25T11:48:11Z master f53209f023) +YJIT dev [arm64-darwin23]
last_commit=[ruby/irb] Cache RDoc::RI::Driver.new (https://github.com/ruby/irb/pull/911)
built-ruby: ruby 3.4.0dev (2024-03-25T15:29:40Z hash-new-rb 77652b08a2) +YJIT dev [arm64-darwin23]
warming up...

|                    |compare-ruby|built-ruby|
|:-------------------|-----------:|---------:|
|new                 |      7.614M|    5.976M|
|                    |       1.27x|         -|
|new_with_capa_1k    |     13.931k|   15.698k|
|                    |           -|     1.13x|
|new_with_capa_100k  |     124.746|   148.283|
|                    |           -|     1.19x|
```
2024-07-08 12:24:33 +02:00
Jeremy Evans
7f1fe5f091 Raise a TypeError for Thread#thread_variable{?,_get} for non-symbol
Previously, a TypeError was not raised if there were no thread
variables, because the conversion to symbol was done after that
check.  Convert to symbol before checking for whether thread
variables are set to make the behavior consistent.

Fixes [Bug #20606]
2024-07-06 12:07:32 +02:00
Andrew Konchin
cee62c6738 Update to ruby/spec@f8987ac 2024-07-02 13:33:48 +02:00
Nobuyoshi Nakada
65b991bc85
Allow ambiguosity of return line 2024-06-25 16:30:14 +09:00
Nobuyoshi Nakada
250fc1223c [Bug #20457] Do not remove final return node
This was an optimization for versions prior to 1.9 that traverse the
AST at runtime.
2024-06-25 11:07:58 +09:00