summaryrefslogtreecommitdiff
path: root/test/ruby/test_data.rb
AgeCommit message (Collapse)Author
2025-06-29merge revision(s) 2e7e78cd590d20aa9d41422e96302f3edd73f623: [Backport #21440]nagachika
[Bug #21440] Stop caching member list in frozen Data/Struct class
2023-11-30Add some test cases to Data testOKURA Masafumi
I noticed that `deconstruct` and `hash` don't have enough coverage. The behavior of `hash` is documented so I copied it.
2023-04-06Add missing test for Data.initializeMarc-Andre Lafortune
Notes: Merged: https://github.com/ruby/ruby/pull/7666
2023-02-14[Bug #19259] `Data#with` should call `initialize` methodNobuyoshi Nakada
2022-12-21Add copy with changes functionality for Data objects (#6766)Ufuk Kayserilioglu
Implements [Feature #19000] This commit adds copy with changes functionality for `Data` objects using a new method `Data#with`. Since Data objects are immutable, the only way to change them is by creating a copy. This PR adds a `with` method for `Data` class instances that optionally takes keyword arguments. If the `with` method is called with no arguments, the behaviour is the same as the `Kernel#dup` method, i.e. a new shallow copy is created with no field values changed. However, if keyword arguments are supplied to the `with` method, then the copy is created with the specified field values changed. For example: ```ruby Point = Data.define(:x, :y) point = Point.new(x: 1, y: 2) point.with(x: 3) # => #<data Point x: 3, y: 2> ``` Passing positional arguments to `with` or passing keyword arguments to it that do not correspond to any of the members of the Data class will raise an `ArgumentError`. Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-12-02[Feature #19163] Marshal-loaded Data object also should be frozenNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6843
2022-12-02[Feature #19163] Data object should be frozenNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6843
2022-10-03Cannot `define` from defined `Data` class againNobuyoshi Nakada
2022-09-30Add Data class implementation: Simple immutable value objectVictor Shepelev
Notes: Merged: https://github.com/ruby/ruby/pull/6353 Merged-By: nobu <nobu@ruby-lang.org>