summaryrefslogtreecommitdiff
path: root/spec/ruby/core
AgeCommit message (Collapse)Author
11 daysUpdate to ruby/spec@f54296dBenoit Daloze
2025-12-30Update version guards in ruby/specBenoit Daloze
2025-12-30[Bug #21784] Fix the Proc#source_location start_column for stabby lambdasBenoit Daloze
* Consistent with plain `blocks` and `for` blocks and methods where the source_location covers their entire definition. * Matches the documentation which mentions "where the definition starts/ends". * Partially reverts d357d50f0a74409446f4cccec78593373f5adf2f which was a workaround to be compatible with parse.y.
2025-12-30Reapply "[Feature #6012] Extend `source_location` for end positionBenoit Daloze
* This reverts commit 065c48cdf11a1c4cece84db44ed8624d294f8fd5. * This functionality is very valuable and has already taken 14 years to agree on the API. * Let's just document it's byte columns (in the next commit). * See https://bugs.ruby-lang.org/issues/21783#note-9
2025-12-29Remove deprecated support for to_set taking argumentsJeremy Evans
2025-12-20Revert pack/unpack support for LEB128Nobuyoshi Nakada
https://bugs.ruby-lang.org/issues/21785#note-10 > It is too late to introduce it in Ruby 4.0, let's aim for 4.1. This reverts commits: * d0b72429a93e54f1f956b4aedfc25c57dc7001aa Add support for signed and unsigned LEB128 to pack/unpack. * 68a900e30b4ca1537d7975c3a619fd94fca7b084 add news for pack / unpack directives
2025-12-18Add support for signed and unsigned LEB128 to pack/unpack.Aaron Patterson
This commit adds a new pack format command `R` and `r` for unsigned and signed LEB128 encoding. The "r" mnemonic is because this is a "vaRiable" length encoding scheme. LEB128 is used in various formats including DWARF, WebAssembly, MQTT, and Protobuf. [Feature #21785]
2025-12-16Box: fix the class name in testsNobuyoshi Nakada
2025-12-16Revert "[Feature #6012] Extend `source_location` for end positionNobuyoshi Nakada
and columns" This reverts commit 073c4e1cc712064e626914fa4a5a8061f903a637. https://bugs.ruby-lang.org/issues/6012#note-31 > we will cancel this feature in 4.0 because of design ambiguities > such as whether to return column positions in bytes or characters as > in [#21783]. [#21783]: https://bugs.ruby-lang.org/issues/21783
2025-12-10Use `ruby_version_is`Nobuyoshi Nakada
As the markers for spec/mspec/tool/remove_old_guards.rb.
2025-12-10Use rb_error_frozen_object in rb_class_modify_checkJeremy Evans
This provides information on the class of the frozen object. It also results in a much simpler implementation. Fixes [Bug #21374]
2025-12-06Add error case tests for `File.path`Nobuyoshi Nakada
- for non-String argument - for NUL-contained argument - for ASCII-incompatible argument
2025-11-28Define Kernel#instance_variables_to_inspectJean Boussier
[Bug #21718] Otherwise objects that don't define it, but define a fairly liberal `method_missing` method will run into errors that are hard to understand: ```ruby class Foo def method_missing(name, ...) name end end p Foo.new.inspect ``` ``` 'Kernel#inspect': wrong argument type Symbol (expected Array) (TypeError) from ../test.rb:7:in '<main>' ```
2025-11-20Remove wrong testNobuyoshi Nakada
`realloc` is not guaranteed to return the same address when shrinking.
2025-11-19Update to ruby/spec@6e62695Benoit Daloze
2025-11-19Fix provided features spec with --repeat 2Benoit Daloze
2025-11-19Update to ruby/spec@2e11d2aCharles Oliver Nutter
2025-11-11[Bug #21666] Get rid of use of unspecified valuesNobuyoshi Nakada
2025-10-30[Feature #19630] Limit the versions with the old behaviorNobuyoshi Nakada
It is already declared as: > This behavior is slated to be removed in Ruby 4.0
2025-10-29Fix for other than UTF-8 environmentsNobuyoshi Nakada
2025-10-29Remove alternatives for ruby 1.8 and earliersNobuyoshi Nakada
2025-10-28Update to ruby/spec@3bc45baAndrew Konchin
2025-10-08Update to ruby/spec@3d7e563Benoit Daloze
2025-10-05[ruby/pp] [Feature #21389] Update rubyspecNobuyoshi Nakada
2025-10-01Interpolation with only string literals must not be frozenEarlopain
Basically a redo of https://github.com/ruby/ruby/commit/a1403fb7cbd1fe0df97c932be9814c86081783dc but respecting the frozen string literal magic comment Fixes [Bug #21187]
2025-09-14Remove tests do not test Regexp methodsNobuyoshi Nakada
The backslashs in these tests are parsed as escapes in string literals by the parser, but not passed to the `Regexp` methods.
2025-08-22Do not respect ruby2_keywords on method/proc with post argumentsJeremy Evans
Previously, ruby2_keywords could be used on a method or proc with post arguments, but I don't think the behavior is desired: ```ruby def a(*c, **kw) [c, kw] end def b(*a, b) a(*a, b) end ruby2_keywords(:b) b({foo: 1}, bar: 1) ``` This changes ruby2_keywords to emit a warning and not set the flag on a method/proc with post arguments. While here, fix the ruby2_keywords specs for warnings, since they weren't testing what they should be testing. They all warned because the method didn't accept a rest argument, not because it accepted a keyword or keyword rest argument.
2025-07-24Support `cause:` in `Thread#raise` and `Fiber#raise`. (#13967)Samuel Williams
* Add support for `cause:` argument to `Fiber#raise` and `Thread#raise`. The implementation behaviour is consistent with `Kernel#raise` and `Exception#initialize` methods, allowing the `cause:` argument to be passed to `Fiber#raise` and `Thread#raise`. This change ensures that the `cause:` argument is handled correctly, providing a more consistent and expected behavior when raising exceptions in fibers and threads. [Feature #21360] * Shared specs for Fiber/Thread/Kernel raise. --------- Co-authored-by: Samuel Williams <samuel.williams@shopify.com>
2025-07-15Provide pathname.so with embedded PathnameHiroshi SHIBATA
2025-07-09Update to ruby/spec@ed254baAndrew Konchin
2025-06-25Simplify Set#inspect outputJeremy Evans
As Set is now a core collection class, it should have special inspect output. Ideally, inspect output should be suitable to eval, similar to array and hash (assuming the elements are also suitable to eval): set = Set[1, 2, 3] eval(set.inspect) == set # should be true The simplest way to do this is to use the Set[] syntax. This deliberately does not use any subclass name in the output, similar to array and hash. It is more important that users know they are dealing with a set than which subclass: Class.new(Set)[] # this does: Set[] # not: #<Class:0x00000c21c78699e0>[] This inspect change breaks the power_assert bundled gem tests, so add power_assert to TEST_BUNDLED_GEMS_ALLOW_FAILURES in the workflows. Implements [Feature #21389]
2025-06-18Exclude internal frames from backtraceYusuke Endoh
This changeset suppresses backtrace locations like `<internal:array>:211` as much as possible. Before the patch: ``` $ ruby -e '[1].fetch_values(42)' <internal:array>:211:in 'Array#fetch': index 42 outside of array bounds: -1...1 (IndexError) from <internal:array>:211:in 'block in Array#fetch_values' from <internal:array>:211:in 'Array#map!' from <internal:array>:211:in 'Array#fetch_values' from -e:1:in '<main>' ``` After the patch: ``` $ ./miniruby -e '[1].fetch_values(42)' -e:1:in 'Array#fetch_values': index 42 outside of array bounds: -1...1 (IndexError) from -e:1:in '<main>' ``` Specifically: * The special backtrace handling of BUILTIN_ATTR_C_TRACE is now always applied to frames with `<internal:...>`. * When multiple consecutive internal frames appear, all but the bottom (caller-side) frame are removed. [Misc #20968] Notes: Merged: https://github.com/ruby/ruby/pull/13238
2025-06-10Fix up birthtime specsNobuyoshi Nakada
There are two different possible messages: unsupported OS/version, and unsupported filesystem on a supported system.
2025-06-09[Feature #21219] Selective inspect of instance variablesNobuyoshi Nakada
Make Kernel#inspect ask which instance variables should be dumped by the result of `#instance_variables_to_inspect`. Co-Authored-By: Jean Boussier <byroot@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/13555
2025-06-06Fix birthtime specs on old LinuxNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13540
2025-06-06Deprecate passing arguments to Set#to_set and Enumerable#to_setJeremy Evans
Array#to_a, Hash#to_h, Enumerable#to_a, and Enumerable#to_h do not allow you to specify subclasses. This has undesired behavior when passing non-Set subclasses. All of these are currently allowed, and none make sense: ```ruby enum = [1,2,3].to_enum enum.to_set(Hash) enum.to_set(Struct.new("A", :a)) enum.to_set(ArgumentError) enum.to_set(Thread){} ``` Users who want to create instances of a subclass of Set from an enumerable should pass the enumerable to SetSubclass.new instead of using to_set. Notes: Merged: https://github.com/ruby/ruby/pull/13489
2025-06-02Update to ruby/spec@4d2fc4dAndrew Konchin
Notes: Merged: https://github.com/ruby/ruby/pull/13495
2025-06-02Handle test failure of mock objectHiroshi SHIBATA
Fixup 4c26a38ed3c https://rubyci.s3.amazonaws.com/amazon2/ruby-master/log/20250601T213003Z.fail.html.gz ``` 1) An exception occurred during: Mock.verify_count File.birthtime accepts an object that has a #to_path method FAILED Mock 'path' expected to receive to_path(:any_args) exactly 1 times but received it 0 times /home/chkbuild/chkbuild/tmp/build/20250601T213003Z/ruby/spec/ruby/core/file/birthtime_spec.rb:4:in 'block in <top (required)>' /home/chkbuild/chkbuild/tmp/build/20250601T213003Z/ruby/spec/ruby/core/file/birthtime_spec.rb:3:in '<top (required)>' ```
2025-06-01Skip birthtime failures on old linuxNobuyoshi Nakada
`statx(2)` is available since Linux 4.11 and glibc 2.28. Notes: Merged: https://github.com/ruby/ruby/pull/13491
2025-05-30[Feature #21205] Fix up birthtime in ruby/specNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13474
2025-05-20Remove SortedSet autoload and set/sorted_setJeremy Evans
Implements [Feature #21287] Notes: Merged: https://github.com/ruby/ruby/pull/13188
2025-05-16[Bug #20009] Support marshaling non-ASCII name class/moduleNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13362
2025-05-16"binary" is not valid encoding name in EmacsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13361
2025-05-13Add specs for Set mutation during iterationJean Boussier
2025-05-13Set#merge: raise if called during iterationJean Boussier
[Bug #21332] Notes: Merged: https://github.com/ruby/ruby/pull/13322
2025-05-11spec/ruby/core/module/ancestors_spec.rb: Add a guard for Namespace feat.Yusuke Endoh
2025-05-11namespace on readSatoshi Tagomori
2025-05-10[Feature #15408] Fix up _id2ref_spec.rbNobuyoshi Nakada
2025-05-09Update to ruby/spec@d8bacefAndrew Konchin
Notes: Merged: https://github.com/ruby/ruby/pull/13265
2025-04-26Implement Set as a core classJeremy Evans
Set has been an autoloaded standard library since Ruby 3.2. The standard library Set is less efficient than it could be, as it uses Hash for storage, which stores unnecessary values for each key. Implementation details: * Core Set uses a modified version of `st_table`, named `set_table`. than `s/st_/set_/`, the main difference is that the stored records do not have values, making them 1/3 smaller. `st_table_entry` stores `hash`, `key`, and `record` (value), while `set_table_entry` only stores `hash` and `key`. This results in large sets using ~33% less memory compared to stdlib Set. For small sets, core Set uses 12% more memory (160 byte object slot and 64 malloc bytes, while stdlib set uses 40 for Set and 160 for Hash). More memory is used because the set_table is embedded and 72 bytes in the object slot are currently wasted. Hopefully we can make this more efficient and have it stored in an 80 byte object slot in the future. * All methods are implemented as cfuncs, except the pretty_print methods, which were moved to `lib/pp.rb` (which is where the pretty_print methods for other core classes are defined). As is typical for core classes, internal calls call C functions and not Ruby methods. For example, to check if something is a Set, `rb_obj_is_kind_of` is used, instead of calling `is_a?(Set)` on the related object. * Almost all methods use the same algorithm that the pure-Ruby implementation used. The exception is when calling `Set#divide` with a block with 2-arity. The pure-Ruby method used tsort to implement this. I developed an algorithm that only allocates a single intermediate hash and does not need tsort. * The `flatten_merge` protected method is no longer necessary, so it is not implemented (it could be). * Similar to Hash/Array, subclasses of Set are no longer reflected in `inspect` output. * RDoc from stdlib Set was moved to core Set, with minor updates. This includes a comprehensive benchmark suite for all public Set methods. As you would expect, the native version is faster in the vast majority of cases, and multiple times faster in many cases. There are a few cases where it is significantly slower: * Set.new with no arguments (~1.6x) * Set#compare_by_identity for small sets (~1.3x) * Set#clone for small sets (~1.5x) * Set#dup for small sets (~1.7x) These are slower as Set does not currently use the AR table optimization that Hash does, so a new set_table is initialized for each call. I'm not sure it's worth the complexity to have an AR table-like optimization for small sets (for hashes it makes sense, as small hashes are used everywhere in Ruby). The rbs and repl_type_completor bundled gems will need updates to support core Set. The pull request marks them as allowed failures. This passes all set tests with no changes. The following specs needed modification: * Modifying frozen set error message (changed for the better) * `Set#divide` when passed a 2-arity block no longer yields the same object as both the first and second argument (this seems like an issue with the previous implementation). * Set-like objects that override `is_a?` such that `is_a?(Set)` return `true` are no longer treated as Set instances. * `Set.allocate.hash` is no longer the same as `nil.hash` * `Set#join` no longer calls `Set#to_a` (it calls the underlying C function). * `Set#flatten_merge` protected method is not implemented. Previously, `set.rb` added a `SortedSet` autoload, which loads `set/sorted_set.rb`. This replaces the `Set` autoload in `prelude.rb` with a `SortedSet` autoload, but I recommend removing it and `set/sorted_set.rb`. This moves `test/set/test_set.rb` to `test/ruby/test_set.rb`, reflecting that switch to a core class. This does not move the spec files, as I'm not sure how they should be handled. Internally, this uses the st_* types and functions as much as possible, and only adds set_* types and functions as needed. The underlying set_table implementation is stored in st.c, but there is no public C-API for it, nor is there one planned, in order to keep the ability to change the internals going forward. For internal uses of st_table with Qtrue values, those can probably be replaced with set_table. To do that, include internal/set_table.h. To handle symbol visibility (rb_ prefix), internal/set_table.h uses the same macro approach that include/ruby/st.h uses. The Set class (rb_cSet) and all methods are defined in set.c. There isn't currently a C-API for the Set class, though C-API functions can be added as needed going forward. Implements [Feature #21216] Co-authored-by: Jean Boussier <jean.boussier@gmail.com> Co-authored-by: Oliver Nutter <mrnoname1000@riseup.net>