ruby/test
Ufuk Kayserilioglu 99cee85775
Add copy with changes functionality for Data objects (#6766)
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>
2022-12-21 16:27:38 -08:00
..
-ext- Remove `require 'io/wait'` where it's no longer necessary. (#6932) 2022-12-15 11:37:01 +13:00
base64
benchmark
bigdecimal [ruby/bigdecimal] Tweak check_rounding_mode_option 2022-11-13 02:02:02 +00:00
cgi [ruby/cgi] Loosen the domain regex to accept '.' 2022-11-28 04:34:11 +00:00
coverage Fix false LocalJumpError when branch coverage is enabled 2022-11-08 14:37:08 +09:00
csv Reapply the following commits related to extend timeout value. 2022-12-09 16:36:22 +09:00
date [ruby/date] Implement Date#deconstruct_keys and DateTime#deconstruct_keys 2022-12-13 19:52:06 +00:00
did_you_mean [ruby/did_you_mean] Do not suggest #name= for #name and vice versa 2022-12-05 13:16:33 +00:00
digest [ruby/digest] Ignore test_ractor.rb on non-Ractor ruby 2022-07-21 11:45:48 +09:00
drb Do not run drb SSL tests on Windows 2022-12-02 10:49:56 -08:00
dtrace
erb [ruby/erb] Fix line numbers after multi-line <%# 2022-11-29 04:56:03 +00:00
error_highlight [ruby/error_highlight] Enable tests for TypeError and ArgumentError 2022-11-14 06:22:35 +00:00
etc
excludes Now Psych uses the proleptic Gregorian calendar 2022-09-07 10:37:01 +09:00
fiber Ensure Fiber storage is only accessed from the Fiber it belongs to 2022-12-20 19:32:23 +01:00
fiddle Merge fiddle-1.1.1 2022-12-09 16:36:22 +09:00
fileutils [ruby/fileutils] [Feature #18925] Add `ln_sr` method and `relative:` option to `ln_s` 2022-11-25 01:03:57 +00:00
fixtures/fake_sorted_set_gem
io Remove `require 'io/wait'` where it's no longer necessary. (#6932) 2022-12-15 11:37:01 +13:00
irb [ruby/irb] PTY module is platform dependent 2022-12-19 17:49:59 +09:00
json [flori/json] test parsing of unicode, mixing literal characters with escaped 2022-07-29 19:10:10 +09:00
lib MJIT: Compile methods in batches (#6900) 2022-12-10 22:21:06 -08:00
logger [ruby/logger] Fix log rotation inter-process lock failed. 2022-01-27 12:33:06 +09:00
mkmf Also the tests should use the configured pkg-config 2022-10-02 15:19:14 +09:00
monitor
net Merge net-protocol-0.2.1 2022-12-09 16:36:22 +09:00
nkf
objspace Indicate if a shape is too_complex in ObjectSpace#dump 2022-12-15 13:41:47 -08:00
open-uri Add :ssl_min_version and :ssl_max_version options 2022-10-12 10:36:51 +09:00
openssl [ruby/openssl] Allow empty string to OpenSSL::Cipher#update 2022-12-13 18:07:41 +09:00
optparse [ruby/optparse] The encoding argument of `Regexp.new` has been ignored since 1.9 2022-12-21 14:09:12 +09:00
ostruct [ruby/ostruct] Fix class and method as attribute names 2022-03-07 20:08:22 +09:00
pathname [ruby/pathname] Implement Pathname#lutime 2022-04-21 17:10:19 +09:00
psych Merge Psych-5.0.1 2022-12-09 16:36:22 +09:00
racc [ruby/racc] Make racc test more flexible (for JRuby). 2022-11-10 22:36:34 +00:00
rdoc [ruby/rdoc] Non-RD part feature has not been imported to RDoc 2022-12-01 02:36:20 +09:00
readline test_readline#test_without_tty: Use EnvUtil.rubybin 2022-12-21 09:40:09 +09:00
reline [ruby/reline] Fix a misparameter of RubyLex#set_input in 2022-12-14 00:00:39 +00:00
resolv
rinda Skip running a DRb test on MinGW 2022-08-25 11:37:39 -07:00
ripper [Bug #18963] Separate string contents by here document terminator 2022-08-28 09:29:24 +09:00
ruby Add copy with changes functionality for Data objects (#6766) 2022-12-21 16:27:38 -08:00
rubygems [rubygems/rubygems] Bump rb-sys 2022-12-20 13:15:02 +09:00
socket test/socket/test_addrinfo.rb: Suppress Errno::EACCES on Windows 2022-12-21 15:18:34 +09:00
stringio [ruby/stringio] Fix the result of `StringIO#truncate` so compatible with `File` 2022-07-01 00:52:29 +09:00
strscan Merge strscan-3.0.5 2022-12-09 16:36:22 +09:00
syslog
uri [ruby/uri] Fix splitting relative URI 2022-10-13 16:24:53 +09:00
win32ole
yaml Relax the timeout of a YAML test 2022-12-01 15:37:41 -08:00
zlib Introduce `IO.new(..., path:)` and promote `File#path` to `IO#path`. (#6867) 2022-12-08 18:19:53 +13:00
runner.rb Use the built bundled gems in test-all as well as test-bundled-gems 2022-12-09 02:20:16 +09:00
test_abbrev.rb
test_delegate.rb [ruby/delegate] Revert "Fix `DelegateClass` block "method redefined" warning" 2022-12-01 08:08:02 +00:00
test_extlibs.rb dbm and gdbm have been extracted gems. 2022-09-28 17:06:12 +09:00
test_find.rb
test_forwardable.rb
test_getoptlong.rb
test_ipaddr.rb [ruby/ipaddr] Fix exception calling `to_range' after `freeze' 2022-02-10 17:18:05 +09:00
test_mutex_m.rb
test_observer.rb
test_open3.rb
test_pp.rb [ruby/pp] [Feature #19045] Add support Data#pretty_print 2022-10-14 21:31:24 +09:00
test_prettyprint.rb
test_pstore.rb [ruby/pstore] Emphasize keys instead of roots, values instead of objects (https://github.com/ruby/pstore/pull/7) 2022-07-07 07:05:01 +09:00
test_pty.rb
test_rbconfig.rb
test_securerandom.rb
test_set.rb [ruby/set] Get rid of use of `Gem::Version` 2022-07-14 17:13:52 +09:00
test_shellwords.rb
test_singleton.rb
test_sorted_set.rb
test_syslog.rb
test_tempfile.rb
test_time.rb
test_timeout.rb [ruby/timeout] Explicit add the timeout thread to default ThreadGroup 2022-09-28 01:59:35 +09:00
test_tmpdir.rb [ruby/tmpdir] Warnings should contain the environment variable name 2022-10-27 03:12:00 +00:00
test_trick.rb
test_tsort.rb
test_unicode_normalize.rb
test_weakref.rb