From 33aaa2aa15980f8ac0f330fc817f179e46daed55 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 16 Apr 2020 18:47:04 +0900 Subject: [PATCH 001/234] Added test for invalid env exec option --- test/ruby/test_process.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index a5eb0a58441d06..e9c7ee62b26a76 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -338,6 +338,10 @@ def test_execopts_env ensure ENV["hmm"] = old end + + assert_raise_with_message(ArgumentError, /fo=fo/) { + system({"fo=fo"=>"ha"}, *ENVCOMMAND) + } end def test_execopt_env_path From f57e2d7296fbdf09041bdb237c7423a12ef06621 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 16 Apr 2020 20:40:19 +0900 Subject: [PATCH 002/234] Preserve encoding in error message for invalid env exec option --- process.c | 2 +- test/ruby/test_process.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/process.c b/process.c index f13ec82ba033ca..129a2e670614e4 100644 --- a/process.c +++ b/process.c @@ -2325,7 +2325,7 @@ check_exec_env_i(st_data_t st_key, st_data_t st_val, st_data_t arg) k = StringValueCStr(key); if (strchr(k, '=')) - rb_raise(rb_eArgError, "environment name contains a equal : %s", k); + rb_raise(rb_eArgError, "environment name contains a equal : %"PRIsVALUE, key); if (!NIL_P(val)) StringValueCStr(val); diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index e9c7ee62b26a76..7170e826d5420e 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -342,6 +342,9 @@ def test_execopts_env assert_raise_with_message(ArgumentError, /fo=fo/) { system({"fo=fo"=>"ha"}, *ENVCOMMAND) } + assert_raise_with_message(ArgumentError, /\u{30c0}=\u{30e1}/) { + system({"\u{30c0}=\u{30e1}"=>"ha"}, *ENVCOMMAND) + } end def test_execopt_env_path From 748c7c7c0b4ce605c0cedf971e94f0076e0e77de Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 16 Apr 2020 20:36:20 +0900 Subject: [PATCH 003/234] Added tests for Process::UID.from_name and Process::GID.from_name --- test/ruby/test_process.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 7170e826d5420e..ccca1834cfd234 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1605,6 +1605,22 @@ def test_setegid rescue NotImplementedError end + if Process::UID.respond_to?(:from_name) + def test_uid_from_name + if u = Etc.getpwuid(Process.uid) + assert_equal(Process.uid, Process::UID.from_name(u.name), u.name) + end + end + end + + if Process::GID.respond_to?(:from_name) + def test_gid_from_name + if g = Etc.getgrgid(Process.gid) + assert_equal(Process.gid, Process::GID.from_name(g.name), g.name) + end + end + end + def test_uid_re_exchangeable_p r = Process::UID.re_exchangeable? assert_include([true, false], r) From fedc8075fe2a2bbbfa12c028c0879330d7db5596 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 16 Apr 2020 20:40:53 +0900 Subject: [PATCH 004/234] Preserve encoding in error messages for invalid user/group name --- process.c | 4 ++-- test/ruby/test_process.rb | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/process.c b/process.c index 129a2e670614e4..efe99843489a4c 100644 --- a/process.c +++ b/process.c @@ -5585,7 +5585,7 @@ obj2uid(VALUE id #ifndef USE_GETPWNAM_R endpwent(); #endif - rb_raise(rb_eArgError, "can't find user for %s", usrname); + rb_raise(rb_eArgError, "can't find user for %"PRIsVALUE, id); } uid = pwptr->pw_uid; #ifndef USE_GETPWNAM_R @@ -5664,7 +5664,7 @@ obj2gid(VALUE id #if !defined(USE_GETGRNAM_R) && defined(HAVE_ENDGRENT) endgrent(); #endif - rb_raise(rb_eArgError, "can't find group for %s", grpname); + rb_raise(rb_eArgError, "can't find group for %"PRIsVALUE, id); } gid = grptr->gr_gid; #if !defined(USE_GETGRNAM_R) && defined(HAVE_ENDGRENT) diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index ccca1834cfd234..e8367b72012ac9 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1610,6 +1610,9 @@ def test_uid_from_name if u = Etc.getpwuid(Process.uid) assert_equal(Process.uid, Process::UID.from_name(u.name), u.name) end + assert_raise_with_message(ArgumentError, /\u{4e0d 5b58 5728}/) { + Process::UID.from_name("\u{4e0d 5b58 5728}") + } end end @@ -1618,6 +1621,9 @@ def test_gid_from_name if g = Etc.getgrgid(Process.gid) assert_equal(Process.gid, Process::GID.from_name(g.name), g.name) end + assert_raise_with_message(ArgumentError, /\u{4e0d 5b58 5728}/) { + Process::GID.from_name("\u{4e0d 5b58 5728}") + } end end From e231f8e8a8659bab7f8ef9992c6b36b8683fb8aa Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 16 Apr 2020 23:44:24 +0900 Subject: [PATCH 005/234] envutil.rb: not try to close pipes twice --- tool/lib/envutil.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tool/lib/envutil.rb b/tool/lib/envutil.rb index 2faf48385e42a4..07d76c0e5329b5 100644 --- a/tool/lib/envutil.rb +++ b/tool/lib/envutil.rb @@ -137,8 +137,10 @@ def invoke_ruby(args, stdin_data = "", capture_stdout = false, capture_stderr = args = [args] if args.kind_of?(String) pid = spawn(child_env, *precommand, rubybin, *args, **opt) in_c.close - out_c.close if capture_stdout - err_c.close if capture_stderr && capture_stderr != :merge_to_stdout + out_c&.close + out_c = nil + err_c&.close + err_c = nil if block_given? return yield in_p, out_p, err_p, pid else From 3cca0d1958a53a18b824af24801b9cbfa04691df Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 16 Apr 2020 23:45:02 +0900 Subject: [PATCH 006/234] core_assertions.rb: fixed fd leak at timeout --- tool/lib/test/unit/core_assertions.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tool/lib/test/unit/core_assertions.rb b/tool/lib/test/unit/core_assertions.rb index e5f741fafbfe2f..127ff49166b362 100644 --- a/tool/lib/test/unit/core_assertions.rb +++ b/tool/lib/test/unit/core_assertions.rb @@ -291,6 +291,7 @@ def assert_separately(args, file = nil, line = nil, src, ignore_stderr: nil, **o args = args.dup args.insert((Hash === args.first ? 1 : 0), "-w", "--disable=gems", *$:.map {|l| "-I#{l}"}) stdout, stderr, status = EnvUtil.invoke_ruby(args, src, capture_stdout, true, **opt) + ensure if res_c res_c.close res = res_p.read @@ -298,6 +299,7 @@ def assert_separately(args, file = nil, line = nil, src, ignore_stderr: nil, **o else res = stdout end + raise if $! abort = status.coredump? || (status.signaled? && ABORT_SIGNALS.include?(status.termsig)) assert(!abort, FailDesc[status, nil, stderr]) self._assertions += res[/^assertions=(\d+)/, 1].to_i From 99a048155c0ff281f4f7035d524110b8b94f0a1d Mon Sep 17 00:00:00 2001 From: git Date: Fri, 17 Apr 2020 00:52:53 +0900 Subject: [PATCH 007/234] * 2020-04-17 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 0149e01d04e962..a9054a18ae22c4 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 16 +#define RUBY_RELEASE_DAY 17 #include "ruby/version.h" From a0bc3f2a1c2c98f225612101cb4e1ea1a6813546 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 17 Apr 2020 00:27:47 +0900 Subject: [PATCH 008/234] Suppress C4267 "possible loss of data" warnings --- ext/win32ole/win32ole.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index f20bfc84f633b3..cd5a62d36d0374 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -2651,7 +2651,7 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket) /*------------------------------------------ hash object ==> named dispatch parameters --------------------------------------------*/ - cNamedArgs = rb_long2int(RHASH_SIZE(param)); + cNamedArgs = SIZET2NUM(RHASH_SIZE(param)); op.dp.cArgs = cNamedArgs + argc - 2; op.pNamedArgs = ALLOCA_N(OLECHAR*, cNamedArgs + 1); op.dp.rgvarg = ALLOCA_N(VARIANTARG, op.dp.cArgs); From c23efbaa99bf39800c32daf69b2424c9371b1f10 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Fri, 17 Apr 2020 06:23:40 +0900 Subject: [PATCH 009/234] Remove lib/rss.rb This is a follow-up of 83240f315a10b42b53c3b62c1fbc428f97912665 . --- lib/rss.rb | 94 ------------------------------------------------------ 1 file changed, 94 deletions(-) delete mode 100644 lib/rss.rb diff --git a/lib/rss.rb b/lib/rss.rb deleted file mode 100644 index 1438d97bd33807..00000000000000 --- a/lib/rss.rb +++ /dev/null @@ -1,94 +0,0 @@ -# frozen_string_literal: false -## -# = RSS reading and writing -# -# Really Simple Syndication (RSS) is a family of formats that describe 'feeds,' -# specially constructed XML documents that allow an interested person to -# subscribe and receive updates from a particular web service. This portion of -# the standard library provides tooling to read and create these feeds. -# -# The standard library supports RSS 0.91, 1.0, 2.0, and Atom, a related format. -# Here are some links to the standards documents for these formats: -# -# * RSS -# * 0.9.1[http://www.rssboard.org/rss-0-9-1-netscape] -# * 1.0[http://web.resource.org/rss/1.0/] -# * 2.0[http://www.rssboard.org/rss-specification] -# * Atom[http://tools.ietf.org/html/rfc4287] -# -# == Consuming RSS -# -# If you'd like to read someone's RSS feed with your Ruby code, you've come to -# the right place. It's really easy to do this, but we'll need the help of -# open-uri: -# -# require 'rss' -# require 'open-uri' -# -# url = 'http://www.ruby-lang.org/en/feeds/news.rss' -# open(url) do |rss| -# feed = RSS::Parser.parse(rss) -# puts "Title: #{feed.channel.title}" -# feed.items.each do |item| -# puts "Item: #{item.title}" -# end -# end -# -# As you can see, the workhorse is RSS::Parser#parse, which takes the source of -# the feed and a parameter that performs validation on the feed. We get back an -# object that has all of the data from our feed, accessible through methods. -# This example shows getting the title out of the channel element, and looping -# through the list of items. -# -# == Producing RSS -# -# Producing our own RSS feeds is easy as well. Let's make a very basic feed: -# -# require "rss" -# -# rss = RSS::Maker.make("atom") do |maker| -# maker.channel.author = "matz" -# maker.channel.updated = Time.now.to_s -# maker.channel.about = "http://www.ruby-lang.org/en/feeds/news.rss" -# maker.channel.title = "Example Feed" -# -# maker.items.new_item do |item| -# item.link = "http://www.ruby-lang.org/en/news/2010/12/25/ruby-1-9-2-p136-is-released/" -# item.title = "Ruby 1.9.2-p136 is released" -# item.updated = Time.now.to_s -# end -# end -# -# puts rss -# -# As you can see, this is a very Builder-like DSL. This code will spit out an -# Atom feed with one item. If we needed a second item, we'd make another block -# with maker.items.new_item and build a second one. -# -# == Copyright -# -# Copyright (c) 2003-2007 Kouhei Sutou -# -# You can redistribute it and/or modify it under the same terms as Ruby. -# -# There is an additional tutorial by the author of RSS at: -# http://www.cozmixng.org/~rwiki/?cmd=view;name=RSS+Parser%3A%3ATutorial.en - -module RSS -end - -require "rss/version" - -require 'rss/1.0' -require 'rss/2.0' -require 'rss/atom' -require 'rss/content' -require 'rss/dublincore' -require 'rss/image' -require 'rss/itunes' -require 'rss/slash' -require 'rss/syndication' -require 'rss/taxonomy' -require 'rss/trackback' - -require "rss/maker" From 36353b272852acdf951e4870286834a76e80b952 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Fri, 17 Apr 2020 09:20:29 +0900 Subject: [PATCH 010/234] test/ruby/test_process.rb: Skip GID.from_name on Android The user management on Android seems very different https://rubyci.org/logs/rubyci.s3.amazonaws.com/android28-x86_64/ruby-master/log/20200416T234122Z.fail.html.gz --- test/ruby/test_process.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index e8367b72012ac9..7bcfa48f4fc588 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1616,7 +1616,7 @@ def test_uid_from_name end end - if Process::GID.respond_to?(:from_name) + if Process::GID.respond_to?(:from_name) && !RUBY_PLATFORM.include?("android") def test_gid_from_name if g = Etc.getgrgid(Process.gid) assert_equal(Process.gid, Process::GID.from_name(g.name), g.name) From 75a0447c15a7ab017bd4240c2a9cc69b134b80b9 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 17 Apr 2020 08:14:38 +0900 Subject: [PATCH 011/234] Suppress C4267 "possible loss of data" warnings Just cast down explicitly. --- ext/win32ole/win32ole.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index cd5a62d36d0374..4b55f6ea54a27c 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -2651,7 +2651,7 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket) /*------------------------------------------ hash object ==> named dispatch parameters --------------------------------------------*/ - cNamedArgs = SIZET2NUM(RHASH_SIZE(param)); + cNamedArgs = rb_long2int((long)RHASH_SIZE(param)); op.dp.cArgs = cNamedArgs + argc - 2; op.pNamedArgs = ALLOCA_N(OLECHAR*, cNamedArgs + 1); op.dp.rgvarg = ALLOCA_N(VARIANTARG, op.dp.cArgs); From 00d927838768894eab84c76e72d44cb4d8b9cc3d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 17 Apr 2020 14:07:14 +0900 Subject: [PATCH 012/234] fileutils now depends on rbconfig.rb due to JRuby support --- common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.mk b/common.mk index 1715518bde24f8..6ac7c2a360f756 100644 --- a/common.mk +++ b/common.mk @@ -224,7 +224,7 @@ mjit_config.h: Makefile # Other `-Dxxx`s preceding `-DMJIT_HEADER` will be removed in transform_mjit_header.rb. # So `-DMJIT_HEADER` should be passed first when rb_mjit_header.h is generated. $(TIMESTAMPDIR)/$(MJIT_HEADER:.h=)$(MJIT_HEADER_SUFFIX).time: probes.h vm.$(OBJEXT) \ - $(TIMESTAMPDIR)/$(arch)/.time $(tooldir)/mjit_tabs.rb $(PREP) + $(TIMESTAMPDIR)/$(arch)/.time $(tooldir)/mjit_tabs.rb $(PREP) $(RBCONFIG) $(ECHO) building $(@F:.time=.h) $(MINIRUBY) $(tooldir)/mjit_tabs.rb "$(MJIT_TABS)" \ $(CPP) -DMJIT_HEADER $(MJIT_HEADER_FLAGS) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(srcdir)/vm.c $(CPPOUTFLAG)$(@F:.time=.h).new From b5132d91c038dc4f7501ab049c31d0d1433addc2 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 15 Apr 2020 01:07:50 +0900 Subject: [PATCH 013/234] Refactored rb_readwrite_syserr_fail * renamed argument `writable` as `waiting` * hosited out creating and raising exception * turned into a `switch` --- io.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/io.c b/io.c index 7f43ca36d608fc..44f608753f40f3 100644 --- a/io.c +++ b/io.c @@ -13014,53 +13014,55 @@ argf_write(VALUE argf, VALUE str) } void -rb_readwrite_sys_fail(enum rb_io_wait_readwrite writable, const char *mesg) +rb_readwrite_sys_fail(enum rb_io_wait_readwrite waiting, const char *mesg) { - rb_readwrite_syserr_fail(writable, errno, mesg); + rb_readwrite_syserr_fail(waiting, errno, mesg); } void -rb_readwrite_syserr_fail(enum rb_io_wait_readwrite writable, int n, const char *mesg) +rb_readwrite_syserr_fail(enum rb_io_wait_readwrite waiting, int n, const char *mesg) { - VALUE arg; + VALUE arg, c = Qnil; arg = mesg ? rb_str_new2(mesg) : Qnil; - if (writable == RB_IO_WAIT_WRITABLE) { + switch (waiting) { + case RB_IO_WAIT_WRITABLE: switch (n) { case EAGAIN: - rb_exc_raise(rb_class_new_instance(1, &arg, rb_eEAGAINWaitWritable)); + c = rb_eEAGAINWaitWritable; break; #if EAGAIN != EWOULDBLOCK case EWOULDBLOCK: - rb_exc_raise(rb_class_new_instance(1, &arg, rb_eEWOULDBLOCKWaitWritable)); + c = rb_eEWOULDBLOCKWaitWritable; break; #endif case EINPROGRESS: - rb_exc_raise(rb_class_new_instance(1, &arg, rb_eEINPROGRESSWaitWritable)); + c = rb_eEINPROGRESSWaitWritable; break; default: - rb_mod_sys_fail_str(rb_mWaitWritable, arg); + rb_mod_syserr_fail_str(rb_mWaitWritable, n, arg); } - } - else if (writable == RB_IO_WAIT_READABLE) { + break; + case RB_IO_WAIT_READABLE: switch (n) { case EAGAIN: - rb_exc_raise(rb_class_new_instance(1, &arg, rb_eEAGAINWaitReadable)); + c = rb_eEAGAINWaitReadable; break; #if EAGAIN != EWOULDBLOCK case EWOULDBLOCK: - rb_exc_raise(rb_class_new_instance(1, &arg, rb_eEWOULDBLOCKWaitReadable)); + c = rb_eEWOULDBLOCKWaitReadable; break; #endif case EINPROGRESS: - rb_exc_raise(rb_class_new_instance(1, &arg, rb_eEINPROGRESSWaitReadable)); + c = rb_eEINPROGRESSWaitReadable; break; default: - rb_mod_sys_fail_str(rb_mWaitReadable, arg); + rb_mod_syserr_fail_str(rb_mWaitReadable, n, arg); } + break; + default: + rb_bug("invalid read/write type passed to rb_readwrite_sys_fail: %d", waiting); } - else { - rb_bug("invalid read/write type passed to rb_readwrite_sys_fail: %d", writable); - } + rb_exc_raise(rb_class_new_instance(1, &arg, c)); } static VALUE From 3152977b31b64dde776724188bdaa927b07d524d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 15 Apr 2020 01:29:13 +0900 Subject: [PATCH 014/234] Rescue EPIPE in _report Instead of letting callers rescue the error always. --- tool/lib/test/unit/parallel.rb | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/tool/lib/test/unit/parallel.rb b/tool/lib/test/unit/parallel.rb index 15f9ac575a2b3e..afb0d0167a706d 100644 --- a/tool/lib/test/unit/parallel.rb +++ b/tool/lib/test/unit/parallel.rb @@ -43,10 +43,9 @@ def _run_suite(suite, type) # :nodoc: th = Thread.new do begin while buf = (self.verbose ? i.gets : i.readpartial(1024)) - _report "p", buf + _report "p", buf or break end rescue IOError - rescue Errno::EPIPE end end @@ -77,9 +76,7 @@ def _run_suite(suite, type) # :nodoc: result << ($: - @old_loadpath) result << suite.name - begin - _report "done", Marshal.dump(result) - rescue Errno::EPIPE; end + _report "done", Marshal.dump(result) return result ensure MiniTest::Unit.output = orig_stdout @@ -128,32 +125,25 @@ def run(args = []) # :nodoc: _run_suites MiniTest::Unit::TestCase.test_suites-suites, $2.to_sym if @need_exit - begin - _report "bye" - rescue Errno::EPIPE; end + _report "bye" exit else _report "ready" end when /^quit$/ - begin - _report "bye" - rescue Errno::EPIPE; end + _report "bye" exit end end - rescue Errno::EPIPE rescue Exception => e - begin - trace = e.backtrace || ['unknown method'] - err = ["#{trace.shift}: #{e.message} (#{e.class})"] + trace.map{|t| "\t" + t } + trace = e.backtrace || ['unknown method'] + err = ["#{trace.shift}: #{e.message} (#{e.class})"] + trace.map{|t| "\t" + t } - if @stdout - _report "bye", Marshal.dump(err.join("\n")) - else - raise "failed to report a failure due to lack of @stdout" - end - rescue Errno::EPIPE;end + if @stdout + _report "bye", Marshal.dump(err.join("\n")) + else + raise "failed to report a failure due to lack of @stdout" + end exit ensure @stdin.close if @stdin @@ -163,6 +153,8 @@ def run(args = []) # :nodoc: def _report(res, *args) # :nodoc: @stdout.write(args.empty? ? "#{res}\n" : "#{res} #{args.pack("m0")}\n") + true + rescue Errno::EPIPE rescue TypeError => e abort("#{e.inspect} in _report(#{res.inspect}, #{args.inspect})\n#{e.backtrace.join("\n")}") end From 62554ca97812b454e78a0a9daf6e962ff7a2f589 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 17 Apr 2020 17:35:17 +0900 Subject: [PATCH 015/234] Removed NIL/TRUE/FALSE Deprerecated constants which had been warned since 2.4. --- object.c | 15 --------------- spec/ruby/language/predefined_spec.rb | 24 ------------------------ 2 files changed, 39 deletions(-) diff --git a/object.c b/object.c index dfe3d14e6e662a..55d28a1500107c 100644 --- a/object.c +++ b/object.c @@ -4692,11 +4692,6 @@ InitVM_Object(void) rb_define_method(rb_cNilClass, "nil?", rb_true, 0); rb_undef_alloc_func(rb_cNilClass); rb_undef_method(CLASS_OF(rb_cNilClass), "new"); - /* - * An obsolete alias of +nil+ - */ - rb_define_global_const("NIL", Qnil); - rb_deprecate_constant(rb_cObject, "NIL"); rb_define_method(rb_cModule, "freeze", rb_mod_freeze, 0); rb_define_method(rb_cModule, "===", rb_mod_eqq, 1); @@ -4781,11 +4776,6 @@ InitVM_Object(void) rb_define_method(rb_cTrueClass, "===", rb_equal, 1); rb_undef_alloc_func(rb_cTrueClass); rb_undef_method(CLASS_OF(rb_cTrueClass), "new"); - /* - * An obsolete alias of +true+ - */ - rb_define_global_const("TRUE", Qtrue); - rb_deprecate_constant(rb_cObject, "TRUE"); rb_cFalseClass = rb_define_class("FalseClass", rb_cObject); rb_cFalseClass_to_s = rb_fstring_enc_lit("false", rb_usascii_encoding()); @@ -4798,11 +4788,6 @@ InitVM_Object(void) rb_define_method(rb_cFalseClass, "===", rb_equal, 1); rb_undef_alloc_func(rb_cFalseClass); rb_undef_method(CLASS_OF(rb_cFalseClass), "new"); - /* - * An obsolete alias of +false+ - */ - rb_define_global_const("FALSE", Qfalse); - rb_deprecate_constant(rb_cObject, "FALSE"); } #include "kernel.rbinc" diff --git a/spec/ruby/language/predefined_spec.rb b/spec/ruby/language/predefined_spec.rb index 970071eccd73f4..b0616da19b7dc4 100644 --- a/spec/ruby/language/predefined_spec.rb +++ b/spec/ruby/language/predefined_spec.rb @@ -1091,8 +1091,6 @@ def obj.foo2; yield; end DATA IO If the main program file contains the directive __END__, then the constant DATA will be initialized so that reading from it will return lines following __END__ from the source file. -FALSE FalseClass Synonym for false. -NIL NilClass Synonym for nil. RUBY_PLATFORM String The identifier of the platform running this program. This string is in the same form as the platform identifier used by the GNU configure utility (which is not a coincidence). @@ -1110,31 +1108,9 @@ def obj.foo2; yield; end the value. TOPLEVEL_BINDING Binding A Binding object representing the binding at Ruby’s top level— the level where programs are initially executed. -TRUE TrueClass Synonym for true. =end describe "The predefined global constants" do - it "includes TRUE" do - Object.const_defined?(:TRUE).should == true - -> { - TRUE.should equal(true) - }.should complain(/constant ::TRUE is deprecated/) - end - - it "includes FALSE" do - Object.const_defined?(:FALSE).should == true - -> { - FALSE.should equal(false) - }.should complain(/constant ::FALSE is deprecated/) - end - - it "includes NIL" do - Object.const_defined?(:NIL).should == true - -> { - NIL.should equal(nil) - }.should complain(/constant ::NIL is deprecated/) - end - it "includes STDIN" do Object.const_defined?(:STDIN).should == true end From 5257a530905a3ccd931577efc76ce09226ff1d06 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Fri, 17 Apr 2020 17:39:42 +0900 Subject: [PATCH 016/234] Removed NIL/TRUE/FALSE from documents too This is follow up of 62554ca97812b454e78a0a9daf6e962ff7a2f589 --- doc/globals.rdoc | 3 --- doc/syntax/literals.rdoc | 3 --- 2 files changed, 6 deletions(-) diff --git a/doc/globals.rdoc b/doc/globals.rdoc index 89b94e9a8ff8bc..1d7cda69f952a6 100644 --- a/doc/globals.rdoc +++ b/doc/globals.rdoc @@ -50,9 +50,6 @@ $-p:: True if option -p is set. Read-only variable. == Pre-defined global constants -TRUE:: The typical true value. Deprecated. -FALSE:: The +false+ itself. Deprecated. -NIL:: The +nil+ itself. Deprecated. STDIN:: The standard input. The default value for $stdin. STDOUT:: The standard output. The default value for $stdout. STDERR:: The standard error output. The default value for $stderr. diff --git a/doc/syntax/literals.rdoc b/doc/syntax/literals.rdoc index 38bfa38676c055..e58430e96f3ea8 100644 --- a/doc/syntax/literals.rdoc +++ b/doc/syntax/literals.rdoc @@ -20,9 +20,6 @@ Literals create objects you can use in your program. Literals include: +true+ is a true value. All objects except +nil+ and +false+ evaluate to a true value in conditional expressions. -(There are also the constants +TRUE+, +FALSE+ and +NIL+, but the lowercase -literal forms are preferred.) - == Numbers You can write integers of any size as follows: From c817868705ee2b1ce5da6c1c2d6348d50662bc3a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 17 Apr 2020 17:49:50 +0900 Subject: [PATCH 017/234] NEWS.md: Mentioned the removal of NIL/TRUE/FALSE [ci skip] --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 2322e468b7b51e..06f6b9f10a3e56 100644 --- a/NEWS.md +++ b/NEWS.md @@ -152,6 +152,8 @@ Excluding feature bug fixes. * When writing to STDOUT redirected to a closed pipe, no broken pipe error message will be shown now. [[Feature #14413]] +* `TRUE`/`FALSE`/`NIL` constants are no longer defined. + ## Stdlib compatibility issues Excluding feature bug fixes. From 92c825885829bb8859c3091ce3fb38a62e13689c Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Fri, 17 Apr 2020 17:59:43 +0900 Subject: [PATCH 018/234] Fix a typo [ci skip] --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 06f6b9f10a3e56..136a21868e7f62 100644 --- a/NEWS.md +++ b/NEWS.md @@ -163,7 +163,7 @@ Excluding feature bug fixes. * C API functions related to $SAFE have been removed. [[Feature #16131]] -* C API header file `ruby/ruby.h` was split. [[GH-2991]] Should have no implact +* C API header file `ruby/ruby.h` was split. [[GH-2991]] Should have no impact on extension libraries, but users might experience slow compilations. ## Implementation improvements From f8b79ef567e4b91eb821886cd4dfa782caed05d3 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 17 Apr 2020 10:11:39 -0700 Subject: [PATCH 019/234] Compilation error does not impact exit status We failed to ignore https://ci.appveyor.com/project/ruby/ruby/builds/32245902/job/xcfxw67uexxysvni --- test/lib/jit_support.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/lib/jit_support.rb b/test/lib/jit_support.rb index b26a5febe43ba9..b5903461988528 100644 --- a/test/lib/jit_support.rb +++ b/test/lib/jit_support.rb @@ -65,8 +65,8 @@ def supported? # Until we figure out why, this allows us to skip testing JIT when it happens. def vs120_pdb_corrupted? return false unless ENV.key?('APPVEYOR') - _stdout, stderr, status = eval_with_jit_without_retry('proc {}.call', verbose: 2, min_calls: 1) - !status.success? && stderr.include?('x64-mswin64_120') && stderr.include?('.pdb is not the pdb file that was used when this precompiled header was created, recreate the precompiled header.') + _stdout, stderr, _status = eval_with_jit_without_retry('proc {}.call', verbose: 2, min_calls: 1) + stderr.include?('x64-mswin64_120') && stderr.include?('.pdb is not the pdb file that was used when this precompiled header was created, recreate the precompiled header.') end def remove_mjit_logs(stderr) From 7c0bc7240b0ba25ccfdb0115840c96bd90e3b610 Mon Sep 17 00:00:00 2001 From: git Date: Sat, 18 Apr 2020 02:12:18 +0900 Subject: [PATCH 020/234] * 2020-04-18 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index a9054a18ae22c4..edbb7f054332ad 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 17 +#define RUBY_RELEASE_DAY 18 #include "ruby/version.h" From 0511bef930f9a91aead9307e2db6257f18cb7e65 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 17 Apr 2020 10:17:19 -0700 Subject: [PATCH 021/234] Remove invalid webhook config According to warnings on Travis, there's no such key. We handle this on webhook side anyway. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1bd1ce88855b0b..48668c5d8f405f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -535,7 +535,6 @@ notifications: webhooks: urls: - secure: mRsoS/UbqDkKkW5p3AEqM27d4SZnV6Gsylo3bm8T/deltQzTsGzZwrm7OIBXZv0UFZdE68XmPlyHfZFLSP2V9QZ7apXMf9/vw0GtcSe1gchtnjpAPF6lYBn7nMCbVPPx9cS0dwL927fjdRM1vj7IKZ2bk4F0lAJ25R25S6teqdk= # ruby-lang slack: ruby/simpler-alerts-bot (travis) - on_pull_requests: false on_success: never on_failure: always From 75f6d7064413851422de1782a6fdefcce6876aec Mon Sep 17 00:00:00 2001 From: Kazuki Tsujimoto Date: Sat, 18 Apr 2020 12:34:33 +0900 Subject: [PATCH 022/234] power_assert repository is transferred to ruby/power_assert --- gems/bundled_gems | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gems/bundled_gems b/gems/bundled_gems index 21e0423bedbe35..f0faa93daa9ba2 100644 --- a/gems/bundled_gems +++ b/gems/bundled_gems @@ -1,5 +1,5 @@ minitest 5.14.0 https://github.com/seattlerb/minitest -power_assert 1.1.7 https://github.com/k-tsj/power_assert +power_assert 1.2.0 https://github.com/ruby/power_assert rake 13.0.1 https://github.com/ruby/rake test-unit 3.3.5 https://github.com/test-unit/test-unit rexml 3.2.4 https://github.com/ruby/rexml From 8d6aa06620b316904fd10d0cab1b85e07f2fbf67 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sat, 18 Apr 2020 14:59:22 +0900 Subject: [PATCH 023/234] test/ruby/test_jit_debug.rb: Skip unsupported platforms --- test/ruby/test_jit_debug.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/ruby/test_jit_debug.rb b/test/ruby/test_jit_debug.rb index 3efc72d6fd2079..362398c1d619ed 100644 --- a/test/ruby/test_jit_debug.rb +++ b/test/ruby/test_jit_debug.rb @@ -8,6 +8,9 @@ class TestJITDebug < TestJIT def setup + unless JITSupport.supported? + skip 'JIT seems not supported on this platform' + end # let `#eval_with_jit` use --jit-debug @jit_debug = true end From 9948addda67f4b7a6e3575f1eba9025f998811d2 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 18 Apr 2020 00:31:33 -0700 Subject: [PATCH 024/234] Skip a too-unstable test on s390x-linux In the last 26-ish hours, it has failed 5 times: https://travis-ci.org/github/ruby/ruby/jobs/676497718 https://travis-ci.org/github/ruby/ruby/jobs/676480295 https://travis-ci.org/github/ruby/ruby/jobs/676103216 https://travis-ci.org/github/ruby/ruby/jobs/676057967 https://travis-ci.org/github/ruby/ruby/jobs/676055113 and I don't think anybody has been working on it right now. To make CI result report of s390x-linux useful, let's skip it until the test is improved to be more stable. --- test/ruby/test_fiber.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb index 947e75aa2c990c..f5480241756490 100644 --- a/test/ruby/test_fiber.rb +++ b/test/ruby/test_fiber.rb @@ -360,6 +360,7 @@ def invoke_rec script, vm_stack_size, machine_stack_size, use_length = true end def test_stack_size + skip 'too unstable on Travis s390x-linux' if RUBY_PLATFORM == 's390x-linux' h_default = eval(invoke_rec('p RubyVM::DEFAULT_PARAMS', nil, nil, false)) h_0 = eval(invoke_rec('p RubyVM::DEFAULT_PARAMS', 0, 0, false)) h_large = eval(invoke_rec('p RubyVM::DEFAULT_PARAMS', 1024 * 1024 * 5, 1024 * 1024 * 10, false)) From dc8ab86a2b30189be0e4f31012c949318e397618 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 18 Apr 2020 00:48:32 -0700 Subject: [PATCH 025/234] Super TestJIT#setup to skip unsupported envs Slightly simplifying 8d6aa06620b316904fd10d0cab1b85e07f2fbf67 --- test/ruby/test_jit_debug.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/ruby/test_jit_debug.rb b/test/ruby/test_jit_debug.rb index 362398c1d619ed..179512fec68cd7 100644 --- a/test/ruby/test_jit_debug.rb +++ b/test/ruby/test_jit_debug.rb @@ -8,9 +8,7 @@ class TestJITDebug < TestJIT def setup - unless JITSupport.supported? - skip 'JIT seems not supported on this platform' - end + super # let `#eval_with_jit` use --jit-debug @jit_debug = true end From 0f7d3e4e405d17a1ea7db4862a1e6d65e1dfc86e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 18 Apr 2020 16:35:20 +0900 Subject: [PATCH 026/234] RUBY_SPECIAL_SHIFT and RUBY_FL_USHIFT are mandatory for rp in lldb_cruby.py --- debug.c | 1 + include/ruby/3/fl_type.h | 2 +- include/ruby/3/special_consts.h | 9 ++++----- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/debug.c b/debug.c index 9b5dc016abe704..d6c8069cae8ff3 100644 --- a/debug.c +++ b/debug.c @@ -44,6 +44,7 @@ const union { enum ruby_method_ids method_ids; enum ruby_id_types id_types; enum ruby_fl_type fl_types; + enum ruby_fl_ushift fl_ushift; enum ruby_encoding_consts encoding_consts; enum ruby_coderange_type enc_coderange_types; enum ruby_econv_flag_type econv_flag_types; diff --git a/include/ruby/3/fl_type.h b/include/ruby/3/fl_type.h index 2adb6006c7b098..6366e7037ce5d6 100644 --- a/include/ruby/3/fl_type.h +++ b/include/ruby/3/fl_type.h @@ -146,7 +146,7 @@ /** @} */ /* This is an enum because GDB wants it (rather than a macro) */ -enum { RUBY_FL_USHIFT = 12 }; +enum ruby_fl_ushift { RUBY_FL_USHIFT = 12 }; /* > The expression that defines the value of an enumeration constant shall be * > an integer constant expression that has a value representable as an `int`. diff --git a/include/ruby/3/special_consts.h b/include/ruby/3/special_consts.h index 683cebf1ed779a..3ef7b57a985cca 100644 --- a/include/ruby/3/special_consts.h +++ b/include/ruby/3/special_consts.h @@ -82,7 +82,7 @@ ruby_special_consts { RUBY_FIXNUM_FLAG = 0x01, /* ...xxxx xxx1 */ RUBY_FLONUM_MASK = 0x03, /* ...0000 0011 */ RUBY_FLONUM_FLAG = 0x02, /* ...xxxx xx10 */ - RUBY_SYMBOL_FLAG = 0x0c /* ...xxxx 1100 */ + RUBY_SYMBOL_FLAG = 0x0c, /* ...xxxx 1100 */ #else RUBY_Qfalse = 0x00, /* ...0000 0000 */ RUBY_Qtrue = 0x02, /* ...0000 0010 */ @@ -92,12 +92,11 @@ ruby_special_consts { RUBY_FIXNUM_FLAG = 0x01, /* ...xxxx xxx1 */ RUBY_FLONUM_MASK = 0x00, /* any values ANDed with FLONUM_MASK cannot be FLONUM_FLAG */ RUBY_FLONUM_FLAG = 0x02, /* ...0000 0010 */ - RUBY_SYMBOL_FLAG = 0x0e /* ...0000 1110 */ + RUBY_SYMBOL_FLAG = 0x0e, /* ...0000 1110 */ #endif -}; -/** Least significant 8 bits are reserved. */ -enum { RUBY_SPECIAL_SHIFT = 8 }; + RUBY_SPECIAL_SHIFT = 8 /** Least significant 8 bits are reserved. */ +}; RUBY3_ATTR_CONST() RUBY3_ATTR_CONSTEXPR(CXX11) From 04e56958e6a3c3278d0d3a087954ee8aca2fbd10 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 18 Apr 2020 01:38:52 -0700 Subject: [PATCH 027/234] Make sure newarraykwsplat accesses a correct index on stack when local_stack_p is enabled. This fixes `RB_FL_TEST_RAW:"RB_FL_ABLE(obj)"` assertion failure on power_assert's test with JIT enabled. --- test/ruby/test_jit.rb | 10 ++++++++++ tool/ruby_vm/views/_mjit_compile_insn_body.erb | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb index ebf4a222e2318b..9e4367b6d19320 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -719,6 +719,16 @@ def mjit#{i} end end + def test_newarraykwsplat_on_stack + assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: "[nil, [{:type=>:development}]]\n", success_count: 1, insns: %i[newarraykwsplat]) + begin; + def arr + [nil, [:type => :development]] + end + p arr + end; + end + def test_local_stack_on_exception assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '3', success_count: 2) begin; diff --git a/tool/ruby_vm/views/_mjit_compile_insn_body.erb b/tool/ruby_vm/views/_mjit_compile_insn_body.erb index a2a750fbdc3f39..bc77b02b71d1ae 100644 --- a/tool/ruby_vm/views/_mjit_compile_insn_body.erb +++ b/tool/ruby_vm/views/_mjit_compile_insn_body.erb @@ -101,7 +101,7 @@ % # #define STACK_ADDR_FROM_TOP(n) (GET_SP()-(n)) % num = Regexp.last_match[:num] fprintf(f, <%= to_cstr.call(line.sub(/\bSTACK_ADDR_FROM_TOP\(([^)]+)\)/, '%s')) %>, - (status->local_stack_p ? "stack + (stack_size - (<%= num %>))" : "STACK_ADDR_FROM_TOP(<%= num %>)")); + (status->local_stack_p ? "(stack + (stack_size - (<%= num %>)))" : "STACK_ADDR_FROM_TOP(<%= num %>)")); % when /\bTOPN\((?[^)]+)\)/ % # #define TOPN(n) (*(GET_SP()-(n)-1)) % num = Regexp.last_match[:num] From e042380e0e2d32c30e5c1ddb9ce0df81e15d44a0 Mon Sep 17 00:00:00 2001 From: Kazuki Tsujimoto Date: Sat, 18 Apr 2020 20:42:00 +0900 Subject: [PATCH 028/234] power_assert repository is transferred to ruby/power_assert --- doc/maintainers.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/maintainers.rdoc b/doc/maintainers.rdoc index 3cf248c51bb09c..4cef5b9b668822 100644 --- a/doc/maintainers.rdoc +++ b/doc/maintainers.rdoc @@ -350,7 +350,7 @@ Zachary Scott (zzak) [minitest] https://github.com/seattlerb/minitest [power_assert] - https://github.com/k-tsj/power_assert + https://github.com/ruby/power_assert [rake] https://github.com/ruby/rake [test-unit] From 08529a61153e5c40f57a65272211357511d6e6db Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 18 Apr 2020 20:39:07 +0900 Subject: [PATCH 029/234] Compare environment variable names in those manor [Bug #16798] --- hash.c | 22 +++++++++++++++++++--- test/ruby/test_env.rb | 2 ++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/hash.c b/hash.c index 769af0df7d2343..71bbfea4a0ef2a 100644 --- a/hash.c +++ b/hash.c @@ -6343,13 +6343,29 @@ env_invert(VALUE _) return rb_hash_invert(env_to_hash()); } +static void +keylist_delete(VALUE keys, VALUE key) +{ + long keylen, elen; + const char *keyptr, *eptr; + RSTRING_GETMEM(key, keyptr, keylen); + for (long i=0; i"bar", "baz"=>"qux"}) check(ENV.to_hash.to_a, [%w(foo bar), %w(baz qux)]) + ENV.replace({"Foo"=>"Bar", "Baz"=>"Qux"}) + check(ENV.to_hash.to_a, [%w(Foo Bar), %w(Baz Qux)]) end def test_update From afe997857ec69771078d04a7d4f9da784f478ad5 Mon Sep 17 00:00:00 2001 From: aycabta Date: Wed, 15 Apr 2020 02:10:27 +0900 Subject: [PATCH 030/234] [ruby/reline] Rename search_history with incremental_search_history https://github.com/ruby/reline/commit/d563063ea0 --- lib/reline/line_editor.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 095a7b5a095079..0a72de1500194b 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -1330,7 +1330,7 @@ def finish end end - private def search_history(key) + private def incremental_search_history(key) unless @history_pointer if @is_multiline @line_backup_in_history = whole_buffer @@ -1412,12 +1412,12 @@ def finish end private def ed_search_prev_history(key) - search_history(key) + incremental_search_history(key) end alias_method :reverse_search_history, :ed_search_prev_history private def ed_search_next_history(key) - search_history(key) + incremental_search_history(key) end alias_method :forward_search_history, :ed_search_next_history From 08c1c3f2203592c219c6068ea05fb5d583493a25 Mon Sep 17 00:00:00 2001 From: aycabta Date: Wed, 15 Apr 2020 02:23:24 +0900 Subject: [PATCH 031/234] [ruby/reline] Use vi_search_{prev,next} to incremental search https://github.com/ruby/reline/commit/cab312f584 --- lib/reline/key_actor/emacs.rb | 12 ++++++------ lib/reline/key_actor/vi_command.rb | 4 ++-- lib/reline/key_actor/vi_insert.rb | 4 ++-- lib/reline/line_editor.rb | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/reline/key_actor/emacs.rb b/lib/reline/key_actor/emacs.rb index 3886d17f226779..1e51d4fa189857 100644 --- a/lib/reline/key_actor/emacs.rb +++ b/lib/reline/key_actor/emacs.rb @@ -37,9 +37,9 @@ class Reline::KeyActor::Emacs < Reline::KeyActor::Base # 17 ^Q :ed_quoted_insert, # 18 ^R - :ed_search_prev_history, + :vi_search_prev, # 19 ^S - :ed_search_next_history, + :vi_search_next, # 20 ^T :ed_transpose_chars, # 21 ^U @@ -413,11 +413,11 @@ class Reline::KeyActor::Emacs < Reline::KeyActor::Base # 205 M-M :ed_unassigned, # 206 M-N - :ed_search_next_history, + :vi_search_next, # 207 M-O :ed_sequence_lead_in, # 208 M-P - :ed_search_prev_history, + :vi_search_prev, # 209 M-Q :ed_unassigned, # 210 M-R @@ -477,11 +477,11 @@ class Reline::KeyActor::Emacs < Reline::KeyActor::Base # 237 M-m :ed_unassigned, # 238 M-n - :ed_search_next_history, + :vi_search_next, # 239 M-o :ed_unassigned, # 240 M-p - :ed_search_prev_history, + :vi_search_prev, # 241 M-q :ed_unassigned, # 242 M-r diff --git a/lib/reline/key_actor/vi_command.rb b/lib/reline/key_actor/vi_command.rb index 865dfa2e00aedb..54b4a60383ffc2 100644 --- a/lib/reline/key_actor/vi_command.rb +++ b/lib/reline/key_actor/vi_command.rb @@ -37,7 +37,7 @@ class Reline::KeyActor::ViCommand < Reline::KeyActor::Base # 17 ^Q :ed_ignore, # 18 ^R - :ed_search_prev_history, + :vi_search_prev, # 19 ^S :ed_ignore, # 20 ^T @@ -151,7 +151,7 @@ class Reline::KeyActor::ViCommand < Reline::KeyActor::Base # 74 J :vi_join_lines, # 75 K - :ed_search_prev_history, + :vi_search_prev, # 76 L :ed_unassigned, # 77 M diff --git a/lib/reline/key_actor/vi_insert.rb b/lib/reline/key_actor/vi_insert.rb index 06e94a9c30c3b7..b8e89f81d8075d 100644 --- a/lib/reline/key_actor/vi_insert.rb +++ b/lib/reline/key_actor/vi_insert.rb @@ -37,9 +37,9 @@ class Reline::KeyActor::ViInsert < Reline::KeyActor::Base # 17 ^Q :ed_ignore, # 18 ^R - :ed_search_prev_history, + :vi_search_prev, # 19 ^S - :ed_search_next_history, + :vi_search_next, # 20 ^T :ed_insert, # 21 ^U diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 0a72de1500194b..7097a3d878c257 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -1411,15 +1411,15 @@ def finish } end - private def ed_search_prev_history(key) + private def vi_search_prev(key) incremental_search_history(key) end - alias_method :reverse_search_history, :ed_search_prev_history + alias_method :reverse_search_history, :vi_search_prev - private def ed_search_next_history(key) + private def vi_search_next(key) incremental_search_history(key) end - alias_method :forward_search_history, :ed_search_next_history + alias_method :forward_search_history, :vi_search_next private def ed_prev_history(key, arg: 1) if @is_multiline and @line_index > 0 From 1e4efbb6d3e1794222703c2df2b0bb69bc4956cc Mon Sep 17 00:00:00 2001 From: aycabta Date: Fri, 17 Apr 2020 04:31:26 +0900 Subject: [PATCH 032/234] [ruby/reline] Rename wrong test name https://github.com/ruby/reline/commit/8480db575b --- test/reline/test_key_actor_emacs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb index ed096f062da330..5ab3032f4eab0a 100644 --- a/test/reline/test_key_actor_emacs.rb +++ b/test/reline/test_key_actor_emacs.rb @@ -1625,7 +1625,7 @@ def test_em_kill_region_mbchar assert_line('') end - def test_ed_search_prev_history + def test_vi_search_prev Reline::HISTORY.concat(%w{abc 123 AAA}) assert_line('') assert_byte_pointer_size('') From bea3e31e5f8b85f0665b94312418f97e71c14fc6 Mon Sep 17 00:00:00 2001 From: aycabta Date: Fri, 17 Apr 2020 03:03:12 +0900 Subject: [PATCH 033/234] [ruby/reline] Add ed_search_prev_history https://github.com/ruby/reline/commit/e9ae288825 --- lib/reline/line_editor.rb | 47 ++++++++++++++++++++ test/reline/test_key_actor_emacs.rb | 69 +++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+) diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 7097a3d878c257..6f7afea2745bf0 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -1421,6 +1421,53 @@ def finish end alias_method :forward_search_history, :vi_search_next + private def ed_search_prev_history(key, arg: 1) + history = nil + h_pointer = nil + line_no = nil + substr = @line.slice(0, @byte_pointer) + if @history_pointer.nil? + return if not @line.empty? and substr.empty? + history = Reline::HISTORY + elsif @history_pointer.zero? + history = nil + h_pointer = nil + else + history = Reline::HISTORY.slice(0, @history_pointer) + end + return if history.nil? + if @is_multiline + h_pointer = history.rindex { |h| + h.split("\n").each_with_index { |l, i| + if l.start_with?(substr) + line_no = i + break + end + } + not line_no.nil? + } + else + h_pointer = history.rindex { |l| + l.start_with?(substr) + } + end + return if h_pointer.nil? + @history_pointer = h_pointer + if @is_multiline + @buffer_of_lines = Reline::HISTORY[@history_pointer].split("\n") + @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty? + @line_index = line_no + @line = @buffer_of_lines.last + @rerender_all = true + else + @line = Reline::HISTORY[@history_pointer] + end + @cursor_max = calculate_width(@line) + arg -= 1 + ed_search_prev_history(key, arg: arg) if arg > 0 + end + alias_method :history_search_backward, :ed_search_prev_history + private def ed_prev_history(key, arg: 1) if @is_multiline and @line_index > 0 @previous_line_index = @line_index diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb index 5ab3032f4eab0a..a5de605314e176 100644 --- a/test/reline/test_key_actor_emacs.rb +++ b/test/reline/test_key_actor_emacs.rb @@ -1912,6 +1912,75 @@ def test_modify_lines_with_wrong_rs $VERBOSE = verbose end + def test_ed_search_prev_history + Reline::HISTORY.concat([ + '12356', # old + '12aaa', + '12345' # new + ]) + input_keys('123') + # The ed_search_prev_history doesn't have default binding + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('123') + assert_cursor(3) + assert_cursor_max(5) + assert_line('12345') + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('123') + assert_cursor(3) + assert_cursor_max(5) + assert_line('12356') + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('123') + assert_cursor(3) + assert_cursor_max(5) + assert_line('12356') + end + + def test_ed_search_prev_history_with_empty + Reline::HISTORY.concat([ + '12356', # old + '12aaa', + '12345' # new + ]) + # The ed_search_prev_history doesn't have default binding + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(5) + assert_line('12345') + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(5) + assert_line('12aaa') + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(5) + assert_line('12356') + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(5) + assert_line('12356') + end + + def test_ed_search_prev_history_without_match + Reline::HISTORY.concat([ + '12356', # old + '12aaa', + '12345' # new + ]) + input_keys('ABC') + # The ed_search_prev_history doesn't have default binding + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('ABC') + assert_cursor(3) + assert_cursor_max(3) + assert_line('ABC') + end + =begin # TODO: move KeyStroke instance from Reline to LineEditor def test_key_delete input_keys('ab') From db0d850d4eac5577104e6d0f22950d97f53c5a13 Mon Sep 17 00:00:00 2001 From: aycabta Date: Fri, 17 Apr 2020 04:38:47 +0900 Subject: [PATCH 034/234] [ruby/reline] Add ed_search_next_history https://github.com/ruby/reline/commit/ca750b676b --- lib/reline/line_editor.rb | 52 ++++++++++++++++++++ test/reline/test_key_actor_emacs.rb | 74 +++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 6f7afea2745bf0..ab4b0915f30223 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -1468,6 +1468,58 @@ def finish end alias_method :history_search_backward, :ed_search_prev_history + private def ed_search_next_history(key, arg: 1) + substr = @line.slice(0, @byte_pointer) + if @history_pointer.nil? + return + elsif @history_pointer == (Reline::HISTORY.size - 1) and not substr.empty? + return + end + history = Reline::HISTORY.slice((@history_pointer + 1)..-1) + h_pointer = nil + line_no = nil + if @is_multiline + h_pointer = history.index { |h| + h.split("\n").each_with_index { |l, i| + if l.start_with?(substr) + line_no = i + break + end + } + not line_no.nil? + } + else + h_pointer = history.index { |l| + l.start_with?(substr) + } + end + h_pointer += @history_pointer + 1 if h_pointer and @history_pointer + return if h_pointer.nil? and not substr.empty? + @history_pointer = h_pointer + if @is_multiline + if @history_pointer.nil? and substr.empty? + @buffer_of_lines = [] + @line_index = 0 + else + @buffer_of_lines = Reline::HISTORY[@history_pointer].split("\n") + @line_index = line_no + end + @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty? + @line = @buffer_of_lines.last + @rerender_all = true + else + if @history_pointer.nil? and substr.empty? + @line = '' + else + @line = Reline::HISTORY[@history_pointer] + end + end + @cursor_max = calculate_width(@line) + arg -= 1 + ed_search_next_history(key, arg: arg) if arg > 0 + end + alias_method :history_search_forward, :ed_search_next_history + private def ed_prev_history(key, arg: 1) if @is_multiline and @line_index > 0 @previous_line_index = @line_index diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb index a5de605314e176..a1e40159994cbe 100644 --- a/test/reline/test_key_actor_emacs.rb +++ b/test/reline/test_key_actor_emacs.rb @@ -1981,6 +1981,80 @@ def test_ed_search_prev_history_without_match assert_line('ABC') end + def test_ed_search_next_history + Reline::HISTORY.concat([ + '12356', # old + '12aaa', + '12345' # new + ]) + input_keys('123') + # The ed_search_prev_history and ed_search_next_history doesn't have default binding + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('123') + assert_cursor(3) + assert_cursor_max(5) + assert_line('12345') + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('123') + assert_cursor(3) + assert_cursor_max(5) + assert_line('12356') + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('123') + assert_cursor(3) + assert_cursor_max(5) + assert_line('12356') + @line_editor.__send__(:ed_search_next_history, "\C-n".ord) + assert_byte_pointer_size('123') + assert_cursor(3) + assert_cursor_max(5) + assert_line('12345') + @line_editor.__send__(:ed_search_next_history, "\C-n".ord) + assert_byte_pointer_size('123') + assert_cursor(3) + assert_cursor_max(5) + assert_line('12345') + end + + def test_ed_search_next_history_with_empty + Reline::HISTORY.concat([ + '12356', # old + '12aaa', + '12345' # new + ]) + # The ed_search_prev_history and ed_search_next_history doesn't have default binding + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(5) + assert_line('12345') + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(5) + assert_line('12aaa') + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(5) + assert_line('12356') + @line_editor.__send__(:ed_search_next_history, "\C-n".ord) + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(5) + assert_line('12aaa') + @line_editor.__send__(:ed_search_next_history, "\C-n".ord) + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(5) + assert_line('12345') + @line_editor.__send__(:ed_search_next_history, "\C-n".ord) + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(0) + assert_line('') + end + =begin # TODO: move KeyStroke instance from Reline to LineEditor def test_key_delete input_keys('ab') From 67e4d5e62340223c95e35afaee855f8c821a499d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 18 Apr 2020 20:45:39 +0900 Subject: [PATCH 035/234] Environment variable values are not case-insensitive Only the names are case-sensitive. --- test/ruby/test_env.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb index 02cd3b85026bb2..6d5fc889151307 100644 --- a/test/ruby/test_env.rb +++ b/test/ruby/test_env.rb @@ -406,8 +406,8 @@ def test_reject def check(as, bs) if IGNORE_CASE - as = as.map {|xs| xs.map {|x| x.upcase } } - bs = bs.map {|xs| xs.map {|x| x.upcase } } + as = as.map {|k, v| [k.upcase, v] } + bs = bs.map {|k, v| [k.upcase, v] } end assert_equal(as.sort, bs.sort) end From ec4e57cae0cc9fede7f7809f8e443cd811ebddb4 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 18 Apr 2020 20:58:35 +0900 Subject: [PATCH 036/234] Hoisted out reset_by_modified_env --- hash.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/hash.c b/hash.c index 71bbfea4a0ef2a..86261019e61b9d 100644 --- a/hash.c +++ b/hash.c @@ -4881,14 +4881,9 @@ env_name(volatile VALUE *s) static VALUE env_aset(VALUE nm, VALUE val); -static VALUE -env_delete(VALUE name) +static void +reset_by_modified_env(const char *nam) { - const char *nam, *val; - - nam = env_name(name); - val = getenv(nam); - /* * ENV['TZ'] = nil has a special meaning. * TZ is no longer considered up-to-date and ruby call tzset() as needed. @@ -4898,6 +4893,15 @@ env_delete(VALUE name) if (ENVMATCH(nam, TZ_ENV)) { ruby_reset_timezone(); } +} + +static VALUE +env_delete(VALUE name) +{ + const char *nam = env_name(name); + const char *val = getenv(nam); + + reset_by_modified_env(nam); if (val) { VALUE value = env_str_new2(val); @@ -5327,9 +5331,7 @@ env_aset(VALUE nm, VALUE val) if (ENVMATCH(name, PATH_ENV)) { RB_GC_GUARD(nm); } - else if (ENVMATCH(name, TZ_ENV)) { - ruby_reset_timezone(); - } + reset_by_modified_env(name); return val; } From 97e8c72e56d3e0e8ce64d530fb133cdc26e326c8 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 18 Apr 2020 21:30:11 +0900 Subject: [PATCH 037/234] Bypass env key encoding conversion if unnecessary --- hash.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/hash.c b/hash.c index 86261019e61b9d..36b595bfdd18ee 100644 --- a/hash.c +++ b/hash.c @@ -5336,17 +5336,21 @@ env_aset(VALUE nm, VALUE val) } static VALUE -env_keys(void) +env_keys(int raw) { char **env; VALUE ary; + rb_encoding *enc = raw ? 0 : rb_locale_encoding(); ary = rb_ary_new(); env = GET_ENVIRON(environ); while (*env) { char *s = strchr(*env, '='); if (s) { - rb_ary_push(ary, env_str_new(*env, s-*env)); + const char *p = *env; + size_t l = s - p; + VALUE e = raw ? rb_utf8_str_new(p, l) : env_enc_str_new(p, l, enc); + rb_ary_push(ary, e); } env++; } @@ -5372,7 +5376,7 @@ env_keys(void) static VALUE env_f_keys(VALUE _) { - return env_keys(); + return env_keys(FALSE); } static VALUE @@ -5415,7 +5419,7 @@ env_each_key(VALUE ehash) long i; RETURN_SIZED_ENUMERATOR(ehash, 0, 0, rb_env_size); - keys = env_keys(); + keys = env_keys(FALSE); for (i=0; i Date: Sat, 18 Apr 2020 21:30:53 +0900 Subject: [PATCH 038/234] Env values removed by ENV.clear are not used --- hash.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hash.c b/hash.c index 36b595bfdd18ee..e0f827b80f5e81 100644 --- a/hash.c +++ b/hash.c @@ -5826,10 +5826,9 @@ rb_env_clear(void) keys = env_keys(TRUE); for (i=0; i Date: Sun, 19 Apr 2020 00:35:20 +0900 Subject: [PATCH 039/234] * 2020-04-19 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index edbb7f054332ad..d867017c2a9240 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 18 +#define RUBY_RELEASE_DAY 19 #include "ruby/version.h" From c0b93267497d47858ea9539ef863be321bc1ddbf Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Sat, 18 Apr 2020 19:35:19 -0500 Subject: [PATCH 040/234] Update workflows/mingw.yml - use setup-ruby-pkgs (#3042) MSP-Greg/actions-ruby is deprecated... --- .github/workflows/mingw.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/mingw.yml b/.github/workflows/mingw.yml index b6704299e55b4c..8ee58fa491a49f 100644 --- a/.github/workflows/mingw.yml +++ b/.github/workflows/mingw.yml @@ -2,10 +2,7 @@ name: MinGW on: [push, pull_request] # Notes: -# Action ENV TEMP and TMP are short 8.3 paths, but the long path differs. -# Code uses TMPDIR, which is Ruby's 'first' check -# -# Console encoding causes issues, see test-all & test-spec steps +# Actions console encoding causes issues, see test-all & test-spec steps # jobs: make: @@ -46,11 +43,10 @@ jobs: shell: bash id: commit_info - name: Set up Ruby & MSYS2 - uses: MSP-Greg/actions-ruby@master + uses: MSP-Greg/setup-ruby-pkgs@v1 with: - ruby-version: 2.6.x - base: update - mingw: gdbm gmp libffi libyaml openssl ragel readline + ruby-version: 2.6 + mingw: _upgrade_ gdbm gmp libffi libyaml openssl ragel readline msys2: automake1.16 bison - name: where check run: | @@ -110,14 +106,12 @@ jobs: timeout-minutes: 5 working-directory: build run: | - $env:TMPDIR = "$pwd/../temp" make test - name: test-all timeout-minutes: 50 working-directory: build run: | - $env:TMPDIR = "$pwd/../temp" # Actions uses UTF8, causes test failures, similar to normal OS setup $PSDefaultParameterValues['*:Encoding'] = 'utf8' [Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding("IBM437") @@ -129,8 +123,7 @@ jobs: timeout-minutes: 10 working-directory: src/spec/ruby run: | - $env:TMPDIR = "$pwd/../../../temp" - $env:PATH = "$pwd/../../../install/bin;$env:PATH" + $env:Path = "$pwd/../../../install/bin;$env:Path" # Actions uses UTF8, causes test failures, similar to normal OS setup $PSDefaultParameterValues['*:Encoding'] = 'utf8' [Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding("IBM437") From 2832ba80d6cb9ff77f1e18b6afccf3bb9d884dd0 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 18 Apr 2020 18:39:32 -0700 Subject: [PATCH 041/234] The pdb header error is printed at stdout https://ci.appveyor.com/project/ruby/ruby/builds/32278754/job/90jmky2jq2k0wjv8 --- test/lib/jit_support.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/lib/jit_support.rb b/test/lib/jit_support.rb index b5903461988528..8f1c024ee7bc09 100644 --- a/test/lib/jit_support.rb +++ b/test/lib/jit_support.rb @@ -65,8 +65,8 @@ def supported? # Until we figure out why, this allows us to skip testing JIT when it happens. def vs120_pdb_corrupted? return false unless ENV.key?('APPVEYOR') - _stdout, stderr, _status = eval_with_jit_without_retry('proc {}.call', verbose: 2, min_calls: 1) - stderr.include?('x64-mswin64_120') && stderr.include?('.pdb is not the pdb file that was used when this precompiled header was created, recreate the precompiled header.') + stdout, _stderr, _status = eval_with_jit_without_retry('proc {}.call', verbose: 2, min_calls: 1) + stdout.include?('x64-mswin64_120') && stdout.include?('.pdb is not the pdb file that was used when this precompiled header was created, recreate the precompiled header.') end def remove_mjit_logs(stderr) From 5a8960b4fe214c10e14911f3f9c27a267b54c27d Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 19 Apr 2020 23:14:31 +0900 Subject: [PATCH 042/234] Skip TestRequire#test_loading_fifo_fd_leak on Android The test fails due to unknown reason. Need to debug in future, but tentatively skipped. --- test/ruby/test_require.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index fa2f2ec5d0a124..30c07b9e5c2139 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -770,6 +770,8 @@ def test_loading_fifo_threading_success end if File.respond_to?(:mkfifo) def test_loading_fifo_fd_leak + skip if RUBY_PLATFORM =~ /android/ # https://rubyci.org/logs/rubyci.s3.amazonaws.com/android29-x86_64/ruby-master/log/20200419T124100Z.fail.html.gz + Tempfile.create(%w'fifo .rb') {|f| f.close File.unlink(f.path) From 2af4c1fc5b19fc96203c2d7e917e689510d3527e Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 19 Apr 2020 23:15:43 +0900 Subject: [PATCH 043/234] Skip Process#clock_getres specs on Android ... just like AIX and OpenBSD. --- spec/ruby/core/process/clock_getres_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/ruby/core/process/clock_getres_spec.rb b/spec/ruby/core/process/clock_getres_spec.rb index 90f775e764e1da..02e36b2d9c57cc 100644 --- a/spec/ruby/core/process/clock_getres_spec.rb +++ b/spec/ruby/core/process/clock_getres_spec.rb @@ -19,13 +19,13 @@ # These are observed - platform_is_not :solaris, :aix, :openbsd do + platform_is_not :solaris, :aix, :openbsd, :android do it "with Process::CLOCK_REALTIME reports at least 1 microsecond" do Process.clock_getres(Process::CLOCK_REALTIME, :nanosecond).should <= 1_000 end end - platform_is_not :aix, :openbsd do + platform_is_not :aix, :openbsd, :android do it "with Process::CLOCK_MONOTONIC reports at least 1 microsecond" do Process.clock_getres(Process::CLOCK_MONOTONIC, :nanosecond).should <= 1_000 end From 73bd2b70e2570279e72404a1aa8bc451ad0f90b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Quang=20Minh?= Date: Sun, 19 Apr 2020 21:38:25 +0700 Subject: [PATCH 044/234] Update VMDEBUG reference doc [ci skip] Since this commit (https://github.com/ruby/ruby/commit/9e1b06e17d27fb4ddf51e9244f205417e9c4dd5c), the VM Debug Level constant is moved from `vm_insnhelper.h` to `vm_core.h`. This PR is a super tiny update to reflect that change so that people won't waste time on searching in a wrong file. --- vm_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm_dump.c b/vm_dump.c index f9edd05b99b251..19070d13ab20b3 100644 --- a/vm_dump.c +++ b/vm_dump.c @@ -37,7 +37,7 @@ #include "vm_core.h" -/* see vm_insnhelper.h for the values */ +/* see vm_core.h for the values */ #ifndef VMDEBUG #define VMDEBUG 0 #endif From e92f3e12169e94ba8b230322de938ce540899345 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 19 Apr 2020 23:40:44 +0900 Subject: [PATCH 045/234] Removed useless VMDEBUG definition [ci skip] VMDEBUG is always defined as defaulted to 0 in vm_core.h. --- vm_dump.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/vm_dump.c b/vm_dump.c index 19070d13ab20b3..ad965ca9c95e54 100644 --- a/vm_dump.c +++ b/vm_dump.c @@ -36,12 +36,6 @@ #include "iseq.h" #include "vm_core.h" - -/* see vm_core.h for the values */ -#ifndef VMDEBUG -#define VMDEBUG 0 -#endif - #define MAX_POSBUF 128 #define VM_CFP_CNT(ec, cfp) \ From 20773a109029ba4464d7749d38a311f880a73293 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 20 Apr 2020 10:44:52 +0900 Subject: [PATCH 046/234] Bail out if no atomic operation found As atomic operations are mandatory now, not-working phony fallback definitions are not only useless but confusing and harmful. --- ruby_atomic.h | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/ruby_atomic.h b/ruby_atomic.h index d4d56da4249270..d2338677ea97ab 100644 --- a/ruby_atomic.h +++ b/ruby_atomic.h @@ -121,30 +121,7 @@ typedef unsigned int rb_atomic_t; # endif #else -typedef int rb_atomic_t; -#define NEED_RUBY_ATOMIC_OPS -extern rb_atomic_t ruby_atomic_exchange(rb_atomic_t *ptr, rb_atomic_t val); -extern rb_atomic_t ruby_atomic_compare_and_swap(rb_atomic_t *ptr, - rb_atomic_t cmp, - rb_atomic_t newval); - -# define ATOMIC_SET(var, val) (void)((var) = (val)) -# define ATOMIC_INC(var) ((var)++) -# define ATOMIC_DEC(var) ((var)--) -# define ATOMIC_OR(var, val) ((var) |= (val)) -# define ATOMIC_EXCHANGE(var, val) ruby_atomic_exchange(&(var), (val)) -# define ATOMIC_CAS(var, oldval, newval) ruby_atomic_compare_and_swap(&(var), (oldval), (newval)) - -# define ATOMIC_SIZE_ADD(var, val) (void)((var) += (val)) -# define ATOMIC_SIZE_SUB(var, val) (void)((var) -= (val)) -# define ATOMIC_SIZE_EXCHANGE(var, val) ruby_atomic_size_exchange(&(var), (val)) -static inline size_t -ruby_atomic_size_exchange(size_t *ptr, size_t val) -{ - size_t old = *ptr; - *ptr = val; - return old; -} +# error No atomic operation found #endif #ifndef ATOMIC_SIZE_INC From b4c9b570f1a16ac33a67eabc1ca70db36d33178c Mon Sep 17 00:00:00 2001 From: git Date: Mon, 20 Apr 2020 12:37:51 +0900 Subject: [PATCH 047/234] * 2020-04-20 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index d867017c2a9240..76ad5a65d0e647 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 19 +#define RUBY_RELEASE_DAY 20 #include "ruby/version.h" From e571bb8436502b1bce54a1e41c40ef682e05c555 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 20 Apr 2020 21:13:08 +0900 Subject: [PATCH 048/234] Removed phony atomic operations for void* and VALUE --- ruby_atomic.h | 36 ++++-------------------------------- tool/sync_default_gems.rb | 10 +++++++--- 2 files changed, 11 insertions(+), 35 deletions(-) diff --git a/ruby_atomic.h b/ruby_atomic.h index d2338677ea97ab..0742791d6476c8 100644 --- a/ruby_atomic.h +++ b/ruby_atomic.h @@ -162,14 +162,7 @@ typedef unsigned int rb_atomic_t; # if SIZEOF_VOIDP == SIZEOF_SIZE_T # define ATOMIC_PTR_EXCHANGE(var, val) (void *)ATOMIC_SIZE_EXCHANGE(*(size_t *)&(var), (size_t)(val)) # else -# define ATOMIC_PTR_EXCHANGE(var, val) ruby_atomic_ptr_exchange((const void **)&(var), (val)) -static inline void * -ruby_atomic_ptr_exchange(const void **ptr, const void *val) -{ - const void *const old = *ptr; - *ptr = val; - return (void *)old; -} +# error No atomic exchange for void* # endif #endif @@ -177,14 +170,7 @@ ruby_atomic_ptr_exchange(const void **ptr, const void *val) # if SIZEOF_VOIDP == SIZEOF_SIZE_T # define ATOMIC_PTR_CAS(var, oldval, val) (void *)ATOMIC_SIZE_CAS(*(size_t *)&(var), (size_t)(oldval), (size_t)(val)) # else -# define ATOMIC_PTR_CAS(var, oldval, val) ruby_atomic_ptr_cas(&(var), (oldval), (val)) -static inline void * -ruby_atomic_ptr_cas(const void **ptr, const void *oldval, const void *val) -{ - const void *const old = *ptr; - if (old == oldval) *ptr = val; - return (void *)old; -} +# error No atomic compare-and-set for void* # endif #endif @@ -192,14 +178,7 @@ ruby_atomic_ptr_cas(const void **ptr, const void *oldval, const void *val) # if SIZEOF_VALUE == SIZEOF_SIZE_T # define ATOMIC_VALUE_EXCHANGE(var, val) ATOMIC_SIZE_EXCHANGE(*(size_t *)&(var), (size_t)(val)) # else -# define ATOMIC_VALUE_EXCHANGE(var, val) ruby_atomic_value_exchange(&(var), (val)) -static inline VALUE -ruby_atomic_value_exchange(VALUE *ptr, VALUE val) -{ - const VALUE old = *ptr; - *ptr = val; - return old; -} +# error No atomic exchange for VALUE # endif #endif @@ -207,14 +186,7 @@ ruby_atomic_value_exchange(VALUE *ptr, VALUE val) # if SIZEOF_VALUE == SIZEOF_SIZE_T # define ATOMIC_VALUE_CAS(var, oldval, val) ATOMIC_SIZE_CAS(*(size_t *)&(var), (size_t)(oldval), (size_t)(val)) # else -# define ATOMIC_VALUE_CAS(var, oldval, val) ruby_atomic_value_cas(&(var), (oldval), (val)) -static inline VALUE -ruby_atomic_value_cas(VALUE *ptr, VALUE oldval, VALUE val) -{ - const VALUE old = *ptr; - if (old == oldval) *ptr = val; - return old; -} +# error No atomic compare-and-set for VALUE # endif #endif diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index d034e723a45363..ddbce8da7b55db 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -374,11 +374,15 @@ def sync_default_gems_with_commits(gem, range) if result.empty? skipped = true - elsif result.start_with?("CONFLICT") + elsif /^CONFLICT/ =~ result result = IO.popen(%W"git status --porcelain", &:readlines).each(&:chomp!) - ignore = result.map {|line| /^DU / =~ line and IGNORE_FILE_PATTERN =~ (name = $') and name} + ignore = result.map {|line| /^.U / =~ line and IGNORE_FILE_PATTERN =~ (name = $') and name} ignore.compact! - system(*%W"git reset", *ignore) unless ignore.empty? + warn "Resetting #{ignore}" + unless ignore.empty? + system(*%W"git reset HEAD --", *ignore) + system(*%W"git checkout HEAD --", *ignore) + end skipped = !system({"GIT_EDITOR"=>"true"}, *%W"git cherry-pick --no-edit --continue") end From aeb9d11594750eec085af60d6bee1ed86dd14686 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 20 Apr 2020 21:21:42 +0900 Subject: [PATCH 049/234] Revert irrelevant change [ci skip] --- tool/sync_default_gems.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index ddbce8da7b55db..d034e723a45363 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -374,15 +374,11 @@ def sync_default_gems_with_commits(gem, range) if result.empty? skipped = true - elsif /^CONFLICT/ =~ result + elsif result.start_with?("CONFLICT") result = IO.popen(%W"git status --porcelain", &:readlines).each(&:chomp!) - ignore = result.map {|line| /^.U / =~ line and IGNORE_FILE_PATTERN =~ (name = $') and name} + ignore = result.map {|line| /^DU / =~ line and IGNORE_FILE_PATTERN =~ (name = $') and name} ignore.compact! - warn "Resetting #{ignore}" - unless ignore.empty? - system(*%W"git reset HEAD --", *ignore) - system(*%W"git checkout HEAD --", *ignore) - end + system(*%W"git reset", *ignore) unless ignore.empty? skipped = !system({"GIT_EDITOR"=>"true"}, *%W"git cherry-pick --no-edit --continue") end From 3cd3a507e336a81c7e00313b9effb80a8e596a6e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 20 Apr 2020 21:23:26 +0900 Subject: [PATCH 050/234] [sync_default_gems.rb] Force reset conflict files to be ignored [ci skip] --- tool/sync_default_gems.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index d034e723a45363..4451a4ed483318 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -374,11 +374,14 @@ def sync_default_gems_with_commits(gem, range) if result.empty? skipped = true - elsif result.start_with?("CONFLICT") + elsif /^CONFLICT/ =~ result result = IO.popen(%W"git status --porcelain", &:readlines).each(&:chomp!) - ignore = result.map {|line| /^DU / =~ line and IGNORE_FILE_PATTERN =~ (name = $') and name} + ignore = result.map {|line| /^.U / =~ line and IGNORE_FILE_PATTERN =~ (name = $') and name} ignore.compact! - system(*%W"git reset", *ignore) unless ignore.empty? + unless ignore.empty? + system(*%W"git reset HEAD --", *ignore) + system(*%W"git checkout HEAD --", *ignore) + end skipped = !system({"GIT_EDITOR"=>"true"}, *%W"git cherry-pick --no-edit --continue") end From 847e25975ce8f5bda46a01afd67e4fdb7f1fef41 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 20 Apr 2020 22:46:53 +0900 Subject: [PATCH 051/234] Skip JIT tests on riscv64 due to SEGV of cc1 --- test/lib/jit_support.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/lib/jit_support.rb b/test/lib/jit_support.rb index 8f1c024ee7bc09..5977e84c1da0d4 100644 --- a/test/lib/jit_support.rb +++ b/test/lib/jit_support.rb @@ -9,9 +9,11 @@ module JITSupport %r[\A.*/bin/intel64/icc\b], %r[\A/opt/developerstudio\d+\.\d+/bin/cc\z], ] + # debian-riscv64: "gcc: internal compiler error: Segmentation fault signal terminated program cc1" https://rubyci.org/logs/rubyci.s3.amazonaws.com/debian-riscv64/ruby-master/log/20200420T083601Z.fail.html.gz # freebsd12: cc1 internal failure https://rubyci.org/logs/rubyci.s3.amazonaws.com/freebsd12/ruby-master/log/20200306T103003Z.fail.html.gz # rhel8: one or more PCH files were found, but they were invalid https://rubyci.org/logs/rubyci.s3.amazonaws.com/rhel8/ruby-master/log/20200306T153003Z.fail.html.gz PENDING_RUBYCI_NICKNAMES = %w[ + debian-riscv64 freebsd12 rhel8 ] From 6985bfb72c8d7e7d94f1aad1f0902b602bbfa6da Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 20 Apr 2020 23:59:05 +0900 Subject: [PATCH 052/234] vm_dump.c: Do not show C backtrace on riscv Currently, objdump -W miniruby emits some errors on riscv, so I guess that DWARF is corrupted. --- vm_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm_dump.c b/vm_dump.c index ad965ca9c95e54..01f54490fa82bc 100644 --- a/vm_dump.c +++ b/vm_dump.c @@ -755,7 +755,7 @@ rb_print_backtrace(void) #define MAX_NATIVE_TRACE 1024 static void *trace[MAX_NATIVE_TRACE]; int n = (int)backtrace(trace, MAX_NATIVE_TRACE); -#if (defined(USE_ELF) || defined(HAVE_MACH_O_LOADER_H)) && defined(HAVE_DLADDR) && !defined(__sparc) +#if (defined(USE_ELF) || defined(HAVE_MACH_O_LOADER_H)) && defined(HAVE_DLADDR) && !defined(__sparc) && !defined(__riscv) rb_dump_backtrace_with_lines(n, trace); #else char **syms = backtrace_symbols(trace, n); From 7a0ac279b75756ac61ae15cf839200b49ddbd586 Mon Sep 17 00:00:00 2001 From: git Date: Tue, 21 Apr 2020 00:00:23 +0900 Subject: [PATCH 053/234] * 2020-04-21 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 76ad5a65d0e647..6c71449bb09a1e 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 20 +#define RUBY_RELEASE_DAY 21 #include "ruby/version.h" From 8e517942656f095af2b3417f0df85ae0b216002a Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Tue, 21 Apr 2020 00:06:07 +0900 Subject: [PATCH 054/234] test/ruby/test_refinement.rb: extend the timeout https://rubyci.org/logs/rubyci.s3.amazonaws.com/debian-riscv64/ruby-master/log/20200420T083601Z.fail.html.gz --- test/ruby/test_refinement.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 1f2a67eeb22c1d..51231bd56cf856 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -920,7 +920,7 @@ def test_prepend_after_refine_wb_miss #{PrependAfterRefine_CODE} undef PrependAfterRefine } - }, timeout: 30 + }, timeout: 60 end def test_prepend_after_refine From b9962f0e8909b1163320fbcfe80060a259b2353d Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 20 Apr 2020 21:20:54 +0900 Subject: [PATCH 055/234] Fixed incorrect man path with ruby installation path [Bug #15359][ruby-core:90164] --- lib/bundler/cli.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 443458f2d99c86..22fca7fdf424bd 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -123,6 +123,8 @@ def help(cli = nil) end man_path = File.expand_path("../../../man", __FILE__) + # man files are located under the share directory with the default gems of bundler + man_path = File.expand_path("../../../../../share/man/man1", __FILE__) unless File.directory?(man_path) man_pages = Hash[Dir.glob(File.join(man_path, "*")).grep(/.*\.\d*\Z/).collect do |f| [File.basename(f, ".*"), f] end] From 4b86194177c65babb28236d2a14994d3f5d3f1bf Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Tue, 21 Apr 2020 12:38:36 +0900 Subject: [PATCH 056/234] Fix typos [ci skip] --- include/ruby/3/arithmetic/long.h | 2 +- include/ruby/3/assume.h | 2 +- include/ruby/3/scan_args.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/ruby/3/arithmetic/long.h b/include/ruby/3/arithmetic/long.h index 46ff76d63e5cda..3263c616b07fce 100644 --- a/include/ruby/3/arithmetic/long.h +++ b/include/ruby/3/arithmetic/long.h @@ -136,7 +136,7 @@ ruby3_fix2long_by_shift(VALUE x) RUBY3_ASSERT_OR_ASSUME(RB_FIXNUM_P(x)); /* :NOTE: VALUE can be wider than long. If right shift is arithmetic, this - * is noticably faster than above. */ + * is noticeably faster than above. */ const SIGNED_VALUE y = x; const SIGNED_VALUE z = y >> 1; const long w = RUBY3_CAST((long)z); diff --git a/include/ruby/3/assume.h b/include/ruby/3/assume.h index 9664f5606ca983..98059d7cbfa362 100644 --- a/include/ruby/3/assume.h +++ b/include/ruby/3/assume.h @@ -59,7 +59,7 @@ # define RUBY3_UNREACHABLE() __assume(0) #endif -/** Wraps (or simulates) `__asume`. */ +/** Wraps (or simulates) `__assume`. */ #if RUBY3_COMPILER_SINCE(Intel, 13, 0, 0) # /* icc warnings are false positives. Ignore them. */ # /* "warning #2261: __assume expression with side effects discarded" */ diff --git a/include/ruby/3/scan_args.h b/include/ruby/3/scan_args.h index bc4faddd56a259..b1a29f706d79b9 100644 --- a/include/ruby/3/scan_args.h +++ b/include/ruby/3/scan_args.h @@ -112,7 +112,7 @@ RUBY3_SYMBOL_EXPORT_END() # * Static assertions need such integer constant expressions as defined in # * ISO/IEC 9899:2018 section 6.7.10 paragraph #3. # * -# * GCC nontheless constant-folds this into no-op, though. */ +# * GCC nonetheless constant-folds this into no-op, though. */ # define rb_scan_args_verify(fmt, varc) \ (sizeof(char[1-2*(rb_scan_args_count(fmt)<0)])!=1 ? \ rb_scan_args_bad_format(fmt) : \ From adab82b9a71f60ad1c7f4f8c134a5ae9198ab32a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Tue, 21 Apr 2020 12:57:33 +0900 Subject: [PATCH 057/234] TRY_WITH_GC: abort immediately NoMemoryError is observed on icc but I fail to reproduce so far. Let me see the backtrace on CI. --- gc.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/gc.c b/gc.c index 115afa17d013f2..82f00f7d8d5c46 100644 --- a/gc.c +++ b/gc.c @@ -9594,6 +9594,7 @@ ruby_memerror_body(void *dummy) return 0; } +RUBY3_ATTR_MAYBE_UNUSED() static void ruby_memerror(void) { @@ -9854,7 +9855,37 @@ objspace_malloc_fixup(rb_objspace_t *objspace, void *mem, size_t size) return mem; } -#define TRY_WITH_GC(alloc) do { \ +#if defined(__GNUC__) /* && RUBY_DEBUG */ +#define RB_BUG_INSTEAD_OF_RB_MEMERROR +#endif + +#ifdef RB_BUG_INSTEAD_OF_RB_MEMERROR +#define TRY_WITH_GC(siz, expr) do { \ + const gc_profile_record_flag gpr = \ + GPR_FLAG_FULL_MARK | \ + GPR_FLAG_IMMEDIATE_MARK | \ + GPR_FLAG_IMMEDIATE_SWEEP | \ + GPR_FLAG_MALLOC; \ + objspace_malloc_gc_stress(objspace); \ + \ + if (LIKELY((expr))) { \ + /* Success on 1st try */ \ + } \ + else if (!garbage_collect_with_gvl(objspace, gpr)) { \ + /* @shyouhei thinks this doesn't happen */ \ + rb_bug("TRY_WITH_GC: could not GC"); \ + } \ + else if ((expr)) { \ + /* Suucess on 2nd try */ \ + } \ + else { \ + rb_bug("TRY_WITH_GC: could not allocate:" \ + "%"PRIdSIZE" bytes for %s", \ + siz, # expr); \ + } \ + } while (0) +#else +#define TRY_WITH_GC(siz, alloc) do { \ objspace_malloc_gc_stress(objspace); \ if (!(alloc) && \ (!garbage_collect_with_gvl(objspace, GPR_FLAG_FULL_MARK | \ @@ -9864,6 +9895,7 @@ objspace_malloc_fixup(rb_objspace_t *objspace, void *mem, size_t size) ruby_memerror(); \ } \ } while (0) +#endif /* these shouldn't be called directly. * objspace_* functinos do not check allocation size. @@ -9874,7 +9906,7 @@ objspace_xmalloc0(rb_objspace_t *objspace, size_t size) void *mem; size = objspace_malloc_prepare(objspace, size); - TRY_WITH_GC(mem = malloc(size)); + TRY_WITH_GC(size, mem = malloc(size)); RB_DEBUG_COUNTER_INC(heap_xmalloc); return objspace_malloc_fixup(objspace, mem, size); } @@ -9945,7 +9977,7 @@ objspace_xrealloc(rb_objspace_t *objspace, void *ptr, size_t new_size, size_t ol #endif old_size = objspace_malloc_size(objspace, ptr, old_size); - TRY_WITH_GC(mem = realloc(ptr, new_size)); + TRY_WITH_GC(new_size, mem = realloc(ptr, new_size)); new_size = objspace_malloc_size(objspace, mem, new_size); #if CALC_EXACT_MALLOC_SIZE @@ -10127,7 +10159,7 @@ objspace_xcalloc(rb_objspace_t *objspace, size_t size) void *mem; size = objspace_malloc_prepare(objspace, size); - TRY_WITH_GC(mem = calloc1(size)); + TRY_WITH_GC(size, mem = calloc1(size)); return objspace_malloc_fixup(objspace, mem, size); } From 735e035bf54e018fa629f6601d882fc0b097e1fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Sat, 18 Apr 2020 05:53:10 +0900 Subject: [PATCH 058/234] __GNUC__ is too lax Ditto for 4b853932eaa7fa4acf8a0f0c9b7c695bb4f5e76d --- internal/sanitizers.h | 2 +- process.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/sanitizers.h b/internal/sanitizers.h index 81ee7e3ea51895..628c225439238d 100644 --- a/internal/sanitizers.h +++ b/internal/sanitizers.h @@ -46,7 +46,7 @@ # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) x #endif -#if defined(NO_SANITIZE) && defined(__GNUC__) &&! defined(__clang__) +#if defined(NO_SANITIZE) && RUBY3_COMPILER_IS(GCC) /* GCC warns about unknown sanitizer, which is annoying. */ # include "internal/warnings.h" # undef NO_SANITIZE diff --git a/process.c b/process.c index efe99843489a4c..0d0b466686fd82 100644 --- a/process.c +++ b/process.c @@ -3958,7 +3958,7 @@ disable_child_handler_fork_child(struct child_handler_disabler_state *old, char } COMPILER_WARNING_PUSH -#ifdef __GNUC__ +#if __has_warning("-Wdeprecated-declarations") || RUBY3_COMPILER_IS(GCC) COMPILER_WARNING_IGNORED(-Wdeprecated-declarations) #endif static rb_pid_t @@ -4076,7 +4076,7 @@ rb_fork_async_signal_safe(int *status, } COMPILER_WARNING_PUSH -#ifdef __GNUC__ +#if __has_warning("-Wdeprecated-declarations") || RUBY3_COMPILER_IS(GCC) COMPILER_WARNING_IGNORED(-Wdeprecated-declarations) #endif rb_pid_t From 32623150cd389f1cdc6a840ec88ce9d1e2a43a87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Sat, 18 Apr 2020 05:40:57 +0900 Subject: [PATCH 059/234] reroute redefinition of NDEBUG NDEBUG can be defined via a command-line argument. Should take care of such situations. --- array.c | 1 + complex.c | 1 + id_table.c | 1 + rational.c | 1 + 4 files changed, 4 insertions(+) diff --git a/array.c b/array.c index 05fcc1c58f62cf..dbb40db50825de 100644 --- a/array.c +++ b/array.c @@ -32,6 +32,7 @@ #include "builtin.h" #if !ARRAY_DEBUG +# undef NDEBUG # define NDEBUG #endif #include "ruby_assert.h" diff --git a/complex.c b/complex.c index 50f78ef1e4998f..2a37c4212649b8 100644 --- a/complex.c +++ b/complex.c @@ -15,6 +15,7 @@ #include #include +#undef NDEBUG #define NDEBUG #include "id.h" #include "internal.h" diff --git a/id_table.c b/id_table.c index 4f8540246cc8ca..ade49cd8da266e 100644 --- a/id_table.c +++ b/id_table.c @@ -7,6 +7,7 @@ #endif #if ID_TABLE_DEBUG == 0 +#undef NDEBUG #define NDEBUG #endif #include "ruby_assert.h" diff --git a/rational.c b/rational.c index b828ec1e39798f..f94bf921c7092c 100644 --- a/rational.c +++ b/rational.c @@ -20,6 +20,7 @@ #include #endif +#undef NDEBUG #define NDEBUG #include "id.h" #include "internal.h" From dc9089b51f33fcb3b68c1a8d42b8f6764994f575 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 21 Apr 2020 13:35:31 +0900 Subject: [PATCH 060/234] Fixed a typo [ci skip] --- gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gc.c b/gc.c index 82f00f7d8d5c46..84e4b8a9c932a4 100644 --- a/gc.c +++ b/gc.c @@ -9876,7 +9876,7 @@ objspace_malloc_fixup(rb_objspace_t *objspace, void *mem, size_t size) rb_bug("TRY_WITH_GC: could not GC"); \ } \ else if ((expr)) { \ - /* Suucess on 2nd try */ \ + /* Success on 2nd try */ \ } \ else { \ rb_bug("TRY_WITH_GC: could not allocate:" \ From c63b5c6179d700ceacf5cae8d3ee86da1294c781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Tue, 21 Apr 2020 16:29:52 +0900 Subject: [PATCH 061/234] rb_memerror: abort immediately Ditto for adab82b9a71f60ad1c7f4f8c134a5ae9198ab32a. TRY_WITH_GC was found innocent. --- gc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gc.c b/gc.c index 84e4b8a9c932a4..67c355678a5309 100644 --- a/gc.c +++ b/gc.c @@ -9642,6 +9642,9 @@ rb_memerror(void) exc = ruby_vm_special_exception_copy(exc); } ec->errinfo = exc; +#ifdef __INTEL_COMPILER + __builtin_trap(); /* Yes, icc has it.*/ +#endif EC_JUMP_TAG(ec, TAG_RAISE); } From 487d0c99d53208594702bb3ce1c657130fb8d65f Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Tue, 21 Apr 2020 17:39:32 +0900 Subject: [PATCH 062/234] eval_error.c: revert the "reversed" backtrace [Feature #8661] Now, the order is good, old-fashioned style: ``` $ ./local/bin/ruby -e 'def foo; raise; end def bar; foo; end def baz; bar; end def qux; baz; end qux ' -e:1:in `foo': unhandled exception from -e:2:in `bar' from -e:3:in `baz' from -e:4:in `qux' from -e:5:in `
' ``` --- eval_error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eval_error.c b/eval_error.c index 74f09a8d8bdc85..809d8aef000866 100644 --- a/eval_error.c +++ b/eval_error.c @@ -362,7 +362,7 @@ rb_ec_error_print(rb_execution_context_t * volatile ec, volatile VALUE errinfo) emesg = rb_get_message(errinfo); } - rb_error_write(errinfo, emesg, errat, Qnil, Qnil, Qnil); + rb_error_write(errinfo, emesg, errat, Qnil, Qnil, Qfalse); EC_POP_TAG(); ec->errinfo = errinfo; From bf11bf31e2e795bb22c939a5b5cd412c98208982 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 21 Apr 2020 19:28:38 +0900 Subject: [PATCH 063/234] NEWS.md: the order of backtrace [Feature #8661] [ci skip] --- NEWS.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS.md b/NEWS.md index 136a21868e7f62..406c5d23099c0d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -182,8 +182,13 @@ Excluding feature bug fixes. * Taint deprecation warnings are now issued in regular mode in addition to verbose warning mode. [[Feature #16131]] +* When an exception is caught in the default handler, the error + message and backtrace are printed in order from the innermost. + [[Feature #8661]] + [Bug #4352]: https://bugs.ruby-lang.org/issues/4352 +[Feature #8661]: https://bugs.ruby-lang.org/issues/8661 [Feature #8709]: https://bugs.ruby-lang.org/issues/8709 [Feature #8948]: https://bugs.ruby-lang.org/issues/8948 [Feature #9573]: https://bugs.ruby-lang.org/issues/9573 From 3ef09c6e66cf28455536593af60a7c7072fb1777 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 21 Apr 2020 18:23:20 +0900 Subject: [PATCH 064/234] eval_error.c: default nil as "reverse" is now false [Feature #8661] --- eval_error.c | 4 ++-- test/ruby/test_exception.rb | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/eval_error.c b/eval_error.c index 809d8aef000866..89e27afe56e728 100644 --- a/eval_error.c +++ b/eval_error.c @@ -309,9 +309,9 @@ rb_error_write(VALUE errinfo, VALUE emesg, VALUE errat, VALUE str, VALUE highlig errat = Qnil; } eclass = CLASS_OF(errinfo); - if (NIL_P(reverse) || NIL_P(highlight)) { + if (NIL_P(reverse)) reverse = Qfalse; + if (NIL_P(highlight)) { VALUE tty = (VALUE)rb_stderr_tty_p(); - if (NIL_P(reverse)) reverse = tty; if (NIL_P(highlight)) highlight = tty; } if (reverse) { diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 9d7ffd882559b0..9529fc80133c66 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -1156,13 +1156,11 @@ def test_full_message if Exception.to_tty? assert_match(/\e/, message) message = message.gsub(/\e\[[\d;]*m/, '') - assert_operator(message, :start_with?, remark) - assert_operator(message, :end_with?, bottom) else assert_not_match(/\e/, message) - assert_operator(message, :start_with?, bottom) - assert_operator(message, :end_with?, top) end + assert_operator(message, :start_with?, bottom) + assert_operator(message, :end_with?, top) end def test_exception_in_message From 405d8014c57f2c1fc365710db77360070e278a21 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 21 Apr 2020 21:00:25 +0900 Subject: [PATCH 065/234] LEGAL: made license names themselves links [ci skip] --- LEGAL | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/LEGAL b/LEGAL index 565c4c9cde49a6..1e6e54c3a92292 100644 --- a/LEGAL +++ b/LEGAL @@ -12,10 +12,7 @@ ccan/check_type/check_type.h:: ccan/container_of/container_of.h:: ccan/str/str.h:: - These files are licensed under the CC0. - - >>> - https://creativecommons.org/choose/zero/ + These files are licensed under the {CC0}[https://creativecommons.org/choose/zero/]. ccan/list/list.h:: @@ -806,10 +803,7 @@ ext/win32ole/win32ole.c:: lib/rdoc/generator/template/darkfish/css/fonts.css:: - This file is licensed under the SIL Open Font License. - - >>> - http://scripts.sil.org/OFL + This file is licensed under the {SIL Open Font License}[http://scripts.sil.org/OFL]. spec/mspec:: spec/ruby:: From 61afd2a2d0e18a6902102aa18133c9d668c0155e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 21 Apr 2020 21:03:09 +0900 Subject: [PATCH 066/234] LEGAL: moved the MIT license and linked [ci skip] --- LEGAL | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/LEGAL b/LEGAL index 1e6e54c3a92292..eb9f5f89807f57 100644 --- a/LEGAL +++ b/LEGAL @@ -16,26 +16,7 @@ ccan/str/str.h:: ccan/list/list.h:: - This file is licensed under the MIT License. - - >>> - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. + This file is licensed under the {MIT License}[rdoc-label:label-MIT+License]. include/ruby/onigmo.h:: include/ruby/oniguruma.h:: @@ -843,8 +824,8 @@ test/rubygems:: >>> RubyGems is copyrighted free software by Chad Fowler, Rich Kilmer, Jim Weirich and others. You can redistribute it and/or modify it under - either the terms of the MIT license (see the file MIT.txt), or the - conditions below: + either the terms of the {MIT license}[rdoc-label:label-MIT+License], or the conditions + below: 1. You may make and give away verbatim copies of the source form of the software without restriction, provided that you duplicate all of the @@ -907,8 +888,10 @@ man/bundle-*,gemfile.*:: Portions copyright (c) 2010 Andre Arko Portions copyright (c) 2009 Engine Yard - MIT License:: + {MIT License}[rdoc-label:label-MIT+License] +== MIT License +>>> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including From cb47ae58d339b7e7adbcd11c2d896a3bb61b8e7c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 21 Apr 2020 21:05:25 +0900 Subject: [PATCH 067/234] LEGAL: moved the old-style BSD license and linked [ci skip] --- LEGAL | 117 +++++++++++++++++----------------------------------------- 1 file changed, 34 insertions(+), 83 deletions(-) diff --git a/LEGAL b/LEGAL index eb9f5f89807f57..53434c71a57334 100644 --- a/LEGAL +++ b/LEGAL @@ -393,8 +393,7 @@ missing/procstat_vm.c:: vsnprintf.c:: - This file is under the old-style BSD license. Note that the - paragraph 3 below is now null and void. + This file is under the {old-style BSD license}[label-Old-style+BSD+license]. >>> Copyright (c) 1990, 1993 @@ -403,35 +402,6 @@ vsnprintf.c:: This code is derived from software contributed to Berkeley by Chris Torek. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. - - IMPORTANT NOTE: - -------------- - From ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change - paragraph 3 above is now null and void. - st.c:: strftime.c:: include/ruby/st.h:: @@ -460,8 +430,7 @@ ext/sdbm/sdbm.h:: missing/crypt.c:: - This file is under the old-style BSD license. Note that the - paragraph 3 below is now null and void. + This file is under the {old-style BSD license}[label-Old-style+BSD+license]. >>> Copyright (c) 1989, 1993 @@ -470,34 +439,9 @@ missing/crypt.c:: This code is derived from software contributed to Berkeley by Tom Truscott. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. - missing/setproctitle.c:: - This file is under the old-style BSD license. Note that the - paragraph 3 below is now null and void. + This file is under the {old-style BSD license}[label-Old-style+BSD+license]. >>> Copyright 2003 Damien Miller @@ -505,30 +449,6 @@ missing/setproctitle.c:: Copyright (c) 1988, 1993 The Regents of the University of California. All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. - missing/strlcat.c:: missing/strlcpy.c:: @@ -910,3 +830,34 @@ man/bundle-*,gemfile.*:: LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +== Old-style BSD license +>>> + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + + IMPORTANT NOTE:: + + From ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change + paragraph 3 above is now null and void. From 6b04c480487ab64d73e1254be2412e722b7b8bd8 Mon Sep 17 00:00:00 2001 From: git Date: Tue, 21 Apr 2020 21:12:00 +0900 Subject: [PATCH 068/234] * remove trailing spaces. [ci skip] --- LEGAL | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/LEGAL b/LEGAL index 53434c71a57334..8b3eb82d52bb1a 100644 --- a/LEGAL +++ b/LEGAL @@ -69,8 +69,8 @@ enc/windows_1251.c:: Onigmo (Oniguruma-mod) LICENSE >>> - Copyright (c) 2002-2009 K.Kosako - Copyright (c) 2011-2014 K.Takata + Copyright (c) 2002-2009 K.Kosako + Copyright (c) 2011-2014 K.Takata All rights reserved. Redistribution and use in source and binary forms, with or without @@ -97,7 +97,7 @@ enc/windows_1251.c:: Oniguruma LICENSE >>> - Copyright (c) 2002-2009 K.Kosako + Copyright (c) 2002-2009 K.Kosako All rights reserved. Redistribution and use in source and binary forms, with or without @@ -165,9 +165,9 @@ enc/trans/JIS/JISX0213-2%UCS@SIP.src:: These files are copyrighted as the following. >>> - Copyright (C) 2001 earthian@tama.or.jp, All Rights Reserved. - Copyright (C) 2001 I'O, All Rights Reserved. - Copyright (C) 2006 Project X0213, All Rights Reserved. + Copyright (C) 2001 earthian@tama.or.jp, All Rights Reserved. + Copyright (C) 2001 I'O, All Rights Reserved. + Copyright (C) 2006 Project X0213, All Rights Reserved. You can use, modify, distribute this table freely. enc/trans/JIS/UCS@BMP%JISX0213-1.src:: @@ -178,8 +178,8 @@ enc/trans/JIS/UCS@SIP%JISX0213-2.src:: These files are copyrighted as the following. >>> - Copyright (C) 2001 earthian@tama.or.jp, All Rights Reserved. - Copyright (C) 2001 I'O, All Rights Reserved. + Copyright (C) 2001 earthian@tama.or.jp, All Rights Reserved. + Copyright (C) 2001 I'O, All Rights Reserved. You can use, modify, distribute this table freely. configure:: @@ -275,7 +275,7 @@ missing/dtoa.c:: OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. >>> - Copyright (c) 2004-2008 David Schultz + Copyright (c) 2004-2008 David Schultz All rights reserved. Redistribution and use in source and binary forms, with or without @@ -316,7 +316,7 @@ missing/mt19937.c:: >>> A C-program for MT19937, with initialization improved 2002/2/10. - Coded by Takuji Nishimura and Makoto Matsumoto. + Coded by Takuji Nishimura and Makoto Matsumoto. This is a faster version by taking Shawn Cokus's optimization, Matthe Bellew's simplification, Isaku Wada's real version. @@ -365,7 +365,7 @@ missing/procstat_vm.c:: This file is under the new-style BSD license. >>> - Copyright (c) 2007 Robert N. M. Watson + Copyright (c) 2007 Robert N. M. Watson All rights reserved. Redistribution and use in source and binary forms, with or without @@ -396,7 +396,7 @@ vsnprintf.c:: This file is under the {old-style BSD license}[label-Old-style+BSD+license]. >>> - Copyright (c) 1990, 1993 + Copyright (c) 1990, 1993 The Regents of the University of California. All rights reserved. This code is derived from software contributed to Berkeley by @@ -433,7 +433,7 @@ missing/crypt.c:: This file is under the {old-style BSD license}[label-Old-style+BSD+license]. >>> - Copyright (c) 1989, 1993 + Copyright (c) 1989, 1993 The Regents of the University of California. All rights reserved. This code is derived from software contributed to Berkeley by @@ -444,9 +444,9 @@ missing/setproctitle.c:: This file is under the {old-style BSD license}[label-Old-style+BSD+license]. >>> - Copyright 2003 Damien Miller - Copyright (c) 1983, 1995-1997 Eric P. Allman - Copyright (c) 1988, 1993 + Copyright 2003 Damien Miller + Copyright (c) 1983, 1995-1997 Eric P. Allman + Copyright (c) 1988, 1993 The Regents of the University of California. All rights reserved. missing/strlcat.c:: @@ -476,7 +476,7 @@ missing/langinfo.c:: author/copyright notice: >>> - Markus.Kuhn@cl.cam.ac.uk -- 2002-03-11 + Markus.Kuhn@cl.cam.ac.uk -- 2002-03-11 Permission to use, copy, modify, and distribute this software for any purpose and without fee is hereby granted. The author disclaims all warranties with regard to this software. @@ -805,8 +805,8 @@ man/bundle-*,gemfile.*:: Bundler is under the following license. >>> - Portions copyright (c) 2010 Andre Arko - Portions copyright (c) 2009 Engine Yard + Portions copyright (c) 2010 Andre Arko + Portions copyright (c) 2009 Engine Yard {MIT License}[rdoc-label:label-MIT+License] From 22226324f7f47a9053d6dbb58b1650c1efee81e8 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 21 Apr 2020 21:33:04 +0900 Subject: [PATCH 069/234] LEGAL: fixed links to the old-style BSD license [ci skip] --- LEGAL | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/LEGAL b/LEGAL index 8b3eb82d52bb1a..952c9ad32248da 100644 --- a/LEGAL +++ b/LEGAL @@ -393,7 +393,7 @@ missing/procstat_vm.c:: vsnprintf.c:: - This file is under the {old-style BSD license}[label-Old-style+BSD+license]. + This file is under the {old-style BSD license}[rdoc-label:label-Old-style+BSD+license]. >>> Copyright (c) 1990, 1993 @@ -430,7 +430,7 @@ ext/sdbm/sdbm.h:: missing/crypt.c:: - This file is under the {old-style BSD license}[label-Old-style+BSD+license]. + This file is under the {old-style BSD license}[rdoc-label:label-Old-style+BSD+license]. >>> Copyright (c) 1989, 1993 @@ -441,7 +441,7 @@ missing/crypt.c:: missing/setproctitle.c:: - This file is under the {old-style BSD license}[label-Old-style+BSD+license]. + This file is under the {old-style BSD license}[rdoc-label:label-Old-style+BSD+license]. >>> Copyright 2003 Damien Miller From 7d918be633c649a4439fb239c1ae22c8d391683c Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Wed, 22 Apr 2020 01:53:53 +0900 Subject: [PATCH 070/234] test/ruby/test_fiber.rb: Skip the problematic test_stack_size on riscv Since it is impossible to detect stack overflow of C functions robustly, the test is a bit unreasonable. https://rubyci.org/logs/rubyci.s3.amazonaws.com/debian-riscv64/ruby-master/log/20200421T120018Z.fail.html.gz --- test/ruby/test_fiber.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb index f5480241756490..e4c5841ff5404c 100644 --- a/test/ruby/test_fiber.rb +++ b/test/ruby/test_fiber.rb @@ -361,6 +361,7 @@ def invoke_rec script, vm_stack_size, machine_stack_size, use_length = true def test_stack_size skip 'too unstable on Travis s390x-linux' if RUBY_PLATFORM == 's390x-linux' + skip 'too unstable on riscv' if RUBY_PLATFORM =~ /riscv/ h_default = eval(invoke_rec('p RubyVM::DEFAULT_PARAMS', nil, nil, false)) h_0 = eval(invoke_rec('p RubyVM::DEFAULT_PARAMS', 0, 0, false)) h_large = eval(invoke_rec('p RubyVM::DEFAULT_PARAMS', 1024 * 1024 * 5, 1024 * 1024 * 10, false)) From cebf575de89e69809e9750ac0f6c5a5f3bcdec2c Mon Sep 17 00:00:00 2001 From: git Date: Wed, 22 Apr 2020 02:05:33 +0900 Subject: [PATCH 071/234] * 2020-04-22 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 6c71449bb09a1e..9d30812da17db6 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 21 +#define RUBY_RELEASE_DAY 22 #include "ruby/version.h" From 92afac8f3346f050ff25ad15a640a6861f690427 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Wed, 22 Apr 2020 01:45:19 +0900 Subject: [PATCH 072/234] configure.ac: Automatically add -D__ANDROID_API=ver on Android --- configure.ac | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/configure.ac b/configure.ac index ba86deffbebbb4..e16c3e44ed8205 100644 --- a/configure.ac +++ b/configure.ac @@ -414,6 +414,30 @@ AC_CHECK_PROG(PKG_CONFIG, pkg-config, [pkg-config], [], [], # checks for UNIX variants that set C preprocessor variables AC_USE_SYSTEM_EXTENSIONS +AC_MSG_CHECKING([whether it is Android]) +AC_TRY_COMPILE([ + @%:@ifdef __ANDROID__ + @%:@error android + @%:@endif +], [], +[AC_MSG_RESULT(no)], +[ + AC_MSG_RESULT(yes) + target_os=${target_os}-android + AC_MSG_CHECKING([for Android API version]) + AC_TRY_COMPILE([ + @%:@ifndef __ANDROID_API__ + @%:@error android + @%:@endif + ], [], + [AC_MSG_RESULT(defined by the compiler)], + [ + rb_android_api=`getprop ro.build.version.sdk` + AC_MSG_RESULT($rb_android_api) + RUBY_APPEND_OPTIONS(CPPFLAGS, -D__ANDROID_API__=$rb_android_api) + ]) +]) + AC_SUBST(RM, ['rm -f']) AC_SUBST(CP, ['cp']) RMDIRS='$(top_srcdir)/tool/rmdirs' From ad63ae6619d26488725e05d74f2bfc3ab185b0c3 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Wed, 22 Apr 2020 02:41:54 +0900 Subject: [PATCH 073/234] .github/workflows/mingw.yml: add `shell: bash` for PR checkout as well as e62aead26909e83f2c8b940186047f0a88b9f2d6 --- .github/workflows/mingw.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/mingw.yml b/.github/workflows/mingw.yml index 8ee58fa491a49f..a3cbf8a458260f 100644 --- a/.github/workflows/mingw.yml +++ b/.github/workflows/mingw.yml @@ -39,6 +39,7 @@ jobs: git clone --single-branch --depth=50 --branch=${{ github.event.pull_request.head.ref }} https://github.com/${{ github.event.pull_request.head.repo.full_name }} src git -C src reset --hard ${{ github.event.pull_request.head.sha }} if: github.event_name == 'pull_request' + shell: bash - run: ./src/tool/actions-commit-info.sh shell: bash id: commit_info From 17083011eed7d56981f2b227574527e4bf23eb65 Mon Sep 17 00:00:00 2001 From: "S.H" Date: Wed, 22 Apr 2020 09:49:13 +0900 Subject: [PATCH 074/234] support builtin for Kernel#Float # Iteration per second (i/s) | |compare-ruby|built-ruby| |:------------|-----------:|---------:| |float | 30.395M| 38.314M| | | -| 1.26x| |float_true | 3.833M| 27.322M| | | -| 7.13x| |float_false | 4.182M| 24.938M| | | -| 5.96x| --- benchmark/kernel_float.yml | 5 +++++ kernel.rb | 24 ++++++++++++++++++++++++ object.c | 28 +++------------------------- 3 files changed, 32 insertions(+), 25 deletions(-) create mode 100644 benchmark/kernel_float.yml diff --git a/benchmark/kernel_float.yml b/benchmark/kernel_float.yml new file mode 100644 index 00000000000000..215f6750fcc080 --- /dev/null +++ b/benchmark/kernel_float.yml @@ -0,0 +1,5 @@ +benchmark: + float: "Float(42)" + float_true: "Float(42, exception: true)" + float_false: "Float(42, exception: false)" +loop_count: 10000 diff --git a/kernel.rb b/kernel.rb index d3fa9d80531856..aa3f8b72a46a4e 100644 --- a/kernel.rb +++ b/kernel.rb @@ -26,4 +26,28 @@ module Kernel def clone(freeze: nil) __builtin_rb_obj_clone2(freeze) end + + module_function + + # + # call-seq: + # Float(arg, exception: true) -> float or nil + # + # Returns arg converted to a float. Numeric types are + # converted directly, and with exception to String and + # nil the rest are converted using + # arg.to_f. Converting a String with invalid + # characters will result in a ArgumentError. Converting + # nil generates a TypeError. Exceptions can be + # suppressed by passing exception: false. + # + # Float(1) #=> 1.0 + # Float("123.456") #=> 123.456 + # Float("123.0_badstring") #=> ArgumentError: invalid value for Float(): "123.0_badstring" + # Float(nil) #=> TypeError: can't convert nil into Float + # Float("123.0_badstring", exception: false) #=> nil + # + def Float(arg, exception: true) + __builtin_rb_f_float(arg, exception) + end end diff --git a/object.c b/object.c index 55d28a1500107c..61a9d6200cc067 100644 --- a/object.c +++ b/object.c @@ -3813,32 +3813,11 @@ rb_Float(VALUE val) return rb_convert_to_float(val, TRUE); } -/* - * call-seq: - * Float(arg, exception: true) -> float or nil - * - * Returns arg converted to a float. Numeric types are - * converted directly, and with exception to String and - * nil the rest are converted using - * arg.to_f. Converting a String with invalid - * characters will result in a ArgumentError. Converting - * nil generates a TypeError. Exceptions can be - * suppressed by passing exception: false. - * - * Float(1) #=> 1.0 - * Float("123.456") #=> 123.456 - * Float("123.0_badstring") #=> ArgumentError: invalid value for Float(): "123.0_badstring" - * Float(nil) #=> TypeError: can't convert nil into Float - * Float("123.0_badstring", exception: false) #=> nil - */ - static VALUE -rb_f_float(int argc, VALUE *argv, VALUE obj) +rb_f_float(rb_execution_context_t *ec, VALUE obj, VALUE arg, VALUE opts) { - VALUE arg = Qnil, opts = Qnil; - - rb_scan_args(argc, argv, "1:", &arg, &opts); - return rb_convert_to_float(arg, opts_exception_p(opts)); + int exception = rb_bool_expected(opts, "exception"); + return rb_convert_to_float(arg, exception); } static VALUE @@ -4668,7 +4647,6 @@ InitVM_Object(void) rb_define_global_function("format", f_sprintf, -1); rb_define_global_function("Integer", rb_f_integer, -1); - rb_define_global_function("Float", rb_f_float, -1); rb_define_global_function("String", rb_f_string, 1); rb_define_global_function("Array", rb_f_array, 1); From 5ce7835520a0567d76352db510383d00229c3da3 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 22 Apr 2020 10:01:11 +0900 Subject: [PATCH 075/234] Update benchmark-driver version --- common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.mk b/common.mk index 6ac7c2a360f756..0ccc85f6bed5a5 100644 --- a/common.mk +++ b/common.mk @@ -47,7 +47,7 @@ GEM_PATH = GEM_VENDOR = BENCHMARK_DRIVER_GIT_URL = https://github.com/benchmark-driver/benchmark-driver -BENCHMARK_DRIVER_GIT_REF = v0.15.7 +BENCHMARK_DRIVER_GIT_REF = v0.15.11 SIMPLECOV_GIT_URL = https://github.com/colszowka/simplecov.git SIMPLECOV_GIT_REF = v0.17.0 SIMPLECOV_HTML_GIT_URL = https://github.com/colszowka/simplecov-html.git From f00b923193d0bbaa7a4ffa5acc2dd256ce32152a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 22 Apr 2020 14:55:34 +0900 Subject: [PATCH 076/234] Revert "* remove trailing spaces. [ci skip]" This reverts commit 6b04c480487ab64d73e1254be2412e722b7b8bd8. Trailing spaces separate paragraphs in RDoc format. --- LEGAL | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/LEGAL b/LEGAL index 952c9ad32248da..61d8dbf2902a7b 100644 --- a/LEGAL +++ b/LEGAL @@ -69,8 +69,8 @@ enc/windows_1251.c:: Onigmo (Oniguruma-mod) LICENSE >>> - Copyright (c) 2002-2009 K.Kosako - Copyright (c) 2011-2014 K.Takata + Copyright (c) 2002-2009 K.Kosako + Copyright (c) 2011-2014 K.Takata All rights reserved. Redistribution and use in source and binary forms, with or without @@ -97,7 +97,7 @@ enc/windows_1251.c:: Oniguruma LICENSE >>> - Copyright (c) 2002-2009 K.Kosako + Copyright (c) 2002-2009 K.Kosako All rights reserved. Redistribution and use in source and binary forms, with or without @@ -165,9 +165,9 @@ enc/trans/JIS/JISX0213-2%UCS@SIP.src:: These files are copyrighted as the following. >>> - Copyright (C) 2001 earthian@tama.or.jp, All Rights Reserved. - Copyright (C) 2001 I'O, All Rights Reserved. - Copyright (C) 2006 Project X0213, All Rights Reserved. + Copyright (C) 2001 earthian@tama.or.jp, All Rights Reserved. + Copyright (C) 2001 I'O, All Rights Reserved. + Copyright (C) 2006 Project X0213, All Rights Reserved. You can use, modify, distribute this table freely. enc/trans/JIS/UCS@BMP%JISX0213-1.src:: @@ -178,8 +178,8 @@ enc/trans/JIS/UCS@SIP%JISX0213-2.src:: These files are copyrighted as the following. >>> - Copyright (C) 2001 earthian@tama.or.jp, All Rights Reserved. - Copyright (C) 2001 I'O, All Rights Reserved. + Copyright (C) 2001 earthian@tama.or.jp, All Rights Reserved. + Copyright (C) 2001 I'O, All Rights Reserved. You can use, modify, distribute this table freely. configure:: @@ -275,7 +275,7 @@ missing/dtoa.c:: OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. >>> - Copyright (c) 2004-2008 David Schultz + Copyright (c) 2004-2008 David Schultz All rights reserved. Redistribution and use in source and binary forms, with or without @@ -316,7 +316,7 @@ missing/mt19937.c:: >>> A C-program for MT19937, with initialization improved 2002/2/10. - Coded by Takuji Nishimura and Makoto Matsumoto. + Coded by Takuji Nishimura and Makoto Matsumoto. This is a faster version by taking Shawn Cokus's optimization, Matthe Bellew's simplification, Isaku Wada's real version. @@ -365,7 +365,7 @@ missing/procstat_vm.c:: This file is under the new-style BSD license. >>> - Copyright (c) 2007 Robert N. M. Watson + Copyright (c) 2007 Robert N. M. Watson All rights reserved. Redistribution and use in source and binary forms, with or without @@ -396,7 +396,7 @@ vsnprintf.c:: This file is under the {old-style BSD license}[rdoc-label:label-Old-style+BSD+license]. >>> - Copyright (c) 1990, 1993 + Copyright (c) 1990, 1993 The Regents of the University of California. All rights reserved. This code is derived from software contributed to Berkeley by @@ -433,7 +433,7 @@ missing/crypt.c:: This file is under the {old-style BSD license}[rdoc-label:label-Old-style+BSD+license]. >>> - Copyright (c) 1989, 1993 + Copyright (c) 1989, 1993 The Regents of the University of California. All rights reserved. This code is derived from software contributed to Berkeley by @@ -444,9 +444,9 @@ missing/setproctitle.c:: This file is under the {old-style BSD license}[rdoc-label:label-Old-style+BSD+license]. >>> - Copyright 2003 Damien Miller - Copyright (c) 1983, 1995-1997 Eric P. Allman - Copyright (c) 1988, 1993 + Copyright 2003 Damien Miller + Copyright (c) 1983, 1995-1997 Eric P. Allman + Copyright (c) 1988, 1993 The Regents of the University of California. All rights reserved. missing/strlcat.c:: @@ -476,7 +476,7 @@ missing/langinfo.c:: author/copyright notice: >>> - Markus.Kuhn@cl.cam.ac.uk -- 2002-03-11 + Markus.Kuhn@cl.cam.ac.uk -- 2002-03-11 Permission to use, copy, modify, and distribute this software for any purpose and without fee is hereby granted. The author disclaims all warranties with regard to this software. @@ -805,8 +805,8 @@ man/bundle-*,gemfile.*:: Bundler is under the following license. >>> - Portions copyright (c) 2010 Andre Arko - Portions copyright (c) 2009 Engine Yard + Portions copyright (c) 2010 Andre Arko + Portions copyright (c) 2009 Engine Yard {MIT License}[rdoc-label:label-MIT+License] From d6ec8da689ae097e442219b7feab491120060cba Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 22 Apr 2020 16:13:42 +0900 Subject: [PATCH 077/234] Update benchmark-driver version --- common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.mk b/common.mk index 0ccc85f6bed5a5..a5e015f975a75b 100644 --- a/common.mk +++ b/common.mk @@ -47,7 +47,7 @@ GEM_PATH = GEM_VENDOR = BENCHMARK_DRIVER_GIT_URL = https://github.com/benchmark-driver/benchmark-driver -BENCHMARK_DRIVER_GIT_REF = v0.15.11 +BENCHMARK_DRIVER_GIT_REF = v0.15.12 SIMPLECOV_GIT_URL = https://github.com/colszowka/simplecov.git SIMPLECOV_GIT_REF = v0.17.0 SIMPLECOV_HTML_GIT_URL = https://github.com/colszowka/simplecov-html.git From 02ad393cd6bd87a7cc21ef71d5b21ad0f3fe2f34 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 22 Apr 2020 18:56:06 +0900 Subject: [PATCH 078/234] Revert "Allow simple R-assign in endless def" This reverts commit 67bcac879a2e0ddfb4e7bbd7cb5e5401422de76a. --- parse.y | 20 +++----------------- test/ruby/test_syntax.rb | 1 - 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/parse.y b/parse.y index 482751582070ff..18f776e87cf959 100644 --- a/parse.y +++ b/parse.y @@ -1104,7 +1104,7 @@ static int looking_at_eol_p(struct parser_params *p); %type string_contents xstring_contents regexp_contents string_content %type words symbols symbol_list qwords qsymbols word_list qword_list qsym_list word %type literal numeric simple_numeric ssym dsym symbol cpath def_name defn_head defs_head -%type top_compstmt top_stmts top_stmt begin_block rassign arg_rassign +%type top_compstmt top_stmts top_stmt begin_block rassign %type bodystmt compstmt stmts stmt_or_begin stmt expr arg primary command command_call method_call %type expr_value expr_value_do arg_value primary_value fcall rel_expr %type if_tail opt_else case_body case_args cases opt_rescue exc_list exc_var opt_ensure @@ -1195,7 +1195,6 @@ static int looking_at_eol_p(struct parser_params *p); %nonassoc tLOWEST %nonassoc tLBRACE_ARG -%left tASSOC %nonassoc modifier_if modifier_unless modifier_while modifier_until keyword_in %left keyword_or keyword_and @@ -1537,19 +1536,6 @@ rassign : arg_value tASSOC lhs } ; -arg_rassign : arg tASSOC lhs %prec tLOWEST - { - /*%%%*/ - $$ = node_assign(p, $3, $1, &@$); - /*% %*/ - /*% ripper: assign!($3, $1) %*/ - } - | arg %prec tLOWEST - { - $$ = $1; - } - ; - command_asgn : lhs '=' command_rhs { /*%%%*/ @@ -2459,7 +2445,7 @@ arg : lhs '=' arg_rhs /*% %*/ /*% ripper: ifop!($1, $3, $6) %*/ } - | defn_head f_arglist_opt '=' arg_rassign + | defn_head f_arglist_opt '=' arg { restore_defun(p, $1->nd_defn); /*%%%*/ @@ -2468,7 +2454,7 @@ arg : lhs '=' arg_rhs /*% ripper: def!(get_value($1), $2, $4) %*/ local_pop(p); } - | defs_head f_arglist_opt '=' arg_rassign + | defs_head f_arglist_opt '=' arg { restore_defun(p, $1->nd_defn); /*%%%*/ diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index ddb813fef9ba29..2f81d729598f91 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -1419,7 +1419,6 @@ def test_methoddef_endless assert_valid_syntax('private def inc(x) = x + 1') assert_valid_syntax('private def obj.foo = 42') assert_valid_syntax('private def obj.inc(x) = x + 1') - assert_valid_syntax('private def obj.inc(x) = x + 1 => @x') end def test_methoddef_in_cond From 1fe5bffefdf799c24f4a0eed97e1ceefc1dc66d6 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 22 Apr 2020 18:56:06 +0900 Subject: [PATCH 079/234] Disallow R-assign in endless def --- test/ruby/test_syntax.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 2f81d729598f91..c471006199ad0e 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -1419,6 +1419,8 @@ def test_methoddef_endless assert_valid_syntax('private def inc(x) = x + 1') assert_valid_syntax('private def obj.foo = 42') assert_valid_syntax('private def obj.inc(x) = x + 1') + eval('def self.inc(x) = x + 1 => @x') + assert_equal(:inc, @x) end def test_methoddef_in_cond From 1997e10f6caeae49660ceb9342a01a4fd2efc788 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 22 Apr 2020 19:07:33 +0900 Subject: [PATCH 080/234] Made parentheses mandatory in endless method defition Even for empty argument list, not to be confusing with a writer method name. --- parse.y | 22 +++++++--------------- test/ruby/test_syntax.rb | 6 ++++-- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/parse.y b/parse.y index 18f776e87cf959..09ba4621240172 100644 --- a/parse.y +++ b/parse.y @@ -1114,7 +1114,7 @@ static int looking_at_eol_p(struct parser_params *p); %type command_rhs arg_rhs %type command_asgn mrhs mrhs_arg superclass block_call block_command %type f_block_optarg f_block_opt -%type f_arglist f_arglist_opt f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs f_rest_marg +%type f_arglist f_paren_args f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs f_rest_marg %type assoc_list assocs assoc undef_list backref string_dvar for_var %type block_param opt_block_param block_param_def f_opt %type f_kwarg f_kw f_block_kwarg f_block_kw @@ -2445,7 +2445,7 @@ arg : lhs '=' arg_rhs /*% %*/ /*% ripper: ifop!($1, $3, $6) %*/ } - | defn_head f_arglist_opt '=' arg + | defn_head f_paren_args '=' arg { restore_defun(p, $1->nd_defn); /*%%%*/ @@ -2454,7 +2454,7 @@ arg : lhs '=' arg_rhs /*% ripper: def!(get_value($1), $2, $4) %*/ local_pop(p); } - | defs_head f_arglist_opt '=' arg + | defs_head f_paren_args '=' arg { restore_defun(p, $1->nd_defn); /*%%%*/ @@ -4888,18 +4888,7 @@ superclass : '<' } ; -f_arglist_opt : f_arglist - | /* none */ - { - /*%%%*/ - $$ = new_args_tail(p, Qnone, Qnone, Qnone, &@0); - $$ = new_args(p, Qnone, Qnone, Qnone, Qnone, $$, &@0); - /*% %*/ - /*% ripper: Qnil %*/ - } - ; - -f_arglist : '(' f_args rparen +f_paren_args : '(' f_args rparen { /*%%%*/ $$ = $2; @@ -4923,6 +4912,9 @@ f_arglist : '(' f_args rparen SET_LEX_STATE(EXPR_BEG); p->command_start = TRUE; } + ; + +f_arglist : f_paren_args | { $$ = p->ctxt; p->ctxt.in_kwarg = 1; diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index c471006199ad0e..df6c2e383fb51b 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -1415,9 +1415,11 @@ def test_method_call_location end def test_methoddef_endless - assert_valid_syntax('private def foo = 42') + assert_syntax_error('private def foo = 42', /unexpected '='/) + assert_valid_syntax('private def foo() = 42') assert_valid_syntax('private def inc(x) = x + 1') - assert_valid_syntax('private def obj.foo = 42') + assert_syntax_error('private def obj.foo = 42', /unexpected '='/) + assert_valid_syntax('private def obj.foo() = 42') assert_valid_syntax('private def obj.inc(x) = x + 1') eval('def self.inc(x) = x + 1 => @x') assert_equal(:inc, @x) From 6292271ef78328a9d520962625f8f1fe457895b3 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Thu, 23 Apr 2020 01:40:01 +0900 Subject: [PATCH 081/234] Fix permission of PATH https://github.com/ruby/actions/runs/608526685?check_suite_focus=true `warning: Insecure world writable dir /home/runner/.config in PATH, mode 040777` --- .github/workflows/mjit.yml | 3 ++- .github/workflows/ubuntu.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mjit.yml b/.github/workflows/mjit.yml index 08a659e3e2bd80..fbeed8d925abb1 100644 --- a/.github/workflows/mjit.yml +++ b/.github/workflows/mjit.yml @@ -33,8 +33,9 @@ jobs: id: commit_info - name: Fixed world writable dirs run: | - chmod go-w $HOME + chmod -v go-w $HOME $HOME/.config sudo chmod -R go-w /usr/share + sudo bash -c 'IFS=:; for d in '"$PATH"'; do chmod -v go-w $d; done' || : - name: Set ENV run: | echo '::set-env name=JOBS::'-j$((1 + $(nproc --all))) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index c98d05c1d78134..17da8d1f70a667 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -39,8 +39,9 @@ jobs: id: commit_info - name: Fixed world writable dirs run: | - chmod go-w $HOME + chmod -v go-w $HOME $HOME/.config sudo chmod -R go-w /usr/share + sudo bash -c 'IFS=:; for d in '"$PATH"'; do chmod -v go-w $d; done' || : - name: Set ENV run: | echo '::set-env name=JOBS::'-j$((1 + $(nproc --all))) From 492e8599c60ed22b940aac40f8907fd58f1a879b Mon Sep 17 00:00:00 2001 From: git Date: Thu, 23 Apr 2020 01:41:21 +0900 Subject: [PATCH 082/234] * 2020-04-23 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 9d30812da17db6..4dd662cfd4a911 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 22 +#define RUBY_RELEASE_DAY 23 #include "ruby/version.h" From 8119bcbfc04772fe4012b5ed396a68f02e312316 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Thu, 23 Apr 2020 02:16:12 +0900 Subject: [PATCH 083/234] rb_method_entry() returns valid me. search_method() can return invalid method, but vm_defined() checks it as valid method entry. This is why defined?(foo) if foo is undef'ed. To solve this problem, check invalidation and return NULL. [Bug #16669] https://twitter.com/kamipo/status/1252881930103558144 Tests will be merged by nobu soon. --- vm_method.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vm_method.c b/vm_method.c index afda598aa1127c..1910b1e46d5082 100644 --- a/vm_method.c +++ b/vm_method.c @@ -936,7 +936,13 @@ search_method_protect(VALUE klass, ID id, VALUE *defined_class_ptr) MJIT_FUNC_EXPORTED const rb_method_entry_t * rb_method_entry(VALUE klass, ID id) { - return search_method(klass, id, NULL); + const rb_method_entry_t *me = search_method(klass, id, NULL); + if (me && me->def && me->def->type != VM_METHOD_TYPE_UNDEF) { + return me; + } + else { + return NULL; + } } static inline const rb_callable_method_entry_t * From de9d6a7a8cb0929e0b4cf0a3120971c7b8ee8927 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 22 Apr 2020 22:21:11 +0900 Subject: [PATCH 084/234] Split test_defined --- test/ruby/test_defined.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/ruby/test_defined.rb b/test/ruby/test_defined.rb index 9976db3b6f7202..d254857dea62d3 100644 --- a/test/ruby/test_defined.rb +++ b/test/ruby/test_defined.rb @@ -23,24 +23,30 @@ def defined_test return !defined?(yield) end - def test_defined + def test_defined_gloval_variable $x = nil assert(defined?($x)) # global variable assert_equal('global-variable', defined?($x))# returns description + end + def test_defined_local_variable assert_nil(defined?(foo)) # undefined foo=5 assert(defined?(foo)) # local variable + end + def test_defined_constant assert(defined?(Array)) # constant assert(defined?(::Array)) # toplevel constant assert(defined?(File::Constants)) # nested constant + end + + def test_defined_method assert(defined?(Object.new)) # method assert(defined?(Object::new)) # method assert(!defined?(Object.print)) # private method assert(defined?(1 == 2)) # operator expression - f = Foo.new assert_nil(defined?(f.foo)) # protected method f.bar(f) { |v| assert(v) } @@ -53,10 +59,14 @@ def test_defined assert_nil(defined?(quux(x))) assert(defined?(f.attr = 1)) f.attrasgn_test { |v| assert(v) } + end + def test_defined_yield assert(defined_test) # not iterator assert(!defined_test{}) # called as iterator + end + def test_defined_matchdata /a/ =~ '' assert_equal nil, defined?($&) assert_equal nil, defined?($`) @@ -85,12 +95,16 @@ def test_defined assert_equal 'global-variable', defined?($+) assert_equal 'global-variable', defined?($1) assert_equal nil, defined?($2) + end + def test_defined_literal assert_equal("nil", defined?(nil)) assert_equal("true", defined?(true)) assert_equal("false", defined?(false)) assert_equal("expression", defined?(1)) + end + def test_defined_empty_paren_expr bug8224 = '[ruby-core:54024] [Bug #8224]' (1..3).each do |level| expr = "("*level+")"*level From da5bd0047d6c961105da210c69d4c88421324b70 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 23 Apr 2020 09:43:30 +0900 Subject: [PATCH 085/234] Test for [Bug #16669] --- test/ruby/test_defined.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/ruby/test_defined.rb b/test/ruby/test_defined.rb index d254857dea62d3..267744ef08f0cb 100644 --- a/test/ruby/test_defined.rb +++ b/test/ruby/test_defined.rb @@ -61,6 +61,14 @@ def test_defined_method f.attrasgn_test { |v| assert(v) } end + def test_defined_undef + x = Object.new + def x.foo; end + assert(defined?(x.foo)) + x.instance_eval {undef :foo} + assert(!defined?(x.foo), "undefed method should not be defined?") + end + def test_defined_yield assert(defined_test) # not iterator assert(!defined_test{}) # called as iterator From 74c8aaef7dd09043cf9f13381c84022da7f1c253 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 23 Apr 2020 10:24:49 +0900 Subject: [PATCH 086/234] Just call search_method_protect [Bug #16669] --- vm_method.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/vm_method.c b/vm_method.c index 1910b1e46d5082..150fc9d55fe5da 100644 --- a/vm_method.c +++ b/vm_method.c @@ -936,13 +936,7 @@ search_method_protect(VALUE klass, ID id, VALUE *defined_class_ptr) MJIT_FUNC_EXPORTED const rb_method_entry_t * rb_method_entry(VALUE klass, ID id) { - const rb_method_entry_t *me = search_method(klass, id, NULL); - if (me && me->def && me->def->type != VM_METHOD_TYPE_UNDEF) { - return me; - } - else { - return NULL; - } + return search_method_protect(klass, id, NULL); } static inline const rb_callable_method_entry_t * From 2e87488d13ebbbdcb8778b0bd2bfae2223e0a8ec Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 23 Apr 2020 10:25:09 +0900 Subject: [PATCH 087/234] Expand retrying test file names to realpath As well as worker processes do in Test::Unit::Worker#run. --- tool/lib/test/unit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb index 376ca8d3d43d3d..a2ee464ff1444c 100644 --- a/tool/lib/test/unit.rb +++ b/tool/lib/test/unit.rb @@ -527,7 +527,7 @@ def _run_parallel suites, type, result parallel = @options[:parallel] @options[:parallel] = false suites, rep = rep.partition {|r| r[:testcase] && r[:file] && r[:report].any? {|e| !e[2].is_a?(MiniTest::Skip)}} - suites.map {|r| r[:file]}.uniq.each {|file| require file} + suites.map {|r| File.realpath(r[:file])}.uniq.each {|file| require file} suites.map! {|r| eval("::"+r[:testcase])} del_status_line or puts unless suites.empty? From d1f50b9872f2768d8790170904ccf6d28aaee633 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 23 Apr 2020 10:44:27 +0900 Subject: [PATCH 088/234] Initialize the class variable for Minitest::Unit.current_repeat_count --- tool/lib/minitest/unit.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/tool/lib/minitest/unit.rb b/tool/lib/minitest/unit.rb index c85b41e5fc44a7..7090f8af3f4bc2 100644 --- a/tool/lib/minitest/unit.rb +++ b/tool/lib/minitest/unit.rb @@ -779,6 +779,7 @@ def options @@installed_at_exit ||= false @@out = $stdout @@after_tests = [] + @@current_repeat_count = 0 ## # A simple hook allowing you to run a block of code after _all_ of From 14e013cdbbd937ab229a929d8743f271c6f89ab2 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 20 Apr 2020 18:41:03 +0900 Subject: [PATCH 089/234] [ruby/rdoc] Drop old rubies * `RbConfig::CONFIG['ridir']` has been set since 1.9.2 * `ENV["HOME"]` has been defaulted to `USERPROFILE` since 1.9.0, and backported to 1.8.5 or later. https://github.com/ruby/rdoc/commit/a3a614e676 --- lib/rdoc/ri/paths.rb | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/rdoc/ri/paths.rb b/lib/rdoc/ri/paths.rb index f76721d318e34b..b1d584878be6eb 100644 --- a/lib/rdoc/ri/paths.rb +++ b/lib/rdoc/ri/paths.rb @@ -12,23 +12,12 @@ module RDoc::RI::Paths version = RbConfig::CONFIG['ruby_version'] - BASE = if RbConfig::CONFIG.key? 'ridir' then - File.join RbConfig::CONFIG['ridir'], version - else - File.join RbConfig::CONFIG['datadir'], 'ri', version - end + BASE = File.join RbConfig::CONFIG['ridir'], version - homedir = begin - File.expand_path('~') + HOMEDIR = begin + File.expand_path('~/.rdoc') rescue ArgumentError end - - homedir ||= ENV['HOME'] || - ENV['USERPROFILE'] || ENV['HOMEPATH'] # for 1.8 compatibility - - HOMEDIR = if homedir then - File.join homedir, ".rdoc" - end #:startdoc: ## From f563f3c5ef517b62f1a95ab03286335e4fe72314 Mon Sep 17 00:00:00 2001 From: Burdette Lamar Date: Thu, 23 Apr 2020 03:46:20 -0500 Subject: [PATCH 090/234] RDoc enhancements for Hash[]. --- doc/implicit_conversion.rdoc | 198 +++++++++++++++++++++++++++++++++++ hash.c | 76 +++++++++++--- 2 files changed, 262 insertions(+), 12 deletions(-) create mode 100644 doc/implicit_conversion.rdoc diff --git a/doc/implicit_conversion.rdoc b/doc/implicit_conversion.rdoc new file mode 100644 index 00000000000000..fae5973f5c2993 --- /dev/null +++ b/doc/implicit_conversion.rdoc @@ -0,0 +1,198 @@ +== Implicit Conversions + +Some Ruby methods accept one or more objects +that can be either: +* Of a given class, and so accepted as is. +* Implicitly convertible to that class, in which case + the called method converts the object. + +For each of the relevant classes, the conversion is done by calling +a specific conversion method: + +* Array: +to_ary+ +* Hash: +to_hash+ +* Integer: +to_int+ +* String: +to_str+ + +=== Array-Convertible Objects + +An Array-convertible object is an object that: +* Has instance method +to_ary+. +* The method accepts no arguments. +* The method returns an object +obj+ for which obj.kind_of?(Array) returns +true+. + +The examples in this section use method Array#replace, +which accepts an Array-convertible argument. + +This class is Array-convertible: + + class ArrayConvertible + def to_ary + [:foo, 'bar', baz = 2] + end + end + a = [] + a.replace(ArrayConvertible.new) # => [:foo, "bar", 2] + +This class is not Array-convertible (no +to_ary+ method): + + class NotArrayConvertible; end + a = [] + # Raises TypeError (no implicit conversion of NotArrayConvertible into Array) + a.replace(NotArrayConvertible.new) + +This class is not Array-convertible (method +to_ary+ takes arguments): + + class NotArrayConvertible + def to_ary(x) + [:foo, 'bar', baz = 2] + end + end + a = [] + # Raises ArgumentError (wrong number of arguments (given 0, expected 1)) + a.replace(NotArrayConvertible.new) + +This class is not Array-convertible (method +to_ary+ returns non-Array): + + class NotArrayConvertible + def to_ary + :foo + end + end + a = [] + # Raises TypeError (can't convert NotArrayConvertible to Array (NotArrayConvertible#to_ary gives Symbol)) + a.replace(NotArrayConvertible.new) + +=== Hash-Convertible Objects + +A Hash-convertible object is an object that: +* Has instance method +to_hash+. +* The method accepts no arguments. +* The method returns an object +obj+ for which obj.kind_of?(Hash) returns +true+. + +The examples in this section use method Hash#merge, +which accepts a Hash-convertible argument. + +This class is Hash-convertible: + + class HashConvertible + def to_hash + {foo: 0, bar: 1, baz: 2} + end + end + h = {} + h.merge(HashConvertible.new) # => {:foo=>0, :bar=>1, :baz=>2} + +This class is not Hash-convertible (no +to_hash+ method): + + class NotHashConvertible; end + h = {} + # Raises TypeError (no implicit conversion of NotHashConvertible into Hash) + h.merge(NotHashConvertible.new) + +This class is not Hash-convertible (method +to_hash+ takes arguments): + + class NotHashConvertible + def to_hash(x) + {foo: 0, bar: 1, baz: 2} + end + end + h = {} + # Raises ArgumentError (wrong number of arguments (given 0, expected 1)) + h.merge(NotHashConvertible.new) + +This class is not Hash-convertible (method +to_hash+ returns non-Hash): + + class NotHashConvertible + def to_hash + :foo + end + end + h = {} + # Raises TypeError (can't convert NotHashConvertible to Hash (ToHashReturnsNonHash#to_hash gives Symbol)) + h.merge(NotHashConvertible.new) + +=== Integer-Convertible Objects + +An Integer-convertible object is an object that: +* Has instance method +to_int+. +* The method accepts no arguments. +* The method returns an object +obj+ for which obj.kind_of?(Integer) returns +true+. + +The examples in this section use method Array.new, +which accepts an Integer-convertible argument. + +This user-defined class is Integer-convertible: + + class IntegerConvertible + def to_int + 3 + end + end + a = Array.new(IntegerConvertible.new).size + a # => 3 + +This class is not Integer-convertible (method +to_int+ takes arguments): + + class NotIntegerConvertible + def to_int(x) + 3 + end + end + # Raises ArgumentError (wrong number of arguments (given 0, expected 1)) + Array.new(NotIntegerConvertible.new) + +This class is not Integer-convertible (method +to_int+ returns non-Integer): + + class NotIntegerConvertible + def to_int + :foo + end + end + # Raises TypeError (can't convert NotIntegerConvertible to Integer (NotIntegerConvertible#to_int gives Symbol)) + Array.new(NotIntegerConvertible.new) + +=== String-Convertible Objects + +A String-convertible object is an object that: +* Has instance method +to_str+. +* The method accepts no arguments. +* The method returns an object +obj+ for which obj.kind_of?(String) returns +true+. + +The examples in this section use method String::new, +which accepts a String-convertible argument. + +This class is String-convertible: + + class StringConvertible + def to_str + 'foo' + end + end + String.new(StringConvertible.new) # => "foo" + +This class is not String-convertible (no +to_str+ method): + + class NotStringConvertible; end + # Raises TypeError (no implicit conversion of NotStringConvertible into String) + String.new(NotStringConvertible.new) + +This class is not String-convertible (method +to_str+ takes arguments): + + class NotStringConvertible + def to_str(x) + 'foo' + end + end + # Raises ArgumentError (wrong number of arguments (given 0, expected 1)) + String.new(NotStringConvertible.new) + +This class is not String-convertible (method +to_str+ returns non-String): + + class NotStringConvertible + def to_str + :foo + end + end + # Raises TypeError (can't convert NotStringConvertible to String (NotStringConvertible#to_str gives Symbol)) + String.new(NotStringConvertible.new) diff --git a/hash.c b/hash.c index e0f827b80f5e81..ab6dd3ba793698 100644 --- a/hash.c +++ b/hash.c @@ -1810,22 +1810,74 @@ rb_hash_initialize(int argc, VALUE *argv, VALUE hash) /* * call-seq: - * Hash[ key, value, ... ] -> new_hash - * Hash[ [ [key, value], ... ] ] -> new_hash - * Hash[ object ] -> new_hash + * Hash[] -> new_empty_hash + * Hash[ [*2_element_arrays] ] -> new_hash + * Hash[*objects] -> new_hash + * Hash[hash_convertible_object] -> new_hash * - * Creates a new hash populated with the given objects. + * Returns a new \Hash object populated with the given objects, if any. * - * Similar to the literal { _key_ => _value_, ... }. In the first - * form, keys and values occur in pairs, so there must be an even number of - * arguments. + * The initial default value and default proc are set to nil + * (see {Default Values}[#class-Hash-label-Default+Values]): * - * The second and third form take a single argument which is either an array - * of key-value pairs or an object convertible to a hash. + * h = Hash[] + * h # => {} + * h.class # => Hash + * h.default # => nil + * h.default_proc # => nil + * + * When argument [*2_element_arrays] is given, + * each element of the outer array must be a 2-element array; + * returns a new \Hash object wherein each 2-element array forms a key-value entry: + * + * Hash[ [ [:foo, 0], [:bar, 1] ] ] # => {:foo=>0, :bar=>1} + * + * When arguments *objects are given, + * the argument count must be an even number; + * returns a new \Hash object wherein each successive pair of arguments has become a key-value entry: + * + * Hash[] # => {} + * Hash[:foo, 0, :bar, 1] # => {:foo=>0, :bar=>1} + * + * When argument hash_convertible_object is given, + * the argument must be a + * {Hash-convertible object}[doc/implicit_conversion_rdoc.html#label-Hash-Convertible+Objects]; + * converts the object and returns the resulting \Hash object: + * + * class Foo + * def to_hash + * {foo: 0, bar: 1} + * end + * end + * Hash[Foo.new] # => {:foo=>0, :bar=>1} + * + * --- + * + * Raises an exception if the argument count is 1, + * but the argument is not an array of 2-element arrays or a + * {Hash-convertible object}[doc/implicit_conversion_rdoc.html#label-Hash-Convertible+Objects]: + * + * Hash[:foo] # Raises ArgumentError (odd number of arguments + * Hash[ [ [:foo, 0, 1] ] ] # Raises ArgumentError (invalid number of elements (3 for 1..2)) + * + * Raises an exception if the argument count is odd and greater than 1: + * + * Hash[0, 1, 2] # Raises ArgumentError (odd number of arguments for Hash) + * + * Raises an exception if the argument is an array containing an element + * that is not a 2-element array: + * + * Hash[ [ :foo ] ] # Raises ArgumentError (wrong element type Symbol at 0 (expected array)) + * + * Raises an exception if the argument is an array containing an element + * that is an array of size different from 2: + * + * Hash[ [ [0, 1, 2] ] ] # Raises ArgumentError (invalid number of elements (3 for 1..2)) + * + * Raises an exception if any proposed key is not a valid key: * - * Hash["a", 100, "b", 200] #=> {"a"=>100, "b"=>200} - * Hash[ [ ["a", 100], ["b", 200] ] ] #=> {"a"=>100, "b"=>200} - * Hash["a" => 100, "b" => 200] #=> {"a"=>100, "b"=>200} + * Hash[:foo, 0, BasicObject.new, 1] # Raises NoMethodError (undefined method `hash' for #) + * Hash[ [ [:foo, 0], [BasicObject.new, 1] ] ] # Raises NoMethodError (undefined method `hash' for #) */ static VALUE From 5c6269c4593f8b1a83b72e157c460dd2b37338c7 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 23 Apr 2020 19:16:06 +0900 Subject: [PATCH 091/234] Support XDG_* (#2174) * Support XDG_CONFIG_HOME for gemrc. * Support XDG_DATA_HOME for .gem * Added test for XDG_DATA_HOME * Do not reuse environmental variable. * Unify .rdoc path to RDoc.home. * Support XDG_DATA_HOME for .rdoc * Ignore exists? * Extracted config_home path * Use XDG_CONFIG_HOME for default credential path * Fixed inconsistency location. * Fixed the broken tests. * Support XDG_CONFIG_HOME for irbrc * Introduce Gem.cache_home as XDG_CACHE_HOME * Use Gem.cache_home instead of Gem.config_home for the credential file of RubyGems. * Initialized the old configurations * Fixed test failure related the configuration initialization * restore XDG_DATA_HOME * Fixed the broken examples of bundler with XDG_* * Do not modify environmental variable on test file * Use XDG_DATA_HOME insted of XDG_CACHE_HOME for credential file * stub out Gem.data_home * Move dir accessor to defaults.rb file * Use XDG_DATA_HOME for signed gem features * Use XDG_DATA_HOME for spec cache * Do not rely on Gem.user_home * Gem.user_home is always exists. Don't need to use FileUitls.mkdir_p * Bump support version to RubyGems 3.2.0+ * Removed the needless fallback configuration * Fixed the inconsistency methods that are find_config_file and config_file * Use Gem.configuration.credentials_path instead of hard-coded path * gem_path is always provided * Removed the duplicated code of find_home * Also removed the duplicated code of user_home * use Gem::UNTAINT instead of untaint for surpressing the warnings * Use File.directory * Restore XDG_DATA_HOME * Use File.write --- lib/irb/init.rb | 9 ++ lib/rdoc.rb | 18 ++++ lib/rdoc/ri/paths.rb | 5 +- lib/rdoc/store.rb | 2 +- lib/rubygems.rb | 41 ------- lib/rubygems/config_file.rb | 11 +- lib/rubygems/defaults.rb | 102 +++++++++++++++++- lib/rubygems/gemcutter_utilities.rb | 2 +- lib/rubygems/test_case.rb | 7 ++ spec/bundler/bundler/env_spec.rb | 10 +- spec/bundler/bundler/friendly_errors_spec.rb | 9 +- test/rdoc/test_rdoc_ri_driver.rb | 22 ++-- test/rdoc/test_rdoc_store.rb | 7 +- test/rubygems/test_gem.rb | 2 + .../test_gem_commands_build_command.rb | 2 - .../test_gem_commands_cert_command.rb | 4 - .../test_gem_commands_signout_command.rb | 1 + test/rubygems/test_gem_config_file.rb | 4 +- test/rubygems/test_gem_source.rb | 2 +- test/rubygems/test_gem_spec_fetcher.rb | 2 +- 20 files changed, 186 insertions(+), 76 deletions(-) diff --git a/lib/irb/init.rb b/lib/irb/init.rb index 37d1f8d6091041..da40bee5e19f9c 100644 --- a/lib/irb/init.rb +++ b/lib/irb/init.rb @@ -271,10 +271,19 @@ def IRB.rc_file_generators if irbrc = ENV["IRBRC"] yield proc{|rc| rc == "rc" ? irbrc : irbrc+rc} end + if xdg_config_home = ENV["XDG_CONFIG_HOME"] + irb_home = File.join(xdg_config_home, "irb") + unless File.exist? irb_home + require 'fileutils' + FileUtils.mkdir_p irb_home + end + yield proc{|rc| irb_home + "/irb#{rc}"} + end if home = ENV["HOME"] yield proc{|rc| home+"/.irb#{rc}"} end current_dir = Dir.pwd + yield proc{|rc| current_dir+"/.config/irb/irb#{rc}"} yield proc{|rc| current_dir+"/.irb#{rc}"} yield proc{|rc| current_dir+"/irb#{rc.sub(/\A_?/, '.')}"} yield proc{|rc| current_dir+"/_irb#{rc}"} diff --git a/lib/rdoc.rb b/lib/rdoc.rb index fc8ad9e1445e08..a05391d769bed6 100644 --- a/lib/rdoc.rb +++ b/lib/rdoc.rb @@ -120,6 +120,24 @@ def self.load_yaml end end + def self.home + rdoc_dir = begin + File.expand_path('~/.rdoc') + rescue ArgumentError + end + + if File.directory?(rdoc_dir) + rdoc_dir + else + # XDG + xdg_data_home = ENV["XDG_DATA_HOME"] || File.join(File.expand_path("~"), '.local', 'share') + unless File.exist?(xdg_data_home) + FileUtils.mkdir_p xdg_data_home + end + File.join xdg_data_home, "rdoc" + end + end + autoload :RDoc, 'rdoc/rdoc' autoload :CrossReference, 'rdoc/cross_reference' diff --git a/lib/rdoc/ri/paths.rb b/lib/rdoc/ri/paths.rb index b1d584878be6eb..7891d1e0acc793 100644 --- a/lib/rdoc/ri/paths.rb +++ b/lib/rdoc/ri/paths.rb @@ -14,10 +14,7 @@ module RDoc::RI::Paths BASE = File.join RbConfig::CONFIG['ridir'], version - HOMEDIR = begin - File.expand_path('~/.rdoc') - rescue ArgumentError - end + HOMEDIR = RDoc.home #:startdoc: ## diff --git a/lib/rdoc/store.rb b/lib/rdoc/store.rb index 0f6cd06e3cf598..05d8383c86dbf8 100644 --- a/lib/rdoc/store.rb +++ b/lib/rdoc/store.rb @@ -482,7 +482,7 @@ def friendly_path when :gem then parent = File.expand_path '..', @path "gem #{File.basename parent}" - when :home then '~/.rdoc' + when :home then RDoc.home when :site then 'ruby site' when :system then 'ruby core' else @path diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 73321ec47bfbe2..5026fc41e6933c 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -337,13 +337,6 @@ def self.clear_paths Gem::Security.reset if defined?(Gem::Security) end - ## - # The path to standard location of the user's .gemrc file. - - def self.config_file - @config_file ||= File.join Gem.user_home, '.gemrc' - end - ## # The standard configuration object for gems. @@ -557,33 +550,6 @@ def self.find_latest_files(glob, check_load_path=true) return files end - ## - # Finds the user's home directory. - #-- - # Some comments from the ruby-talk list regarding finding the home - # directory: - # - # I have HOME, USERPROFILE and HOMEDRIVE + HOMEPATH. Ruby seems - # to be depending on HOME in those code samples. I propose that - # it should fallback to USERPROFILE and HOMEDRIVE + HOMEPATH (at - # least on Win32). - #++ - #-- - # - #++ - - def self.find_home - Dir.home.dup - rescue - if Gem.win_platform? - File.expand_path File.join(ENV['HOMEDRIVE'] || ENV['SystemDrive'], '/') - else - File.expand_path "/" - end - end - - private_class_method :find_home - ## # Top level install helper method. Allows you to install gems interactively: # @@ -1056,13 +1022,6 @@ def self.use_paths(home, *paths) self.paths = hash end - ## - # The home directory for the user. - - def self.user_home - @user_home ||= find_home.tap(&Gem::UNTAINT) - end - ## # Is this a windows platform? diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb index 54d8a9c152a439..393f947d776ce0 100644 --- a/lib/rubygems/config_file.rb +++ b/lib/rubygems/config_file.rb @@ -261,7 +261,12 @@ def check_credentials_permissions # Location of RubyGems.org credentials def credentials_path - File.join Gem.user_home, '.gem', 'credentials' + credentials = File.join Gem.user_home, '.gem', 'credentials' + if File.exist? credentials + credentials + else + File.join Gem.data_home, "gem", "credentials" + end end def load_api_keys @@ -444,6 +449,10 @@ def to_yaml # :nodoc: # Writes out this config file, replacing its source. def write + unless File.exist?(File.dirname(config_file_name)) + FileUtils.mkdir_p File.dirname(config_file_name) + end + File.open config_file_name, 'w' do |io| io.write to_yaml end diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb index 0e83f1b006de09..2d0b077fdca976 100644 --- a/lib/rubygems/defaults.rb +++ b/lib/rubygems/defaults.rb @@ -20,7 +20,13 @@ def self.default_sources # specified in the environment def self.default_spec_cache_dir - File.join Gem.user_home, '.gem', 'specs' + default_spec_cache_dir = File.join Gem.user_home, '.gem', 'specs' + + unless File.exist?(default_spec_cache_dir) + default_spec_cache_dir = File.join Gem.data_home, 'gem', 'specs' + end + + default_spec_cache_dir end ## @@ -70,15 +76,91 @@ def self.default_specifications_dir File.join(Gem.default_dir, "specifications", "default") end + ## + # Finds the user's home directory. + #-- + # Some comments from the ruby-talk list regarding finding the home + # directory: + # + # I have HOME, USERPROFILE and HOMEDRIVE + HOMEPATH. Ruby seems + # to be depending on HOME in those code samples. I propose that + # it should fallback to USERPROFILE and HOMEDRIVE + HOMEPATH (at + # least on Win32). + #++ + #-- + # + #++ + + def self.find_home + Dir.home.dup + rescue + if Gem.win_platform? + File.expand_path File.join(ENV['HOMEDRIVE'] || ENV['SystemDrive'], '/') + else + File.expand_path "/" + end + end + + private_class_method :find_home + + ## + # The home directory for the user. + + def self.user_home + @user_home ||= find_home.tap(&Gem::UNTAINT) + end + ## # Path for gems in the user's home directory def self.user_dir - parts = [Gem.user_home, '.gem', ruby_engine] + gem_dir = File.join(Gem.user_home, ".gem") + gem_dir = File.join(Gem.data_home, "gem") unless File.exist?(gem_dir) + parts = [gem_dir, ruby_engine] parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? File.join parts end + ## + # The path to standard location of the user's configuration directory. + + def self.config_home + @config_home ||= (ENV["XDG_CONFIG_HOME"] || File.join(Gem.user_home, '.config')) + end + + ## + # Finds the user's config file + + def self.find_config_file + gemrc = File.join Gem.user_home, '.gemrc' + if File.exist? gemrc + gemrc + else + File.join Gem.config_home, "gem", "gemrc" + end + end + + ## + # The path to standard location of the user's .gemrc file. + + def self.config_file + @config_file ||= find_config_file.tap(&Gem::UNTAINT) + end + + ## + # The path to standard location of the user's cache directory. + + def self.cache_home + @cache_home ||= (ENV["XDG_CACHE_HOME"] || File.join(Gem.user_home, '.cache')) + end + + ## + # The path to standard location of the user's data directory. + + def self.data_home + @data_home ||= (ENV["XDG_DATA_HOME"] || File.join(Gem.user_home, '.local', 'share')) + end + ## # How String Gem paths should be split. Overridable for esoteric platforms. @@ -130,14 +212,26 @@ def self.ruby_engine # The default signing key path def self.default_key_path - File.join Gem.user_home, ".gem", "gem-private_key.pem" + default_key_path = File.join Gem.user_home, ".gem", "gem-private_key.pem" + + unless File.exist?(default_key_path) + default_key_path = File.join Gem.data_home, "gem", "gem-private_key.pem" + end + + default_key_path end ## # The default signing certificate chain path def self.default_cert_path - File.join Gem.user_home, ".gem", "gem-public_cert.pem" + default_cert_path = File.join Gem.user_home, ".gem", "gem-public_cert.pem" + + unless File.exist?(default_cert_path) + default_cert_path = File.join Gem.data_home, "gem", "gem-public_cert.pem" + end + + default_cert_path end ## diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb index 2950d94dc12077..bba92806918dc0 100644 --- a/lib/rubygems/gemcutter_utilities.rb +++ b/lib/rubygems/gemcutter_utilities.rb @@ -19,7 +19,7 @@ module Gem::GemcutterUtilities def add_key_option add_option('-k', '--key KEYNAME', Symbol, 'Use the given API key', - 'from ~/.gem/credentials') do |value,options| + "from #{Gem.configuration.credentials_path}") do |value,options| options[:key] = value end end diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index e56150caf9f240..d02825446580f3 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -363,6 +363,13 @@ def setup Dir.chdir @tempdir ENV['HOME'] = @userhome + FileUtils.mkdir_p File.join(@userhome, ".gem") + File.write File.join(@userhome, ".gemrc"), "--- {}" + temp_cred = File.join(@userhome, '.gem', 'credentials') + FileUtils.mkdir_p File.dirname(temp_cred) + File.write temp_cred, ':rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97' + File.chmod 0600, temp_cred + Gem.instance_variable_set :@user_home, nil Gem.instance_variable_set :@gemdeps, nil Gem.instance_variable_set :@env_requirements_by_name, nil diff --git a/spec/bundler/bundler/env_spec.rb b/spec/bundler/bundler/env_spec.rb index 7686fe386a8397..9631a109bd706b 100644 --- a/spec/bundler/bundler/env_spec.rb +++ b/spec/bundler/bundler/env_spec.rb @@ -41,9 +41,15 @@ end it "prints user path" do - with_clear_paths("HOME", "/a/b/c") do + if Gem::VERSION >= "3.2.0.pre.1" + allow(Gem).to receive(:data_home) { "/a/b/c/.local/share" } out = described_class.report - expect(out).to include("User Path /a/b/c/.gem") + expect(out).to include("User Path /a/b/c/.local/share/gem") + else + with_clear_paths("HOME", "/a/b/c") do + out = described_class.report + expect(out).to include("User Path /a/b/c/.gem") + end end end diff --git a/spec/bundler/bundler/friendly_errors_spec.rb b/spec/bundler/bundler/friendly_errors_spec.rb index e9189b0514148b..8df653c0f14f1a 100644 --- a/spec/bundler/bundler/friendly_errors_spec.rb +++ b/spec/bundler/bundler/friendly_errors_spec.rb @@ -6,7 +6,10 @@ RSpec.describe Bundler, "friendly errors" do context "with invalid YAML in .gemrc" do + let(:config_home) { File.dirname(Gem.configuration.config_file_name) } + before do + FileUtils.mkdir_p config_home File.open(Gem.configuration.config_file_name, "w") do |f| f.write "invalid: yaml: hah" end @@ -24,7 +27,11 @@ bundle :install, :env => { "DEBUG" => "true" } - expect(err).to include("Failed to load #{home(".gemrc")}") + if Gem::VERSION >= "3.2.0.pre.1" + expect(err).to include("Failed to load #{File.join(config_home, "gemrc")}") + else + expect(err).to include("Failed to load #{home(".gemrc")}") + end expect(exitstatus).to eq(0) if exitstatus end end diff --git a/test/rdoc/test_rdoc_ri_driver.rb b/test/rdoc/test_rdoc_ri_driver.rb index 6f17fecec919ba..1a8ac3dde536d7 100644 --- a/test/rdoc/test_rdoc_ri_driver.rb +++ b/test/rdoc/test_rdoc_ri_driver.rb @@ -15,6 +15,8 @@ def setup @orig_ri = ENV['RI'] @orig_home = ENV['HOME'] ENV['HOME'] = @tmpdir + @rdoc_home = File.join ENV["HOME"], ".rdoc" + FileUtils.mkdir_p @rdoc_home ENV.delete 'RI' @options = RDoc::RI::Driver.default_options @@ -81,7 +83,7 @@ def test_add_also_in @RM::Rule.new(1), @RM::Paragraph.new('Also found in:'), @RM::Verbatim.new("ruby core", "\n", - "~/.rdoc", "\n")) + @rdoc_home, "\n")) assert_equal expected, out end @@ -231,7 +233,7 @@ def test_add_method doc( head(1, 'Foo::Bar#blah'), blank_line, - para('(from ~/.rdoc)'), + para("(from #{@rdoc_home})"), head(3, 'Implementation from Bar'), rule(1), verb("blah(5) => 5\n", @@ -254,7 +256,7 @@ def test_add_method_that_is_alias_for_original doc( head(1, 'Qux#aliased'), blank_line, - para('(from ~/.rdoc)'), + para("(from #{@rdoc_home})"), rule(1), blank_line, para('alias comment'), @@ -280,7 +282,7 @@ def test_add_method_attribute doc( head(1, 'Foo::Bar#attr'), blank_line, - para('(from ~/.rdoc)'), + para("(from #{@rdoc_home})"), rule(1), blank_line, blank_line) @@ -299,7 +301,7 @@ def test_add_method_inherited doc( head(1, 'Bar#inherit'), blank_line, - para('(from ~/.rdoc)'), + para("(from #{@rdoc_home})"), head(3, 'Implementation from Foo'), rule(1), blank_line, @@ -343,13 +345,13 @@ def test_add_method_documentation doc( head(1, 'Foo#inherit'), blank_line, - para('(from ~/.rdoc)'), + para("(from #{@rdoc_home})"), rule(1), blank_line, blank_line, head(1, 'Foo#override'), blank_line, - para('(from ~/.rdoc)'), + para("(from #{@rdoc_home})"), rule(1), blank_line, para('must not be displayed in Bar#override'), @@ -802,7 +804,7 @@ def test_display_page_ambiguous @driver.display_page 'home:README' end - assert_match %r%= README pages in ~/\.rdoc%, out + assert_match %r%= README pages in #{@rdoc_home}%, out assert_match %r%README\.rdoc%, out assert_match %r%README\.md%, out end @@ -856,7 +858,7 @@ def test_display_page_missing @driver.display_page_list @store1 end - assert_match %r%= Pages in ~/\.rdoc%, out + assert_match %r%= Pages in #{@rdoc_home}%, out assert_match %r%README\.rdoc%, out end @@ -876,7 +878,7 @@ def test_display_page_list @driver.display_page_list @store1 end - assert_match %r%= Pages in ~/\.rdoc%, out + assert_match %r%= Pages in #{@rdoc_home}%, out assert_match %r%README\.rdoc%, out assert_match %r%OTHER\.rdoc%, out end diff --git a/test/rdoc/test_rdoc_store.rb b/test/rdoc/test_rdoc_store.rb index 8332d9233ed911..076b8e7d4e4ba3 100644 --- a/test/rdoc/test_rdoc_store.rb +++ b/test/rdoc/test_rdoc_store.rb @@ -317,6 +317,9 @@ def test_find_text_page end def test_friendly_path + @orig_xdg_data_home = ENV['XDG_DATA_HOME'] + ENV.delete('XDG_DATA_HOME') + @s.path = @tmpdir @s.type = nil assert_equal @s.path, @s.friendly_path @@ -331,11 +334,13 @@ def test_friendly_path assert_equal "ruby site", @s.friendly_path @s.type = :home - assert_equal "~/.rdoc", @s.friendly_path + assert_equal File.expand_path("~/.local/share/rdoc"), @s.friendly_path @s.type = :gem @s.path = "#{@tmpdir}/gem_repository/doc/gem_name-1.0/ri" assert_equal "gem gem_name-1.0", @s.friendly_path + ensure + ENV['XDG_DATA_HOME'] = @orig_xdg_data_home end def test_dry_run diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index 1f5e0e6768dbfb..5f70a2ac6b1c3a 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -1359,6 +1359,8 @@ def test_self_user_dir parts = [@userhome, '.gem', Gem.ruby_engine] parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? + FileUtils.mkdir_p File.join(parts) + assert_equal File.join(parts), Gem.user_dir end diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb index a2e8f284eb2393..ca9f8b66c9f548 100644 --- a/test/rubygems/test_gem_commands_build_command.rb +++ b/test/rubygems/test_gem_commands_build_command.rb @@ -376,7 +376,6 @@ def test_build_signed_gem_with_cert_expiration_length_days skip 'openssl is missing' unless defined?(OpenSSL::SSL) && !java_platform? gem_path = File.join Gem.user_home, ".gem" - Dir.mkdir gem_path Gem::Security.trust_dir @@ -420,7 +419,6 @@ def test_build_auto_resign_cert skip 'openssl is missing' unless defined?(OpenSSL::SSL) && !java_platform? gem_path = File.join Gem.user_home, ".gem" - Dir.mkdir gem_path Gem::Security.trust_dir diff --git a/test/rubygems/test_gem_commands_cert_command.rb b/test/rubygems/test_gem_commands_cert_command.rb index fd1e66b915d9e5..bb9ed9e630ba33 100644 --- a/test/rubygems/test_gem_commands_cert_command.rb +++ b/test/rubygems/test_gem_commands_cert_command.rb @@ -597,7 +597,6 @@ def test_execute_sign_no_key def test_execute_re_sign gem_path = File.join Gem.user_home, ".gem" - Dir.mkdir gem_path path = File.join @tempdir, 'cert.pem' Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0600 @@ -628,9 +627,6 @@ def test_execute_re_sign end def test_execute_re_sign_with_cert_expiration_length_days - gem_path = File.join Gem.user_home, ".gem" - Dir.mkdir gem_path - path = File.join @tempdir, 'cert.pem' Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0600 diff --git a/test/rubygems/test_gem_commands_signout_command.rb b/test/rubygems/test_gem_commands_signout_command.rb index 814b55cf4f2803..9a47dafe7cd6f0 100644 --- a/test/rubygems/test_gem_commands_signout_command.rb +++ b/test/rubygems/test_gem_commands_signout_command.rb @@ -8,6 +8,7 @@ class TestGemCommandsSignoutCommand < Gem::TestCase def setup super + File.delete Gem.configuration.credentials_path if File.exist?(Gem.configuration.credentials_path) @cmd = Gem::Commands::SignoutCommand.new end diff --git a/test/rubygems/test_gem_config_file.rb b/test/rubygems/test_gem_config_file.rb index 260a94953e3acc..d31d55eba1270b 100644 --- a/test/rubygems/test_gem_config_file.rb +++ b/test/rubygems/test_gem_config_file.rb @@ -170,7 +170,7 @@ def test_api_keys assert_nil @cfg.instance_variable_get :@api_keys temp_cred = File.join Gem.user_home, '.gem', 'credentials' - FileUtils.mkdir File.dirname(temp_cred) + FileUtils.mkdir_p File.dirname(temp_cred) File.open temp_cred, 'w', 0600 do |fp| fp.puts ':rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97' end @@ -296,7 +296,7 @@ def test_handle_arguments_norc def test_load_api_keys temp_cred = File.join Gem.user_home, '.gem', 'credentials' - FileUtils.mkdir File.dirname(temp_cred) + FileUtils.mkdir_p File.dirname(temp_cred) File.open temp_cred, 'w', 0600 do |fp| fp.puts ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97" fp.puts ":other: a5fdbb6ba150cbb83aad2bb2fede64c" diff --git a/test/rubygems/test_gem_source.rb b/test/rubygems/test_gem_source.rb index 05e443c7f1b672..24b8edb055e156 100644 --- a/test/rubygems/test_gem_source.rb +++ b/test/rubygems/test_gem_source.rb @@ -230,7 +230,7 @@ def test_update_cache_eh end def test_update_cache_eh_home_nonexistent - FileUtils.rmdir Gem.user_home + FileUtils.rm_rf Gem.user_home refute @source.update_cache? end diff --git a/test/rubygems/test_gem_spec_fetcher.rb b/test/rubygems/test_gem_spec_fetcher.rb index b7547112bbd020..d1633c4e3cc225 100644 --- a/test/rubygems/test_gem_spec_fetcher.rb +++ b/test/rubygems/test_gem_spec_fetcher.rb @@ -33,7 +33,7 @@ def test_initialize_source end def test_initialize_nonexistent_home_dir - FileUtils.rmdir Gem.user_home + FileUtils.rm_rf Gem.user_home assert Gem::SpecFetcher.new end From 03e4eeabbf3bbb5a467956920705bf346d790efa Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 23 Apr 2020 21:11:21 +0900 Subject: [PATCH 092/234] Skip the initialization of XDG_DATA_HOME with Permission denied --- lib/rdoc.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/rdoc.rb b/lib/rdoc.rb index a05391d769bed6..2d3f8c1122451d 100644 --- a/lib/rdoc.rb +++ b/lib/rdoc.rb @@ -129,12 +129,15 @@ def self.home if File.directory?(rdoc_dir) rdoc_dir else - # XDG - xdg_data_home = ENV["XDG_DATA_HOME"] || File.join(File.expand_path("~"), '.local', 'share') - unless File.exist?(xdg_data_home) - FileUtils.mkdir_p xdg_data_home + begin + # XDG + xdg_data_home = ENV["XDG_DATA_HOME"] || File.join(File.expand_path("~"), '.local', 'share') + unless File.exist?(xdg_data_home) + FileUtils.mkdir_p xdg_data_home + end + File.join xdg_data_home, "rdoc" + rescue Errno::EACCES end - File.join xdg_data_home, "rdoc" end end From a52a459b16ce1b5cf32cb6393960ff59e35c48d0 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 23 Apr 2020 20:17:24 +0900 Subject: [PATCH 093/234] Truncate too long thread name before setting [Bug #16808] --- thread_pthread.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/thread_pthread.c b/thread_pthread.c index b9ac63f298cb91..6bcb18d89bef6a 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1572,6 +1572,15 @@ setup_communication_pipe_internal(int pipes[2]) # define SET_CURRENT_THREAD_NAME(name) prctl(PR_SET_NAME, name) #endif +#if defined(__linux__) +static const size_t thread_name_max = 16; +#elif defined(__APPLE__) +/* Undocumented, and main thread seems unlimited */ +static const size_t thread_name_max = 64; +#else +static const size_t thread_name_max = 16; +#endif + static VALUE threadptr_invoke_proc_location(rb_thread_t *th); static void @@ -1584,14 +1593,14 @@ native_set_thread_name(rb_thread_t *th) } else if ((loc = threadptr_invoke_proc_location(th)) != Qnil) { char *name, *p; - char buf[16]; + char buf[thread_name_max]; size_t len; int n; name = RSTRING_PTR(RARRAY_AREF(loc, 0)); p = strrchr(name, '/'); /* show only the basename of the path. */ if (p && p[1]) - name = p + 1; + name = p + 1; n = snprintf(buf, sizeof(buf), "%s:%d", name, NUM2INT(RARRAY_AREF(loc, 1))); rb_gc_force_recycle(loc); /* acts as a GC guard, too */ @@ -1606,15 +1615,30 @@ native_set_thread_name(rb_thread_t *th) #endif } -static VALUE +static void native_set_another_thread_name(rb_nativethread_id_t thread_id, VALUE name) { -#ifdef SET_ANOTHER_THREAD_NAME +#if defined SET_ANOTHER_THREAD_NAME || defined SET_CURRENT_THREAD_NAME + char buf[thread_name_max]; const char *s = ""; - if (!NIL_P(name)) s = RSTRING_PTR(name); +# if !defined SET_ANOTHER_THREAD_NAME + if (pthread_equal(pthread_self(), thread_id)) return; +# endif + if (!NIL_P(name)) { + long n; + RSTRING_GETMEM(name, s, n); + if (n >= (int)sizeof(buf)) { + memcpy(buf, s, sizeof(buf)-1); + buf[sizeof(buf)-1] = '\0'; + s = buf; + } + } +# if defined SET_ANOTHER_THREAD_NAME SET_ANOTHER_THREAD_NAME(thread_id, s); +# elif defined SET_CURRENT_THREAD_NAME + SET_CURRENT_THREAD_NAME(s); +# endif #endif - return name; } static void From 0f5ae7a200673d38d035e7d3165f5441fe0d49a7 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 23 Apr 2020 22:19:28 +0900 Subject: [PATCH 094/234] Fixed inverted current thread condition [Bug #16808] --- thread_pthread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thread_pthread.c b/thread_pthread.c index 6bcb18d89bef6a..f5eebf5b58104e 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1622,7 +1622,7 @@ native_set_another_thread_name(rb_nativethread_id_t thread_id, VALUE name) char buf[thread_name_max]; const char *s = ""; # if !defined SET_ANOTHER_THREAD_NAME - if (pthread_equal(pthread_self(), thread_id)) return; + if (!pthread_equal(pthread_self(), thread_id)) return; # endif if (!NIL_P(name)) { long n; From ac2106acc276854ae2ac8cc5fa6859aa28362f2f Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 24 Apr 2020 11:06:52 +0900 Subject: [PATCH 095/234] [DOC] Fixed explanation for Method#>> [Bug #16813] [ci skip] --- proc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proc.c b/proc.c index 50ebdbde6703a6..e92746915e4289 100644 --- a/proc.c +++ b/proc.c @@ -3530,8 +3530,8 @@ rb_method_compose_to_left(VALUE self, VALUE g) * meth >> g -> a_proc * * Returns a proc that is the composition of this method and the given g. - * The returned proc takes a variable number of arguments, calls g with them - * then calls this method with the result. + * The returned proc takes a variable number of arguments, calls this method + * with them then calls g with the result. * * def f(x) * x * x From cf90df22c74da2f87421749e8d065cfbd3812afd Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 24 Apr 2020 11:10:44 +0900 Subject: [PATCH 096/234] [DOC] Separated Method#[] from Method#call [Bug #16813] [ci skip] --- proc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/proc.c b/proc.c index e92746915e4289..38d4fc6bf73e6d 100644 --- a/proc.c +++ b/proc.c @@ -2271,10 +2271,22 @@ method_clone(VALUE self) */ +/* Document-method: Method#[] + * + * call-seq: + * meth[args, ...] -> obj + * + * Invokes the meth with the specified arguments, returning the + * method's return value, like #call. + * + * m = 12.method("+") + * m[3] #=> 15 + * m[20] #=> 32 + */ + /* * call-seq: * meth.call(args, ...) -> obj - * meth[args, ...] -> obj * * Invokes the meth with the specified arguments, returning the * method's return value. From 71f84018b7fada5c32dfc384f856b6099cc0da6e Mon Sep 17 00:00:00 2001 From: git Date: Fri, 24 Apr 2020 12:23:01 +0900 Subject: [PATCH 097/234] * 2020-04-24 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 4dd662cfd4a911..fce46be583e5cf 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 23 +#define RUBY_RELEASE_DAY 24 #include "ruby/version.h" From 81b0b7919718bf7f8a6bd9590651b62279977327 Mon Sep 17 00:00:00 2001 From: aycabta Date: Tue, 21 Apr 2020 18:17:27 +0900 Subject: [PATCH 098/234] [ruby/reline] Support XDG_CONFIG_HOME In the XDG Specification, if ~/.config/readline/inputrc exists, then ~/.inputrc should not be read, but for compatibility with GNU Readline, if ~/.inputrc exists, then it is given priority. https://github.com/ruby/reline/commit/97f1e7db04 --- lib/reline/config.rb | 22 +++++++++++++++++----- test/reline/test_config.rb | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/lib/reline/config.rb b/lib/reline/config.rb index 53b868fd2e7fd5..0e5488eefb8b20 100644 --- a/lib/reline/config.rb +++ b/lib/reline/config.rb @@ -3,8 +3,6 @@ class Reline::Config attr_reader :test_mode - DEFAULT_PATH = '~/.inputrc' - KEYSEQ_PATTERN = /\\(?:C|Control)-[A-Za-z_]|\\(?:M|Meta)-[0-9A-Za-z_]|\\(?:C|Control)-(?:M|Meta)-[A-Za-z_]|\\(?:M|Meta)-(?:C|Control)-[A-Za-z_]|\\e|\\[\\\"\'abdfnrtv]|\\\d{1,3}|\\x\h{1,2}|./ class InvalidInputrc < RuntimeError @@ -86,14 +84,28 @@ def keymap def inputrc_path case ENV['INPUTRC'] when nil, '' - DEFAULT_PATH else - ENV['INPUTRC'] + return File.expand_path(ENV['INPUTRC']) + end + + # In the XDG Specification, if ~/.config/readline/inputrc exists, then + # ~/.inputrc should not be read, but for compatibility with GNU Readline, + # if ~/.inputrc exists, then it is given priority. + path = File.expand_path('~/.inputrc') + return path if File.exist?(path) + + case ENV['XDG_CONFIG_HOME'] + when nil, '' + path = File.expand_path('~/.config/readline/inputrc') + return path if File.exist?(path) + else + path = File.expand_path("#{ENV['XDG_CONFIG_HOME']}/readline/inputrc") + return path if File.exist?(path) end end def read(file = nil) - file ||= File.expand_path(inputrc_path) + file ||= inputrc_path begin if file.respond_to?(:readlines) lines = file.readlines diff --git a/test/reline/test_config.rb b/test/reline/test_config.rb index cecb364f898bad..c1a4a46ecf12d3 100644 --- a/test/reline/test_config.rb +++ b/test/reline/test_config.rb @@ -215,4 +215,42 @@ def test_empty_inputrc_env end ENV['INPUTRC'] = inputrc_backup end + + def test_inputrc + inputrc_backup = ENV['INPUTRC'] + expected = "#{@tmpdir}/abcde" + ENV['INPUTRC'] = expected + assert_equal expected, @config.inputrc_path + ENV['INPUTRC'] = inputrc_backup + end + + def test_xdg_config_home + home_backup = ENV['HOME'] + xdg_config_home_backup = ENV['XDG_CONFIG_HOME'] + nonexistence_dir = '/the_nonexistence_dir!!!!!!' + xdg_config_home = File.expand_path("#{@tmpdir}/.config/example_dir") + expected = File.expand_path("#{xdg_config_home}/readline/inputrc") + FileUtils.mkdir_p(File.dirname(expected)) + FileUtils.touch(expected) + ENV['HOME'] = nonexistence_dir + ENV['XDG_CONFIG_HOME'] = xdg_config_home + assert_equal expected, @config.inputrc_path + FileUtils.rm(expected) + ENV['XDG_CONFIG_HOME'] = xdg_config_home_backup + ENV['HOME'] = home_backup + end + + def test_empty_xdg_config_home + home_backup = ENV['HOME'] + xdg_config_home_backup = ENV['XDG_CONFIG_HOME'] + ENV['HOME'] = @tmpdir + ENV['XDG_CONFIG_HOME'] = '' + expected = File.expand_path('~/.config/readline/inputrc') + FileUtils.mkdir_p(File.dirname(expected)) + FileUtils.touch(expected) + assert_equal expected, @config.inputrc_path + FileUtils.rm(expected) + ENV['XDG_CONFIG_HOME'] = xdg_config_home_backup + ENV['HOME'] = home_backup + end end From 9fb20711fd4c4c452b1b7391a8ca86a4d82f6b90 Mon Sep 17 00:00:00 2001 From: aycabta Date: Fri, 24 Apr 2020 03:10:41 +0900 Subject: [PATCH 099/234] [ruby/reline] Treat home dir correctly https://github.com/ruby/reline/commit/9b1327d2f4 --- lib/reline/config.rb | 6 ++++-- test/reline/test_config.rb | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/reline/config.rb b/lib/reline/config.rb index 0e5488eefb8b20..b299bcc9cd798b 100644 --- a/lib/reline/config.rb +++ b/lib/reline/config.rb @@ -91,8 +91,8 @@ def inputrc_path # In the XDG Specification, if ~/.config/readline/inputrc exists, then # ~/.inputrc should not be read, but for compatibility with GNU Readline, # if ~/.inputrc exists, then it is given priority. - path = File.expand_path('~/.inputrc') - return path if File.exist?(path) + home_rc_path = File.expand_path('~/.inputrc') + return home_rc_path if File.exist?(home_rc_path) case ENV['XDG_CONFIG_HOME'] when nil, '' @@ -102,6 +102,8 @@ def inputrc_path path = File.expand_path("#{ENV['XDG_CONFIG_HOME']}/readline/inputrc") return path if File.exist?(path) end + + return home_rc_path end def read(file = nil) diff --git a/test/reline/test_config.rb b/test/reline/test_config.rb index c1a4a46ecf12d3..bf980a2c9863b1 100644 --- a/test/reline/test_config.rb +++ b/test/reline/test_config.rb @@ -227,12 +227,11 @@ def test_inputrc def test_xdg_config_home home_backup = ENV['HOME'] xdg_config_home_backup = ENV['XDG_CONFIG_HOME'] - nonexistence_dir = '/the_nonexistence_dir!!!!!!' xdg_config_home = File.expand_path("#{@tmpdir}/.config/example_dir") expected = File.expand_path("#{xdg_config_home}/readline/inputrc") FileUtils.mkdir_p(File.dirname(expected)) FileUtils.touch(expected) - ENV['HOME'] = nonexistence_dir + ENV['HOME'] = @tmpdir ENV['XDG_CONFIG_HOME'] = xdg_config_home assert_equal expected, @config.inputrc_path FileUtils.rm(expected) From 04a55763fac6c7ec5765733760a67483e013eea9 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 24 Apr 2020 18:13:24 +0900 Subject: [PATCH 100/234] [DOC] Split "How to run a part of the test suite" [ci skip] --- doc/make_cheatsheet.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/doc/make_cheatsheet.md b/doc/make_cheatsheet.md index e01eb2d001d71a..80fe1cfec531fa 100644 --- a/doc/make_cheatsheet.md +++ b/doc/make_cheatsheet.md @@ -52,22 +52,35 @@ $ make test-spec MSPECOPT=-Vfs ## How to run a part of the test suite +### Runs a directory ``` -# Runs a directory $ make test-all TESTS=test/rubygems $ make test-all TESTS=rubygems +``` -# Runs a file +### Runs a file +``` $ make test-all TESTS=test/ruby/test_foo.rb $ make test-all TESTS=ruby/foo +``` -# Runs a test whose name includes test_bar +### Runs a test whose name includes test_bar +``` $ make test-all TESTS="test/ruby/test_foo.rb -n /test_bar/" ``` +### Runs a ruby-spec directory +``` +$ make test-spec MSPECOPT=spec/ruby/core/foo +``` + +### Runs a ruby-spec file ``` $ make test-spec MSPECOPT=spec/ruby/core/foo/bar_spec.rb +``` +### Runs a bundler spec file +``` $ make test-bundler BUNDLER_SPECS=commands/exec_spec.rb:58 ``` From 5b8c36dfb25a060543fcec00abe34d516fcb44f6 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 24 Apr 2020 18:32:07 +0900 Subject: [PATCH 101/234] [DOC] Added GNU make specific targets [ci skip] --- doc/make_cheatsheet.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/make_cheatsheet.md b/doc/make_cheatsheet.md index 80fe1cfec531fa..bf245bea031b33 100644 --- a/doc/make_cheatsheet.md +++ b/doc/make_cheatsheet.md @@ -69,6 +69,12 @@ $ make test-all TESTS=ruby/foo $ make test-all TESTS="test/ruby/test_foo.rb -n /test_bar/" ``` +### Runs a file or directory with GNU make +``` +$ make test/ruby/test_foo.rb +$ make test/ruby/test_foo.rb TESTOPTS="-n /test_bar/" +``` + ### Runs a ruby-spec directory ``` $ make test-spec MSPECOPT=spec/ruby/core/foo @@ -79,6 +85,11 @@ $ make test-spec MSPECOPT=spec/ruby/core/foo $ make test-spec MSPECOPT=spec/ruby/core/foo/bar_spec.rb ``` +### Runs a ruby-spec file or directory with GNU make +``` +$ make spec/ruby/core/foo/bar_spec.rb +``` + ### Runs a bundler spec file ``` $ make test-bundler BUNDLER_SPECS=commands/exec_spec.rb:58 From c5b17b0354755c6540e8cd51aea0a30773437eaf Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 24 Apr 2020 21:22:05 +0900 Subject: [PATCH 102/234] Remove and Restore the original HOME dir (#3057) --- test/rdoc/support/test_case.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/rdoc/support/test_case.rb b/test/rdoc/support/test_case.rb index 9a4f04b76e654d..bce480252ff123 100644 --- a/test/rdoc/support/test_case.rb +++ b/test/rdoc/support/test_case.rb @@ -49,6 +49,9 @@ class RDoc::TestCase < Test::Unit::TestCase def setup super + @orig_home = ENV["HOME"] + ENV["HOME"] = Dir.tmpdir + @top_level = nil @RM = RDoc::Markup @@ -69,6 +72,15 @@ def g.file_dir() end RDoc::Markup::PreProcess.reset end + ## + # Abstract test-case teardown + + def teardown + ENV["HOME"] = @orig_home + + super + end + ## # Asserts +path+ is a file From 21598b0cc2aeac3d985e5512e13322fd854d3341 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 24 Apr 2020 22:43:48 +0900 Subject: [PATCH 103/234] Fixed a typo [ci skip] --- .github/workflows/ubuntu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 17da8d1f70a667..27ce6ae68257f5 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -48,7 +48,7 @@ jobs: - run: autoconf working-directory: src - run: mkdir build - - name: Run confiugre + - name: Run configure run: ../src/configure -C --disable-install-doc working-directory: build - run: make $JOBS From c6020ba277b8e666b38e25dab65acdcbd1c2121c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 24 Apr 2020 23:56:48 +0900 Subject: [PATCH 104/234] Clear cached XDG path names --- lib/rubygems/test_case.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index d02825446580f3..960fe9efe059ff 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -371,6 +371,8 @@ def setup File.chmod 0600, temp_cred Gem.instance_variable_set :@user_home, nil + Gem.instance_variable_set :@cache_home, nil + Gem.instance_variable_set :@data_home, nil Gem.instance_variable_set :@gemdeps, nil Gem.instance_variable_set :@env_requirements_by_name, nil Gem.send :remove_instance_variable, :@ruby_version if From cf5b3d6798509631b7b4dd72ff3d5dedc68c0d25 Mon Sep 17 00:00:00 2001 From: git Date: Sat, 25 Apr 2020 02:36:24 +0900 Subject: [PATCH 105/234] * 2020-04-25 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index fce46be583e5cf..01b1d54bfc5312 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 24 +#define RUBY_RELEASE_DAY 25 #include "ruby/version.h" From ae235db25d6d6437862d4823d053d42702d1a07a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 25 Apr 2020 00:19:01 +0900 Subject: [PATCH 106/234] [ruby/rdoc] Should teardown in reverse order of setup https://github.com/ruby/rdoc/commit/00fb4dd2a3 --- test/rdoc/test_rdoc_parser_changelog.rb | 2 ++ test/rdoc/test_rdoc_ri_driver.rb | 4 ++-- test/rdoc/test_rdoc_ri_paths.rb | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/rdoc/test_rdoc_parser_changelog.rb b/test/rdoc/test_rdoc_parser_changelog.rb index cb6406259c5509..d93cb7decae70d 100644 --- a/test/rdoc/test_rdoc_parser_changelog.rb +++ b/test/rdoc/test_rdoc_parser_changelog.rb @@ -14,6 +14,8 @@ def setup def teardown @tempfile.close! + + super end def test_class_can_parse diff --git a/test/rdoc/test_rdoc_ri_driver.rb b/test/rdoc/test_rdoc_ri_driver.rb index 1a8ac3dde536d7..e62323338b4d33 100644 --- a/test/rdoc/test_rdoc_ri_driver.rb +++ b/test/rdoc/test_rdoc_ri_driver.rb @@ -33,11 +33,11 @@ def setup end def teardown - super - ENV['HOME'] = @orig_home ENV['RI'] = @orig_ri FileUtils.rm_rf @tmpdir + + super end DUMMY_PAGER = ":;\n" diff --git a/test/rdoc/test_rdoc_ri_paths.rb b/test/rdoc/test_rdoc_ri_paths.rb index 726922daf01d0f..78e1a04f7355af 100644 --- a/test/rdoc/test_rdoc_ri_paths.rb +++ b/test/rdoc/test_rdoc_ri_paths.rb @@ -36,12 +36,12 @@ def setup end def teardown - super - Gem.use_paths(*@orig_gem_path) Gem::Specification.reset FileUtils.rm_rf @tempdir ENV.replace(@orig_env) + + super end def test_class_each From cc8f55e9e31e8057c6b5bfd417ca4f70d41b9a33 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 25 Apr 2020 01:43:38 +0900 Subject: [PATCH 107/234] [ruby/rdoc] HOME is preserved by RDoc::TestCase https://github.com/ruby/rdoc/commit/6c4801d1f6 --- test/rdoc/test_rdoc_markdown.rb | 2 ++ test/rdoc/test_rdoc_ri_driver.rb | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/rdoc/test_rdoc_markdown.rb b/test/rdoc/test_rdoc_markdown.rb index 021d94297be014..9c7a406224d4b9 100644 --- a/test/rdoc/test_rdoc_markdown.rb +++ b/test/rdoc/test_rdoc_markdown.rb @@ -8,6 +8,8 @@ class TestRDocMarkdown < RDoc::TestCase def setup + super + @RM = RDoc::Markup @parser = RDoc::Markdown.new diff --git a/test/rdoc/test_rdoc_ri_driver.rb b/test/rdoc/test_rdoc_ri_driver.rb index e62323338b4d33..f79d17b1cd087c 100644 --- a/test/rdoc/test_rdoc_ri_driver.rb +++ b/test/rdoc/test_rdoc_ri_driver.rb @@ -13,7 +13,6 @@ def setup FileUtils.mkdir_p @home_ri @orig_ri = ENV['RI'] - @orig_home = ENV['HOME'] ENV['HOME'] = @tmpdir @rdoc_home = File.join ENV["HOME"], ".rdoc" FileUtils.mkdir_p @rdoc_home @@ -33,7 +32,6 @@ def setup end def teardown - ENV['HOME'] = @orig_home ENV['RI'] = @orig_ri FileUtils.rm_rf @tmpdir From 42ac3f79ba7104b234546f906f51de485d3a1823 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 25 Apr 2020 09:29:27 +0900 Subject: [PATCH 108/234] Assert that typed data is distinguished from non-typed --- gc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gc.c b/gc.c index 67c355678a5309..56e907ad2eee3f 100644 --- a/gc.c +++ b/gc.c @@ -2327,6 +2327,7 @@ rb_imemo_new_debug(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0, VALUE rb_data_object_wrap(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree) { + RUBY_ASSERT_ALWAYS(dfree != (RUBY_DATA_FUNC)1); if (klass) Check_Type(klass, T_CLASS); return newobj_of(klass, T_DATA, (VALUE)dmark, (VALUE)dfree, (VALUE)datap, FALSE); } @@ -2342,6 +2343,7 @@ rb_data_object_zalloc(VALUE klass, size_t size, RUBY_DATA_FUNC dmark, RUBY_DATA_ VALUE rb_data_typed_object_wrap(VALUE klass, void *datap, const rb_data_type_t *type) { + RUBY_ASSERT_ALWAYS(type); if (klass) Check_Type(klass, T_CLASS); return newobj_of(klass, T_DATA, (VALUE)type, (VALUE)1, (VALUE)datap, type->flags & RUBY_FL_WB_PROTECTED); } From c2700379add15f8b0e13072a19cabc2cd5957c43 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sat, 25 Apr 2020 12:15:01 +0900 Subject: [PATCH 109/234] `git co` is alias of `git checkout` --- tool/sync_default_gems.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 4451a4ed483318..504c3b1980689c 100644 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -446,12 +446,12 @@ def update_default_gems(gem) end `git fetch ruby-core master --no-tags` unless `git branch`.match(/ruby\-core/) - `git co ruby-core/master` + `git checkout ruby-core/master` `git branch ruby-core` end - `git co ruby-core` + `git checkout ruby-core` `git rebase ruby-core/master` - `git co master` + `git checkout master` `git fetch origin master` `git rebase origin/master` end From f12f9f511ddf2116ed5da9a580336b148812ad23 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 25 Apr 2020 13:16:40 +0900 Subject: [PATCH 110/234] fetch-bundled_gems.rb: Quiet detached HEAD advice --- tool/fetch-bundled_gems.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tool/fetch-bundled_gems.rb b/tool/fetch-bundled_gems.rb index 28ae3d43275395..bb6f33abff425c 100755 --- a/tool/fetch-bundled_gems.rb +++ b/tool/fetch-bundled_gems.rb @@ -17,8 +17,9 @@ puts "retrieving #{n} ..." system(*%W"git clone #{u} #{n}") or abort end -unless system(*%W"git checkout #{v.sub(/\A(?=\d)/, 'v')}", chdir: n) - unless /\A\d/ =~ v and system(*%W"git checkout #{v}", chdir: n) +checkout = %w"git checkout -c advice.detachedHead=false" +unless system(*checkout, v.sub(/\A(?=\d)/, 'v'), chdir: n) + unless /\A\d/ =~ v and system(*checkout, v, chdir: n) abort end end From 7c88bb3eba77295cb4cd8ee1a713bae40d92600a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 25 Apr 2020 13:56:24 +0900 Subject: [PATCH 111/234] fetch-bundled_gems.rb: Fixed the position of -c --- tool/fetch-bundled_gems.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/fetch-bundled_gems.rb b/tool/fetch-bundled_gems.rb index bb6f33abff425c..4ba1848d00604a 100755 --- a/tool/fetch-bundled_gems.rb +++ b/tool/fetch-bundled_gems.rb @@ -17,7 +17,7 @@ puts "retrieving #{n} ..." system(*%W"git clone #{u} #{n}") or abort end -checkout = %w"git checkout -c advice.detachedHead=false" +checkout = %w"git -c advice.detachedHead=false checkout" unless system(*checkout, v.sub(/\A(?=\d)/, 'v'), chdir: n) unless /\A\d/ =~ v and system(*checkout, v, chdir: n) abort From fefb5fafbc44a02c0eaf91de14ca38ac890653ab Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 25 Apr 2020 17:52:27 +0900 Subject: [PATCH 112/234] More enums are mandatory for rp in lldb_cruby.py --- debug.c | 4 ++++ include/ruby/3/core/rarray.h | 2 +- include/ruby/3/core/robject.h | 2 +- include/ruby/3/core/rstring.h | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/debug.c b/debug.c index d6c8069cae8ff3..e841b76f0fb687 100644 --- a/debug.c +++ b/debug.c @@ -48,10 +48,14 @@ const union { enum ruby_encoding_consts encoding_consts; enum ruby_coderange_type enc_coderange_types; enum ruby_econv_flag_type econv_flag_types; + rb_econv_result_t econv_result; enum ruby_robject_flags robject_flags; + enum ruby_robject_consts robject_consts; enum ruby_rmodule_flags rmodule_flags; enum ruby_rstring_flags rstring_flags; + enum ruby_rstring_consts rstring_consts; enum ruby_rarray_flags rarray_flags; + enum ruby_rarray_consts rarray_consts; enum { RUBY_FMODE_READABLE = FMODE_READABLE, RUBY_FMODE_WRITABLE = FMODE_WRITABLE, diff --git a/include/ruby/3/core/rarray.h b/include/ruby/3/core/rarray.h index 3234daae90dcf9..added0c41c325d 100644 --- a/include/ruby/3/core/rarray.h +++ b/include/ruby/3/core/rarray.h @@ -79,7 +79,7 @@ enum ruby_rarray_flags { #endif }; -enum { +enum ruby_rarray_consts { RARRAY_EMBED_LEN_SHIFT = RUBY_FL_USHIFT + 3, RARRAY_EMBED_LEN_MAX = RUBY3_EMBED_LEN_MAX_OF(VALUE) }; diff --git a/include/ruby/3/core/robject.h b/include/ruby/3/core/robject.h index 3f298214a923d4..c6101af2d24fb1 100644 --- a/include/ruby/3/core/robject.h +++ b/include/ruby/3/core/robject.h @@ -43,7 +43,7 @@ enum ruby_robject_flags { ROBJECT_EMBED = RUBY_FL_USER1 }; -enum { ROBJECT_EMBED_LEN_MAX = RUBY3_EMBED_LEN_MAX_OF(VALUE) }; +enum ruby_robject_consts { ROBJECT_EMBED_LEN_MAX = RUBY3_EMBED_LEN_MAX_OF(VALUE) }; struct RObject { struct RBasic basic; diff --git a/include/ruby/3/core/rstring.h b/include/ruby/3/core/rstring.h index 8951dd0d3017be..10104c7a555855 100644 --- a/include/ruby/3/core/rstring.h +++ b/include/ruby/3/core/rstring.h @@ -65,7 +65,7 @@ enum ruby_rstring_flags { RSTRING_FSTR = RUBY_FL_USER17 }; -enum { +enum ruby_rstring_consts { RSTRING_EMBED_LEN_SHIFT = RUBY_FL_USHIFT + 2, RSTRING_EMBED_LEN_MAX = RUBY3_EMBED_LEN_MAX_OF(char) - 1 }; From 7ccb7a992da072f681e2fb570999743305bab115 Mon Sep 17 00:00:00 2001 From: Sorah Fukumori Date: Sun, 26 Apr 2020 02:00:45 +0900 Subject: [PATCH 113/234] [DOC] explicit_bzero exists in modern Linux [ci skip] --- missing/explicit_bzero.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/missing/explicit_bzero.c b/missing/explicit_bzero.c index 1804cdd42e69c4..1220e5f9ad7c23 100644 --- a/missing/explicit_bzero.c +++ b/missing/explicit_bzero.c @@ -17,9 +17,9 @@ /* OS support note: * BSDs have explicit_bzero(). - * OS-X has memset_s(). + * macOS has memset_s(). * Windows has SecureZeroMemory() since XP. - * Linux has none. *Sigh* + * Linux has explicit_bzero() since glibc 2.25, musl libc 1.1.20. */ /* From 9fd3f2432e851610c5170647ec92893bbed169c8 Mon Sep 17 00:00:00 2001 From: git Date: Sun, 26 Apr 2020 02:01:35 +0900 Subject: [PATCH 114/234] * 2020-04-26 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 01b1d54bfc5312..e8287f1b2684f3 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 25 +#define RUBY_RELEASE_DAY 26 #include "ruby/version.h" From 63fe3739dd13beeb049319606af6ffc6093a4c1e Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Sun, 26 Apr 2020 11:07:42 +0900 Subject: [PATCH 115/234] Fix errors when `RDoc::RI::Paths::HOMEDIR` is nil https://rubyci.org/logs/rubyci.s3.amazonaws.com/scw-ad7f67/ruby-master/log/20200425T175405Z.fail.html.gz ``` 4) Error: TestRDocServlet#test_asset: NoMethodError: undefined method `replace' for nil:NilClass /home/chkbuild/build/20200425T175405Z/ruby/test/rdoc/test_rdoc_servlet.rb:48:in `setup' 5) Error: TestRDocServlet#test_asset: NoMethodError: undefined method `replace' for nil:NilClass /home/chkbuild/build/20200425T175405Z/ruby/test/rdoc/test_rdoc_servlet.rb:63:in `teardown' ``` ... ``` 74) Error: TestRDocServlet#test_store_for_site: NoMethodError: undefined method `replace' for nil:NilClass /home/chkbuild/build/20200425T175405Z/ruby/test/rdoc/test_rdoc_servlet.rb:48:in `setup' 75) Error: TestRDocServlet#test_store_for_site: NoMethodError: undefined method `replace' for nil:NilClass /home/chkbuild/build/20200425T175405Z/ruby/test/rdoc/test_rdoc_servlet.rb:63:in `teardown' ``` --- test/rdoc/test_rdoc_servlet.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/rdoc/test_rdoc_servlet.rb b/test/rdoc/test_rdoc_servlet.rb index 1127408193a32d..977251308aca75 100644 --- a/test/rdoc/test_rdoc_servlet.rb +++ b/test/rdoc/test_rdoc_servlet.rb @@ -45,7 +45,8 @@ def @req.path= path @orig_base = RDoc::RI::Paths::BASE RDoc::RI::Paths::BASE.replace @base @orig_ri_path_homedir = RDoc::RI::Paths::HOMEDIR - RDoc::RI::Paths::HOMEDIR.replace @home_dir + RDoc::RI::Paths.send :remove_const, :HOMEDIR + RDoc::RI::Paths.const_set :HOMEDIR, @home_dir RDoc::RI::Paths.instance_variable_set \ :@gemdirs, %w[/nonexistent/gems/example-1.0/ri] @@ -60,7 +61,8 @@ def teardown FileUtils.rm_rf @tempdir RDoc::RI::Paths::BASE.replace @orig_base - RDoc::RI::Paths::HOMEDIR.replace @orig_ri_path_homedir + RDoc::RI::Paths.send :remove_const, :HOMEDIR + RDoc::RI::Paths.const_set :HOMEDIR, @orig_ri_path_homedir RDoc::RI::Paths.instance_variable_set :@gemdirs, nil end From 034b8472ba369b3f044c3735b0cab8e5e76e38f7 Mon Sep 17 00:00:00 2001 From: "S.H" Date: Sun, 26 Apr 2020 12:39:44 +0900 Subject: [PATCH 116/234] remove unused rb_str_clear define (#3059) --- string.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/string.c b/string.c index b17d41158cfef4..97c7a048288b41 100644 --- a/string.c +++ b/string.c @@ -76,8 +76,6 @@ #undef rb_str_cat_cstr #undef rb_fstring_cstr -static VALUE rb_str_clear(VALUE str); - VALUE rb_cString; VALUE rb_cSymbol; From b5174beae6e02b109ed2c5d5ad9c4653596236e4 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 26 Apr 2020 12:28:56 +0900 Subject: [PATCH 117/234] lldb_cruby.py: fixed empty string dump [ci skip] --- misc/lldb_cruby.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/misc/lldb_cruby.py b/misc/lldb_cruby.py index a582b7dde039c7..88765813e469f4 100755 --- a/misc/lldb_cruby.py +++ b/misc/lldb_cruby.py @@ -132,7 +132,10 @@ def lldb_inspect(debugger, target, result, val): result.write('T_STRING: %s' % flaginfo) tRString = target.FindFirstType("struct RString").GetPointerType() ptr, len = string2cstr(val.Cast(tRString)) - append_command_output(debugger, "print *(const char (*)[%d])%0#x" % (len, ptr), result) + if len == 0: + result.write("(empty)\n") + else: + append_command_output(debugger, "print *(const char (*)[%d])%0#x" % (len, ptr), result) elif flType == RUBY_T_SYMBOL: result.write('T_SYMBOL: %s' % flaginfo) tRSymbol = target.FindFirstType("struct RSymbol").GetPointerType() From 7860277527b9fef577cdaa0958147eb78a0ee9b7 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 26 Apr 2020 12:26:03 +0900 Subject: [PATCH 118/234] [ruby/spec] Fixed missing should --- spec/ruby/library/bigdecimal/precs_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/ruby/library/bigdecimal/precs_spec.rb b/spec/ruby/library/bigdecimal/precs_spec.rb index f9320f2b9ee787..78a62341e80aa1 100644 --- a/spec/ruby/library/bigdecimal/precs_spec.rb +++ b/spec/ruby/library/bigdecimal/precs_spec.rb @@ -40,7 +40,7 @@ it "returns the maximum number of significant digits as the second value" do BigDecimal("3.14159").precs[1].should >= 6 BigDecimal('1').precs[1].should >= 1 - BigDecimal('1' + '0' * 100).precs[1] >= 101 + BigDecimal('1' + '0' * 100).precs[1].should >= 101 [@infinity, @infinity_neg, @nan, @zero, @zero_neg].each do |value| value.precs[1].should >= 1 end From d0f41aa2382612022162d033ddb3d9c9cc62099e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 26 Apr 2020 12:26:42 +0900 Subject: [PATCH 119/234] [ruby/spec] Removed space between method name and argument list paren --- spec/ruby/library/bigdecimal/comparison_spec.rb | 2 +- spec/ruby/library/bigdecimal/gt_spec.rb | 2 +- spec/ruby/library/bigdecimal/gte_spec.rb | 2 +- spec/ruby/library/bigdecimal/lt_spec.rb | 2 +- spec/ruby/library/bigdecimal/lte_spec.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/ruby/library/bigdecimal/comparison_spec.rb b/spec/ruby/library/bigdecimal/comparison_spec.rb index a1e09b601fbbf6..c53187b727d830 100644 --- a/spec/ruby/library/bigdecimal/comparison_spec.rb +++ b/spec/ruby/library/bigdecimal/comparison_spec.rb @@ -18,7 +18,7 @@ class << @int_mock def coerce(other) return [other, BigDecimal('123')] end - def >= (other) + def >=(other) BigDecimal('123') >= other end end diff --git a/spec/ruby/library/bigdecimal/gt_spec.rb b/spec/ruby/library/bigdecimal/gt_spec.rb index 4717cfdd9d670c..78547fb85f152f 100644 --- a/spec/ruby/library/bigdecimal/gt_spec.rb +++ b/spec/ruby/library/bigdecimal/gt_spec.rb @@ -17,7 +17,7 @@ class << @int_mock def coerce(other) return [other, BigDecimal('123')] end - def > (other) + def >(other) BigDecimal('123') > other end end diff --git a/spec/ruby/library/bigdecimal/gte_spec.rb b/spec/ruby/library/bigdecimal/gte_spec.rb index 8dc81707f063eb..2a5cc025ba3821 100644 --- a/spec/ruby/library/bigdecimal/gte_spec.rb +++ b/spec/ruby/library/bigdecimal/gte_spec.rb @@ -17,7 +17,7 @@ class << @int_mock def coerce(other) return [other, BigDecimal('123')] end - def >= (other) + def >=(other) BigDecimal('123') >= other end end diff --git a/spec/ruby/library/bigdecimal/lt_spec.rb b/spec/ruby/library/bigdecimal/lt_spec.rb index 61f4f199120cda..02390e76e33b61 100644 --- a/spec/ruby/library/bigdecimal/lt_spec.rb +++ b/spec/ruby/library/bigdecimal/lt_spec.rb @@ -17,7 +17,7 @@ class << @int_mock def coerce(other) return [other, BigDecimal('123')] end - def < (other) + def <(other) BigDecimal('123') < other end end diff --git a/spec/ruby/library/bigdecimal/lte_spec.rb b/spec/ruby/library/bigdecimal/lte_spec.rb index fc632315f8d5c3..b92be04123f106 100644 --- a/spec/ruby/library/bigdecimal/lte_spec.rb +++ b/spec/ruby/library/bigdecimal/lte_spec.rb @@ -17,7 +17,7 @@ class << @int_mock def coerce(other) return [other, BigDecimal('123')] end - def <= (other) + def <=(other) BigDecimal('123') <= other end end From 36ed700711b04ba70e284c00feb54dcd98d872bb Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Sun, 26 Apr 2020 16:14:14 +0900 Subject: [PATCH 120/234] Fix failures of test/rdoc/test_rdoc_ri_paths.rb yield `home_dir` when HOMEDIR is not falsy only. https://github.com/ruby/ruby/blob/d0f41aa2382612022162d033ddb3d9c9cc62099e/lib/rdoc/ri/paths.rb#L43 ``` yield home_dir, :home if home and HOMEDIR ``` https://rubyci.org/logs/rubyci.s3.amazonaws.com/archlinux/ruby-master/log/20200426T033503Z.fail.html.gz ``` 1) Failure: TestRDocRIPaths#test_class_each [/home/chkbuild/build/20200426T033503Z/ruby/test/rdoc/test_rdoc_ri_paths.rb:54]: expected but was <"/home/naruse/chkbuild/tmp/build/20200426T033503Z/tmp/test_rdoc_ri_paths_1033468/doc/nodoc-1.0/ri">. 2) Failure: TestRDocRIPaths#test_class_raw_path [/home/chkbuild/build/20200426T033503Z/ruby/test/rdoc/test_rdoc_ri_paths.rb:131]: expected but was <"/home/naruse/chkbuild/tmp/build/20200426T033503Z/tmp/test_rdoc_ri_paths_1033468/doc/rake-10.0.1/ri">. 3) Failure: TestRDocRIPaths#test_class_raw_path_extra_dirs [/home/chkbuild/build/20200426T033503Z/ruby/test/rdoc/test_rdoc_ri_paths.rb:141]: expected but was <"/home/naruse/chkbuild/tmp/build/20200426T033503Z/tmp/test_rdoc_ri_paths_1033468/doc/rake-10.0.1/ri">. ``` --- test/rdoc/test_rdoc_ri_paths.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/rdoc/test_rdoc_ri_paths.rb b/test/rdoc/test_rdoc_ri_paths.rb index 78e1a04f7355af..c01a4711ee9e47 100644 --- a/test/rdoc/test_rdoc_ri_paths.rb +++ b/test/rdoc/test_rdoc_ri_paths.rb @@ -51,7 +51,7 @@ def test_class_each assert_equal RDoc::RI::Paths.system_dir, path.shift assert_equal RDoc::RI::Paths.site_dir, path.shift - assert_equal RDoc::RI::Paths.home_dir, path.shift + assert_equal RDoc::RI::Paths.home_dir, path.shift if RDoc::RI::Paths.home_dir assert_equal File.join(@nodoc.doc_dir, 'ri'), path.shift assert_equal File.join(@rake_10.doc_dir, 'ri'), path.shift assert_equal File.join(@rdoc_4_0.doc_dir, 'ri'), path.shift @@ -128,7 +128,7 @@ def test_class_raw_path assert_equal RDoc::RI::Paths.system_dir, path.shift assert_equal RDoc::RI::Paths.site_dir, path.shift - assert_equal RDoc::RI::Paths.home_dir, path.shift + assert_equal RDoc::RI::Paths.home_dir, path.shift if RDoc::RI::Paths.home_dir assert_equal File.join(@rake_10.doc_dir, 'ri'), path.shift end @@ -138,7 +138,7 @@ def test_class_raw_path_extra_dirs assert_equal '/nonexistent', path.shift assert_equal RDoc::RI::Paths.system_dir, path.shift assert_equal RDoc::RI::Paths.site_dir, path.shift - assert_equal RDoc::RI::Paths.home_dir, path.shift + assert_equal RDoc::RI::Paths.home_dir, path.shift if RDoc::RI::Paths.home_dir assert_equal File.join(@rake_10.doc_dir, 'ri'), path.shift end From 1760c60174b80e837371a19ec13b1148629262cb Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 26 Apr 2020 19:34:07 +0900 Subject: [PATCH 121/234] Clarified return value of atomic macros --- ruby_atomic.h | 69 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 56 insertions(+), 13 deletions(-) diff --git a/ruby_atomic.h b/ruby_atomic.h index 0742791d6476c8..eaa9fcd869b599 100644 --- a/ruby_atomic.h +++ b/ruby_atomic.h @@ -1,12 +1,17 @@ #ifndef RUBY_ATOMIC_H #define RUBY_ATOMIC_H +/* + * - ATOMIC_CAS, ATOMIC_EXCHANGE, ATOMIC_FETCH_*: + * return the old * value. + * - ATOMIC_ADD, ATOMIC_SUB, ATOMIC_INC, ATOMIC_DEC, ATOMIC_OR, ATOMIC_SET: + * may be void. + */ #if 0 #elif defined HAVE_GCC_ATOMIC_BUILTINS typedef unsigned int rb_atomic_t; -# define ATOMIC_SET(var, val) (void)__atomic_exchange_n(&(var), (val), __ATOMIC_SEQ_CST) -# define ATOMIC_INC(var) __atomic_fetch_add(&(var), 1, __ATOMIC_SEQ_CST) -# define ATOMIC_DEC(var) __atomic_fetch_sub(&(var), 1, __ATOMIC_SEQ_CST) +# define ATOMIC_FETCH_ADD(var, val) __atomic_fetch_add(&(var), (val), __ATOMIC_SEQ_CST) +# define ATOMIC_FETCH_SUB(var, val) __atomic_fetch_sub(&(var), (val), __ATOMIC_SEQ_CST) # define ATOMIC_OR(var, val) __atomic_fetch_or(&(var), (val), __ATOMIC_SEQ_CST) # define ATOMIC_EXCHANGE(var, val) __atomic_exchange_n(&(var), (val), __ATOMIC_SEQ_CST) # define ATOMIC_CAS(var, oldval, newval) RB_GNUC_EXTENSION_BLOCK( \ @@ -14,9 +19,6 @@ typedef unsigned int rb_atomic_t; __atomic_compare_exchange_n(&(var), &oldvaldup, (newval), 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); \ oldvaldup ) -# define ATOMIC_SIZE_ADD(var, val) __atomic_fetch_add(&(var), (val), __ATOMIC_SEQ_CST) -# define ATOMIC_SIZE_SUB(var, val) __atomic_fetch_sub(&(var), (val), __ATOMIC_SEQ_CST) - # define RUBY_ATOMIC_GENERIC_MACRO 1 #elif defined HAVE_GCC_SYNC_BUILTINS @@ -25,16 +27,12 @@ typedef unsigned int rb_atomic_t; * http://gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html */ typedef unsigned int rb_atomic_t; /* Anything OK */ -# define ATOMIC_SET(var, val) (void)__sync_lock_test_and_set(&(var), (val)) -# define ATOMIC_INC(var) __sync_fetch_and_add(&(var), 1) -# define ATOMIC_DEC(var) __sync_fetch_and_sub(&(var), 1) +# define ATOMIC_FETCH_ADD(var, val) __sync_fetch_and_add(&(var), (val)) +# define ATOMIC_FETCH_SUB(var, var) __sync_fetch_and_sub(&(var), (val)) # define ATOMIC_OR(var, val) __sync_fetch_and_or(&(var), (val)) # define ATOMIC_EXCHANGE(var, val) __sync_lock_test_and_set(&(var), (val)) # define ATOMIC_CAS(var, oldval, newval) __sync_val_compare_and_swap(&(var), (oldval), (newval)) -# define ATOMIC_SIZE_ADD(var, val) __sync_fetch_and_add(&(var), (val)) -# define ATOMIC_SIZE_SUB(var, val) __sync_fetch_and_sub(&(var), (val)) - # define RUBY_ATOMIC_GENERIC_MACRO 1 #elif defined _WIN32 @@ -46,6 +44,8 @@ typedef LONG rb_atomic_t; # define ATOMIC_SET(var, val) InterlockedExchange(&(var), (val)) # define ATOMIC_INC(var) InterlockedIncrement(&(var)) # define ATOMIC_DEC(var) InterlockedDecrement(&(var)) +# define ATOMIC_FETCH_ADD(var, val) InterlockedExchangeAdd(&(var), (val)) +# define ATOMIC_FETCH_SUB(var, val) InterlockedExchangeAdd(&(var), -(LONG)(val)) #if defined __GNUC__ # define ATOMIC_OR(var, val) __asm__("lock\n\t" "orl\t%1, %0" : "=m"(var) : "Ir"(val)) #elif MSC_VERSION_BEFORE(1300) @@ -98,13 +98,28 @@ rb_w32_atomic_cas(volatile rb_atomic_t *var, rb_atomic_t oldval, rb_atomic_t new #include typedef unsigned int rb_atomic_t; -# define ATOMIC_SET(var, val) (void)atomic_swap_uint(&(var), (val)) # define ATOMIC_INC(var) atomic_inc_uint(&(var)) # define ATOMIC_DEC(var) atomic_dec_uint(&(var)) +# define ATOMIC_FETCH_ADD(var, val) rb_atomic_fetch_add(&(var), (val)) +# define ATOMIC_FETCH_SUB(var, val) rb_atomic_fetch_sub(&(var), (val)) +# define ATOMIC_ADD(var, val) atomic_add_uint(&(var), (val)) +# define ATOMIC_SUB(var, val) atomic_sub_uint(&(var), (val)) # define ATOMIC_OR(var, val) atomic_or_uint(&(var), (val)) # define ATOMIC_EXCHANGE(var, val) atomic_swap_uint(&(var), (val)) # define ATOMIC_CAS(var, oldval, newval) atomic_cas_uint(&(var), (oldval), (newval)) +static inline rb_atomic_t +rb_atomic_fetch_add(volatile rb_atomic_t *var, rb_atomic_t val) +{ + return atomic_add_int_nv(var, val) - val; +} + +static inline rb_atomic_t +rb_atomic_fetch_sub(volatile rb_atomic_t *var, rb_atomic_t val) +{ + return atomic_sub_int_nv(var, val) + val; +} + # if defined(_LP64) || defined(_I32LPx) # define ATOMIC_SIZE_ADD(var, val) atomic_add_long(&(var), (val)) # define ATOMIC_SIZE_SUB(var, val) atomic_add_long(&(var), -(val)) @@ -124,6 +139,26 @@ typedef unsigned int rb_atomic_t; # error No atomic operation found #endif +#ifndef ATOMIC_SET +# define ATOMIC_SET(var, val) (void)ATOMIC_EXCHANGE(var, val) +#endif + +#ifndef ATOMIC_ADD +# define ATOMIC_ADD(var, val) (void)ATOMIC_FETCH_ADD(var, val) +#endif + +#ifndef ATOMIC_SUB +# define ATOMIC_SUB(var, val) (void)ATOMIC_FETCH_SUB(var, val) +#endif + +#ifndef ATOMIC_INC +# define ATOMIC_INC(var) ATOMIC_ADD(var, 1) +#endif + +#ifndef ATOMIC_DEC +# define ATOMIC_DEC(var) ATOMIC_SUB(var, 1) +#endif + #ifndef ATOMIC_SIZE_INC # define ATOMIC_SIZE_INC(var) ATOMIC_INC(var) #endif @@ -140,6 +175,14 @@ typedef unsigned int rb_atomic_t; # define ATOMIC_SIZE_CAS(var, oldval, val) ATOMIC_CAS(var, oldval, val) #endif +#ifndef ATOMIC_SIZE_ADD +# define ATOMIC_SIZE_ADD(var, val) ATOMIC_ADD(var, val) +#endif + +#ifndef ATOMIC_SIZE_SUB +# define ATOMIC_SIZE_SUB(var, val) ATOMIC_SUB(var, val) +#endif + #if RUBY_ATOMIC_GENERIC_MACRO # ifndef ATOMIC_PTR_EXCHANGE # define ATOMIC_PTR_EXCHANGE(var, val) ATOMIC_EXCHANGE(var, val) From 257e01b61db90ecf3a53957281770b5f3db3f919 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 26 Apr 2020 22:39:36 +0900 Subject: [PATCH 122/234] Solaris does not provide atomic_sub family --- ruby_atomic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruby_atomic.h b/ruby_atomic.h index eaa9fcd869b599..fa888a1db02a73 100644 --- a/ruby_atomic.h +++ b/ruby_atomic.h @@ -117,7 +117,7 @@ rb_atomic_fetch_add(volatile rb_atomic_t *var, rb_atomic_t val) static inline rb_atomic_t rb_atomic_fetch_sub(volatile rb_atomic_t *var, rb_atomic_t val) { - return atomic_sub_int_nv(var, val) + val; + return atomic_add_int_nv(var, (rb_atomic_t)(-(int)val)) + val; } # if defined(_LP64) || defined(_I32LPx) From 6560ff6e36f3d9811a0457ab8bae2199c2fe082e Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Mon, 27 Apr 2020 00:54:16 +0900 Subject: [PATCH 123/234] Fix a typo [ci skip] --- ext/socket/raddrinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c index 9ec2fdc329ead4..079f66dddc2da3 100644 --- a/ext/socket/raddrinfo.c +++ b/ext/socket/raddrinfo.c @@ -1913,7 +1913,7 @@ addrinfo_to_sockaddr(VALUE self) * call-seq: * addrinfo.canonname => string or nil * - * returns the canonical name as an string. + * returns the canonical name as a string. * * nil is returned if no canonical name. * From 33767d1e3d1c7a5dc8eddeefd9c923a8a3dda1e1 Mon Sep 17 00:00:00 2001 From: git Date: Mon, 27 Apr 2020 00:54:57 +0900 Subject: [PATCH 124/234] * 2020-04-27 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index e8287f1b2684f3..e5a60b9a59d9e0 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 26 +#define RUBY_RELEASE_DAY 27 #include "ruby/version.h" From a217d3cedce3f5aa5c27a1ce6c72b65ec37da057 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 27 Apr 2020 00:40:43 +0900 Subject: [PATCH 125/234] check: compare with right upstream --- common.mk | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common.mk b/common.mk index a5e015f975a75b..616276eb2a17b7 100644 --- a/common.mk +++ b/common.mk @@ -723,8 +723,10 @@ clean-spec: PHONY check: main test test-tool test-all test-spec $(ECHO) check succeeded - -$(Q) if [ x"$(GIT)" != x ] && $(CHDIR) "$(srcdir)" && $(GIT) rev-parse > /dev/null 2>&1; then \ - set -x; $(GIT) --no-pager log --format=oneline -G "^ *# *include" origin/master..HEAD; \ + -$(Q) if [ x"$(GIT)" != x ] && $(CHDIR) "$(srcdir)" && \ + b=`$(GIT) symbolic-ref --short HEAD 2>&1` && \ + u=`$(GIT) branch --list --format='%(upstream:short)' $$b`; then \ + set -x; $(GIT) --no-pager log --format=oneline -G "^ *# *include" $$u..HEAD --; \ fi check-ruby: test test-ruby From 93ed465dcdc866013cd93c3662937497900c8086 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 27 Apr 2020 02:09:08 +0900 Subject: [PATCH 126/234] test/ruby/test_fiber.rb (test_stack_size): re-enabled on s390x Revert 9948addda67f4b7a6e3575f1eba9025f998811d2. It is now discussed in https://bugs.ruby-lang.org/issues/16814, and an assert is added with a217d3cedce3f5aa5c27a1ce6c72b65ec37da057. It would be good to give it a try. --- test/ruby/test_fiber.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb index e4c5841ff5404c..7070fdf03c7f56 100644 --- a/test/ruby/test_fiber.rb +++ b/test/ruby/test_fiber.rb @@ -360,7 +360,6 @@ def invoke_rec script, vm_stack_size, machine_stack_size, use_length = true end def test_stack_size - skip 'too unstable on Travis s390x-linux' if RUBY_PLATFORM == 's390x-linux' skip 'too unstable on riscv' if RUBY_PLATFORM =~ /riscv/ h_default = eval(invoke_rec('p RubyVM::DEFAULT_PARAMS', nil, nil, false)) h_0 = eval(invoke_rec('p RubyVM::DEFAULT_PARAMS', 0, 0, false)) From fd2df584515f1a764c6fdc369f1d3049825e02eb Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Mon, 27 Apr 2020 09:41:45 +0900 Subject: [PATCH 127/234] Fix a typo [ci skip] --- gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gc.c b/gc.c index 56e907ad2eee3f..2638fce8fe77da 100644 --- a/gc.c +++ b/gc.c @@ -9903,7 +9903,7 @@ objspace_malloc_fixup(rb_objspace_t *objspace, void *mem, size_t size) #endif /* these shouldn't be called directly. - * objspace_* functinos do not check allocation size. + * objspace_* functions do not check allocation size. */ static void * objspace_xmalloc0(rb_objspace_t *objspace, size_t size) From c180c58fc17935a2bacffac57a3707d68b11eb4f Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 27 Apr 2020 01:29:17 +0900 Subject: [PATCH 128/234] Removed already resolved test [ci skip] That bug has been fixed by ec0c394b9eb, and the test has been added by 181ffea5e04. --- bootstraptest/pending.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/bootstraptest/pending.rb b/bootstraptest/pending.rb index 0959bfa2b09324..66aab1e677f56b 100644 --- a/bootstraptest/pending.rb +++ b/bootstraptest/pending.rb @@ -31,13 +31,6 @@ def m end } -assert_normal_exit %q{ - r = Range.allocate - def r.<=>(o) true end - r.instance_eval { initialize r, r } - r.inspect -} - # This randomly fails on mswin. assert_equal %q{[]}, %q{ Thread.new{sleep}.backtrace From 6009790e4072c8c6736773cf22addb20ad5aac02 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 27 Apr 2020 01:50:23 +0900 Subject: [PATCH 129/234] Moved already resolved test Couldn't figure out failed/fixed versions. --- bootstraptest/pending.rb | 16 ---------------- test/ruby/test_module.rb | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bootstraptest/pending.rb b/bootstraptest/pending.rb index 66aab1e677f56b..2c4b85a4193d0c 100644 --- a/bootstraptest/pending.rb +++ b/bootstraptest/pending.rb @@ -1,19 +1,3 @@ -assert_equal 'A', %q{ - class A - @@a = 'A' - def a=(x) - @@a = x - end - def a - @@a - end - end - - B = A.dup - B.new.a = 'B' - A.new.a -}, '[ruby-core:17019]' - assert_equal 'ok', %q{ def m lambda{ diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index e5586edc6d1d1e..e3cd62713f9cc8 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -2161,6 +2161,22 @@ def test_class_variables assert_equal([:@@bar], m2.class_variables(false)) end + def test_class_variable_in_dup_class + a = Class.new do + @@a = 'A' + def a=(x) + @@a = x + end + def a + @@a + end + end + + b = a.dup + b.new.a = 'B' + assert_equal 'A', a.new.a, '[ruby-core:17019]' + end + Bug6891 = '[ruby-core:47241]' def test_extend_module_with_protected_method From aca935a67042dd7b82e34844ae6139cedd66339d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 27 Apr 2020 15:28:06 +0900 Subject: [PATCH 130/234] Fixed typos in racc --- lib/racc/parser-text.rb | 6 +++--- lib/racc/parser.rb | 6 +++--- libexec/racc | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/racc/parser-text.rb b/lib/racc/parser-text.rb index 8dadeadee51c94..c40736bc99dd6e 100644 --- a/lib/racc/parser-text.rb +++ b/lib/racc/parser-text.rb @@ -181,8 +181,8 @@ class ParseError < StandardError; end # Your own parser is completely yours. module Racc - unless defined?(Racc_No_Extentions) - Racc_No_Extentions = false # :nodoc: + unless defined?(Racc_No_Extensions) + Racc_No_Extensions = false # :nodoc: end class Parser @@ -202,7 +202,7 @@ class Parser unless new.respond_to?(:_racc_do_parse_c, true) raise LoadError, 'old cparse.so' end - if Racc_No_Extentions + if Racc_No_Extensions raise LoadError, 'selecting ruby version of racc runtime core' end diff --git a/lib/racc/parser.rb b/lib/racc/parser.rb index 8346f0193f1b27..e1133f75904034 100644 --- a/lib/racc/parser.rb +++ b/lib/racc/parser.rb @@ -179,8 +179,8 @@ class ParseError < StandardError; end # Your own parser is completely yours. module Racc - unless defined?(Racc_No_Extentions) - Racc_No_Extentions = false # :nodoc: + unless defined?(Racc_No_Extensions) + Racc_No_Extensions = false # :nodoc: end class Parser @@ -200,7 +200,7 @@ class Parser unless new.respond_to?(:_racc_do_parse_c, true) raise LoadError, 'old cparse.so' end - if Racc_No_Extentions + if Racc_No_Extensions raise LoadError, 'selecting ruby version of racc runtime core' end diff --git a/libexec/racc b/libexec/racc index 5656b25e421c0b..70e1032bfc5abc 100755 --- a/libexec/racc +++ b/libexec/racc @@ -88,7 +88,7 @@ def main debug_flags = Racc::DebugFlags.parse_option_string(flags) } #parser.on('--no-extensions', 'Run Racc without any Ruby extension.') { - # Racc.const_set :Racc_No_Extentions, true + # Racc.const_set :Racc_No_Extensions, true #} parser.on('--version', 'Prints version and quit.') { puts "racc version #{Racc::Version}" From de58dfc911738b2cbb2b848fa2e2cc93616a0ec5 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 20 Apr 2020 10:06:45 +0900 Subject: [PATCH 131/234] [rubygems/rubygems] Removed the depdendency of English library English.rb is extracted to the default gems at https://github.com/ruby/ruby/commit/2c5764ec223d976e0d0da1494596a1519104be3e https://github.com/rubygems/rubygems/commit/532f488c0b --- lib/rubygems/commands/contents_command.rb | 4 ++-- lib/rubygems/commands/open_command.rb | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb index 989ca5855c95c1..2da8c490316394 100644 --- a/lib/rubygems/commands/contents_command.rb +++ b/lib/rubygems/commands/contents_command.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -require 'English' require 'rubygems/command' require 'rubygems/version_option' @@ -106,7 +105,8 @@ def files_in_default_gem(spec) spec.files.map do |file| case file when /\A#{spec.bindir}\// - [RbConfig::CONFIG['bindir'], $POSTMATCH] + # $' is POSTMATCH + [RbConfig::CONFIG['bindir'], $'] when /\.so\z/ [RbConfig::CONFIG['archdir'], file] else diff --git a/lib/rubygems/commands/open_command.rb b/lib/rubygems/commands/open_command.rb index 8eaeb64ba953bc..e538e58d469f10 100644 --- a/lib/rubygems/commands/open_command.rb +++ b/lib/rubygems/commands/open_command.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -require 'English' require 'rubygems/command' require 'rubygems/version_option' require 'rubygems/util' From 2c2b0d4ec1bc3ede33b056e24dea011edc69bd5f Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Wed, 22 Apr 2020 14:37:42 +0900 Subject: [PATCH 132/234] [rubygems/rubygems] Make the test suite pass under `umask 077` Some tests had failed under `umask 077` mode. As far as I investigated, there is no actual bug. All failures were caused by tests that create a wrong-permission file or expect wrong permission. This changeset fixes the tests. https://github.com/rubygems/rubygems/commit/078213e527 --- .../rubygems/test_gem_commands_build_command.rb | 9 +++++++-- test/rubygems/test_gem_installer.rb | 2 +- test/rubygems/test_gem_specification.rb | 17 +++++++++++------ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb index ca9f8b66c9f548..9dfba75cf51c20 100644 --- a/test/rubygems/test_gem_commands_build_command.rb +++ b/test/rubygems/test_gem_commands_build_command.rb @@ -17,8 +17,13 @@ def setup readme_file = File.join(@tempdir, 'README.md') - File.open readme_file, 'w' do |f| - f.write 'My awesome gem' + begin + umask_orig = File.umask(2) + File.open readme_file, 'w' do |f| + f.write 'My awesome gem' + end + ensure + File.umask(umask_orig) end @gem = util_spec 'some_gem' do |s| diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 89fcecb68d449e..34759a8fd04fda 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -2200,7 +2200,7 @@ def util_conflict_executable(wrappers) end def mask - 0100755 & (~File.umask) + 0100755 end end diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 1df7d71d8e56cf..1848e52e169f92 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -3823,12 +3823,17 @@ def util_setup_validate FileUtils.mkdir_p "test" FileUtils.mkdir_p "bin" - FileUtils.touch File.join("ext", "a", "extconf.rb") - FileUtils.touch File.join("lib", "code.rb") - FileUtils.touch File.join("test", "suite.rb") - - File.open "bin/exec", "w", 0755 do |fp| - fp.puts "#!#{Gem.ruby}" + begin + umask_orig = File.umask(2) + FileUtils.touch File.join("ext", "a", "extconf.rb") + FileUtils.touch File.join("lib", "code.rb") + FileUtils.touch File.join("test", "suite.rb") + + File.open "bin/exec", "w", 0755 do |fp| + fp.puts "#!#{Gem.ruby}" + end + ensure + File.umask(umask_orig) end end end From 5b77fc8abe4d3c347b5a846c8b330a3bb51d1ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sat, 25 Apr 2020 14:28:41 +0200 Subject: [PATCH 133/234] [rubygems/rubygems] Remove commented out code https://github.com/rubygems/rubygems/commit/42aa0d7ebc --- test/rubygems/test_deprecate.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/rubygems/test_deprecate.rb b/test/rubygems/test_deprecate.rb index f5cd83ee8908c3..6d36b673dfd47d 100644 --- a/test/rubygems/test_deprecate.rb +++ b/test/rubygems/test_deprecate.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true require 'rubygems/test_case' -# require 'rubygems/builder' -# require 'rubygems/package' require 'rubygems/deprecate' class TestDeprecate < Gem::TestCase @@ -9,7 +7,6 @@ class TestDeprecate < Gem::TestCase def setup super - # Gem::Deprecate.saved_warnings.clear @original_skip = Gem::Deprecate.skip Gem::Deprecate.skip = false end @@ -17,7 +14,6 @@ def setup def teardown super - # Gem::Deprecate.saved_warnings.clear Gem::Deprecate.skip = @original_skip end From 442866c2d445cbd30a0f4ae651c828ced0f8976c Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 21 Apr 2020 19:34:26 +0900 Subject: [PATCH 134/234] [rubygems/rubygems] Pass the rubocop lint https://github.com/rubygems/rubygems/commit/d4486ca061 --- lib/bundler/cli.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 22fca7fdf424bd..3ef0e28f2678d2 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -122,7 +122,7 @@ def help(cli = nil) else command = "bundle-#{cli}" end - man_path = File.expand_path("../../../man", __FILE__) + man_path = File.expand_path("../../../man", __FILE__) # man files are located under the share directory with the default gems of bundler man_path = File.expand_path("../../../../../share/man/man1", __FILE__) unless File.directory?(man_path) man_pages = Hash[Dir.glob(File.join(man_path, "*")).grep(/.*\.\d*\Z/).collect do |f| From 3acdb31871ac2c763d139d8d4a07268224fb24f6 Mon Sep 17 00:00:00 2001 From: git Date: Tue, 28 Apr 2020 11:39:28 +0900 Subject: [PATCH 135/234] * 2020-04-28 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index e5a60b9a59d9e0..def2177efcc4ff 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 27 +#define RUBY_RELEASE_DAY 28 #include "ruby/version.h" From 3497152515693cb3898bf3aea502f6e162ffe21f Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 28 Apr 2020 15:05:59 +0900 Subject: [PATCH 136/234] Remove rubyspec temporary directory --- common.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/common.mk b/common.mk index 616276eb2a17b7..449f032074af11 100644 --- a/common.mk +++ b/common.mk @@ -823,6 +823,7 @@ test-spec: $(TEST_RUNNABLE)-test-spec yes-test-spec: test-spec-precheck $(gnumake_recursive)$(Q) \ $(RUNRUBY) -r./$(arch)-fake $(srcdir)/spec/mspec/bin/mspec run -B $(srcdir)/spec/default.mspec $(MSPECOPT) $(SPECOPTS) + $(RMDIR) rubyspec_temp no-test-spec: RUNNABLE = $(LIBRUBY_RELATIVE:no=un)-runnable From 86431f5075d0495783776b0d7f162df387e7cde6 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 28 Apr 2020 19:00:33 +0900 Subject: [PATCH 137/234] Remove rubyspec temporary directories --- common.mk | 1 - spec/mspec/lib/mspec/helpers/tmp.rb | 18 +++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/common.mk b/common.mk index 449f032074af11..616276eb2a17b7 100644 --- a/common.mk +++ b/common.mk @@ -823,7 +823,6 @@ test-spec: $(TEST_RUNNABLE)-test-spec yes-test-spec: test-spec-precheck $(gnumake_recursive)$(Q) \ $(RUNRUBY) -r./$(arch)-fake $(srcdir)/spec/mspec/bin/mspec run -B $(srcdir)/spec/default.mspec $(MSPECOPT) $(SPECOPTS) - $(RMDIR) rubyspec_temp no-test-spec: RUNNABLE = $(LIBRUBY_RELATIVE:no=un)-runnable diff --git a/spec/mspec/lib/mspec/helpers/tmp.rb b/spec/mspec/lib/mspec/helpers/tmp.rb index 5062991d6354b1..433c0b6d883118 100644 --- a/spec/mspec/lib/mspec/helpers/tmp.rb +++ b/spec/mspec/lib/mspec/helpers/tmp.rb @@ -4,13 +4,25 @@ # directory is empty when the process exits. SPEC_TEMP_DIR_PID = Process.pid -SPEC_TEMP_DIR = File.expand_path(ENV["SPEC_TEMP_DIR"] || "rubyspec_temp/#{SPEC_TEMP_DIR_PID}") +SPEC_TEMP_DIR_LIST = [] +if tmpdir = ENV['SPEC_TEMP_DIR'] + temppath = File.expand_path(tmpdir) + "/" +else + tmpdir = File.expand_path("rubyspec_temp") + temppath = tmpdir + "/#{SPEC_TEMP_DIR_PID}" + SPEC_TEMP_DIR_LIST << tmpdir +end +SPEC_TEMP_DIR_LIST << temppath +SPEC_TEMP_DIR = temppath SPEC_TEMP_UNIQUIFIER = "0" at_exit do begin if SPEC_TEMP_DIR_PID == Process.pid - Dir.delete SPEC_TEMP_DIR if File.directory? SPEC_TEMP_DIR + while temppath = SPEC_TEMP_DIR_LIST.pop + next unless File.directory? temppath + Dir.delete temppath + end end rescue SystemCallError STDERR.puts <<-EOM @@ -18,7 +30,7 @@ ----------------------------------------------------- The rubyspec temp directory is not empty. Ensure that all specs are cleaning up temporary files: - #{SPEC_TEMP_DIR} + #{temppath} ----------------------------------------------------- EOM From 1c7f5a57125001447dc6173847dc68aa50bd8e93 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 28 Apr 2020 23:36:16 +0900 Subject: [PATCH 138/234] Removed unnecessary RLIMIT_AS Even without this limit, these assertions almost certainly cause a NoMemoryError by removing the fix in 72ad8595f20. --- test/ripper/test_parser_events.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb index feb3db05d85d4f..b6eeb77cda4b2c 100644 --- a/test/ripper/test_parser_events.rb +++ b/test/ripper/test_parser_events.rb @@ -1490,16 +1490,9 @@ def test_local_variables end def test_block_variables - assert_equal("[fcall(proc,[],&block([],[void()]))]", parse("proc{|;y|}")) - if defined?(Process::RLIMIT_AS) - dir = File.dirname(__FILE__) - as = 100 * 1024 * 1024 # 100MB - as *= 2 if RubyVM::MJIT.enabled? # space for compiler - assert_in_out_err(%W(-I#{dir} -rdummyparser), - "Process.setrlimit(Process::RLIMIT_AS,#{as}); "\ - "puts DummyParser.new('proc{|;y|!y}').parse", - ["[fcall(proc,[],&block([],[unary(!,ref(y))]))]"], [], '[ruby-dev:39423]') - end + bug4159 = '[ruby-dev:39423]' + assert_equal("[fcall(proc,[],&block([],[void()]))]", parse("proc{|;y|}"), bug4159) + assert_equal("[fcall(proc,[],&block([],[unary(!,ref(y))]))]", parse("proc{|;y|!y}"), bug4159) end def test_unterminated_regexp From 31a4ee4caa3c73549cb8f3a14c99494daaa2f204 Mon Sep 17 00:00:00 2001 From: git Date: Wed, 29 Apr 2020 00:01:40 +0900 Subject: [PATCH 139/234] * 2020-04-29 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index def2177efcc4ff..41e1490eac315c 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 28 +#define RUBY_RELEASE_DAY 29 #include "ruby/version.h" From 1994ed90e4013b3a35d72743a0e7648efc31576c Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Wed, 29 Apr 2020 00:01:46 +0900 Subject: [PATCH 140/234] Remove debugging code from gc.c Partially revert adab82b9a71f60ad1c7f4f8c134a5ae9198ab32a and c63b5c6179d700ceacf5cae8d3ee86da1294c781. The issue that these commits attempt to address was maybe fixed with 1c7f5a57125001447dc6173847dc68aa50bd8e93. --- gc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gc.c b/gc.c index 2638fce8fe77da..5d313c982ff2b4 100644 --- a/gc.c +++ b/gc.c @@ -9644,9 +9644,6 @@ rb_memerror(void) exc = ruby_vm_special_exception_copy(exc); } ec->errinfo = exc; -#ifdef __INTEL_COMPILER - __builtin_trap(); /* Yes, icc has it.*/ -#endif EC_JUMP_TAG(ec, TAG_RAISE); } @@ -9860,7 +9857,7 @@ objspace_malloc_fixup(rb_objspace_t *objspace, void *mem, size_t size) return mem; } -#if defined(__GNUC__) /* && RUBY_DEBUG */ +#if defined(__GNUC__) && RUBY_DEBUG #define RB_BUG_INSTEAD_OF_RB_MEMERROR #endif From ac0c760843b8bef48d314cacf3f552963391ed16 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 29 Apr 2020 00:27:50 +0900 Subject: [PATCH 141/234] Mark ruby_memerror as NORETURN --- gc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gc.c b/gc.c index 5d313c982ff2b4..205a986271c8f4 100644 --- a/gc.c +++ b/gc.c @@ -9596,6 +9596,7 @@ ruby_memerror_body(void *dummy) return 0; } +NORETURN(static void ruby_memerror(void)); RUBY3_ATTR_MAYBE_UNUSED() static void ruby_memerror(void) @@ -9610,9 +9611,9 @@ ruby_memerror(void) else { /* no ruby thread */ fprintf(stderr, "[FATAL] failed to allocate memory\n"); - exit(EXIT_FAILURE); } } + exit(EXIT_FAILURE); } void From 56d6cfe88ae355a089a164f351dcd7f2112cf852 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 28 Apr 2020 19:54:14 +0900 Subject: [PATCH 142/234] .travis.yml: hoisted out spec-on-old-ruby --- .travis.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 48668c5d8f405f..c720cb354daa32 100644 --- a/.travis.yml +++ b/.travis.yml @@ -360,27 +360,25 @@ env: -Wunused-variable' - LDFLAGS=-Wno-unused-command-line-argument - - &rubyspec25 - name: Check ruby/spec version guards on Ruby 2.5 + - &spec-on-old-ruby language: ruby - rvm: 2.5.7 before_install: install: before_script: chmod -R u+w spec/ruby # -j randomly hangs. script: ruby -C spec/ruby ../mspec/bin/mspec . + + - &rubyspec25 + name: Check ruby/spec version guards on Ruby 2.5 + rvm: 2.5.7 + <<: *spec-on-old-ruby after_failure: - echo "ruby/spec failed on Ruby 2.5. This is likely because of a missing ruby_version_is guard, please add it. See spec/README.md." - &rubyspec27 name: Check ruby/spec version guards on Ruby 2.7 - language: ruby rvm: 2.7.0 - before_install: - install: - before_script: chmod -R u+w spec/ruby - # -j randomly hangs. - script: ruby -C spec/ruby ../mspec/bin/mspec . + <<: *spec-on-old-ruby after_failure: - echo "ruby/spec failed on Ruby 2.7. This is likely because of a missing ruby_version_is guard, please add it. See spec/README.md." From 32e7d9140eb2bc9890a690fd62bf1690ee8fd5e3 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 29 Apr 2020 14:38:03 +0900 Subject: [PATCH 143/234] [ruby/spec] Temporary directories should be under the mock_dir --- spec/ruby/core/dir/fixtures/common.rb | 2 +- spec/ruby/core/dir/mkdir_spec.rb | 34 ++++++++++++++----------- spec/ruby/shared/file/world_readable.rb | 2 +- spec/ruby/shared/file/world_writable.rb | 2 +- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/spec/ruby/core/dir/fixtures/common.rb b/spec/ruby/core/dir/fixtures/common.rb index f6708b04f78a2d..96dba56c93b690 100644 --- a/spec/ruby/core/dir/fixtures/common.rb +++ b/spec/ruby/core/dir/fixtures/common.rb @@ -22,7 +22,7 @@ def self.clear_dirs [0xe9].pack('U') ].each do |dir| begin - Dir.rmdir dir + Dir.rmdir mock_dir(dir) rescue end end diff --git a/spec/ruby/core/dir/mkdir_spec.rb b/spec/ruby/core/dir/mkdir_spec.rb index c6e2f164e2f633..0ed28f5a99dc79 100644 --- a/spec/ruby/core/dir/mkdir_spec.rb +++ b/spec/ruby/core/dir/mkdir_spec.rb @@ -13,29 +13,33 @@ it "creates the named directory with the given permissions" do DirSpecs.clear_dirs + nonexisting = DirSpecs.mock_dir('nonexisting') + default_perms = DirSpecs.mock_dir('default_perms') + reduced = DirSpecs.mock_dir('reduced') begin - File.should_not.exist?('nonexisting') - Dir.mkdir 'nonexisting' - File.should.exist?('nonexisting') + File.should_not.exist?(nonexisting) + Dir.mkdir nonexisting + File.should.exist?(nonexisting) platform_is_not :windows do - Dir.mkdir 'default_perms' - a = File.stat('default_perms').mode - Dir.mkdir 'reduced', (a - 1) - File.stat('reduced').mode.should_not == a + Dir.mkdir default_perms + a = File.stat(default_perms).mode + Dir.mkdir reduced, (a - 1) + File.stat(reduced).mode.should_not == a end platform_is :windows do - Dir.mkdir 'default_perms', 0666 - a = File.stat('default_perms').mode - Dir.mkdir 'reduced', 0444 - File.stat('reduced').mode.should_not == a + Dir.mkdir default_perms, 0666 + a = File.stat(default_perms).mode + Dir.mkdir reduced, 0444 + File.stat(reduced).mode.should_not == a end - Dir.mkdir('always_returns_0').should == 0 + always_returns_0 = DirSpecs.mock_dir('always_returns_0') + Dir.mkdir(always_returns_0).should == 0 platform_is_not(:windows) do - File.chmod(0777, "nonexisting","default_perms","reduced","always_returns_0") + File.chmod(0777, nonexisting, default_perms, reduced, always_returns_0) end platform_is_not(:windows) do - File.chmod(0644, "nonexisting","default_perms","reduced","always_returns_0") + File.chmod(0644, nonexisting, default_perms, reduced, always_returns_0) end ensure DirSpecs.clear_dirs @@ -45,7 +49,7 @@ it "calls #to_path on non-String arguments" do DirSpecs.clear_dirs p = mock('path') - p.should_receive(:to_path).and_return('nonexisting') + p.should_receive(:to_path).and_return(DirSpecs.mock_dir('nonexisting')) Dir.mkdir(p) DirSpecs.clear_dirs end diff --git a/spec/ruby/shared/file/world_readable.rb b/spec/ruby/shared/file/world_readable.rb index 85761e633f2be4..c2c62646277fd9 100644 --- a/spec/ruby/shared/file/world_readable.rb +++ b/spec/ruby/shared/file/world_readable.rb @@ -35,7 +35,7 @@ end it "returns a Fixnum if the file is a directory and chmod 644" do - dir = rand().to_s + '-ww' + dir = tmp(rand().to_s + '-ww') Dir.mkdir(dir) Dir.should.exist?(dir) File.chmod(0644, dir) diff --git a/spec/ruby/shared/file/world_writable.rb b/spec/ruby/shared/file/world_writable.rb index 61b691bcb6d162..84d7deb5d3eba1 100644 --- a/spec/ruby/shared/file/world_writable.rb +++ b/spec/ruby/shared/file/world_writable.rb @@ -34,7 +34,7 @@ end it "returns a Fixnum if the file is a directory and chmod 777" do - dir = rand().to_s + '-ww' + dir = tmp(rand().to_s + '-ww') Dir.mkdir(dir) Dir.should.exist?(dir) File.chmod(0777, dir) From e801e9ba65f6d98f6fee32a1e7e553e6586230cd Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 29 Apr 2020 14:40:14 +0900 Subject: [PATCH 144/234] [ruby/spec] expand temporary directory to the real path It may contain symbolic links. --- spec/mspec/lib/mspec/helpers/tmp.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/mspec/lib/mspec/helpers/tmp.rb b/spec/mspec/lib/mspec/helpers/tmp.rb index 433c0b6d883118..df242f73c155ca 100644 --- a/spec/mspec/lib/mspec/helpers/tmp.rb +++ b/spec/mspec/lib/mspec/helpers/tmp.rb @@ -6,9 +6,9 @@ SPEC_TEMP_DIR_PID = Process.pid SPEC_TEMP_DIR_LIST = [] if tmpdir = ENV['SPEC_TEMP_DIR'] - temppath = File.expand_path(tmpdir) + "/" + temppath = File.realdirpath(tmpdir) + "/" else - tmpdir = File.expand_path("rubyspec_temp") + tmpdir = File.realdirpath("rubyspec_temp") temppath = tmpdir + "/#{SPEC_TEMP_DIR_PID}" SPEC_TEMP_DIR_LIST << tmpdir end From 0ac5009165e0d743b82ac673d4eb98e871f4ea0b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 24 Apr 2020 17:54:54 +0900 Subject: [PATCH 145/234] [ruby/reline] Ignore non-absolute XDG_CONFIG_HOME https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html > All paths set in these environment variables must be absolute. > If an implementation encounters a relative path in any of these > variables it should consider the path invalid and ignore it. https://github.com/ruby/reline/commit/45af6eea77 --- lib/reline/config.rb | 11 ++++++----- test/reline/test_config.rb | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/lib/reline/config.rb b/lib/reline/config.rb index b299bcc9cd798b..fd761aeb21361f 100644 --- a/lib/reline/config.rb +++ b/lib/reline/config.rb @@ -94,15 +94,16 @@ def inputrc_path home_rc_path = File.expand_path('~/.inputrc') return home_rc_path if File.exist?(home_rc_path) - case ENV['XDG_CONFIG_HOME'] + case path = ENV['XDG_CONFIG_HOME'] when nil, '' - path = File.expand_path('~/.config/readline/inputrc') - return path if File.exist?(path) else - path = File.expand_path("#{ENV['XDG_CONFIG_HOME']}/readline/inputrc") - return path if File.exist?(path) + path = File.join(path, 'readline/inputrc') + return path if File.exist?(path) and path == File.expand_path(path) end + path = File.expand_path('~/.config/readline/inputrc') + return path if File.exist?(path) + return home_rc_path end diff --git a/test/reline/test_config.rb b/test/reline/test_config.rb index bf980a2c9863b1..d24d4e837e7101 100644 --- a/test/reline/test_config.rb +++ b/test/reline/test_config.rb @@ -213,6 +213,7 @@ def test_empty_inputrc_env assert_nothing_raised do @config.read end + ensure ENV['INPUTRC'] = inputrc_backup end @@ -221,6 +222,7 @@ def test_inputrc expected = "#{@tmpdir}/abcde" ENV['INPUTRC'] = expected assert_equal expected, @config.inputrc_path + ensure ENV['INPUTRC'] = inputrc_backup end @@ -234,6 +236,7 @@ def test_xdg_config_home ENV['HOME'] = @tmpdir ENV['XDG_CONFIG_HOME'] = xdg_config_home assert_equal expected, @config.inputrc_path + ensure FileUtils.rm(expected) ENV['XDG_CONFIG_HOME'] = xdg_config_home_backup ENV['HOME'] = home_backup @@ -248,6 +251,28 @@ def test_empty_xdg_config_home FileUtils.mkdir_p(File.dirname(expected)) FileUtils.touch(expected) assert_equal expected, @config.inputrc_path + ensure + FileUtils.rm(expected) + ENV['XDG_CONFIG_HOME'] = xdg_config_home_backup + ENV['HOME'] = home_backup + end + + def test_relative_xdg_config_home + home_backup = ENV['HOME'] + xdg_config_home_backup = ENV['XDG_CONFIG_HOME'] + ENV['HOME'] = @tmpdir + expected = File.expand_path('~/.config/readline/inputrc') + FileUtils.mkdir_p(File.dirname(expected)) + FileUtils.touch(expected) + result = Dir.chdir(@tmpdir) do + xdg_config_home = ".config/example_dir" + ENV['XDG_CONFIG_HOME'] = xdg_config_home + inputrc = "#{xdg_config_home}/readline/inputrc" + FileUtils.mkdir_p(File.dirname(inputrc)) + FileUtils.touch(inputrc) + @config.inputrc_path + end + assert_equal expected, result FileUtils.rm(expected) ENV['XDG_CONFIG_HOME'] = xdg_config_home_backup ENV['HOME'] = home_backup From d27fa87418bcec8fff909f75a547a7c5e6dc83e5 Mon Sep 17 00:00:00 2001 From: aycabta Date: Sat, 25 Apr 2020 01:45:03 +0900 Subject: [PATCH 146/234] [ruby/reline] New items to history are dropped if history_size is zero https://github.com/ruby/reline/commit/9bdbed9cbc --- lib/reline/history.rb | 4 ++++ test/reline/test_history.rb | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/reline/history.rb b/lib/reline/history.rb index d95f1cebc3b8e4..2e6a12ecf32a1e 100644 --- a/lib/reline/history.rb +++ b/lib/reline/history.rb @@ -29,6 +29,8 @@ def concat(*val) end def push(*val) + # If history_size is zero, all histories are dropped. + return self if @config.history_size.zero? diff = size + val.size - @config.history_size if diff > 0 if diff <= size @@ -43,6 +45,8 @@ def push(*val) end def <<(val) + # If history_size is zero, all histories are dropped. + return self if @config.history_size.zero? shift if size + 1 > @config.history_size super(String.new(val, encoding: Reline.encoding_system_needs)) end diff --git a/test/reline/test_history.rb b/test/reline/test_history.rb index 189f2db86d583e..0cb148d112bc0e 100644 --- a/test/reline/test_history.rb +++ b/test/reline/test_history.rb @@ -242,6 +242,16 @@ def test_delete_at__out_of_range end end + def test_history_size_zero + history = history_new(history_size: 0) + assert_equal 0, history.size + history << 'aa' + history << 'bb' + assert_equal 0, history.size + history.push(*%w{aa bb cc}) + assert_equal 0, history.size + end + private def history_new(history_size: 10) From 4859352df62c05bbc10e1e62f966d493eb771e66 Mon Sep 17 00:00:00 2001 From: aycabta Date: Sat, 25 Apr 2020 02:20:52 +0900 Subject: [PATCH 147/234] [ruby/reline] Negative history_size means unlimited And unlimited is default. https://github.com/ruby/reline/commit/f5149c3ca6 --- lib/reline/config.rb | 2 +- lib/reline/history.rb | 38 ++++++++++++++++++++++++++----------- test/reline/test_history.rb | 10 ++++++++++ 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/lib/reline/config.rb b/lib/reline/config.rb index fd761aeb21361f..c5e4450034737a 100644 --- a/lib/reline/config.rb +++ b/lib/reline/config.rb @@ -52,7 +52,7 @@ def initialize @key_actors[:emacs] = Reline::KeyActor::Emacs.new @key_actors[:vi_insert] = Reline::KeyActor::ViInsert.new @key_actors[:vi_command] = Reline::KeyActor::ViCommand.new - @history_size = 500 + @history_size = -1 # unlimited @keyseq_timeout = 500 @test_mode = false end diff --git a/lib/reline/history.rb b/lib/reline/history.rb index 2e6a12ecf32a1e..7a1ed6b90baa41 100644 --- a/lib/reline/history.rb +++ b/lib/reline/history.rb @@ -31,29 +31,45 @@ def concat(*val) def push(*val) # If history_size is zero, all histories are dropped. return self if @config.history_size.zero? - diff = size + val.size - @config.history_size - if diff > 0 - if diff <= size - shift(diff) - else - diff -= size - clear - val.shift(diff) + # If history_size is negative, history size is unlimited. + if @config.history_size.positive? + diff = size + val.size - @config.history_size + if diff > 0 + if diff <= size + shift(diff) + else + diff -= size + clear + val.shift(diff) + end end end - super(*(val.map{ |v| String.new(v, encoding: Reline.encoding_system_needs) })) + super(*(val.map{ |v| + String.new(v, encoding: Reline.encoding_system_needs) + })) end def <<(val) # If history_size is zero, all histories are dropped. return self if @config.history_size.zero? - shift if size + 1 > @config.history_size + # If history_size is negative, history size is unlimited. + if @config.history_size.positive? + shift if size + 1 > @config.history_size + end super(String.new(val, encoding: Reline.encoding_system_needs)) end private def check_index(index) index += size if index < 0 - raise RangeError.new("index=<#{index}>") if index < -@config.history_size or @config.history_size < index + if index < -2147483648 or 2147483647 < index + raise RangeError.new("integer #{index} too big to convert to `int'") + end + # If history_size is negative, history size is unlimited. + if @config.history_size.positive? + if index < -@config.history_size or @config.history_size < index + raise RangeError.new("index=<#{index}>") + end + end raise IndexError.new("index=<#{index}>") if index < 0 or size <= index index end diff --git a/test/reline/test_history.rb b/test/reline/test_history.rb index 0cb148d112bc0e..58c240fc962287 100644 --- a/test/reline/test_history.rb +++ b/test/reline/test_history.rb @@ -252,6 +252,16 @@ def test_history_size_zero assert_equal 0, history.size end + def test_history_size_negative_unlimited + history = history_new(history_size: -1) + assert_equal 0, history.size + history << 'aa' + history << 'bb' + assert_equal 2, history.size + history.push(*%w{aa bb cc}) + assert_equal 5, history.size + end + private def history_new(history_size: 10) From 213ebec7a7a861eeb5fddd0bd0cf74498a520e63 Mon Sep 17 00:00:00 2001 From: aycabta Date: Sat, 25 Apr 2020 17:15:24 +0900 Subject: [PATCH 148/234] [ruby/reline] Version 0.1.4 https://github.com/ruby/reline/commit/298144b06a --- lib/reline/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reline/version.rb b/lib/reline/version.rb index 1bf544d74b82c3..a243bf31a0056c 100644 --- a/lib/reline/version.rb +++ b/lib/reline/version.rb @@ -1,3 +1,3 @@ module Reline - VERSION = '0.1.3' + VERSION = '0.1.4' end From 009092b04cf1fc36feb2e9257d131ec57242984f Mon Sep 17 00:00:00 2001 From: aycabta Date: Sun, 26 Apr 2020 03:18:38 +0900 Subject: [PATCH 149/234] [ruby/reline] Add URL reference of history-size https://github.com/ruby/reline/commit/13420197b8 --- lib/reline/config.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/reline/config.rb b/lib/reline/config.rb index c5e4450034737a..deca11f0ab9734 100644 --- a/lib/reline/config.rb +++ b/lib/reline/config.rb @@ -52,6 +52,7 @@ def initialize @key_actors[:emacs] = Reline::KeyActor::Emacs.new @key_actors[:vi_insert] = Reline::KeyActor::ViInsert.new @key_actors[:vi_command] = Reline::KeyActor::ViCommand.new + # https://tiswww.case.edu/php/chet/readline/readline.html#IDX25 @history_size = -1 # unlimited @keyseq_timeout = 500 @test_mode = false From 98a346d065cc981d60ec0e45f7f15ba7328b6ad6 Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 27 Apr 2020 18:27:19 +0900 Subject: [PATCH 150/234] [ruby/irb] Add irb_info command https://github.com/ruby/irb/commit/a6fe58e916 --- lib/irb/cmd/info.rb | 25 +++++++++++++++ lib/irb/extend-command.rb | 4 +++ lib/irb/input-method.rb | 33 ++++++++++++++++++++ test/irb/test_cmd.rb | 64 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 lib/irb/cmd/info.rb create mode 100644 test/irb/test_cmd.rb diff --git a/lib/irb/cmd/info.rb b/lib/irb/cmd/info.rb new file mode 100644 index 00000000000000..ddf57b00b40407 --- /dev/null +++ b/lib/irb/cmd/info.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: false + +require_relative "nop" + +# :stopdoc: +module IRB + module ExtendCommand + class Info < Nop + def execute + Class.new { + def inspect + <<~EOM.chomp + Ruby version: #{RUBY_VERSION} + IRB version: #{IRB.version} + InputMethod: #{IRB.CurrentContext.io.inspect} + .irbrc path: #{IRB.rc_file} + EOM + end + alias_method :to_s, :inspect + }.new + end + end + end +end +# :startdoc: diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb index de145e962db85d..828103ccc9344f 100644 --- a/lib/irb/extend-command.rb +++ b/lib/irb/extend-command.rb @@ -121,6 +121,10 @@ def irb_context [:help, NO_OVERRIDE], ], + [ + :irb_info, :Info, "irb/cmd/info" + ], + ] # Installs the default irb commands: diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb index 9fbbaeb0f33e32..47fc5db84f2684 100644 --- a/lib/irb/input-method.rb +++ b/lib/irb/input-method.rb @@ -43,6 +43,11 @@ def gets def readable_after_eof? false end + + # For debug message + def inspect + 'Abstract InputMethod' + end end class StdioInputMethod < InputMethod @@ -93,6 +98,11 @@ def line(line_no) def encoding @stdin.external_encoding end + + # For debug message + def inspect + 'StdioInputMethod' + end end # Use a File for IO with irb, see InputMethod @@ -125,6 +135,11 @@ def gets def encoding @io.external_encoding end + + # For debug message + def inspect + 'FileInputMethod' + end end begin @@ -202,6 +217,13 @@ def encoding end Readline.completion_append_character = nil Readline.completion_proc = IRB::InputCompletor::CompletionProc + + # For debug message + def inspect + inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc') + readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline' + "ReadlineInputMethod with #{readline_impl} #{Readline::VERSION} and #{inputrc_path}" + end end rescue LoadError end @@ -297,5 +319,16 @@ def line(line_no) def encoding @stdin.external_encoding end + + # For debug message + def inspect + config = Reline::Config.new + if config.respond_to?(:inputrc_path) + inputrc_path = config.inputrc_path + else + inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc') + end + "ReidlineInputMethod with Reline #{Reline::VERSION} and #{inputrc_path}" + end end end diff --git a/test/irb/test_cmd.rb b/test/irb/test_cmd.rb new file mode 100644 index 00000000000000..1f385512a68dd9 --- /dev/null +++ b/test/irb/test_cmd.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: false +require "test/unit" +require "irb" +require "irb/extend-command" + +module TestIRB + class ExtendCommand < Test::Unit::TestCase + def setup + @pwd = Dir.pwd + @tmpdir = File.join(Dir.tmpdir, "test_reline_config_#{$$}") + begin + Dir.mkdir(@tmpdir) + rescue Errno::EEXIST + FileUtils.rm_rf(@tmpdir) + Dir.mkdir(@tmpdir) + end + Dir.chdir(@tmpdir) + @home_backup = ENV["HOME"] + ENV["HOME"] = @tmpdir + end + + def teardown + ENV["HOME"] = @home_backup + Dir.chdir(@pwd) + FileUtils.rm_rf(@tmpdir) + end + + def test_irb_info_multiline + FileUtils.touch("#{@tmpdir}/.inputrc") + FileUtils.touch("#{@tmpdir}/.irbrc") + IRB.setup(__FILE__, argv: []) + IRB.conf[:USE_MULTILINE] = true + IRB.conf[:USE_SINGLELINE] = false + workspace = IRB::WorkSpace.new(self) + irb = IRB::Irb.new(workspace) + IRB.conf[:MAIN_CONTEXT] = irb.context + expected = %r{ + Ruby\sversion: .+\n + IRB\sversion:\sirb .+\n + InputMethod:\sReidlineInputMethod\swith\sReline .+ and .+\n + \.irbrc\spath: .+ + }x + assert_match expected, irb.context.main.irb_info.to_s + end + + def test_irb_info_singleline + FileUtils.touch("#{@tmpdir}/.inputrc") + FileUtils.touch("#{@tmpdir}/.irbrc") + IRB.setup(__FILE__, argv: []) + IRB.conf[:USE_MULTILINE] = false + IRB.conf[:USE_SINGLELINE] = true + workspace = IRB::WorkSpace.new(self) + irb = IRB::Irb.new(workspace) + IRB.conf[:MAIN_CONTEXT] = irb.context + expected = %r{ + Ruby\sversion: .+\n + IRB\sversion:\sirb .+\n + InputMethod:\sReadlineInputMethod\swith .+ and .+\n + \.irbrc\spath: .+ + }x + assert_match expected, irb.context.main.irb_info.to_s + end + end +end From 3864fbc6d85b834be4567fa1d5bd0dccc4dfd808 Mon Sep 17 00:00:00 2001 From: aycabta Date: Tue, 28 Apr 2020 17:06:43 +0900 Subject: [PATCH 151/234] [ruby/irb] Check existence of rc files in irb_info command https://github.com/ruby/irb/commit/cdbb9dfc9f --- lib/irb/cmd/info.rb | 11 +++++---- lib/irb/input-method.rb | 10 ++++++--- test/irb/test_cmd.rb | 50 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 9 deletions(-) diff --git a/lib/irb/cmd/info.rb b/lib/irb/cmd/info.rb index ddf57b00b40407..53ec71d754739f 100644 --- a/lib/irb/cmd/info.rb +++ b/lib/irb/cmd/info.rb @@ -9,12 +9,11 @@ class Info < Nop def execute Class.new { def inspect - <<~EOM.chomp - Ruby version: #{RUBY_VERSION} - IRB version: #{IRB.version} - InputMethod: #{IRB.CurrentContext.io.inspect} - .irbrc path: #{IRB.rc_file} - EOM + str = "Ruby version: #{RUBY_VERSION}\n" + str += "IRB version: #{IRB.version}\n" + str += "InputMethod: #{IRB.CurrentContext.io.inspect}\n" + str += ".irbrc path: #{IRB.rc_file}\n" if File.exist?(IRB.rc_file) + str end alias_method :to_s, :inspect }.new diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb index 47fc5db84f2684..8f337e0eac8f91 100644 --- a/lib/irb/input-method.rb +++ b/lib/irb/input-method.rb @@ -220,9 +220,11 @@ def encoding # For debug message def inspect - inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc') readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline' - "ReadlineInputMethod with #{readline_impl} #{Readline::VERSION} and #{inputrc_path}" + str = "ReadlineInputMethod with #{readline_impl} #{Readline::VERSION}" + inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc') + str += " and #{inputrc_path}" if File.exist?(inputrc_path) + str end end rescue LoadError @@ -323,12 +325,14 @@ def encoding # For debug message def inspect config = Reline::Config.new + str = "ReidlineInputMethod with Reline #{Reline::VERSION}" if config.respond_to?(:inputrc_path) inputrc_path = config.inputrc_path else inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc') end - "ReidlineInputMethod with Reline #{Reline::VERSION} and #{inputrc_path}" + str += " and #{inputrc_path}" if File.exist?(inputrc_path) + str end end end diff --git a/test/irb/test_cmd.rb b/test/irb/test_cmd.rb index 1f385512a68dd9..7a9e7d79e1e09a 100644 --- a/test/irb/test_cmd.rb +++ b/test/irb/test_cmd.rb @@ -60,5 +60,55 @@ def test_irb_info_singleline }x assert_match expected, irb.context.main.irb_info.to_s end + + def test_irb_info_multiline_without_rc_files + inputrc_backup = ENV["INPUTRC"] + ENV["INPUTRC"] = "unkown_inpurc" + ext_backup = IRB::IRBRC_EXT + IRB.__send__(:remove_const, :IRBRC_EXT) + IRB.const_set(:IRBRC_EXT, "unkown_ext") + IRB.setup(__FILE__, argv: []) + IRB.conf[:USE_MULTILINE] = true + IRB.conf[:USE_SINGLELINE] = false + workspace = IRB::WorkSpace.new(self) + irb = IRB::Irb.new(workspace) + IRB.conf[:MAIN_CONTEXT] = irb.context + expected = %r{ + Ruby\sversion: .+\n + IRB\sversion:\sirb .+\n + InputMethod:\sReidlineInputMethod\swith\sReline\s[^ ]+(?!\sand\s.+)\n + \z + }x + assert_match expected, irb.context.main.irb_info.to_s + ensure + ENV["INPUTRC"] = inputrc_backup + IRB.__send__(:remove_const, :IRBRC_EXT) + IRB.const_set(:IRBRC_EXT, ext_backup) + end + + def test_irb_info_singleline_without_rc_files + inputrc_backup = ENV["INPUTRC"] + ENV["INPUTRC"] = "unkown_inpurc" + ext_backup = IRB::IRBRC_EXT + IRB.__send__(:remove_const, :IRBRC_EXT) + IRB.const_set(:IRBRC_EXT, "unkown_ext") + IRB.setup(__FILE__, argv: []) + IRB.conf[:USE_MULTILINE] = false + IRB.conf[:USE_SINGLELINE] = true + workspace = IRB::WorkSpace.new(self) + irb = IRB::Irb.new(workspace) + IRB.conf[:MAIN_CONTEXT] = irb.context + expected = %r{ + Ruby\sversion: .+\n + IRB\sversion:\sirb .+\n + InputMethod:\sReadlineInputMethod\swith\s[^ ]+\s[^ ]+(?!\sand\s.+)\n + \z + }x + assert_match expected, irb.context.main.irb_info.to_s + ensure + ENV["INPUTRC"] = inputrc_backup + IRB.__send__(:remove_const, :IRBRC_EXT) + IRB.const_set(:IRBRC_EXT, ext_backup) + end end end From 7e5253d15ea1d2cdfc7942213f9c7ba79c3eda2b Mon Sep 17 00:00:00 2001 From: aycabta Date: Tue, 28 Apr 2020 17:07:27 +0900 Subject: [PATCH 152/234] [ruby/irb] Suppress "method redefined" warning https://github.com/ruby/irb/commit/5f0aee56fa --- lib/irb/extend-command.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb index 828103ccc9344f..2f4fcfb5c6f1fe 100644 --- a/lib/irb/extend-command.rb +++ b/lib/irb/extend-command.rb @@ -173,11 +173,14 @@ def #{cmd_name}(*opts, &b) args << "&block" args = args.join(", ") line = __LINE__; eval %[ - def #{cmd_name}(\#{args}) - ExtendCommand::#{cmd_class}.execute(irb_context, \#{args}) + unless self.class.class_variable_defined?(:@@#{cmd_name}_) + self.class.class_variable_set(:@@#{cmd_name}_, true) + def #{cmd_name}_(\#{args}) + ExtendCommand::#{cmd_class}.execute(irb_context, \#{args}) + end end ], nil, __FILE__, line - send :#{cmd_name}, *opts, &b + send :#{cmd_name}_, *opts, &b end ], nil, __FILE__, line else From b3ce6fa099b2fdb330d19372ab1a51fd7c97fc51 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 30 Apr 2020 11:44:09 +0900 Subject: [PATCH 153/234] [ruby/irb] Relaxed regexp for readline Readline::VERSION may not be a single word, e.g EditLine wrapper when linked with editline. --- test/irb/test_cmd.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/irb/test_cmd.rb b/test/irb/test_cmd.rb index 7a9e7d79e1e09a..92b65dd5d037b0 100644 --- a/test/irb/test_cmd.rb +++ b/test/irb/test_cmd.rb @@ -101,7 +101,7 @@ def test_irb_info_singleline_without_rc_files expected = %r{ Ruby\sversion: .+\n IRB\sversion:\sirb .+\n - InputMethod:\sReadlineInputMethod\swith\s[^ ]+\s[^ ]+(?!\sand\s.+)\n + InputMethod:\sReadlineInputMethod\swith\s(?~.*\sand\s.+)\n \z }x assert_match expected, irb.context.main.irb_info.to_s From 14b5a3b414348c44aa61471eb61fd3458452729c Mon Sep 17 00:00:00 2001 From: git Date: Thu, 30 Apr 2020 11:48:24 +0900 Subject: [PATCH 154/234] * 2020-04-30 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 41e1490eac315c..d2f9119501b530 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 29 +#define RUBY_RELEASE_DAY 30 #include "ruby/version.h" From 9d1b272b01079b95f377b7e6adc009a0d5b293c7 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 30 Apr 2020 11:56:52 +0900 Subject: [PATCH 155/234] [ruby/irb] Suppress messages switching inspect mode --- test/irb/test_cmd.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/irb/test_cmd.rb b/test/irb/test_cmd.rb index 92b65dd5d037b0..daf6375f14d3b5 100644 --- a/test/irb/test_cmd.rb +++ b/test/irb/test_cmd.rb @@ -31,6 +31,7 @@ def test_irb_info_multiline IRB.setup(__FILE__, argv: []) IRB.conf[:USE_MULTILINE] = true IRB.conf[:USE_SINGLELINE] = false + IRB.conf[:VERBOSE] = false workspace = IRB::WorkSpace.new(self) irb = IRB::Irb.new(workspace) IRB.conf[:MAIN_CONTEXT] = irb.context @@ -49,6 +50,7 @@ def test_irb_info_singleline IRB.setup(__FILE__, argv: []) IRB.conf[:USE_MULTILINE] = false IRB.conf[:USE_SINGLELINE] = true + IRB.conf[:VERBOSE] = false workspace = IRB::WorkSpace.new(self) irb = IRB::Irb.new(workspace) IRB.conf[:MAIN_CONTEXT] = irb.context @@ -70,6 +72,7 @@ def test_irb_info_multiline_without_rc_files IRB.setup(__FILE__, argv: []) IRB.conf[:USE_MULTILINE] = true IRB.conf[:USE_SINGLELINE] = false + IRB.conf[:VERBOSE] = false workspace = IRB::WorkSpace.new(self) irb = IRB::Irb.new(workspace) IRB.conf[:MAIN_CONTEXT] = irb.context @@ -95,6 +98,7 @@ def test_irb_info_singleline_without_rc_files IRB.setup(__FILE__, argv: []) IRB.conf[:USE_MULTILINE] = false IRB.conf[:USE_SINGLELINE] = true + IRB.conf[:VERBOSE] = false workspace = IRB::WorkSpace.new(self) irb = IRB::Irb.new(workspace) IRB.conf[:MAIN_CONTEXT] = irb.context From 4a8acf46258e1b6fb57e75e4461f9e4895064bda Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 30 Apr 2020 22:54:42 +0900 Subject: [PATCH 156/234] [ruby/irb] Restore the default encodings IRB::ReadlineInputMethod#initialize sets via IRB.set_encoding. --- test/irb/test_cmd.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/irb/test_cmd.rb b/test/irb/test_cmd.rb index daf6375f14d3b5..e50d036f1976f8 100644 --- a/test/irb/test_cmd.rb +++ b/test/irb/test_cmd.rb @@ -17,12 +17,16 @@ def setup Dir.chdir(@tmpdir) @home_backup = ENV["HOME"] ENV["HOME"] = @tmpdir + @default_encoding = [Encoding.default_external, Encoding.default_internal] end def teardown ENV["HOME"] = @home_backup Dir.chdir(@pwd) FileUtils.rm_rf(@tmpdir) + EnvUtil.suppress_warning { + Encoding.default_external, Encoding.default_internal = *@default_encoding + } end def test_irb_info_multiline From 5a9d2da76e89412cc3d13d4197f624a620f85393 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Thu, 30 Apr 2020 09:14:04 -0700 Subject: [PATCH 157/234] Remove deprecated rb_require_safe --- include/ruby/3/intern/load.h | 1 - load.c | 17 ----------------- 2 files changed, 18 deletions(-) diff --git a/include/ruby/3/intern/load.h b/include/ruby/3/intern/load.h index 1a1dfb001efefe..6baf6b72b6dd59 100644 --- a/include/ruby/3/intern/load.h +++ b/include/ruby/3/intern/load.h @@ -32,7 +32,6 @@ int rb_provided(const char*); int rb_feature_provided(const char *, const char **); void rb_provide(const char*); VALUE rb_f_require(VALUE, VALUE); -VALUE rb_require_safe(VALUE, int); /* Remove in 3.0 */ VALUE rb_require_string(VALUE); RUBY3_SYMBOL_EXPORT_END() diff --git a/load.c b/load.c index 0cb0dd3cfa8dd7..f917a736f2aec2 100644 --- a/load.c +++ b/load.c @@ -1087,23 +1087,6 @@ ruby_require_internal(const char *fname, unsigned int len) return result == TAG_RETURN ? 1 : result ? -1 : 0; } -VALUE -rb_require_safe(VALUE fname, int safe) -{ - rb_warn("rb_require_safe will be removed in Ruby 3.0"); - rb_execution_context_t *ec = GET_EC(); - int result = require_internal(ec, fname, 1); - - if (result > TAG_RETURN) { - EC_JUMP_TAG(ec, result); - } - if (result < 0) { - load_failed(fname); - } - - return result ? Qtrue : Qfalse; -} - VALUE rb_require_string(VALUE fname) { From 9014c900b66514cdb12c77115d5fcd7cf7a4c3c3 Mon Sep 17 00:00:00 2001 From: git Date: Fri, 1 May 2020 02:32:56 +0900 Subject: [PATCH 158/234] * 2020-05-01 [ci skip] --- version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.h b/version.h index d2f9119501b530..2ea9bb48931e16 100644 --- a/version.h +++ b/version.h @@ -15,8 +15,8 @@ #define RUBY_PATCHLEVEL -1 #define RUBY_RELEASE_YEAR 2020 -#define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 30 +#define RUBY_RELEASE_MONTH 5 +#define RUBY_RELEASE_DAY 1 #include "ruby/version.h" From 520ac5da22c30d6db25de6dcbff9607d8a9cd870 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 1 May 2020 10:58:27 +0900 Subject: [PATCH 159/234] [pty] do not check openpty twice if found in util library --- ext/pty/extconf.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/pty/extconf.rb b/ext/pty/extconf.rb index 7721a744c812af..038bdf4d2c337f 100644 --- a/ext/pty/extconf.rb +++ b/ext/pty/extconf.rb @@ -10,9 +10,9 @@ have_header("util.h") # OpenBSD openpty have_header("pty.h") have_header("pwd.h") - have_library("util", "openpty") + util = have_library("util", "openpty") if have_func("posix_openpt") or - have_func("openpty") or + (util or have_func("openpty")) or have_func("_getpty") or have_func("ptsname") or have_func("ioctl") From e8a78d7df899291aa025e41207436a450235a4d7 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 30 Apr 2020 21:37:55 -0700 Subject: [PATCH 160/234] Do not stop the world during JIT compaction Running C compiler for JIT compaction inside a critical section may lock main thread for a long time when it triggers GC. As I'm planning to increase this duration a bit, I'd like to make sure this doesn't stop the world. For now, I chose to give up unloading units when it's during JIT compaction, assuming other calls may unload them later. --- mjit.c | 18 +++++++++++------- mjit_worker.c | 18 ++++++++++-------- test/ruby/test_jit.rb | 6 ++++-- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/mjit.c b/mjit.c index c394cd5ddb329f..59e58f3f704f16 100644 --- a/mjit.c +++ b/mjit.c @@ -362,11 +362,7 @@ unload_units(void) free_unit(worst); } - if (units_num == active_units.length && mjit_opts.wait) { - mjit_opts.max_cache_size++; // avoid infinite loop on `rb_mjit_wait_call`. Note that --jit-wait is just for testing. - verbose(1, "No units can be unloaded -- incremented max-cache-size to %d for --jit-wait", mjit_opts.max_cache_size); - } - else { + if (units_num > active_units.length) { verbose(1, "Too many JIT code -- %d units unloaded", units_num - active_units.length); } } @@ -389,8 +385,16 @@ mjit_add_iseq_to_process(const rb_iseq_t *iseq, const struct rb_mjit_compile_inf CRITICAL_SECTION_START(3, "in add_iseq_to_process"); add_to_list(iseq->body->jit_unit, &unit_queue); if (active_units.length >= mjit_opts.max_cache_size) { - RB_DEBUG_COUNTER_INC(mjit_unload_units); - unload_units(); + if (in_compact) { + verbose(1, "Too many JIT code, but skipped unloading units for JIT compaction"); + } else { + RB_DEBUG_COUNTER_INC(mjit_unload_units); + unload_units(); + } + if (active_units.length == mjit_opts.max_cache_size && mjit_opts.wait) { // Sometimes all methods may be in use + mjit_opts.max_cache_size++; // avoid infinite loop on `rb_mjit_wait_call`. Note that --jit-wait is just for testing. + verbose(1, "No units can be unloaded -- incremented max-cache-size to %d for --jit-wait", mjit_opts.max_cache_size); + } } verbose(3, "Sending wakeup signal to workers in mjit_add_iseq_to_process"); rb_native_cond_broadcast(&mjit_worker_wakeup); diff --git a/mjit_worker.c b/mjit_worker.c index a2f62448e1e7a1..04eac1f55fee40 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -221,9 +221,11 @@ static rb_nativethread_cond_t mjit_worker_wakeup; // A thread conditional to wake up workers if at the end of GC. static rb_nativethread_cond_t mjit_gc_wakeup; // True when GC is working. -static bool in_gc; +static bool in_gc = false; // True when JIT is working. -static bool in_jit; +static bool in_jit = false; +// True when JIT compaction is running. +static bool in_compact = false; // Set to true to stop worker. static bool stop_worker_p; // Set to true if worker is stopped. @@ -913,21 +915,21 @@ compact_all_jit_code(void) // NULL-ending for form_args o_files = alloca(sizeof(char *) * (active_units.length + 1)); o_files[active_units.length] = NULL; - CRITICAL_SECTION_START(3, "in compact_all_jit_code to keep .o files"); + CRITICAL_SECTION_START(3, "in compact_all_jit_code to guard .o files from unload_units"); list_for_each(&active_units.head, cur, unode) { o_files[i] = cur->o_file; i++; } + in_compact = true; + CRITICAL_SECTION_FINISH(3, "in compact_all_jit_code to guard .o files from unload_units"); start_time = real_ms_time(); bool success = link_o_to_so(o_files, so_file); end_time = real_ms_time(); - // TODO: Shrink this big critical section. For now, this is needed to prevent failure by missing .o files. - // This assumes that o -> so link doesn't take long time because the bottleneck, which is compiler optimization, - // is already done. But actually it takes about 500ms for 5,000 methods on my Linux machine, so it's better to - // finish this critical section before link_o_to_so by disabling unload_units. - CRITICAL_SECTION_FINISH(3, "in compact_all_jit_code to keep .o files"); + CRITICAL_SECTION_START(3, "in compact_all_jit_code to release .o files"); + in_compact = false; + CRITICAL_SECTION_FINISH(3, "in compact_all_jit_code to release .o files"); if (success) { void *handle = dlopen(so_file, RTLD_NOW); diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb index 9e4367b6d19320..1d0c86d7d71356 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -14,6 +14,7 @@ class TestJIT < Test::Unit::TestCase ] MAX_CACHE_PATTERNS = [ /\AJIT compaction \([^)]+\): .+\n\z/, + /\AToo many JIT code, but skipped unloading units for JIT compaction\n\z/, /\ANo units can be unloaded -- .+\n\z/, ] @@ -700,8 +701,9 @@ def mjit#{i} 10.times do |i| assert_match(/\A#{JIT_SUCCESS_PREFIX}: mjit#{i}@\(eval\):/, errs[i], debug_info) end - assert_equal("Too many JIT code -- 1 units unloaded\n", errs[10], debug_info) - assert_match(/\A#{JIT_SUCCESS_PREFIX}: mjit10@\(eval\):/, errs[11], debug_info) + assert_equal("Too many JIT code, but skipped unloading units for JIT compaction\n", errs[10], debug_info) + assert_equal("No units can be unloaded -- incremented max-cache-size to 11 for --jit-wait\n", errs[11], debug_info) + assert_match(/\A#{JIT_SUCCESS_PREFIX}: mjit10@\(eval\):/, errs[12], debug_info) # On --jit-wait, when the number of JIT-ed code reaches --jit-max-cache, # it should trigger compaction. From 96837dc9e039d6f8be667f0662f36635df71cbbe Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 30 Apr 2020 22:21:45 -0700 Subject: [PATCH 161/234] Switch test_unload_units_and_compaction on mswin because we support JIT compaction on it --- test/ruby/test_jit.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb index 1d0c86d7d71356..d4e3ccba3f9446 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -701,13 +701,17 @@ def mjit#{i} 10.times do |i| assert_match(/\A#{JIT_SUCCESS_PREFIX}: mjit#{i}@\(eval\):/, errs[i], debug_info) end - assert_equal("Too many JIT code, but skipped unloading units for JIT compaction\n", errs[10], debug_info) - assert_equal("No units can be unloaded -- incremented max-cache-size to 11 for --jit-wait\n", errs[11], debug_info) - assert_match(/\A#{JIT_SUCCESS_PREFIX}: mjit10@\(eval\):/, errs[12], debug_info) # On --jit-wait, when the number of JIT-ed code reaches --jit-max-cache, # it should trigger compaction. - unless RUBY_PLATFORM.match?(/mswin|mingw/) # compaction is not supported on Windows yet + if RUBY_PLATFORM.match?(/mswin|mingw/) # compaction is not supported on Windows yet + assert_equal("Too many JIT code -- 1 units unloaded\n", errs[10], debug_info) + assert_match(/\A#{JIT_SUCCESS_PREFIX}: mjit10@\(eval\):/, errs[11], debug_info) + else + assert_equal("Too many JIT code, but skipped unloading units for JIT compaction\n", errs[10], debug_info) + assert_equal("No units can be unloaded -- incremented max-cache-size to 11 for --jit-wait\n", errs[11], debug_info) + assert_match(/\A#{JIT_SUCCESS_PREFIX}: mjit10@\(eval\):/, errs[12], debug_info) + assert_equal(3, compactions.size, debug_info) end From f5ddbba9a233c2d32118507158c5ef451167cfe0 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 30 Apr 2020 22:58:07 -0700 Subject: [PATCH 162/234] Include unit id in a function name of an inlined method I'm trying to make it possible to include all JIT-ed code in a single C file. This is needed to guarantee uniqueness of all function names --- mjit.h | 2 +- mjit_compile.c | 13 +++++++------ mjit_worker.c | 2 +- tool/ruby_vm/views/_mjit_compile_send.erb | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/mjit.h b/mjit.h index 94e0b7bd8509df..5fe7b939bb1161 100644 --- a/mjit.h +++ b/mjit.h @@ -83,7 +83,7 @@ extern struct rb_mjit_compile_info* rb_mjit_iseq_compile_info(const struct rb_is extern void rb_mjit_recompile_iseq(const rb_iseq_t *iseq); RUBY_SYMBOL_EXPORT_END -extern bool mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname); +extern bool mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname, int id); extern void mjit_init(const struct mjit_options *opts); extern void mjit_gc_start_hook(void); extern void mjit_gc_exit_hook(void); diff --git a/mjit_compile.c b/mjit_compile.c index 4d0a6252fc8fff..c3b44bdb1f8a09 100644 --- a/mjit_compile.c +++ b/mjit_compile.c @@ -55,6 +55,7 @@ struct compile_status { int cc_entries_index; // A pointer to root (i.e. not inlined) iseq being compiled. const struct rb_iseq_constant_body *compiled_iseq; + int compiled_id; // Just a copy of compiled_iseq->jit_unit->id // Mutated optimization levels struct rb_mjit_compile_info *compile_info; // If `inlined_iseqs[pos]` is not NULL, `mjit_compile_body` tries to inline ISeq there. @@ -439,7 +440,7 @@ precompile_inlinable_iseqs(FILE *f, const rb_iseq_t *iseq, struct compile_status RSTRING_PTR(child_iseq->body->location.label), RSTRING_PTR(rb_iseq_path(child_iseq)), FIX2INT(child_iseq->body->location.first_lineno)); - struct compile_status child_status = { .compiled_iseq = status->compiled_iseq }; + struct compile_status child_status = { .compiled_iseq = status->compiled_iseq, .compiled_id = status->compiled_id }; INIT_COMPILE_STATUS(child_status, child_iseq->body, false); child_status.inline_context = (struct inlined_call_context){ .orig_argc = vm_ci_argc(ci), @@ -452,12 +453,12 @@ precompile_inlinable_iseqs(FILE *f, const rb_iseq_t *iseq, struct compile_status return false; } - fprintf(f, "ALWAYS_INLINE(static VALUE _mjit_inlined_%d(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const VALUE orig_self, const rb_iseq_t *original_iseq));\n", pos); - fprintf(f, "static inline VALUE\n_mjit_inlined_%d(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const VALUE orig_self, const rb_iseq_t *original_iseq)\n{\n", pos); + fprintf(f, "ALWAYS_INLINE(static VALUE _mjit%d_inlined_%d(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const VALUE orig_self, const rb_iseq_t *original_iseq));\n", status->compiled_id, pos); + fprintf(f, "static inline VALUE\n_mjit%d_inlined_%d(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const VALUE orig_self, const rb_iseq_t *original_iseq)\n{\n", status->compiled_id, pos); fprintf(f, " const VALUE *orig_pc = reg_cfp->pc;\n"); fprintf(f, " const VALUE *orig_sp = reg_cfp->sp;\n"); bool success = mjit_compile_body(f, child_iseq, &child_status); - fprintf(f, "\n} /* end of _mjit_inlined_%d */\n\n", pos); + fprintf(f, "\n} /* end of _mjit%d_inlined_%d */\n\n", status->compiled_id, pos); if (!success) return false; @@ -470,7 +471,7 @@ precompile_inlinable_iseqs(FILE *f, const rb_iseq_t *iseq, struct compile_status // Compile ISeq to C code in `f`. It returns true if it succeeds to compile. bool -mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname) +mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname, int id) { // For performance, we verify stack size only on compilation time (mjit_compile.inc.erb) without --jit-debug if (!mjit_opts.debug) { @@ -478,7 +479,7 @@ mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname) fprintf(f, "#define OPT_CHECKED_RUN 0\n\n"); } - struct compile_status status = { .compiled_iseq = iseq->body }; + struct compile_status status = { .compiled_iseq = iseq->body, .compiled_id = id }; INIT_COMPILE_STATUS(status, iseq->body, true); if ((iseq->body->ci_size > 0 && status.cc_entries_index == -1) || (status.is_entries != NULL && !mjit_copy_cache_from_main_thread(iseq, status.is_entries))) { diff --git a/mjit_worker.c b/mjit_worker.c index 04eac1f55fee40..791a6ab76f5ff1 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -1120,7 +1120,7 @@ convert_unit_to_func(struct rb_mjit_unit *unit) verbose(2, "start compilation: %s@%s:%ld -> %s", iseq_label, iseq_path, iseq_lineno, c_file); fprintf(f, "/* %s@%s:%ld */\n\n", iseq_label, iseq_path, iseq_lineno); - bool success = mjit_compile(f, unit->iseq, funcname); + bool success = mjit_compile(f, unit->iseq, funcname, unit->id); // release blocking mjit_gc_start_hook CRITICAL_SECTION_START(3, "after mjit_compile to wakeup client for GC"); diff --git a/tool/ruby_vm/views/_mjit_compile_send.erb b/tool/ruby_vm/views/_mjit_compile_send.erb index 2b1ecdb2f3c903..d1f4692b5f549d 100644 --- a/tool/ruby_vm/views/_mjit_compile_send.erb +++ b/tool/ruby_vm/views/_mjit_compile_send.erb @@ -50,7 +50,7 @@ fprintf(f, " {\n"); fprintf(f, " VALUE orig_self = reg_cfp->self;\n"); fprintf(f, " reg_cfp->self = stack[%d];\n", b->stack_size + sp_inc - 1); - fprintf(f, " stack[%d] = _mjit_inlined_%d(ec, reg_cfp, orig_self, original_iseq);\n", b->stack_size + sp_inc - 1, pos); + fprintf(f, " stack[%d] = _mjit%d_inlined_%d(ec, reg_cfp, orig_self, original_iseq);\n", b->stack_size + sp_inc - 1, status->compiled_id, pos); fprintf(f, " reg_cfp->self = orig_self;\n"); fprintf(f, " }\n"); } From c925cc01c5e8d595449156556416f067b914f6ca Mon Sep 17 00:00:00 2001 From: zverok Date: Sat, 26 Oct 2019 12:52:08 +0300 Subject: [PATCH 163/234] [ruby-matrix] Update docs (nicer rendering, undocumented method) --- lib/matrix.rb | 194 +++++++++++++++++++++++++++----------------------- 1 file changed, 105 insertions(+), 89 deletions(-) diff --git a/lib/matrix.rb b/lib/matrix.rb index 81e3f596cad441..a0f116095c142e 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -72,8 +72,8 @@ class Matrix # # Creates a matrix where each argument is a row. # Matrix[ [25, 93], [-1, 66] ] - # => 25 93 - # -1 66 + # # => 25 93 + # # -1 66 # def Matrix.[](*rows) rows(rows, false) @@ -84,8 +84,8 @@ def Matrix.[](*rows) # of the matrix. If the optional argument +copy+ is false, use the given # arrays as the internal structure of the matrix without copying. # Matrix.rows([[25, 93], [-1, 66]]) - # => 25 93 - # -1 66 + # # => 25 93 + # # -1 66 # def Matrix.rows(rows, copy = true) rows = convert_to_array(rows, copy) @@ -102,8 +102,8 @@ def Matrix.rows(rows, copy = true) # # Creates a matrix using +columns+ as an array of column vectors. # Matrix.columns([[25, 93], [-1, 66]]) - # => 25 -1 - # 93 66 + # # => 25 -1 + # # 93 66 # def Matrix.columns(columns) rows(columns, false).transpose @@ -116,9 +116,9 @@ def Matrix.columns(columns) # Returns an enumerator if no block is given. # # m = Matrix.build(2, 4) {|row, col| col - row } - # => Matrix[[0, 1, 2, 3], [-1, 0, 1, 2]] + # # => Matrix[[0, 1, 2, 3], [-1, 0, 1, 2]] # m = Matrix.build(3) { rand } - # => a 3x3 matrix with random elements + # # => a 3x3 matrix with random elements # def Matrix.build(row_count, column_count = row_count) row_count = CoercionHelper.coerce_to_int(row_count) @@ -136,9 +136,9 @@ def Matrix.build(row_count, column_count = row_count) # # Creates a matrix where the diagonal elements are composed of +values+. # Matrix.diagonal(9, 5, -3) - # => 9 0 0 - # 0 5 0 - # 0 0 -3 + # # => 9 0 0 + # # 0 5 0 + # # 0 0 -3 # def Matrix.diagonal(*values) size = values.size @@ -155,8 +155,8 @@ def Matrix.diagonal(*values) # Creates an +n+ by +n+ diagonal matrix where each diagonal element is # +value+. # Matrix.scalar(2, 5) - # => 5 0 - # 0 5 + # # => 5 0 + # # 0 5 # def Matrix.scalar(n, value) diagonal(*Array.new(n, value)) @@ -165,8 +165,8 @@ def Matrix.scalar(n, value) # # Creates an +n+ by +n+ identity matrix. # Matrix.identity(2) - # => 1 0 - # 0 1 + # # => 1 0 + # # 0 1 # def Matrix.identity(n) scalar(n, 1) @@ -179,8 +179,8 @@ class << Matrix # # Creates a zero matrix. # Matrix.zero(2) - # => 0 0 - # 0 0 + # # => 0 0 + # # 0 0 # def Matrix.zero(row_count, column_count = row_count) rows = Array.new(row_count){Array.new(column_count, 0)} @@ -191,7 +191,7 @@ def Matrix.zero(row_count, column_count = row_count) # Creates a single-row matrix where the values of that row are as given in # +row+. # Matrix.row_vector([4,5,6]) - # => 4 5 6 + # # => 4 5 6 # def Matrix.row_vector(row) row = convert_to_array(row) @@ -202,9 +202,9 @@ def Matrix.row_vector(row) # Creates a single-column matrix where the values of that column are as given # in +column+. # Matrix.column_vector([4,5,6]) - # => 4 - # 5 - # 6 + # # => 4 + # # 5 + # # 6 # def Matrix.column_vector(column) column = convert_to_array(column) @@ -217,12 +217,12 @@ def Matrix.column_vector(column) # # m = Matrix.empty(2, 0) # m == Matrix[ [], [] ] - # => true + # # => true # n = Matrix.empty(0, 3) # n == Matrix.columns([ [], [], [] ]) - # => true + # # => true # m * n - # => Matrix[[0, 0, 0], [0, 0, 0]] + # # => Matrix[[0, 0, 0], [0, 0, 0]] # def Matrix.empty(row_count = 0, column_count = 0) raise ArgumentError, "One size must be 0" if column_count != 0 && row_count != 0 @@ -276,6 +276,8 @@ def Matrix.hstack(x, *matrices) new result, total_column_count end + # :call-seq: + # Matrix.combine(*matrices) { |*elements| ... } # # Create a matrix by combining matrices entrywise, using the given block # @@ -301,12 +303,21 @@ def Matrix.combine(*matrices) new rows, x.column_count end + # :call-seq: + # combine(*other_matrices) { |*elements| ... } + # + # Creates new matrix by combining with other_matrices entrywise, + # using the given block. + # + # x = Matrix[[6, 6], [4, 4]] + # y = Matrix[[1, 2], [3, 4]] + # x.combine(y) {|a, b| a - b} # => Matrix[[5, 4], [1, 0]] def combine(*matrices, &block) Matrix.combine(self, *matrices, &block) end # - # Matrix.new is private; use Matrix.rows, columns, [], etc... to create. + # Matrix.new is private; use ::rows, ::columns, ::[], etc... to create. # def initialize(rows, column_count = rows[0].size) # No checking is done at this point. rows must be an Array of Arrays. @@ -491,8 +502,8 @@ def column(j) # :yield: e # * :strict_upper: yields only elements above the diagonal # * :upper: yields only elements on or above the diagonal # Matrix[ [1,2], [3,4] ].collect { |e| e**2 } - # => 1 4 - # 9 16 + # # => 1 4 + # # 9 16 # def collect(which = :all, &block) # :yield: e return to_enum(:collect, which) unless block_given? @@ -537,9 +548,9 @@ def freeze # * :strict_upper: yields only elements above the diagonal # * :upper: yields only elements on or above the diagonal # - # Matrix[ [1,2], [3,4] ].each { |e| puts e } - # # => prints the numbers 1 to 4 - # Matrix[ [1,2], [3,4] ].each(:strict_lower).to_a # => [3] + # Matrix[ [1,2], [3,4] ].each { |e| puts e } + # # => prints the numbers 1 to 4 + # Matrix[ [1,2], [3,4] ].each(:strict_lower).to_a # => [3] # def each(which = :all, &block) # :yield: e return to_enum :each, which unless block_given? @@ -688,8 +699,8 @@ def index(*args) # * row_range, col_range # # Matrix.diagonal(9, 5, -3).minor(0..1, 0..2) - # => 9 0 0 - # 0 5 0 + # # => 9 0 0 + # # 0 5 0 # # Like Array#[], negative indices count backward from the end of the # row or column (-1 is the last element). Returns nil if the starting @@ -732,9 +743,9 @@ def minor(*param) # Returns the submatrix obtained by deleting the specified row and column. # # Matrix.diagonal(9, 5, -3, 4).first_minor(1, 2) - # => 9 0 0 - # 0 0 0 - # 0 0 4 + # # => 9 0 0 + # # 0 0 0 + # # 0 0 4 # def first_minor(row, column) raise RuntimeError, "first_minor of empty matrix is not defined" if empty? @@ -761,7 +772,7 @@ def first_minor(row, column) # the first minor by (-1)**(row + column). # # Matrix.diagonal(9, 5, -3, 4).cofactor(1, 1) - # => -108 + # # => -108 # def cofactor(row, column) raise RuntimeError, "cofactor of empty matrix is not defined" if empty? @@ -775,8 +786,8 @@ def cofactor(row, column) # Returns the adjugate of the matrix. # # Matrix[ [7,6],[3,9] ].adjugate - # => 9 -6 - # -3 7 + # # => 9 -6 + # # -3 7 # def adjugate raise ErrDimensionMismatch unless square? @@ -789,10 +800,10 @@ def adjugate # Returns the Laplace expansion along given row or column. # # Matrix[[7,6], [3,9]].laplace_expansion(column: 1) - # => 45 + # # => 45 # # Matrix[[Vector[1, 0], Vector[0, 1]], [2, 3]].laplace_expansion(row: 0) - # => Vector[3, -2] + # # => Vector[3, -2] # # def laplace_expansion(row: nil, column: nil) @@ -1039,8 +1050,8 @@ def hash # # Matrix multiplication. # Matrix[[2,4], [6,8]] * Matrix.identity(2) - # => 2 4 - # 6 8 + # # => 2 4 + # # 6 8 # def *(m) # m is matrix or vector or number case(m) @@ -1072,8 +1083,8 @@ def *(m) # m is matrix or vector or number # # Matrix addition. # Matrix.scalar(2,5) + Matrix[[1,0], [-4,7]] - # => 6 0 - # -4 12 + # # => 6 0 + # # -4 12 # def +(m) case m @@ -1099,8 +1110,8 @@ def +(m) # # Matrix subtraction. # Matrix[[1,5], [4,2]] - Matrix[[9,3], [-4,1]] - # => -8 2 - # 8 1 + # # => -8 2 + # # 8 1 # def -(m) case m @@ -1126,8 +1137,8 @@ def -(m) # # Matrix division (multiplication by the inverse). # Matrix[[7,6], [3,9]] / Matrix[[2,9], [3,1]] - # => -7 1 - # -3 -6 + # # => -7 1 + # # -3 -6 # def /(other) case other @@ -1146,8 +1157,8 @@ def /(other) # # Hadamard product # Matrix[[1,2], [3,4]].hadamard_product(Matrix[[1,2], [3,2]]) - # => 1 4 - # 9 8 + # # => 1 4 + # # 9 8 # def hadamard_product(m) combine(m){|a, b| a * b} @@ -1157,8 +1168,8 @@ def hadamard_product(m) # # Returns the inverse of the matrix. # Matrix[[-1, -1], [0, -1]].inverse - # => -1 1 - # 0 -1 + # # => -1 1 + # # 0 -1 # def inverse raise ErrDimensionMismatch unless square? @@ -1216,8 +1227,8 @@ def inverse # Non integer exponents will be handled by diagonalizing the matrix. # # Matrix[[7,6], [3,9]] ** 2 - # => 67 96 - # 48 99 + # # => 67 96 + # # 48 99 # def **(other) case other @@ -1246,6 +1257,11 @@ def +@ self end + # Unary matrix negation. + # + # -Matrix[[1,5], [4,2]] + # # => -1 -5 + # # -4 -2 def -@ collect {|e| -e } end @@ -1269,7 +1285,7 @@ def abs # Consider using exact types like Rational or BigDecimal instead. # # Matrix[[7,6], [3,9]].determinant - # => 45 + # # => 45 # def determinant raise ErrDimensionMismatch unless square? @@ -1377,7 +1393,7 @@ def hstack(*matrices) # Consider using exact types like Rational or BigDecimal instead. # # Matrix[[7,6], [3,9]].rank - # => 2 + # # => 2 # def rank # We currently use Bareiss' multistep integer-preserving gaussian elimination @@ -1425,7 +1441,7 @@ def round(ndigits=0) # # Returns the trace (sum of diagonal elements) of the matrix. # Matrix[[7,6], [3,9]].trace - # => 16 + # # => 16 # def trace raise ErrDimensionMismatch unless square? @@ -1438,12 +1454,12 @@ def trace # # Returns the transpose of the matrix. # Matrix[[1,2], [3,4], [5,6]] - # => 1 2 - # 3 4 - # 5 6 + # # => 1 2 + # # 3 4 + # # 5 6 # Matrix[[1,2], [3,4], [5,6]].transpose - # => 1 3 5 - # 2 4 6 + # # => 1 3 5 + # # 2 4 6 # def transpose return self.class.empty(column_count, 0) if row_count.zero? @@ -1502,11 +1518,11 @@ def lup # # Returns the conjugate of the matrix. # Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]] - # => 1+2i i 0 - # 1 2 3 + # # => 1+2i i 0 + # # 1 2 3 # Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].conjugate - # => 1-2i -i 0 - # 1 2 3 + # # => 1-2i -i 0 + # # 1 2 3 # def conjugate collect(&:conjugate) @@ -1516,11 +1532,11 @@ def conjugate # # Returns the imaginary part of the matrix. # Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]] - # => 1+2i i 0 - # 1 2 3 + # # => 1+2i i 0 + # # 1 2 3 # Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].imaginary - # => 2i i 0 - # 0 0 0 + # # => 2i i 0 + # # 0 0 0 # def imaginary collect(&:imaginary) @@ -1530,11 +1546,11 @@ def imaginary # # Returns the real part of the matrix. # Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]] - # => 1+2i i 0 - # 1 2 3 + # # => 1+2i i 0 + # # 1 2 3 # Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].real - # => 1 0 0 - # 1 2 3 + # # => 1 0 0 + # # 1 2 3 # def real collect(&:real) @@ -1544,7 +1560,7 @@ def real # Returns an array containing matrices corresponding to the real and imaginary # parts of the matrix # - # m.rect == [m.real, m.imag] # ==> true for all matrices m + # m.rect == [m.real, m.imag] # ==> true for all matrices m # def rect [real, imag] @@ -1605,7 +1621,7 @@ def to_a # Deprecated. # - # Use map(&:to_f) + # Use map(&:to_f) def elements_to_f warn "Matrix#elements_to_f is deprecated, use map(&:to_f)", uplevel: 1 map(&:to_f) @@ -1613,7 +1629,7 @@ def elements_to_f # Deprecated. # - # Use map(&:to_i) + # Use map(&:to_i) def elements_to_i warn "Matrix#elements_to_i is deprecated, use map(&:to_i)", uplevel: 1 map(&:to_i) @@ -1621,7 +1637,7 @@ def elements_to_i # Deprecated. # - # Use map(&:to_r) + # Use map(&:to_r) def elements_to_r warn "Matrix#elements_to_r is deprecated, use map(&:to_r)", uplevel: 1 map(&:to_r) @@ -1857,8 +1873,8 @@ def **(other) # * #-@ # # Vector functions: -# * #inner_product(v), dot(v) -# * #cross_product(v), cross(v) +# * #inner_product(v), #dot(v) +# * #cross_product(v), #cross(v) # * #collect # * #collect! # * #magnitude @@ -1923,7 +1939,7 @@ def Vector.basis(size:, index:) # # Return a zero vector. # - # Vector.zero(3) => Vector[0, 0, 0] + # Vector.zero(3) # => Vector[0, 0, 0] # def Vector.zero(size) raise ArgumentError, "invalid size (#{size} for 0..)" if size < 0 @@ -2054,10 +2070,10 @@ def collect2(v) # :yield: e1, e2 # Returns +true+ iff all of vectors are linearly independent. # # Vector.independent?(Vector[1,0], Vector[0,1]) - # => true + # # => true # # Vector.independent?(Vector[1,2], Vector[2,4]) - # => false + # # => false # def Vector.independent?(*vs) vs.each do |v| @@ -2072,10 +2088,10 @@ def Vector.independent?(*vs) # Returns +true+ iff all of vectors are linearly independent. # # Vector[1,0].independent?(Vector[0,1]) - # => true + # # => true # # Vector[1,2].independent?(Vector[2,4]) - # => false + # # => false # def independent?(*vs) self.class.independent?(self, *vs) @@ -2212,7 +2228,7 @@ def -@ # # Returns the inner product of this vector with the other. - # Vector[4,7].inner_product Vector[10,1] => 47 + # Vector[4,7].inner_product Vector[10,1] # => 47 # def inner_product(v) raise ErrDimensionMismatch if size != v.size @@ -2227,7 +2243,7 @@ def inner_product(v) # # Returns the cross product of this vector with the others. - # Vector[1, 0, 0].cross_product Vector[0, 1, 0] => Vector[0, 0, 1] + # Vector[1, 0, 0].cross_product Vector[0, 1, 0] # => Vector[0, 0, 1] # # It is generalized to other dimensions to return a vector perpendicular # to the arguments. @@ -2282,7 +2298,7 @@ def collect!(&block) # # Returns the modulus (Pythagorean distance) of the vector. - # Vector[5,8,2].r => 9.643650761 + # Vector[5,8,2].r # => 9.643650761 # def magnitude Math.sqrt(@elements.inject(0) {|v, e| v + e.abs2}) @@ -2305,7 +2321,7 @@ class ZeroVectorError < StandardError # Returns a new vector with the same direction but with norm 1. # v = Vector[5,8,2].normalize # # => Vector[0.5184758473652127, 0.8295613557843402, 0.20739033894608505] - # v.norm => 1.0 + # v.norm # => 1.0 # def normalize n = magnitude From 7d360efe92d2db11a4e51820ed2f52de36b3257f Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Thu, 30 Apr 2020 17:49:06 -0400 Subject: [PATCH 164/234] [ruby/matrix] Fix Matrix#unitary? [#14] --- lib/matrix.rb | 6 +++--- test/matrix/test_matrix.rb | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/matrix.rb b/lib/matrix.rb index a0f116095c142e..9d6650370d4fbf 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -983,11 +983,11 @@ def antisymmetric? # def unitary? raise ErrDimensionMismatch unless square? - rows.each_with_index do |row, i| - column_count.times do |j| + rows.each_with_index do |row_i, i| + rows.each_with_index do |row_j, j| s = 0 row_count.times do |k| - s += row[k].conj * rows[k][j] + s += row_i[k].conj * row_j[k] end return false unless s == (i == j ? 1 : 0) end diff --git a/test/matrix/test_matrix.rb b/test/matrix/test_matrix.rb index 7dbb1000d9faee..9206678261993f 100644 --- a/test/matrix/test_matrix.rb +++ b/test/matrix/test_matrix.rb @@ -18,6 +18,7 @@ def setup @a3 = Matrix[[4, 1, -3], [0, 3, 7], [11, -4, 2]] @a5 = Matrix[[2, 0, 9, 3, 9], [8, 7, 0, 1, 9], [7, 5, 6, 6, 5], [0, 7, 8, 3, 0], [7, 8, 2, 3, 1]] @b3 = Matrix[[-7, 7, -10], [9, -3, -2], [-1, 3, 9]] + @rot = Matrix[[0, -1, 0], [1, 0, 0], [0, 0, -1]] end def test_matrix @@ -792,4 +793,11 @@ def test_eigenvalues_and_eigenvectors_nonsymmetric assert_in_epsilon(vectors[0][0], vectors[0][1]) assert_in_epsilon(-4 * vectors[1][0], vectors[1][1]) end + + def test_unitary? + assert_equal true, @rot.unitary? + assert_equal true, ((0+1i) * @rot).unitary? + assert_equal false, @a3.unitary? + assert_raise(Matrix::ErrDimensionMismatch) { @m1.unitary? } + end end From 3cb038cc7a9b1e01685a7e8a513e7ac7fb56b112 Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Thu, 30 Apr 2020 18:00:47 -0400 Subject: [PATCH 165/234] [ruby/matrix] Fix Matrix#orthogonal? --- lib/matrix.rb | 7 ++++--- test/matrix/test_matrix.rb | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/matrix.rb b/lib/matrix.rb index 9d6650370d4fbf..7d35b61fc5ac73 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -890,11 +890,12 @@ def normal? # def orthogonal? raise ErrDimensionMismatch unless square? - rows.each_with_index do |row, i| - column_count.times do |j| + + rows.each_with_index do |row_i, i| + rows.each_with_index do |row_j, j| s = 0 row_count.times do |k| - s += row[k] * rows[k][j] + s += row_i[k] * row_j[k] end return false unless s == (i == j ? 1 : 0) end diff --git a/test/matrix/test_matrix.rb b/test/matrix/test_matrix.rb index 9206678261993f..f963b2d06aa4de 100644 --- a/test/matrix/test_matrix.rb +++ b/test/matrix/test_matrix.rb @@ -800,4 +800,11 @@ def test_unitary? assert_equal false, @a3.unitary? assert_raise(Matrix::ErrDimensionMismatch) { @m1.unitary? } end + + def test_orthogonal + assert_equal true, @rot.orthogonal? + assert_equal false, ((0+1i) * @rot).orthogonal? + assert_equal false, @a3.orthogonal? + assert_raise(Matrix::ErrDimensionMismatch) { @m1.orthogonal? } + end end From 07fd6dc49ba87ea2f0732851ec7628a526f3dcbd Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Thu, 30 Apr 2020 17:04:46 -0400 Subject: [PATCH 166/234] [ruby/matrix] Optimize Matrix#* --- lib/matrix.rb | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/matrix.rb b/lib/matrix.rb index 7d35b61fc5ac73..75b5da29c7a6b7 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -1057,25 +1057,27 @@ def hash def *(m) # m is matrix or vector or number case(m) when Numeric - rows = @rows.collect {|row| + new_rows = @rows.collect {|row| row.collect {|e| e * m } } - return new_matrix rows, column_count + return new_matrix new_rows, column_count when Vector m = self.class.column_vector(m) r = self * m return r.column(0) when Matrix raise ErrDimensionMismatch if column_count != m.row_count - - rows = Array.new(row_count) {|i| - Array.new(m.column_count) {|j| - (0 ... column_count).inject(0) do |vij, k| - vij + self[i, k] * m[k, j] + m_rows = m.rows + new_rows = rows.map do |row_i| + Array.new(m.column_count) do |j| + vij = 0 + column_count.times do |k| + vij += row_i[k] * m_rows[k][j] end - } - } - return new_matrix rows, m.column_count + vij + end + end + return new_matrix new_rows, m.column_count else return apply_through_coercion(m, __method__) end From 9b5675b325c9d4533e4f3db080cd2aa019068aad Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Thu, 30 Apr 2020 18:04:30 -0400 Subject: [PATCH 167/234] [ruby/matrix] Add Matrix#adjoint [#14] Patch adapted from Alessandro Minali --- lib/matrix.rb | 11 +++++++++++ test/matrix/test_matrix.rb | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/lib/matrix.rb b/lib/matrix.rb index 75b5da29c7a6b7..336a92877b9785 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -1532,6 +1532,17 @@ def conjugate end alias_method :conj, :conjugate + # + # Returns the adjoint of the matrix. + # + # Matrix[ [i,1],[2,-i] ].adjoint + # # => -i 2 + # # 1 i + # + def adjoint + conjugate.transpose + end + # # Returns the imaginary part of the matrix. # Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]] diff --git a/test/matrix/test_matrix.rb b/test/matrix/test_matrix.rb index f963b2d06aa4de..b134bfb3a10ab0 100644 --- a/test/matrix/test_matrix.rb +++ b/test/matrix/test_matrix.rb @@ -807,4 +807,9 @@ def test_orthogonal assert_equal false, @a3.orthogonal? assert_raise(Matrix::ErrDimensionMismatch) { @m1.orthogonal? } end + + def test_adjoint + assert_equal(Matrix[[(1-2i), 1], [(0-1i), 2], [0, 3]], @c1.adjoint) + assert_equal(Matrix.empty(0,2), @e1.adjoint) + end end From 6eed4d1b7474b3ac349089a895c7d5e5dcd5381a Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Fri, 1 May 2020 03:22:18 -0400 Subject: [PATCH 168/234] [ruby/matrix] v0.3.0 --- lib/matrix/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matrix/version.rb b/lib/matrix/version.rb index e6f91dae3c3e83..ce9ea828fdc5cd 100644 --- a/lib/matrix/version.rb +++ b/lib/matrix/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true class Matrix - VERSION = "0.2.0" + VERSION = "0.3.0" end From 5c8bfad078bf37797256f3214b29c578ac763109 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 1 May 2020 00:40:21 -0700 Subject: [PATCH 169/234] Make sure unit->id is inherited to child compile_status --- mjit_compile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mjit_compile.c b/mjit_compile.c index c3b44bdb1f8a09..57ab034494e769 100644 --- a/mjit_compile.c +++ b/mjit_compile.c @@ -396,6 +396,7 @@ inlinable_iseq_p(const struct rb_iseq_constant_body *body) alloca(sizeof(union iseq_inline_storage_entry) * body->is_size) : NULL, \ .cc_entries_index = (body->ci_size > 0) ? \ mjit_capture_cc_entries(status.compiled_iseq, body) : -1, \ + .compiled_id = status.compiled_id, \ .compiled_iseq = status.compiled_iseq, \ .compile_info = compile_root_p ? \ rb_mjit_iseq_compile_info(body) : alloca(sizeof(struct rb_mjit_compile_info)) \ From 76507bfc3d06984b02e3124cd6557c81af2171cd Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 1 May 2020 00:45:17 -0700 Subject: [PATCH 170/234] Fix matrix spec for 7d360efe92d2db11a4e51820ed2f52de36b3257f --- spec/ruby/library/matrix/unitary_spec.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spec/ruby/library/matrix/unitary_spec.rb b/spec/ruby/library/matrix/unitary_spec.rb index 9c2a106ea55eb9..b0c23e0e846099 100644 --- a/spec/ruby/library/matrix/unitary_spec.rb +++ b/spec/ruby/library/matrix/unitary_spec.rb @@ -5,10 +5,15 @@ it "returns false for non unitary matrices" do Matrix[[0, 1], [1, 2]].unitary?.should == false Matrix[[0, Complex(0, 2)], [Complex(0, 2), 0]].unitary?.should == false - Matrix[[0, Complex(0, 1)], [Complex(0, -1), 0]].unitary?.should == false Matrix[[1, 1, 0], [0, 1, 1], [1, 0, 1]].unitary?.should == false end + ruby_version_is '2.8' do # matrix v0.3.0 + it "returns false for non unitary matrix" do + Matrix[[0, Complex(0, 1)], [Complex(0, -1), 0]].unitary?.should == true + end + end + it "returns true for unitary matrices" do Matrix[[0, Complex(0, 1)], [Complex(0, 1), 0]].unitary?.should == true end From 773afeb73d658129ddeb0a89ddb7e2ea49165a1d Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 1 May 2020 00:46:01 -0700 Subject: [PATCH 171/234] Fix a typo --- spec/ruby/library/matrix/unitary_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/ruby/library/matrix/unitary_spec.rb b/spec/ruby/library/matrix/unitary_spec.rb index b0c23e0e846099..c5b8cb6cee96eb 100644 --- a/spec/ruby/library/matrix/unitary_spec.rb +++ b/spec/ruby/library/matrix/unitary_spec.rb @@ -9,7 +9,7 @@ end ruby_version_is '2.8' do # matrix v0.3.0 - it "returns false for non unitary matrix" do + it "returns true for non unitary matrix" do Matrix[[0, Complex(0, 1)], [Complex(0, -1), 0]].unitary?.should == true end end From 818d6d33368a396d9cd3d1a34a84015a9e76c5c8 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 30 Apr 2020 23:58:50 -0700 Subject: [PATCH 172/234] Deduplicate functions in compacted JIT code to improve code locality. Using benchmark-driver/sinatra with 100 methods JIT-ed, [Before] 12149.97 rps 1.3M /tmp/_ruby_mjit_p31171u145.so [After] 12818.83 rps 260K /tmp/_ruby_mjit_p32155u145.so (VM is 13714.89 rps) --- mjit.c | 4 +- mjit_worker.c | 153 +++++++++++++++++++++--------------------- test/ruby/test_jit.rb | 4 +- 3 files changed, 81 insertions(+), 80 deletions(-) diff --git a/mjit.c b/mjit.c index 59e58f3f704f16..2c2af0a2a678f5 100644 --- a/mjit.c +++ b/mjit.c @@ -191,7 +191,7 @@ free_list(struct rb_mjit_unit_list *list, bool close_handle_p) if (unit->handle && dlclose(unit->handle)) { mjit_warning("failed to close handle for u%d: %s", unit->id, dlerror()); } - clean_object_files(unit); + clean_temp_files(unit); free(unit); } else { @@ -889,7 +889,7 @@ skip_cleaning_object_files(struct rb_mjit_unit_list *list) // No mutex for list, assuming MJIT worker does not exist yet since it's immediately after fork. list_for_each_safe(&list->head, unit, next, unode) { #ifndef _MSC_VER // Actually mswin does not reach here since it doesn't have fork - if (unit->o_file) unit->o_file_inherited_p = true; + if (unit->c_file) unit->c_file_inherited_p = true; #endif #if defined(_WIN32) // mswin doesn't reach here either. This is for MinGW. diff --git a/mjit_worker.c b/mjit_worker.c index 791a6ab76f5ff1..b64c769ef21d4b 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -146,11 +146,11 @@ struct rb_mjit_unit { rb_iseq_t *iseq; #ifndef _MSC_VER // This value is always set for `compact_all_jit_code`. Also used for lazy deletion. - char *o_file; + char *c_file; // true if it's inherited from parent Ruby process and lazy deletion should be skipped. - // `o_file = NULL` can't be used to skip lazy deletion because `o_file` could be used + // `c_file = NULL` can't be used to skip lazy deletion because `c_file` could be used // by child for `compact_all_jit_code`. - bool o_file_inherited_p; + bool c_file_inherited_p; #endif #if defined(_WIN32) // DLL cannot be removed while loaded on Windows. If this is set, it'll be lazily deleted. @@ -388,20 +388,20 @@ remove_file(const char *filename) } } -// Lazily delete .o and/or .so files. +// Lazily delete .c and/or .so files. static void -clean_object_files(struct rb_mjit_unit *unit) +clean_temp_files(struct rb_mjit_unit *unit) { #ifndef _MSC_VER - if (unit->o_file) { - char *o_file = unit->o_file; + if (unit->c_file) { + char *c_file = unit->c_file; - unit->o_file = NULL; - // For compaction, unit->o_file is always set when compilation succeeds. + unit->c_file = NULL; + // For compaction, unit->c_file is always set when compilation succeeds. // So save_temps needs to be checked here. - if (!mjit_opts.save_temps && !unit->o_file_inherited_p) - remove_file(o_file); - free(o_file); + if (!mjit_opts.save_temps && !unit->c_file_inherited_p) + remove_file(c_file); + free(c_file); } #endif @@ -439,7 +439,7 @@ free_unit(struct rb_mjit_unit *unit) if (unit->handle && dlclose(unit->handle)) { // handle is NULL if it's in queue mjit_warning("failed to close handle for u%d: %s", unit->id, dlerror()); } - clean_object_files(unit); + clean_temp_files(unit); free(unit); } @@ -683,7 +683,7 @@ remove_so_file(const char *so_file, struct rb_mjit_unit *unit) { #if defined(_WIN32) // Windows can't remove files while it's used. - unit->so_file = strdup(so_file); // lazily delete on `clean_object_files()` + unit->so_file = strdup(so_file); // lazily delete on `clean_temp_files()` if (unit->so_file == NULL) mjit_warning("failed to allocate memory to lazily remove '%s': %s", so_file, strerror(errno)); #else @@ -844,19 +844,23 @@ make_pch(void) CRITICAL_SECTION_FINISH(3, "in make_pch"); } -// Compile .c file to .o file. It returns true if it succeeds. (non-mswin) +// Compile .c file to .so file. It returns true if it succeeds. (non-mswin) static bool -compile_c_to_o(const char *c_file, const char *o_file) +compile_c_to_so(const char *c_file, const char *so_file) { - const char *files[] = { - "-o", o_file, c_file, + const char *options[] = { + "-o", so_file, c_file, # ifdef __clang__ "-include-pch", pch_file, # endif - "-c", NULL +# ifdef _WIN32 + libruby_pathflag, +# endif + NULL }; - char **args = form_args(5, cc_common_args, CC_CODEFLAG_ARGS, cc_added_args, files, CC_LINKER_ARGS); + char **args = form_args(6, CC_LDSHARED_ARGS, CC_CODEFLAG_ARGS, + options, CC_LIBS, CC_DLDFLAGS_ARGS, CC_LINKER_ARGS); if (args == NULL) return false; @@ -864,47 +868,52 @@ compile_c_to_o(const char *c_file, const char *o_file) free(args); if (exit_code != 0) - verbose(2, "compile_c_to_o: compile error: %d", exit_code); + verbose(2, "compile_c_to_so: compile error: %d", exit_code); return exit_code == 0; } -// Link .o files to .so file. It returns true if it succeeds. (non-mswin) +static void compile_prelude(FILE *f); + +static const int c_file_access_mode = +#ifdef O_BINARY + O_BINARY| +#endif + O_WRONLY|O_EXCL|O_CREAT; + static bool -link_o_to_so(const char **o_files, const char *so_file) +compile_compact_jit_code(char* c_file) { - const char *options[] = { - "-o", so_file, -# ifdef _WIN32 - libruby_pathflag, -# endif - NULL - }; - - char **args = form_args(7, CC_LDSHARED_ARGS, CC_CODEFLAG_ARGS, - options, o_files, CC_LIBS, CC_DLDFLAGS_ARGS, CC_LINKER_ARGS); - if (args == NULL) + FILE *f; + int fd = rb_cloexec_open(c_file, c_file_access_mode, 0600); + if (fd < 0 || (f = fdopen(fd, "w")) == NULL) { + int e = errno; + if (fd >= 0) (void)close(fd); + verbose(1, "Failed to fopen '%s', giving up JIT for it (%s)", c_file, strerror(e)); return false; + } - int exit_code = exec_process(cc_path, args); - free(args); + compile_prelude(f); - if (exit_code != 0) - verbose(2, "link_o_to_so: link error: %d", exit_code); - return exit_code == 0; + struct rb_mjit_unit *cur = 0; + list_for_each(&active_units.head, cur, unode) { + fprintf(f, "#include \"%s\"\n", cur->c_file); + } + + fclose(f); + return true; } -// Link all cached .o files and build a .so file. Reload all JIT func from it. This -// allows to avoid JIT code fragmentation and improve performance to call JIT-ed code. +// Compile all cached .c files and build a single .so file. Reload all JIT func from it. +// This improves the code locality for better performance in terms of iTLB and iCache. static void compact_all_jit_code(void) { # ifndef _WIN32 // This requires header transformation but we don't transform header on Windows for now struct rb_mjit_unit *unit, *cur = 0; double start_time, end_time; + static const char c_ext[] = ".c"; static const char so_ext[] = DLEXT; - char so_file[MAXPATHLEN]; - const char **o_files; - int i = 0; + char c_file[MAXPATHLEN], so_file[MAXPATHLEN]; // Abnormal use case of rb_mjit_unit that doesn't have ISeq unit = calloc(1, sizeof(struct rb_mjit_unit)); // To prevent GC, don't use ZALLOC @@ -912,24 +921,23 @@ compact_all_jit_code(void) unit->id = current_unit_num++; sprint_uniq_filename(so_file, (int)sizeof(so_file), unit->id, MJIT_TMP_PREFIX, so_ext); - // NULL-ending for form_args - o_files = alloca(sizeof(char *) * (active_units.length + 1)); - o_files[active_units.length] = NULL; - CRITICAL_SECTION_START(3, "in compact_all_jit_code to guard .o files from unload_units"); - list_for_each(&active_units.head, cur, unode) { - o_files[i] = cur->o_file; - i++; - } + sprint_uniq_filename(c_file, (int)sizeof(c_file), unit->id, MJIT_TMP_PREFIX, c_ext); + CRITICAL_SECTION_START(3, "in compact_all_jit_code to guard .c files from unload_units"); + bool success = compile_compact_jit_code(c_file); in_compact = true; - CRITICAL_SECTION_FINISH(3, "in compact_all_jit_code to guard .o files from unload_units"); + CRITICAL_SECTION_FINISH(3, "in compact_all_jit_code to guard .c files from unload_units"); start_time = real_ms_time(); - bool success = link_o_to_so(o_files, so_file); + if (success) { + success = compile_c_to_so(c_file, so_file); + if (!mjit_opts.save_temps) + remove_file(c_file); + } end_time = real_ms_time(); - CRITICAL_SECTION_START(3, "in compact_all_jit_code to release .o files"); + CRITICAL_SECTION_START(3, "in compact_all_jit_code to release .c files"); in_compact = false; - CRITICAL_SECTION_FINISH(3, "in compact_all_jit_code to release .o files"); + CRITICAL_SECTION_FINISH(3, "in compact_all_jit_code to release .c files"); if (success) { void *handle = dlopen(so_file, RTLD_NOW); @@ -963,7 +971,7 @@ compact_all_jit_code(void) } } CRITICAL_SECTION_FINISH(3, "in compact_all_jit_code to read list"); - verbose(1, "JIT compaction (%.1fms): Compacted %d methods -> %s", end_time - start_time, active_units.length, so_file); + verbose(1, "JIT compaction (%.1fms): Compacted %d methods %s -> %s", end_time - start_time, active_units.length, c_file, so_file); } else { free(unit); @@ -1015,6 +1023,8 @@ compile_prelude(FILE *f) const char *s = pch_file; const char *e = header_name_end(s); + fprintf(f, "#ifndef MJIT_PCH\n"); + fprintf(f, "#define MJIT_PCH\n"); fprintf(f, "#include \""); // print pch_file except .gch for gcc, but keep .pch for mswin for (; s < e; s++) { @@ -1025,6 +1035,7 @@ compile_prelude(FILE *f) fputc(*s, f); } fprintf(f, "\"\n"); + fprintf(f, "#endif\n"); #endif #ifdef _WIN32 @@ -1046,11 +1057,6 @@ convert_unit_to_func(struct rb_mjit_unit *unit) int c_file_len = (int)sizeof(c_file_buff); static const char c_ext[] = ".c"; static const char so_ext[] = DLEXT; - const int access_mode = -#ifdef O_BINARY - O_BINARY| -#endif - O_WRONLY|O_EXCL|O_CREAT; #ifndef _MSC_VER static const char o_ext[] = ".o"; char *o_file; @@ -1075,7 +1081,7 @@ convert_unit_to_func(struct rb_mjit_unit *unit) sprint_funcname(funcname, unit); - fd = rb_cloexec_open(c_file, access_mode, 0600); + fd = rb_cloexec_open(c_file, c_file_access_mode, 0600); if (fd < 0 || (f = fdopen(fd, "w")) == NULL) { int e = errno; if (fd >= 0) (void)close(fd); @@ -1138,25 +1144,20 @@ convert_unit_to_func(struct rb_mjit_unit *unit) } start_time = real_ms_time(); -#ifdef _MSC_VER success = compile_c_to_so(c_file, so_file); -#else - // splitting .c -> .o step and .o -> .so step, to cache .o files in the future - if ((success = compile_c_to_o(c_file, o_file)) != false) { - success = link_o_to_so((const char *[]){ o_file, NULL }, so_file); - - // Always set o_file for compaction. The value is also used for lazy deletion. - unit->o_file = strdup(o_file); - if (unit->o_file == NULL) { - mjit_warning("failed to allocate memory to remember '%s' (%s), removing it...", o_file, strerror(errno)); - remove_file(o_file); +#ifndef _MSC_VER + if (success) { + // Always set c_file for compaction. The value is also used for lazy deletion. + unit->c_file = strdup(c_file); + if (unit->c_file == NULL) { + mjit_warning("failed to allocate memory to remember '%s' (%s), removing it...", c_file, strerror(errno)); } } #endif + if (!mjit_opts.save_temps && unit->c_file == NULL) + remove_file(c_file); end_time = real_ms_time(); - if (!mjit_opts.save_temps) - remove_file(c_file); if (!success) { verbose(2, "Failed to generate so: %s", so_file); return (mjit_func_t)NOT_COMPILED_JIT_ISEQ_FUNC; diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb index d4e3ccba3f9446..a5d5fb45a96827 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -696,7 +696,7 @@ def mjit#{i} debug_info = %Q[stdout:\n"""\n#{out}\n"""\n\nstderr:\n"""\n#{err}"""\n] assert_equal('012345678910', out, debug_info) compactions, errs = err.lines.partition do |l| - l.match?(/\AJIT compaction \(\d+\.\dms\): Compacted \d+ methods ->/) + l.match?(/\AJIT compaction \(\d+\.\dms\): Compacted \d+ methods /) end 10.times do |i| assert_match(/\A#{JIT_SUCCESS_PREFIX}: mjit#{i}@\(eval\):/, errs[i], debug_info) @@ -719,7 +719,7 @@ def mjit#{i} # "Permission Denied" error is preventing to remove so file on AppVeyor/RubyCI. skip 'Removing so file is randomly failing on AppVeyor/RubyCI mswin due to Permission Denied.' else - # verify .o files are deleted on unload_units + # verify .c files are deleted on unload_units assert_send([Dir, :empty?, dir], debug_info) end end From 72aa4dd183921aaf7405d8611af4ca5613bfaf4d Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 1 May 2020 01:56:04 -0700 Subject: [PATCH 173/234] c_file_access_mode should be defined for Windows as well. And also unit->c_file doesn't exist in mswin. https://github.com/ruby/ruby/runs/635915704 --- mjit_worker.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/mjit_worker.c b/mjit_worker.c index b64c769ef21d4b..5a108c711800c2 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -725,6 +725,12 @@ sprint_funcname(char *funcname, const struct rb_mjit_unit *unit) } } +static const int c_file_access_mode = +#ifdef O_BINARY + O_BINARY| +#endif + O_WRONLY|O_EXCL|O_CREAT; + #define append_str2(p, str, len) ((char *)memcpy((p), str, (len))+(len)) #define append_str(p, str) append_str2(p, str, sizeof(str)-1) #define append_lit(p, str) append_str2(p, str, rb_strlen_lit(str)) @@ -874,12 +880,6 @@ compile_c_to_so(const char *c_file, const char *so_file) static void compile_prelude(FILE *f); -static const int c_file_access_mode = -#ifdef O_BINARY - O_BINARY| -#endif - O_WRONLY|O_EXCL|O_CREAT; - static bool compile_compact_jit_code(char* c_file) { @@ -1145,7 +1145,10 @@ convert_unit_to_func(struct rb_mjit_unit *unit) start_time = real_ms_time(); success = compile_c_to_so(c_file, so_file); -#ifndef _MSC_VER +#ifdef _MSC_VER + if (!mjit_opts.save_temps) + remove_file(c_file); +#else if (success) { // Always set c_file for compaction. The value is also used for lazy deletion. unit->c_file = strdup(c_file); @@ -1153,9 +1156,9 @@ convert_unit_to_func(struct rb_mjit_unit *unit) mjit_warning("failed to allocate memory to remember '%s' (%s), removing it...", c_file, strerror(errno)); } } -#endif if (!mjit_opts.save_temps && unit->c_file == NULL) remove_file(c_file); +#endif end_time = real_ms_time(); if (!success) { From 90969edf9bfa7cb87c0818f930bb6b548867a99f Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 1 May 2020 02:12:42 -0700 Subject: [PATCH 174/234] Fix a wrong argument of vm_exec on JIT cancel --- mjit_compile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mjit_compile.c b/mjit_compile.c index 57ab034494e769..9ceca5b30644d2 100644 --- a/mjit_compile.c +++ b/mjit_compile.c @@ -256,7 +256,7 @@ compile_inlined_cancel_handler(FILE *f, const struct rb_iseq_constant_body *body } // We're not just returning Qundef here so that caller's normal cancel handler can // push back `stack` to `cfp->sp`. - fprintf(f, " return vm_exec(ec, ec->cfp);\n"); + fprintf(f, " return vm_exec(ec, FALSE);\n"); } // Print the block to cancel JIT execution. From e19f4b3ac0d5b21563a8f864741602e9b6889120 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 1 May 2020 02:35:18 -0700 Subject: [PATCH 175/234] Fix MJIT compiler warnings in clang --- mjit_compile.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mjit_compile.c b/mjit_compile.c index 9ceca5b30644d2..b64cbb42b7c552 100644 --- a/mjit_compile.c +++ b/mjit_compile.c @@ -233,8 +233,8 @@ compile_inlined_cancel_handler(FILE *f, const struct rb_iseq_constant_body *body fprintf(f, " rb_mjit_recompile_iseq(original_iseq);\n"); // Swap pc/sp set on cancel with original pc/sp. - fprintf(f, " const VALUE current_pc = reg_cfp->pc;\n"); - fprintf(f, " const VALUE current_sp = reg_cfp->sp;\n"); + fprintf(f, " const VALUE *current_pc = reg_cfp->pc;\n"); + fprintf(f, " VALUE *current_sp = reg_cfp->sp;\n"); fprintf(f, " reg_cfp->pc = orig_pc;\n"); fprintf(f, " reg_cfp->sp = orig_sp;\n\n"); @@ -457,7 +457,7 @@ precompile_inlinable_iseqs(FILE *f, const rb_iseq_t *iseq, struct compile_status fprintf(f, "ALWAYS_INLINE(static VALUE _mjit%d_inlined_%d(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const VALUE orig_self, const rb_iseq_t *original_iseq));\n", status->compiled_id, pos); fprintf(f, "static inline VALUE\n_mjit%d_inlined_%d(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const VALUE orig_self, const rb_iseq_t *original_iseq)\n{\n", status->compiled_id, pos); fprintf(f, " const VALUE *orig_pc = reg_cfp->pc;\n"); - fprintf(f, " const VALUE *orig_sp = reg_cfp->sp;\n"); + fprintf(f, " VALUE *orig_sp = reg_cfp->sp;\n"); bool success = mjit_compile_body(f, child_iseq, &child_status); fprintf(f, "\n} /* end of _mjit%d_inlined_%d */\n\n", status->compiled_id, pos); From 76d9be9ce9c304f3fd59cee7624dbbcea1d2db39 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 1 May 2020 14:12:12 +0900 Subject: [PATCH 176/234] Get rid of -Wgnu-zero-variadic-macro-arguments errors As zero variadic macro argument, `rb_scan_args(argc, argv, "")` (or `"0"`), means 0-arity method and should be defined so, that case doesn't need to consider. --- include/ruby/3/scan_args.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ruby/3/scan_args.h b/include/ruby/3/scan_args.h index b1a29f706d79b9..409cef909f2f15 100644 --- a/include/ruby/3/scan_args.h +++ b/include/ruby/3/scan_args.h @@ -380,7 +380,7 @@ rb_scan_args_set(int kw_flag, int argc, const VALUE *argv, argc, argvp, fmt, \ (sizeof((VALUE*[]){__VA_ARGS__})/sizeof(VALUE*)), \ ((VALUE*[]){__VA_ARGS__})), \ - (rb_scan_args)(argc, argvp, fmt, ## __VA_ARGS__)) + (rb_scan_args)(argc, argvp, fmt, __VA_ARGS__)) # define rb_scan_args_kw(kw_flag, argc, argvp, fmt, ...) \ __builtin_choose_expr( \ __builtin_constant_p(fmt), \ @@ -388,7 +388,7 @@ rb_scan_args_set(int kw_flag, int argc, const VALUE *argv, kw_flag, argc, argvp, fmt, \ (sizeof((VALUE*[]){__VA_ARGS__})/sizeof(VALUE*)), \ ((VALUE*[]){__VA_ARGS__})), \ - (rb_scan_args_kw)(kw_flag, argc, argvp, fmt, ## __VA_ARGS__)) + (rb_scan_args_kw)(kw_flag, argc, argvp, fmt, __VA_ARGS__ /**/)) #endif #endif /* RUBY3_SCAN_ARGS_H */ From e4d3d5ceab25b7315f04f7d32a7940862b7b7946 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 1 May 2020 02:53:59 -0700 Subject: [PATCH 177/234] Stop generating MJIT_PCH include guard to fix https://ci.appveyor.com/project/ruby/ruby/builds/32577700/job/yh61rom35wt2uv39 It was for JIT compaction, and we don't support it on mswin. --- mjit_worker.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mjit_worker.c b/mjit_worker.c index 5a108c711800c2..037aa297e28768 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -1023,8 +1023,10 @@ compile_prelude(FILE *f) const char *s = pch_file; const char *e = header_name_end(s); +# ifndef _MSC_VER // Visual Studio doesn't expect macro changes around headers. Anyway we don't support compaction there... fprintf(f, "#ifndef MJIT_PCH\n"); fprintf(f, "#define MJIT_PCH\n"); +# endif fprintf(f, "#include \""); // print pch_file except .gch for gcc, but keep .pch for mswin for (; s < e; s++) { @@ -1035,7 +1037,9 @@ compile_prelude(FILE *f) fputc(*s, f); } fprintf(f, "\"\n"); +# ifndef _MSC_VER fprintf(f, "#endif\n"); +# endif #endif #ifdef _WIN32 From 41bbdd7806edd64e73fbca4bfda396946b694f24 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 1 May 2020 03:06:49 -0700 Subject: [PATCH 178/234] Skip MinGW TestJIT* and macOS TestJITDebug failures caused by 818d6d33368a396d9cd3d1a34a84015a9e76c5c8, for now. I'll take a look at them tomorrow. --- test/lib/jit_support.rb | 2 +- test/ruby/test_jit_debug.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/lib/jit_support.rb b/test/lib/jit_support.rb index 5977e84c1da0d4..5e803e97bf8e10 100644 --- a/test/lib/jit_support.rb +++ b/test/lib/jit_support.rb @@ -56,7 +56,7 @@ def supported? return @supported if defined?(@supported) @supported = UNSUPPORTED_COMPILERS.all? do |regexp| !regexp.match?(RbConfig::CONFIG['MJIT_CC']) - end && RbConfig::CONFIG["MJIT_SUPPORT"] != 'no' && !PENDING_RUBYCI_NICKNAMES.include?(ENV['RUBYCI_NICKNAME']) && !vs120_pdb_corrupted? + end && RbConfig::CONFIG["MJIT_SUPPORT"] != 'no' && !PENDING_RUBYCI_NICKNAMES.include?(ENV['RUBYCI_NICKNAME']) && !vs120_pdb_corrupted? && /mingw/ !~ RUBY_PLATFORM # TODO: remove mingw exclusion after investigation end # AppVeyor's Visual Studio 2013 is known to spuriously generate broken pch / pdb, like: diff --git a/test/ruby/test_jit_debug.rb b/test/ruby/test_jit_debug.rb index 179512fec68cd7..0d357ee7e0832a 100644 --- a/test/ruby/test_jit_debug.rb +++ b/test/ruby/test_jit_debug.rb @@ -5,6 +5,7 @@ return if ENV.key?('RUBYCI_NICKNAME') return if ENV['RUBY_DEBUG']&.include?('ci') # ci.rvm.jp return if /mswin/ =~ RUBY_PLATFORM +return if /darwin/ =~ RUBY_PLATFORM # TODO: remove this after investigation class TestJITDebug < TestJIT def setup From dc3bc425bb7fd505bd7ee45ff88246b528614004 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 1 May 2020 18:46:09 +0900 Subject: [PATCH 179/234] Get rid of -Wgnu-folding-constant errors Also renamed as like as a constant. --- thread_pthread.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/thread_pthread.c b/thread_pthread.c index f5eebf5b58104e..ee2f7bc9091231 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1572,14 +1572,17 @@ setup_communication_pipe_internal(int pipes[2]) # define SET_CURRENT_THREAD_NAME(name) prctl(PR_SET_NAME, name) #endif +enum { + THREAD_NAME_MAX = #if defined(__linux__) -static const size_t thread_name_max = 16; + 16 #elif defined(__APPLE__) /* Undocumented, and main thread seems unlimited */ -static const size_t thread_name_max = 64; + 64 #else -static const size_t thread_name_max = 16; + 16 #endif +}; static VALUE threadptr_invoke_proc_location(rb_thread_t *th); @@ -1593,7 +1596,7 @@ native_set_thread_name(rb_thread_t *th) } else if ((loc = threadptr_invoke_proc_location(th)) != Qnil) { char *name, *p; - char buf[thread_name_max]; + char buf[THREAD_NAME_MAX]; size_t len; int n; @@ -1619,7 +1622,7 @@ static void native_set_another_thread_name(rb_nativethread_id_t thread_id, VALUE name) { #if defined SET_ANOTHER_THREAD_NAME || defined SET_CURRENT_THREAD_NAME - char buf[thread_name_max]; + char buf[THREAD_NAME_MAX]; const char *s = ""; # if !defined SET_ANOTHER_THREAD_NAME if (!pthread_equal(pthread_self(), thread_id)) return; From 28aa5f7fa6d7a37de6a4c348f19cf0a595cc2553 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 1 May 2020 19:34:24 +0900 Subject: [PATCH 180/234] Fixed a message and version guard then moved to the existing block --- spec/ruby/library/matrix/unitary_spec.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/spec/ruby/library/matrix/unitary_spec.rb b/spec/ruby/library/matrix/unitary_spec.rb index c5b8cb6cee96eb..69739a2cd21472 100644 --- a/spec/ruby/library/matrix/unitary_spec.rb +++ b/spec/ruby/library/matrix/unitary_spec.rb @@ -8,14 +8,11 @@ Matrix[[1, 1, 0], [0, 1, 1], [1, 0, 1]].unitary?.should == false end - ruby_version_is '2.8' do # matrix v0.3.0 - it "returns true for non unitary matrix" do - Matrix[[0, Complex(0, 1)], [Complex(0, -1), 0]].unitary?.should == true - end - end - it "returns true for unitary matrices" do Matrix[[0, Complex(0, 1)], [Complex(0, 1), 0]].unitary?.should == true + version_is((Matrix::const_defined?(:VERSION) ? Matrix::VERSION : "0.1.0"), "0.3.0") do + Matrix[[0, Complex(0, 1)], [Complex(0, -1), 0]].unitary?.should == true + end end it "raises an error for rectangular matrices" do From 72c0612c40bc0d9684e870cb93d91ba584a3d35e Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 1 May 2020 10:40:43 -0700 Subject: [PATCH 181/234] Skip Solaris RubyCI TestJIT for now to be investigated later https://rubyci.org/logs/rubyci.s3.amazonaws.com/solaris10-gcc/ruby-master/log/20200501T160004Z.fail.html.gz --- test/lib/jit_support.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lib/jit_support.rb b/test/lib/jit_support.rb index 5e803e97bf8e10..b443a6f3a8702f 100644 --- a/test/lib/jit_support.rb +++ b/test/lib/jit_support.rb @@ -56,7 +56,7 @@ def supported? return @supported if defined?(@supported) @supported = UNSUPPORTED_COMPILERS.all? do |regexp| !regexp.match?(RbConfig::CONFIG['MJIT_CC']) - end && RbConfig::CONFIG["MJIT_SUPPORT"] != 'no' && !PENDING_RUBYCI_NICKNAMES.include?(ENV['RUBYCI_NICKNAME']) && !vs120_pdb_corrupted? && /mingw/ !~ RUBY_PLATFORM # TODO: remove mingw exclusion after investigation + end && RbConfig::CONFIG["MJIT_SUPPORT"] != 'no' && !PENDING_RUBYCI_NICKNAMES.include?(ENV['RUBYCI_NICKNAME']) && !vs120_pdb_corrupted? && /mingw/ !~ RUBY_PLATFORM && /solaris/ !~ RUBY_PLATFORM # TODO: remove mingw / solaris exclusion after investigation end # AppVeyor's Visual Studio 2013 is known to spuriously generate broken pch / pdb, like: From bb2ca762375d89a9c48abb14c4f79d68f2b49a5a Mon Sep 17 00:00:00 2001 From: git Date: Sat, 2 May 2020 02:41:15 +0900 Subject: [PATCH 182/234] * 2020-05-02 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 2ea9bb48931e16..39b64b2fb666a0 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 1 +#define RUBY_RELEASE_DAY 2 #include "ruby/version.h" From 91e4e2403e950d06eb49840bdb11409321002847 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sat, 2 May 2020 21:34:10 +0900 Subject: [PATCH 183/234] internal/process.h: add a no-warning simple wrapper for fork(2) As fork(2) is deprecated, its calls must be guarded by `COMPILER_WARNING_IGNORED(-Wdeprecated-declarations)`. All usages of fork(2) in process have been alread guarded. A new call to fork(2) was added in ruby.c with f22c4ff359498ab342e4b6d6feb21af6004ee270. This caused a build failure on Solaris 11. It may hide a bug to guard big code unnecessarily, so this change introduces a simple wrapper "rb_fork" whose definition is guarded, and replaces all calls to fork(2) with the wrapper function. --- common.mk | 1 + internal/process.h | 12 ++++++++++++ process.c | 16 +++------------- ruby.c | 3 ++- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/common.mk b/common.mk index 616276eb2a17b7..811ccf0851a3fd 100644 --- a/common.mk +++ b/common.mk @@ -11806,6 +11806,7 @@ ruby.$(OBJEXT): $(top_srcdir)/internal/parse.h ruby.$(OBJEXT): $(top_srcdir)/internal/serial.h ruby.$(OBJEXT): $(top_srcdir)/internal/static_assert.h ruby.$(OBJEXT): $(top_srcdir)/internal/string.h +ruby.$(OBJEXT): $(top_srcdir)/internal/process.h ruby.$(OBJEXT): $(top_srcdir)/internal/variable.h ruby.$(OBJEXT): $(top_srcdir)/internal/vm.h ruby.$(OBJEXT): $(top_srcdir)/internal/warnings.h diff --git a/internal/process.h b/internal/process.h index b47f857bb4b609..62d54d8b3760e8 100644 --- a/internal/process.h +++ b/internal/process.h @@ -22,6 +22,7 @@ #include "ruby/ruby.h" /* for VALUE */ #include "internal/imemo.h" /* for RB_IMEMO_TMPBUF_PTR */ +#include "internal/warnings.h" /* for COMPILER_WARNING_PUSH */ #define RB_MAX_GROUPS (65536) @@ -113,4 +114,15 @@ ARGVSTR2ARGC(VALUE argv_str) return i - 1; } +COMPILER_WARNING_PUSH +#if __has_warning("-Wdeprecated-declarations") || RUBY3_COMPILER_IS(GCC) +COMPILER_WARNING_IGNORED(-Wdeprecated-declarations) +#endif +static inline rb_pid_t +rb_fork(void) +{ + return fork(); +} +COMPILER_WARNING_POP + #endif /* INTERNAL_PROCESS_H */ diff --git a/process.c b/process.c index 0d0b466686fd82..e5cfed8cf20ea5 100644 --- a/process.c +++ b/process.c @@ -3957,10 +3957,6 @@ disable_child_handler_fork_child(struct child_handler_disabler_state *old, char return 0; } -COMPILER_WARNING_PUSH -#if __has_warning("-Wdeprecated-declarations") || RUBY3_COMPILER_IS(GCC) -COMPILER_WARNING_IGNORED(-Wdeprecated-declarations) -#endif static rb_pid_t retry_fork_async_signal_safe(int *status, int *ep, int (*chfunc)(void*, char *, size_t), void *charg, @@ -3985,9 +3981,9 @@ retry_fork_async_signal_safe(int *status, int *ep, if (!has_privilege()) pid = vfork(); else - pid = fork(); + pid = rb_fork(); #else - pid = fork(); + pid = rb_fork(); #endif if (pid == 0) {/* fork succeed, child process */ int ret; @@ -4021,7 +4017,6 @@ retry_fork_async_signal_safe(int *status, int *ep, return -1; } } -COMPILER_WARNING_POP static rb_pid_t fork_check_err(int *status, int (*chfunc)(void*, char *, size_t), void *charg, @@ -4075,10 +4070,6 @@ rb_fork_async_signal_safe(int *status, return fork_check_err(status, chfunc, charg, fds, errmsg, errmsg_buflen, 0); } -COMPILER_WARNING_PUSH -#if __has_warning("-Wdeprecated-declarations") || RUBY3_COMPILER_IS(GCC) -COMPILER_WARNING_IGNORED(-Wdeprecated-declarations) -#endif rb_pid_t rb_fork_ruby(int *status) { @@ -4093,7 +4084,7 @@ rb_fork_ruby(int *status) if (mjit_enabled) mjit_pause(false); // Don't leave locked mutex to child. Note: child_handler must be enabled to pause MJIT. disable_child_handler_before_fork(&old); before_fork_ruby(); - pid = fork(); + pid = rb_fork(); err = errno; after_fork_ruby(); disable_child_handler_fork_parent(&old); /* yes, bad name */ @@ -4105,7 +4096,6 @@ rb_fork_ruby(int *status) return -1; } } -COMPILER_WARNING_POP #endif diff --git a/ruby.c b/ruby.c index 405891f8737f33..f2577f51f1ebf0 100644 --- a/ruby.c +++ b/ruby.c @@ -56,6 +56,7 @@ #include "internal/missing.h" #include "internal/object.h" #include "internal/parse.h" +#include "internal/process.h" #include "internal/variable.h" #include "mjit.h" #include "ruby/encoding.h" @@ -1635,7 +1636,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) #ifdef HAVE_WORKING_FORK int fds[2]; if (rb_pipe(fds) == 0) { - rb_pid_t pid = fork(); + rb_pid_t pid = rb_fork(); if (pid > 0) { /* exec PAGER with reading from child */ dup2(fds[0], 0); From b78fba447ae543664b9dd0a7cede4d2648f63fa9 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sat, 2 May 2020 22:17:03 +0900 Subject: [PATCH 184/234] internal/process.h: forgot to guard "#ifdef HAVE_WORKING_FORK" --- internal/process.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/process.h b/internal/process.h index 62d54d8b3760e8..1ee9b03cca5d42 100644 --- a/internal/process.h +++ b/internal/process.h @@ -114,6 +114,7 @@ ARGVSTR2ARGC(VALUE argv_str) return i - 1; } +#ifdef HAVE_WORKING_FORK COMPILER_WARNING_PUSH #if __has_warning("-Wdeprecated-declarations") || RUBY3_COMPILER_IS(GCC) COMPILER_WARNING_IGNORED(-Wdeprecated-declarations) @@ -124,5 +125,6 @@ rb_fork(void) return fork(); } COMPILER_WARNING_POP +#endif #endif /* INTERNAL_PROCESS_H */ From a68ddf42879005905176bc38285906fe01707aff Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 2 May 2020 16:03:12 +0200 Subject: [PATCH 185/234] Update to ruby/mspec@ee29a34 --- spec/mspec/lib/mspec/helpers/ruby_exe.rb | 4 +- spec/mspec/lib/mspec/helpers/tmp.rb | 18 +----- spec/mspec/lib/mspec/runner/formatters.rb | 1 + .../lib/mspec/runner/formatters/stats.rb | 57 +++++++++++++++++++ spec/mspec/lib/mspec/utils/options.rb | 6 +- spec/mspec/spec/utils/options_spec.rb | 19 +++++++ spec/mspec/tool/sync/sync-rubyspec.rb | 4 +- 7 files changed, 89 insertions(+), 20 deletions(-) create mode 100644 spec/mspec/lib/mspec/runner/formatters/stats.rb diff --git a/spec/mspec/lib/mspec/helpers/ruby_exe.rb b/spec/mspec/lib/mspec/helpers/ruby_exe.rb index 6d5470bbb5731b..075a8aaef52997 100644 --- a/spec/mspec/lib/mspec/helpers/ruby_exe.rb +++ b/spec/mspec/lib/mspec/helpers/ruby_exe.rb @@ -153,5 +153,7 @@ def ruby_cmd(code, opts = {}) body = "-e #{code.inspect}" end - [RUBY_EXE, opts[:options], body, opts[:args]].compact.join(' ') + command = [RUBY_EXE, opts[:options], body, opts[:args]].compact.join(' ') + STDERR.puts "\nruby_cmd: #{command}" if ENV["DEBUG_MSPEC_RUBY_CMD"] == "true" + command end diff --git a/spec/mspec/lib/mspec/helpers/tmp.rb b/spec/mspec/lib/mspec/helpers/tmp.rb index df242f73c155ca..5062991d6354b1 100644 --- a/spec/mspec/lib/mspec/helpers/tmp.rb +++ b/spec/mspec/lib/mspec/helpers/tmp.rb @@ -4,25 +4,13 @@ # directory is empty when the process exits. SPEC_TEMP_DIR_PID = Process.pid -SPEC_TEMP_DIR_LIST = [] -if tmpdir = ENV['SPEC_TEMP_DIR'] - temppath = File.realdirpath(tmpdir) + "/" -else - tmpdir = File.realdirpath("rubyspec_temp") - temppath = tmpdir + "/#{SPEC_TEMP_DIR_PID}" - SPEC_TEMP_DIR_LIST << tmpdir -end -SPEC_TEMP_DIR_LIST << temppath -SPEC_TEMP_DIR = temppath +SPEC_TEMP_DIR = File.expand_path(ENV["SPEC_TEMP_DIR"] || "rubyspec_temp/#{SPEC_TEMP_DIR_PID}") SPEC_TEMP_UNIQUIFIER = "0" at_exit do begin if SPEC_TEMP_DIR_PID == Process.pid - while temppath = SPEC_TEMP_DIR_LIST.pop - next unless File.directory? temppath - Dir.delete temppath - end + Dir.delete SPEC_TEMP_DIR if File.directory? SPEC_TEMP_DIR end rescue SystemCallError STDERR.puts <<-EOM @@ -30,7 +18,7 @@ ----------------------------------------------------- The rubyspec temp directory is not empty. Ensure that all specs are cleaning up temporary files: - #{temppath} + #{SPEC_TEMP_DIR} ----------------------------------------------------- EOM diff --git a/spec/mspec/lib/mspec/runner/formatters.rb b/spec/mspec/lib/mspec/runner/formatters.rb index d085031a1246a8..66f515ddffc314 100644 --- a/spec/mspec/lib/mspec/runner/formatters.rb +++ b/spec/mspec/lib/mspec/runner/formatters.rb @@ -7,6 +7,7 @@ require 'mspec/runner/formatters/unit' require 'mspec/runner/formatters/spinner' require 'mspec/runner/formatters/method' +require 'mspec/runner/formatters/stats' require 'mspec/runner/formatters/yaml' require 'mspec/runner/formatters/profile' require 'mspec/runner/formatters/junit' diff --git a/spec/mspec/lib/mspec/runner/formatters/stats.rb b/spec/mspec/lib/mspec/runner/formatters/stats.rb new file mode 100644 index 00000000000000..8cff96d145ae3f --- /dev/null +++ b/spec/mspec/lib/mspec/runner/formatters/stats.rb @@ -0,0 +1,57 @@ +require 'mspec/runner/formatters/base' + +class StatsPerFileFormatter < BaseFormatter + def initialize(out = nil) + super(out) + @data = {} + @root = File.expand_path(MSpecScript.get(:prefix) || '.') + end + + def register + super + MSpec.register :load, self + MSpec.register :unload, self + end + + # Resets the tallies so the counts are only for this file. + def load + tally.counter.examples = 0 + tally.counter.errors = 0 + tally.counter.failures = 0 + tally.counter.tagged = 0 + end + + def unload + file = format_file MSpec.file + + raise if @data.key?(file) + @data[file] = { + examples: tally.counter.examples, + errors: tally.counter.errors, + failures: tally.counter.failures, + tagged: tally.counter.tagged, + } + end + + def finish + width = @data.keys.max_by(&:size).size + f = "%3d" + @data.each_pair do |file, data| + total = data[:examples] + passing = total - data[:errors] - data[:failures] - data[:tagged] + puts "#{file.ljust(width)} #{f % passing}/#{f % total}" + end + + require 'yaml' + yaml = YAML.dump(@data) + File.write "results-#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}.yml", yaml + end + + private def format_file(file) + if file.start_with?(@root) + file[@root.size+1..-1] + else + raise file + end + end +end diff --git a/spec/mspec/lib/mspec/utils/options.rb b/spec/mspec/lib/mspec/utils/options.rb index 886707e0c488ae..cb466f6a83cee1 100644 --- a/spec/mspec/lib/mspec/utils/options.rb +++ b/spec/mspec/lib/mspec/utils/options.rb @@ -274,6 +274,8 @@ def formatters config[:formatter] = SpinnerFormatter when 't', 'method' config[:formatter] = MethodFormatter + when 'e', 'stats' + config[:formatter] = StatsPerFileFormatter when 'y', 'yaml' config[:formatter] = YamlFormatter when 'p', 'profile' @@ -300,6 +302,7 @@ def formatters doc " m, summary SummaryFormatter" doc " a, *, spin SpinnerFormatter" doc " t, method MethodFormatter" + doc " e, stats StatsPerFileFormatter" doc " y, yaml YamlFormatter" doc " p, profile ProfileFormatter" doc " j, junit JUnitFormatter\n" @@ -467,8 +470,6 @@ def debug end def all - # Generated with: - # puts File.read(__FILE__).scan(/def (\w+).*\n\s*on\(/) configure {} targets formatters @@ -481,6 +482,7 @@ def all repeat verbose interrupt + timeout verify action_filters actions diff --git a/spec/mspec/spec/utils/options_spec.rb b/spec/mspec/spec/utils/options_spec.rb index ef85c412465ddb..f3a704652640aa 100644 --- a/spec/mspec/spec/utils/options_spec.rb +++ b/spec/mspec/spec/utils/options_spec.rb @@ -1283,3 +1283,22 @@ end end end + +describe "MSpecOptions#all" do + it "includes all options" do + meth = MSpecOptions.instance_method(:all) + file, line = meth.source_location + contents = File.read(file) + lines = contents.lines + + from = line + to = from + to += 1 until /^\s*end\s*$/ =~ lines[to] + calls = lines[from...to].map(&:strip) + + option_methods = contents.scan(/def (\w+).*\n\s*on\(/).map(&:first) + option_methods[0].sub!("configure", "configure {}") + + calls.should == option_methods + end +end diff --git a/spec/mspec/tool/sync/sync-rubyspec.rb b/spec/mspec/tool/sync/sync-rubyspec.rb index c1218bb02ca4a0..8a66217e4e0c18 100644 --- a/spec/mspec/tool/sync/sync-rubyspec.rb +++ b/spec/mspec/tool/sync/sync-rubyspec.rb @@ -18,7 +18,7 @@ MSPEC = ARGV.delete('--mspec') CHECK_LAST_MERGE = ENV['CHECK_LAST_MERGE'] != 'false' -TEST_TRUNK = ENV['TEST_TRUNK'] != 'false' +TEST_MASTER = ENV['TEST_MASTER'] != 'false' MSPEC_REPO = File.expand_path("../../..", __FILE__) raise MSPEC_REPO if !Dir.exist?(MSPEC_REPO) or !Dir.exist?("#{MSPEC_REPO}/.git") @@ -172,7 +172,7 @@ def test_new_specs run_test[min_version] run_test[max_version] - run_test["trunk"] if TEST_TRUNK + run_test["master"] if TEST_MASTER end end From c9213aa864fb8527388679c21f1ea8ce129e2f1a Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 2 May 2020 16:03:14 +0200 Subject: [PATCH 186/234] Update to ruby/spec@d394dfd --- spec/ruby/core/enumerator/next_spec.rb | 11 +++ spec/ruby/core/exception/key_error_spec.rb | 6 ++ spec/ruby/core/file/join_spec.rb | 9 ++ spec/ruby/core/file/stat_spec.rb | 5 +- spec/ruby/core/io/copy_stream_spec.rb | 40 +++++++++ spec/ruby/core/io/fixtures/classes.rb | 4 +- spec/ruby/core/io/fixtures/copy_in_out.rb | 2 + .../ruby/core/kernel/require_relative_spec.rb | 10 +++ spec/ruby/core/module/using_spec.rb | 90 +++++++++++++++++++ .../core/objectspace/weakmap/each_key_spec.rb | 11 +++ .../objectspace/weakmap/each_pair_spec.rb | 11 +++ .../core/objectspace/weakmap/each_spec.rb | 11 +++ .../objectspace/weakmap/each_value_spec.rb | 11 +++ .../weakmap/element_reference_spec.rb | 24 +++++ .../objectspace/weakmap/element_set_spec.rb | 61 +++++++++++++ .../core/objectspace/weakmap/include_spec.rb | 6 ++ .../core/objectspace/weakmap/inspect_spec.rb | 25 ++++++ .../ruby/core/objectspace/weakmap/key_spec.rb | 6 ++ .../core/objectspace/weakmap/keys_spec.rb | 6 ++ .../core/objectspace/weakmap/length_spec.rb | 6 ++ .../core/objectspace/weakmap/member_spec.rb | 6 ++ .../core/objectspace/weakmap/shared/each.rb | 10 +++ .../objectspace/weakmap/shared/include.rb | 34 +++++++ .../objectspace/weakmap/shared/members.rb | 14 +++ .../core/objectspace/weakmap/shared/size.rb | 14 +++ .../core/objectspace/weakmap/size_spec.rb | 6 ++ .../core/objectspace/weakmap/values_spec.rb | 6 ++ spec/ruby/core/objectspace/weakmap_spec.rb | 12 +++ spec/ruby/core/process/clock_getres_spec.rb | 4 +- spec/ruby/core/time/shared/to_i.rb | 7 ++ spec/ruby/core/tracepoint/inspect_spec.rb | 22 +++-- spec/ruby/language/string_spec.rb | 11 +++ spec/ruby/library/matrix/unitary_spec.rb | 5 +- .../net/http/http/fixtures/http_server.rb | 12 ++- spec/ruby/library/rbconfig/rbconfig_spec.rb | 16 ++++ spec/ruby/optional/capi/class_spec.rb | 66 +++++++++++++- spec/ruby/optional/capi/ext/class_spec.c | 24 +++++ spec/ruby/optional/capi/ext/rbasic_spec.c | 71 +++++++++++++++ spec/ruby/optional/capi/ext/symbol_spec.c | 5 ++ spec/ruby/optional/capi/ext/tracepoint_spec.c | 49 ++++++++++ spec/ruby/optional/capi/rbasic_spec.rb | 22 +++++ spec/ruby/optional/capi/shared/rbasic.rb | 81 +++++++++++++++++ spec/ruby/optional/capi/symbol_spec.rb | 16 ++++ spec/ruby/optional/capi/tracepoint_spec.rb | 56 ++++++++++++ 44 files changed, 904 insertions(+), 20 deletions(-) create mode 100644 spec/ruby/core/io/fixtures/copy_in_out.rb create mode 100644 spec/ruby/core/objectspace/weakmap/each_key_spec.rb create mode 100644 spec/ruby/core/objectspace/weakmap/each_pair_spec.rb create mode 100644 spec/ruby/core/objectspace/weakmap/each_spec.rb create mode 100644 spec/ruby/core/objectspace/weakmap/each_value_spec.rb create mode 100644 spec/ruby/core/objectspace/weakmap/element_reference_spec.rb create mode 100644 spec/ruby/core/objectspace/weakmap/element_set_spec.rb create mode 100644 spec/ruby/core/objectspace/weakmap/include_spec.rb create mode 100644 spec/ruby/core/objectspace/weakmap/inspect_spec.rb create mode 100644 spec/ruby/core/objectspace/weakmap/key_spec.rb create mode 100644 spec/ruby/core/objectspace/weakmap/keys_spec.rb create mode 100644 spec/ruby/core/objectspace/weakmap/length_spec.rb create mode 100644 spec/ruby/core/objectspace/weakmap/member_spec.rb create mode 100644 spec/ruby/core/objectspace/weakmap/shared/each.rb create mode 100644 spec/ruby/core/objectspace/weakmap/shared/include.rb create mode 100644 spec/ruby/core/objectspace/weakmap/shared/members.rb create mode 100644 spec/ruby/core/objectspace/weakmap/shared/size.rb create mode 100644 spec/ruby/core/objectspace/weakmap/size_spec.rb create mode 100644 spec/ruby/core/objectspace/weakmap/values_spec.rb create mode 100644 spec/ruby/core/objectspace/weakmap_spec.rb create mode 100644 spec/ruby/optional/capi/ext/rbasic_spec.c create mode 100644 spec/ruby/optional/capi/ext/tracepoint_spec.c create mode 100644 spec/ruby/optional/capi/rbasic_spec.rb create mode 100644 spec/ruby/optional/capi/shared/rbasic.rb create mode 100644 spec/ruby/optional/capi/tracepoint_spec.rb diff --git a/spec/ruby/core/enumerator/next_spec.rb b/spec/ruby/core/enumerator/next_spec.rb index 3e9ed8b015017e..a5e01a399d41c2 100644 --- a/spec/ruby/core/enumerator/next_spec.rb +++ b/spec/ruby/core/enumerator/next_spec.rb @@ -24,4 +24,15 @@ @enum.rewind @enum.next.should == 1 end + + it "restarts the enumerator if an exception terminated a previous iteration" do + exception = StandardError.new + enum = Enumerator.new do + raise exception + end + + result = 2.times.map { enum.next rescue $! } + + result.should == [exception, exception] + end end diff --git a/spec/ruby/core/exception/key_error_spec.rb b/spec/ruby/core/exception/key_error_spec.rb index ad280279d8902e..71bf2b46ff50d4 100644 --- a/spec/ruby/core/exception/key_error_spec.rb +++ b/spec/ruby/core/exception/key_error_spec.rb @@ -10,6 +10,12 @@ error.receiver.should == receiver error.key.should == key + + error = KeyError.new("message", receiver: receiver, key: key) + + error.message.should == "message" + error.receiver.should == receiver + error.key.should == key end end end diff --git a/spec/ruby/core/file/join_spec.rb b/spec/ruby/core/file/join_spec.rb index f1eab02de01d5a..0feedbae93c499 100644 --- a/spec/ruby/core/file/join_spec.rb +++ b/spec/ruby/core/file/join_spec.rb @@ -136,4 +136,13 @@ File.join(bin).should == "bin" File.join("usr", bin).should == "usr/bin" end + + it "raises errors for null bytes" do + -> { File.join("\x00x", "metadata.gz") }.should raise_error(ArgumentError) { |e| + e.message.should == 'string contains null byte' + } + -> { File.join("metadata.gz", "\x00x") }.should raise_error(ArgumentError) { |e| + e.message.should == 'string contains null byte' + } + end end diff --git a/spec/ruby/core/file/stat_spec.rb b/spec/ruby/core/file/stat_spec.rb index 76b0becbf0fc4a..275eae36d5dad1 100644 --- a/spec/ruby/core/file/stat_spec.rb +++ b/spec/ruby/core/file/stat_spec.rb @@ -43,10 +43,11 @@ end it "returns an error when given missing non-ASCII path" do - missing_path = "/missingfilepath\xE3E4".force_encoding("ASCII-8BIT") + missing_path = "/missingfilepath\xE3E4".b -> { File.stat(missing_path) - }.should raise_error(Errno::ENOENT) { |e| + }.should raise_error(SystemCallError) { |e| + [Errno::ENOENT, Errno::EILSEQ].should include(e.class) e.message.should include(missing_path) } end diff --git a/spec/ruby/core/io/copy_stream_spec.rb b/spec/ruby/core/io/copy_stream_spec.rb index c541e96e14c80f..df9c5c7390e446 100644 --- a/spec/ruby/core/io/copy_stream_spec.rb +++ b/spec/ruby/core/io/copy_stream_spec.rb @@ -279,4 +279,44 @@ end end + + + describe "with a destination that does partial reads" do + before do + @from_out, @from_in = IO.pipe + @to_out, @to_in = IO.pipe + end + + after do + [@from_out, @from_in, @to_out, @to_in].each {|io| io.close rescue nil} + end + + it "calls #write repeatedly on the destination Object" do + @from_in.write "1234" + @from_in.close + + th = Thread.new do + IO.copy_stream(@from_out, @to_in) + end + + copied = "" + 4.times do + copied += @to_out.read(1) + end + + th.join + + copied.should == "1234" + end + + end +end + +describe "IO.copy_stream" do + it "does not use buffering when writing to STDOUT" do + IO.popen([*ruby_exe, fixture(__FILE__ , "copy_in_out.rb")], "r+") do |io| + io.write("bar") + io.read(3).should == "bar" + end + end end diff --git a/spec/ruby/core/io/fixtures/classes.rb b/spec/ruby/core/io/fixtures/classes.rb index 460dd62387f748..5cc42c9b44e835 100644 --- a/spec/ruby/core/io/fixtures/classes.rb +++ b/spec/ruby/core/io/fixtures/classes.rb @@ -164,7 +164,7 @@ def initialize(io) @io = io end - def read(size, buf=nil) + def read(size, buf) @io.read size, buf end @@ -178,7 +178,7 @@ def initialize(io) @io = io end - def readpartial(size, buf=nil) + def readpartial(size, buf) @io.readpartial size, buf end diff --git a/spec/ruby/core/io/fixtures/copy_in_out.rb b/spec/ruby/core/io/fixtures/copy_in_out.rb new file mode 100644 index 00000000000000..b9d4085a47e976 --- /dev/null +++ b/spec/ruby/core/io/fixtures/copy_in_out.rb @@ -0,0 +1,2 @@ +STDOUT.sync = false +IO.copy_stream(STDIN, STDOUT) diff --git a/spec/ruby/core/kernel/require_relative_spec.rb b/spec/ruby/core/kernel/require_relative_spec.rb index b292a46c638e4f..d4146eb3c8befb 100644 --- a/spec/ruby/core/kernel/require_relative_spec.rb +++ b/spec/ruby/core/kernel/require_relative_spec.rb @@ -90,6 +90,16 @@ ScratchPad.recorded.should == [] end + it "raises a LoadError that includes the missing path" do + missing_path = "#{@dir}/nonexistent.rb" + expanded_missing_path = File.expand_path(missing_path, File.dirname(__FILE__)) + -> { require_relative(missing_path) }.should raise_error(LoadError) { |e| + e.message.should include(expanded_missing_path) + e.path.should == expanded_missing_path + } + ScratchPad.recorded.should == [] + end + it "raises a LoadError if basepath does not exist" do -> { eval("require_relative('#{@dir}/nonexistent.rb')") }.should raise_error(LoadError) end diff --git a/spec/ruby/core/module/using_spec.rb b/spec/ruby/core/module/using_spec.rb index 533d87d0809fa2..4781b99bb7b483 100644 --- a/spec/ruby/core/module/using_spec.rb +++ b/spec/ruby/core/module/using_spec.rb @@ -243,6 +243,96 @@ def self.call_foo(c) mod.call_foo(c).should == "foo from refinement" end + it "is active for module defined via Module.new {}" do + refinement = Module.new do + refine Integer do + def foo; "foo from refinement"; end + end + end + + result = nil + + Module.new do + using refinement + + Module.new do + result = 1.foo + end + end + + result.should == "foo from refinement" + end + + it "is active for class defined via Class.new {}" do + refinement = Module.new do + refine Integer do + def foo; "foo from refinement"; end + end + end + + result = nil + + Module.new do + using refinement + + Class.new do + result = 1.foo + end + end + + result.should == "foo from refinement" + end + + it "is active for block called via instance_exec" do + refinement = Module.new do + refine Integer do + def foo; "foo from refinement"; end + end + end + + c = Class.new do + using refinement + + def abc + block = -> { + 1.foo + } + + self.instance_exec(&block) + end + end + + c.new.abc.should == "foo from refinement" + end + + it "is active for block called via instance_eval" do + refinement = Module.new do + refine String do + def foo; "foo from refinement"; end + end + end + + c = Class.new do + using refinement + + def initialize + @a = "1703" + + @a.instance_eval do + def abc + "#{self}: #{self.foo}" + end + end + end + + def abc + @a.abc + end + end + + c.new.abc.should == "1703: foo from refinement" + end + it "is not active if `using` call is not evaluated" do result = nil diff --git a/spec/ruby/core/objectspace/weakmap/each_key_spec.rb b/spec/ruby/core/objectspace/weakmap/each_key_spec.rb new file mode 100644 index 00000000000000..df971deeb9ce79 --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap/each_key_spec.rb @@ -0,0 +1,11 @@ +require_relative '../../../spec_helper' +require_relative 'shared/members' +require_relative 'shared/each' + +describe "ObjectSpace::WeakMap#each_key" do + it_behaves_like :weakmap_members, -> map { a = []; map.each_key{ |k| a << k }; a }, %w[A B] +end + +describe "ObjectSpace::WeakMap#each_key" do + it_behaves_like :weakmap_each, :each_key +end diff --git a/spec/ruby/core/objectspace/weakmap/each_pair_spec.rb b/spec/ruby/core/objectspace/weakmap/each_pair_spec.rb new file mode 100644 index 00000000000000..ea29edbd2fee92 --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap/each_pair_spec.rb @@ -0,0 +1,11 @@ +require_relative '../../../spec_helper' +require_relative 'shared/members' +require_relative 'shared/each' + +describe "ObjectSpace::WeakMap#each_pair" do + it_behaves_like :weakmap_members, -> map { a = []; map.each_pair{ |k,v| a << "#{k}#{v}" }; a }, %w[Ax By] +end + +describe "ObjectSpace::WeakMap#each_key" do + it_behaves_like :weakmap_each, :each_pair +end diff --git a/spec/ruby/core/objectspace/weakmap/each_spec.rb b/spec/ruby/core/objectspace/weakmap/each_spec.rb new file mode 100644 index 00000000000000..46fcb66a6f5b42 --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap/each_spec.rb @@ -0,0 +1,11 @@ +require_relative '../../../spec_helper' +require_relative 'shared/members' +require_relative 'shared/each' + +describe "ObjectSpace::WeakMap#each" do + it_behaves_like :weakmap_members, -> map { a = []; map.each{ |k,v| a << "#{k}#{v}" }; a }, %w[Ax By] +end + +describe "ObjectSpace::WeakMap#each_key" do + it_behaves_like :weakmap_each, :each +end diff --git a/spec/ruby/core/objectspace/weakmap/each_value_spec.rb b/spec/ruby/core/objectspace/weakmap/each_value_spec.rb new file mode 100644 index 00000000000000..65a1a7f6fe6283 --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap/each_value_spec.rb @@ -0,0 +1,11 @@ +require_relative '../../../spec_helper' +require_relative 'shared/members' +require_relative 'shared/each' + +describe "ObjectSpace::WeakMap#each_value" do + it_behaves_like :weakmap_members, -> map { a = []; map.each_value{ |k| a << k }; a }, %w[x y] +end + +describe "ObjectSpace::WeakMap#each_key" do + it_behaves_like :weakmap_each, :each_value +end diff --git a/spec/ruby/core/objectspace/weakmap/element_reference_spec.rb b/spec/ruby/core/objectspace/weakmap/element_reference_spec.rb new file mode 100644 index 00000000000000..cb3174cbfa589a --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap/element_reference_spec.rb @@ -0,0 +1,24 @@ +require_relative '../../../spec_helper' + +describe "ObjectSpace::WeakMap#[]" do + it "is faithful to the map's content" do + map = ObjectSpace::WeakMap.new + key1, key2 = %w[a b].map(&:upcase) + ref1, ref2 = %w[x y] + map[key1] = ref1 + map[key1].should == ref1 + map[key1] = ref1 + map[key1].should == ref1 + map[key2] = ref2 + map[key1].should == ref1 + map[key2].should == ref2 + end + + it "matches using identity semantics" do + map = ObjectSpace::WeakMap.new + key1, key2 = %w[a a].map(&:upcase) + ref = "x" + map[key1] = ref + map[key2].should == nil + end +end diff --git a/spec/ruby/core/objectspace/weakmap/element_set_spec.rb b/spec/ruby/core/objectspace/weakmap/element_set_spec.rb new file mode 100644 index 00000000000000..2b536501482f85 --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap/element_set_spec.rb @@ -0,0 +1,61 @@ +require_relative '../../../spec_helper' + +describe "ObjectSpace::WeakMap#[]=" do + def should_accept(map, key, value) + (map[key] = value).should == value + map.should.key?(key) + map[key].should == value + end + + it "is correct" do + map = ObjectSpace::WeakMap.new + key1, key2 = %w[a b].map(&:upcase) + ref1, ref2 = %w[x y] + should_accept(map, key1, ref1) + should_accept(map, key1, ref1) + should_accept(map, key2, ref2) + map[key1].should == ref1 + end + + ruby_version_is ""..."2.7" do + it "does not accept primitive or frozen keys or values" do + map = ObjectSpace::WeakMap.new + x = Object.new + -> { map[true] = x }.should raise_error(ArgumentError) + -> { map[false] = x }.should raise_error(ArgumentError) + -> { map[nil] = x }.should raise_error(ArgumentError) + -> { map[42] = x }.should raise_error(ArgumentError) + -> { map[:foo] = x }.should raise_error(ArgumentError) + -> { map[x] = true }.should raise_error(ArgumentError) + -> { map[x] = false }.should raise_error(ArgumentError) + -> { map[x] = nil }.should raise_error(ArgumentError) + -> { map[x] = 42 }.should raise_error(ArgumentError) + -> { map[x] = :foo }.should raise_error(ArgumentError) + + y = Object.new.freeze + -> { map[x] = y}.should raise_error(FrozenError) + -> { map[y] = x}.should raise_error(FrozenError) + end + end + + ruby_version_is "2.7" do + it "accepts primitive or frozen keys or values" do + map = ObjectSpace::WeakMap.new + x = Object.new + should_accept(map, true, x) + should_accept(map, false, x) + should_accept(map, nil, x) + should_accept(map, 42, x) + should_accept(map, :foo, x) + + should_accept(map, x, true) + should_accept(map, x, false) + should_accept(map, x, 42) + should_accept(map, x, :foo) + + y = Object.new.freeze + should_accept(map, x, y) + should_accept(map, y, x) + end + end +end diff --git a/spec/ruby/core/objectspace/weakmap/include_spec.rb b/spec/ruby/core/objectspace/weakmap/include_spec.rb new file mode 100644 index 00000000000000..54ca6b303080ad --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap/include_spec.rb @@ -0,0 +1,6 @@ +require_relative '../../../spec_helper' +require_relative 'shared/include' + +describe "ObjectSpace::WeakMap#include?" do + it_behaves_like :weakmap_include?, :include? +end diff --git a/spec/ruby/core/objectspace/weakmap/inspect_spec.rb b/spec/ruby/core/objectspace/weakmap/inspect_spec.rb new file mode 100644 index 00000000000000..f064f6e3eaa637 --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap/inspect_spec.rb @@ -0,0 +1,25 @@ +require_relative '../../../spec_helper' + +describe "ObjectSpace::WeakMap#inspect" do + it "displays object pointers in output" do + map = ObjectSpace::WeakMap.new + # important to test with BasicObject (without Kernel) here to test edge cases + key1, key2 = [BasicObject.new, Object.new] + ref1, ref2 = [BasicObject.new, Object.new] + map.inspect.should =~ /\A\#\z/ + map[key1] = ref1 + map.inspect.should =~ /\A\# => \#>\z/ + map[key1] = ref1 + map.inspect.should =~ /\A\# => \#>\z/ + map[key2] = ref2 + + regexp1 = /\A\# => \#, \# => \#>\z/ + regexp2 = /\A\# => \#, \# => \#>\z/ + str = map.inspect + if str =~ regexp1 + str.should =~ regexp1 + else + str.should =~ regexp2 + end + end +end diff --git a/spec/ruby/core/objectspace/weakmap/key_spec.rb b/spec/ruby/core/objectspace/weakmap/key_spec.rb new file mode 100644 index 00000000000000..999685ff951cab --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap/key_spec.rb @@ -0,0 +1,6 @@ +require_relative '../../../spec_helper' +require_relative 'shared/include' + +describe "ObjectSpace::WeakMap#key?" do + it_behaves_like :weakmap_include?, :key? +end diff --git a/spec/ruby/core/objectspace/weakmap/keys_spec.rb b/spec/ruby/core/objectspace/weakmap/keys_spec.rb new file mode 100644 index 00000000000000..7b1494bdd7c68a --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap/keys_spec.rb @@ -0,0 +1,6 @@ +require_relative '../../../spec_helper' +require_relative 'shared/members' + +describe "ObjectSpace::WeakMap#keys" do + it_behaves_like :weakmap_members, -> map { map.keys }, %w[A B] +end diff --git a/spec/ruby/core/objectspace/weakmap/length_spec.rb b/spec/ruby/core/objectspace/weakmap/length_spec.rb new file mode 100644 index 00000000000000..3a935648b14306 --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap/length_spec.rb @@ -0,0 +1,6 @@ +require_relative '../../../spec_helper' +require_relative 'shared/size' + +describe "ObjectSpace::WeakMap#length" do + it_behaves_like :weakmap_size, :length +end diff --git a/spec/ruby/core/objectspace/weakmap/member_spec.rb b/spec/ruby/core/objectspace/weakmap/member_spec.rb new file mode 100644 index 00000000000000..cefb190ce7cfd7 --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap/member_spec.rb @@ -0,0 +1,6 @@ +require_relative '../../../spec_helper' +require_relative 'shared/include' + +describe "ObjectSpace::WeakMap#member?" do + it_behaves_like :weakmap_include?, :member? +end diff --git a/spec/ruby/core/objectspace/weakmap/shared/each.rb b/spec/ruby/core/objectspace/weakmap/shared/each.rb new file mode 100644 index 00000000000000..3d43a19347971a --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap/shared/each.rb @@ -0,0 +1,10 @@ +describe :weakmap_each, shared: true do + it "must take a block, except when empty" do + map = ObjectSpace::WeakMap.new + key = "a".upcase + ref = "x" + map.send(@method).should == map + map[key] = ref + -> { map.send(@method) }.should raise_error(LocalJumpError) + end +end diff --git a/spec/ruby/core/objectspace/weakmap/shared/include.rb b/spec/ruby/core/objectspace/weakmap/shared/include.rb new file mode 100644 index 00000000000000..370359e6caa9b8 --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap/shared/include.rb @@ -0,0 +1,34 @@ +describe :weakmap_include?, shared: true do + it "recognizes keys in use" do + map = ObjectSpace::WeakMap.new + key1, key2 = %w[a b].map(&:upcase) + ref1, ref2 = %w[x y] + + map[key1] = ref1 + map.send(@method, key1).should == true + map[key1] = ref1 + map.send(@method, key1).should == true + map[key2] = ref2 + map.send(@method, key2).should == true + end + + it "matches using identity semantics" do + map = ObjectSpace::WeakMap.new + key1, key2 = %w[a a].map(&:upcase) + ref = "x" + map[key1] = ref + map.send(@method, key2).should == false + end + + ruby_version_is "2.7" do + ruby_bug "#16826", "2.7.0"..."2.8.1" do + it "reports true if the pair exists and the value is nil" do + map = ObjectSpace::WeakMap.new + key = Object.new + map[key] = nil + map.size.should == 1 + map.send(@method, key).should == true + end + end + end +end diff --git a/spec/ruby/core/objectspace/weakmap/shared/members.rb b/spec/ruby/core/objectspace/weakmap/shared/members.rb new file mode 100644 index 00000000000000..57226c8d7a0b6c --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap/shared/members.rb @@ -0,0 +1,14 @@ +describe :weakmap_members, shared: true do + it "is correct" do + map = ObjectSpace::WeakMap.new + key1, key2 = %w[a b].map(&:upcase) + ref1, ref2 = %w[x y] + @method.call(map).should == [] + map[key1] = ref1 + @method.call(map).should == @object[0..0] + map[key1] = ref1 + @method.call(map).should == @object[0..0] + map[key2] = ref2 + @method.call(map).sort.should == @object + end +end diff --git a/spec/ruby/core/objectspace/weakmap/shared/size.rb b/spec/ruby/core/objectspace/weakmap/shared/size.rb new file mode 100644 index 00000000000000..1064f99d1b987b --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap/shared/size.rb @@ -0,0 +1,14 @@ +describe :weakmap_size, shared: true do + it "is correct" do + map = ObjectSpace::WeakMap.new + key1, key2 = %w[a b].map(&:upcase) + ref1, ref2 = %w[x y] + map.send(@method).should == 0 + map[key1] = ref1 + map.send(@method).should == 1 + map[key1] = ref1 + map.send(@method).should == 1 + map[key2] = ref2 + map.send(@method).should == 2 + end +end diff --git a/spec/ruby/core/objectspace/weakmap/size_spec.rb b/spec/ruby/core/objectspace/weakmap/size_spec.rb new file mode 100644 index 00000000000000..1446abaa24d661 --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap/size_spec.rb @@ -0,0 +1,6 @@ +require_relative '../../../spec_helper' +require_relative 'shared/size' + +describe "ObjectSpace::WeakMap#size" do + it_behaves_like :weakmap_size, :size +end diff --git a/spec/ruby/core/objectspace/weakmap/values_spec.rb b/spec/ruby/core/objectspace/weakmap/values_spec.rb new file mode 100644 index 00000000000000..6f6f90d0ba3509 --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap/values_spec.rb @@ -0,0 +1,6 @@ +require_relative '../../../spec_helper' +require_relative 'shared/members' + +describe "ObjectSpace::WeakMap#values" do + it_behaves_like :weakmap_members, -> map { map.values }, %w[x y] +end diff --git a/spec/ruby/core/objectspace/weakmap_spec.rb b/spec/ruby/core/objectspace/weakmap_spec.rb new file mode 100644 index 00000000000000..2f3f93c291fced --- /dev/null +++ b/spec/ruby/core/objectspace/weakmap_spec.rb @@ -0,0 +1,12 @@ +require_relative '../../spec_helper' + +describe "ObjectSpace::WeakMap" do + + # Note that we can't really spec the most important aspect of this class: that entries get removed when the values + # become unreachable. This is because Ruby does not offer a way to reliable invoke GC (GC.start is not enough, neither + # on MRI or on alternative implementations). + + it "includes Enumerable" do + ObjectSpace::WeakMap.include?(Enumerable).should == true + end +end diff --git a/spec/ruby/core/process/clock_getres_spec.rb b/spec/ruby/core/process/clock_getres_spec.rb index 02e36b2d9c57cc..b3fc9a4e31e197 100644 --- a/spec/ruby/core/process/clock_getres_spec.rb +++ b/spec/ruby/core/process/clock_getres_spec.rb @@ -19,13 +19,13 @@ # These are observed - platform_is_not :solaris, :aix, :openbsd, :android do + platform_is :linux, :darwin, :windows do it "with Process::CLOCK_REALTIME reports at least 1 microsecond" do Process.clock_getres(Process::CLOCK_REALTIME, :nanosecond).should <= 1_000 end end - platform_is_not :aix, :openbsd, :android do + platform_is :linux, :darwin, :windows do it "with Process::CLOCK_MONOTONIC reports at least 1 microsecond" do Process.clock_getres(Process::CLOCK_MONOTONIC, :nanosecond).should <= 1_000 end diff --git a/spec/ruby/core/time/shared/to_i.rb b/spec/ruby/core/time/shared/to_i.rb index 03497c700bd01c..06c966b7085b1e 100644 --- a/spec/ruby/core/time/shared/to_i.rb +++ b/spec/ruby/core/time/shared/to_i.rb @@ -6,4 +6,11 @@ it "doesn't return an actual number of seconds in time" do Time.at(65.5).send(@method).should == 65 end + + it "rounds fractional seconds toward zero" do + t = Time.utc(1960, 1, 1, 0, 0, 0, 999_999) + + t.to_f.to_i.should == -315619199 + t.to_i.should == -315619200 + end end diff --git a/spec/ruby/core/tracepoint/inspect_spec.rb b/spec/ruby/core/tracepoint/inspect_spec.rb index 9ff1653ae83b42..465f01e2298396 100644 --- a/spec/ruby/core/tracepoint/inspect_spec.rb +++ b/spec/ruby/core/tracepoint/inspect_spec.rb @@ -3,26 +3,32 @@ describe 'TracePoint#inspect' do it 'returns a string containing a human-readable TracePoint status' do - TracePoint.new(:line) {}.inspect.should == - '#' + TracePoint.new(:line) {}.inspect.should == '#' end it 'returns a String showing the event, path and line' do inspect = nil - line = __LINE__ - TracePoint.new(:line) { |tp| inspect = tp.inspect }.enable do - inspect.should == "#" + line = nil + TracePoint.new(:line) { |tp| + inspect ||= tp.inspect + }.enable do + line = __LINE__ end + + inspect.should == "#" end it 'returns a String showing the event, path and line for a :class event' do inspect = nil - line = __LINE__ - TracePoint.new(:class) { |tp| inspect = tp.inspect }.enable do + line = nil + TracePoint.new(:class) { |tp| + inspect ||= tp.inspect + }.enable do + line = __LINE__ + 1 class TracePointSpec::C end end - inspect.should == "#" + inspect.should == "#" end end diff --git a/spec/ruby/language/string_spec.rb b/spec/ruby/language/string_spec.rb index 68c5fd221b97a6..d19b909cab49de 100644 --- a/spec/ruby/language/string_spec.rb +++ b/spec/ruby/language/string_spec.rb @@ -32,6 +32,11 @@ "#@my_ip".should == 'xxx' end + it "does not interpolate invalid variable names" do + "#@".should == '#@' + "#$%".should == '#$%' + end + it "has characters [.(=?!# end simple # interpolation" do "#@ip[".should == 'xxx[' "#@ip.".should == 'xxx.' @@ -260,6 +265,12 @@ def long_string_literals end describe "Ruby String interpolation" do + it "permits an empty expression" do + s = "#{}" # rubocop:disable Lint/EmptyInterpolation + s.should.empty? + s.should_not.frozen? + end + it "returns a string with the source encoding by default" do "a#{"b"}c".encoding.should == Encoding::BINARY eval('"a#{"b"}c"'.force_encoding("us-ascii")).encoding.should == Encoding::US_ASCII diff --git a/spec/ruby/library/matrix/unitary_spec.rb b/spec/ruby/library/matrix/unitary_spec.rb index 69739a2cd21472..c52f9d97d92ae8 100644 --- a/spec/ruby/library/matrix/unitary_spec.rb +++ b/spec/ruby/library/matrix/unitary_spec.rb @@ -10,7 +10,10 @@ it "returns true for unitary matrices" do Matrix[[0, Complex(0, 1)], [Complex(0, 1), 0]].unitary?.should == true - version_is((Matrix::const_defined?(:VERSION) ? Matrix::VERSION : "0.1.0"), "0.3.0") do + end + + version_is((Matrix::const_defined?(:VERSION) ? Matrix::VERSION : "0.1.0"), "0.3.0") do + it "returns true for unitary matrices with a Complex and a negative #imag" do Matrix[[0, Complex(0, 1)], [Complex(0, -1), 0]].unitary?.should == true end end diff --git a/spec/ruby/library/net/http/http/fixtures/http_server.rb b/spec/ruby/library/net/http/http/fixtures/http_server.rb index 49e8f437ccf39b..aeb0babda19564 100644 --- a/spec/ruby/library/net/http/http/fixtures/http_server.rb +++ b/spec/ruby/library/net/http/http/fixtures/http_server.rb @@ -53,10 +53,10 @@ def reply(req, res) end end - class << self - @server = nil - @server_thread = nil + @server = nil + @server_thread = nil + class << self def port raise "server not started" unless @server @server.config[:Port] @@ -89,8 +89,12 @@ def stop_server if @server begin @server.shutdown - rescue Errno::EPIPE + rescue Errno::EPIPE, Errno::EBADF # Because WEBrick is not thread-safe and only catches IOError + + # EBADF can happen because WEBrick @server_thread concurrently closes the shutdown pipe + # once @status = :Shutdown, while the current thread does write_nonblock("\0"). + # On MRI this EBADF is replaced by IOError due to the GIL around both #close and #write_nonblock. end @server = nil end diff --git a/spec/ruby/library/rbconfig/rbconfig_spec.rb b/spec/ruby/library/rbconfig/rbconfig_spec.rb index f88dc673e5dc9b..1aa12df7417e99 100644 --- a/spec/ruby/library/rbconfig/rbconfig_spec.rb +++ b/spec/ruby/library/rbconfig/rbconfig_spec.rb @@ -51,6 +51,22 @@ end end end + + platform_is :linux do + it "['AR'] exists and can be executed" do + ar = RbConfig::CONFIG.fetch('AR') + out = `#{ar} --version` + $?.should.success? + out.should_not be_empty + end + + it "['STRIP'] exists and can be executed" do + strip = RbConfig::CONFIG.fetch('STRIP') + out = `#{strip} --version` + $?.should.success? + out.should_not be_empty + end + end end describe "RbConfig::TOPDIR" do diff --git a/spec/ruby/optional/capi/class_spec.rb b/spec/ruby/optional/capi/class_spec.rb index 0b03fb9e6c8c19..c2424668b91f53 100644 --- a/spec/ruby/optional/capi/class_spec.rb +++ b/spec/ruby/optional/capi/class_spec.rb @@ -1,5 +1,6 @@ require_relative 'spec_helper' require_relative 'fixtures/class' +require_relative '../../core/module/fixtures/classes' load_extension("class") compile_extension("class_under_autoload") @@ -39,6 +40,69 @@ @s = CApiClassSpecs.new end + describe "rb_class_instance_methods" do + it "returns the public and protected methods of self and its ancestors" do + methods = @s.rb_class_instance_methods(ModuleSpecs::Basic) + methods.should include(:protected_module, :public_module) + + methods = @s.rb_class_instance_methods(ModuleSpecs::Basic, true) + methods.should include(:protected_module, :public_module) + end + + it "when passed false as a parameter, returns the instance methods of the class" do + methods = @s.rb_class_instance_methods(ModuleSpecs::Child, false) + methods.should include(:protected_child, :public_child) + end + end + + describe "rb_class_public_instance_methods" do + it "returns a list of public methods in module and its ancestors" do + methods = @s.rb_class_public_instance_methods(ModuleSpecs::CountsChild) + methods.should include(:public_3) + methods.should include(:public_2) + methods.should include(:public_1) + + methods = @s.rb_class_public_instance_methods(ModuleSpecs::CountsChild, true) + methods.should include(:public_3) + methods.should include(:public_2) + methods.should include(:public_1) + end + + it "when passed false as a parameter, should return only methods defined in that module" do + @s.rb_class_public_instance_methods(ModuleSpecs::CountsChild, false).should == [:public_1] + end + end + + describe "rb_class_protected_instance_methods" do + it "returns a list of protected methods in module and its ancestors" do + methods = @s.rb_class_protected_instance_methods(ModuleSpecs::CountsChild) + methods.should include(:protected_3) + methods.should include(:protected_2) + methods.should include(:protected_1) + + methods = @s.rb_class_protected_instance_methods(ModuleSpecs::CountsChild, true) + methods.should include(:protected_3) + methods.should include(:protected_2) + methods.should include(:protected_1) + end + + it "when passed false as a parameter, should return only methods defined in that module" do + @s.rb_class_public_instance_methods(ModuleSpecs::CountsChild, false).should == [:public_1] + end + end + + describe "rb_class_private_instance_methods" do + it "returns a list of private methods in module and its ancestors" do + @s.rb_class_private_instance_methods(ModuleSpecs::CountsChild).should == ModuleSpecs::CountsChild.private_instance_methods + @s.rb_class_private_instance_methods(ModuleSpecs::CountsChild, true).should == ModuleSpecs::CountsChild.private_instance_methods + end + + it "when passed false as a parameter, should return only methods defined in that module" do + methods = @s.rb_class_private_instance_methods(ModuleSpecs::CountsChild, false) + methods.should == [:private_1] + end + end + describe "rb_class_new_instance" do it "allocates and initializes a new object" do o = @s.rb_class_new_instance(0, nil, CApiClassSpecs::Alloc) @@ -338,7 +402,7 @@ end describe "rb_class_new" do - it "returns an new subclass of the superclass" do + it "returns a new subclass of the superclass" do subclass = @s.rb_class_new(CApiClassSpecs::NewClass) CApiClassSpecs::NewClass.should be_ancestor_of(subclass) end diff --git a/spec/ruby/optional/capi/ext/class_spec.c b/spec/ruby/optional/capi/ext/class_spec.c index e62b9efe2e0ca9..36b8c8f2f30a7b 100644 --- a/spec/ruby/optional/capi/ext/class_spec.c +++ b/spec/ruby/optional/capi/ext/class_spec.c @@ -37,6 +37,26 @@ static VALUE class_spec_rb_path_to_class(VALUE self, VALUE path) { return rb_path_to_class(path); } +static VALUE class_spec_rb_class_instance_methods(int argc, VALUE* argv, VALUE self) { + VALUE mod = argv[0]; + return rb_class_instance_methods(--argc, ++argv, mod); +} + +static VALUE class_spec_rb_class_public_instance_methods(int argc, VALUE* argv, VALUE self) { + VALUE mod = argv[0]; + return rb_class_public_instance_methods(--argc, ++argv, mod); +} + +static VALUE class_spec_rb_class_protected_instance_methods(int argc, VALUE* argv, VALUE self) { + VALUE mod = argv[0]; + return rb_class_protected_instance_methods(--argc, ++argv, mod); +} + +static VALUE class_spec_rb_class_private_instance_methods(int argc, VALUE* argv, VALUE self) { + VALUE mod = argv[0]; + return rb_class_private_instance_methods(--argc, ++argv, mod); +} + static VALUE class_spec_rb_class_new(VALUE self, VALUE super) { return rb_class_new(super); } @@ -146,6 +166,10 @@ void Init_class_spec(void) { rb_define_method(cls, "rb_class2name", class_spec_rb_class2name, 1); rb_define_method(cls, "rb_path2class", class_spec_rb_path2class, 1); rb_define_method(cls, "rb_path_to_class", class_spec_rb_path_to_class, 1); + rb_define_method(cls, "rb_class_instance_methods", class_spec_rb_class_instance_methods, -1); + rb_define_method(cls, "rb_class_public_instance_methods", class_spec_rb_class_public_instance_methods, -1); + rb_define_method(cls, "rb_class_protected_instance_methods", class_spec_rb_class_protected_instance_methods, -1); + rb_define_method(cls, "rb_class_private_instance_methods", class_spec_rb_class_private_instance_methods, -1); rb_define_method(cls, "rb_class_new", class_spec_rb_class_new, 1); rb_define_method(cls, "rb_class_new_instance", class_spec_rb_class_new_instance, 3); rb_define_method(cls, "rb_class_real", class_spec_rb_class_real, 1); diff --git a/spec/ruby/optional/capi/ext/rbasic_spec.c b/spec/ruby/optional/capi/ext/rbasic_spec.c new file mode 100644 index 00000000000000..b5779ef062e3eb --- /dev/null +++ b/spec/ruby/optional/capi/ext/rbasic_spec.c @@ -0,0 +1,71 @@ +#include "ruby.h" +#include "rubyspec.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +VALUE rbasic_spec_taint_flag(VALUE self) { + return INT2FIX(RUBY_FL_TAINT); +} + +VALUE rbasic_spec_freeze_flag(VALUE self) { + return INT2FIX(RUBY_FL_FREEZE); +} + +VALUE rbasic_spec_get_flags(VALUE self, VALUE val) { + return INT2FIX(RBASIC(val)->flags); +} + +VALUE rbasic_spec_set_flags(VALUE self, VALUE val, VALUE flags) { + RBASIC(val)->flags = FIX2INT(flags); + return INT2FIX(RBASIC(val)->flags); +} + +VALUE rbasic_spec_copy_flags(VALUE self, VALUE to, VALUE from) { + RBASIC(to)->flags = RBASIC(from)->flags; + return INT2FIX(RBASIC(to)->flags); +} + +VALUE rbasic_spec_get_klass(VALUE self, VALUE val) { + return RBASIC(val)->klass; +} + +VALUE rbasic_rdata_spec_get_flags(VALUE self, VALUE structure) { + return INT2FIX(RDATA(structure)->basic.flags); +} + +VALUE rbasic_rdata_spec_set_flags(VALUE self, VALUE structure, VALUE flags) { + RDATA(structure)->basic.flags = FIX2INT(flags); + return INT2FIX(RDATA(structure)->basic.flags); +} + +VALUE rbasic_rdata_spec_copy_flags(VALUE self, VALUE to, VALUE from) { + RDATA(to)->basic.flags = RDATA(from)->basic.flags; + return INT2FIX(RDATA(to)->basic.flags); +} + +VALUE rbasic_rdata_spec_get_klass(VALUE self, VALUE structure) { + return RDATA(structure)->basic.klass; +} + +void Init_rbasic_spec(void) { + VALUE cls = rb_define_class("CApiRBasicSpecs", rb_cObject); + rb_define_method(cls, "taint_flag", rbasic_spec_taint_flag, 0); + rb_define_method(cls, "freeze_flag", rbasic_spec_freeze_flag, 0); + rb_define_method(cls, "get_flags", rbasic_spec_get_flags, 1); + rb_define_method(cls, "set_flags", rbasic_spec_set_flags, 2); + rb_define_method(cls, "copy_flags", rbasic_spec_copy_flags, 2); + rb_define_method(cls, "get_klass", rbasic_spec_get_klass, 1); + + cls = rb_define_class("CApiRBasicRDataSpecs", rb_cObject); + rb_define_method(cls, "get_flags", rbasic_rdata_spec_get_flags, 1); + rb_define_method(cls, "set_flags", rbasic_rdata_spec_set_flags, 2); + rb_define_method(cls, "copy_flags", rbasic_rdata_spec_copy_flags, 2); + rb_define_method(cls, "get_klass", rbasic_rdata_spec_get_klass, 1); +} + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/spec/ruby/optional/capi/ext/symbol_spec.c b/spec/ruby/optional/capi/ext/symbol_spec.c index d2ca62d81ed760..7d9a7b4379554a 100644 --- a/spec/ruby/optional/capi/ext/symbol_spec.c +++ b/spec/ruby/optional/capi/ext/symbol_spec.c @@ -75,6 +75,10 @@ VALUE symbol_spec_rb_sym2str(VALUE self, VALUE sym) { return rb_sym2str(sym); } +VALUE symbol_spec_rb_to_symbol(VALUE self, VALUE val) { + return rb_to_symbol(val); +} + void Init_symbol_spec(void) { VALUE cls = rb_define_class("CApiSymbolSpecs", rb_cObject); rb_define_method(cls, "SYMBOL_P", symbol_spec_SYMBOL_P, 1); @@ -93,6 +97,7 @@ void Init_symbol_spec(void) { rb_define_method(cls, "rb_is_const_id", symbol_spec_rb_is_const_id, 1); rb_define_method(cls, "rb_is_instance_id", symbol_spec_rb_is_instance_id, 1); rb_define_method(cls, "rb_sym2str", symbol_spec_rb_sym2str, 1); + rb_define_method(cls, "rb_to_symbol", symbol_spec_rb_to_symbol, 1); } #ifdef __cplusplus diff --git a/spec/ruby/optional/capi/ext/tracepoint_spec.c b/spec/ruby/optional/capi/ext/tracepoint_spec.c new file mode 100644 index 00000000000000..78c459d6cbe1f7 --- /dev/null +++ b/spec/ruby/optional/capi/ext/tracepoint_spec.c @@ -0,0 +1,49 @@ +#include "ruby.h" +#include "rubyspec.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +static VALUE callback_called = Qnil; + +static void callback(VALUE tpval, void *data) { + callback_called = (VALUE) data; +} + +static VALUE tracepoint_spec_rb_tracepoint_new(VALUE self, VALUE data) { + return rb_tracepoint_new(Qnil, RUBY_EVENT_LINE, callback, (void*) data); +} + +static VALUE tracepoint_spec_callback_called(VALUE self){ + return callback_called; +} + +static VALUE tracepoint_spec_rb_tracepoint_disable(VALUE self, VALUE trace) { + rb_tracepoint_disable(trace); + return rb_tracepoint_enabled_p(trace); +} + +static VALUE tracepoint_spec_rb_tracepoint_enable(VALUE self, VALUE trace) { + rb_tracepoint_enable(trace); + return rb_tracepoint_enabled_p(trace); +} + +static VALUE tracepoint_spec_rb_tracepoint_enabled_p(VALUE self, VALUE trace) { + return rb_tracepoint_enabled_p(trace); +} + +void Init_tracepoint_spec(void) { + VALUE cls = rb_define_class("CApiTracePointSpecs", rb_cObject); + rb_define_method(cls, "rb_tracepoint_new", tracepoint_spec_rb_tracepoint_new, 1); + rb_define_method(cls, "rb_tracepoint_disable", tracepoint_spec_rb_tracepoint_disable, 1); + rb_define_method(cls, "rb_tracepoint_enable", tracepoint_spec_rb_tracepoint_enable, 1); + rb_define_method(cls, "rb_tracepoint_enabled_p", tracepoint_spec_rb_tracepoint_enabled_p, 1); + rb_define_method(cls, "callback_called?", tracepoint_spec_callback_called, 0); +} + +#ifdef __cplusplus +} +#endif diff --git a/spec/ruby/optional/capi/rbasic_spec.rb b/spec/ruby/optional/capi/rbasic_spec.rb new file mode 100644 index 00000000000000..283e70db706adc --- /dev/null +++ b/spec/ruby/optional/capi/rbasic_spec.rb @@ -0,0 +1,22 @@ +require_relative 'spec_helper' +require_relative 'shared/rbasic' +load_extension("rbasic") +load_extension("data") +load_extension("array") + +describe "RBasic support for regular objects" do + before :all do + @specs = CApiRBasicSpecs.new + @data = -> { [Object.new, Object.new] } + end + it_should_behave_like :rbasic +end + +describe "RBasic support for RData" do + before :all do + @specs = CApiRBasicRDataSpecs.new + @wrapping = CApiWrappedStructSpecs.new + @data = -> { [@wrapping.wrap_struct(1024), @wrapping.wrap_struct(1025)] } + end + it_should_behave_like :rbasic +end diff --git a/spec/ruby/optional/capi/shared/rbasic.rb b/spec/ruby/optional/capi/shared/rbasic.rb new file mode 100644 index 00000000000000..efd5c85e61b036 --- /dev/null +++ b/spec/ruby/optional/capi/shared/rbasic.rb @@ -0,0 +1,81 @@ +describe :rbasic, shared: true do + + before :all do + specs = CApiRBasicSpecs.new + @taint = specs.taint_flag + @freeze = specs.freeze_flag + end + + it "reports the appropriate FREEZE flag for the object when reading" do + obj, _ = @data.call + initial = @specs.get_flags(obj) + obj.freeze + @specs.get_flags(obj).should == @freeze | initial + end + + it "supports setting the FREEZE flag" do + obj, _ = @data.call + initial = @specs.get_flags(obj) + @specs.set_flags(obj, @freeze | initial).should == @freeze | initial + obj.frozen?.should == true + end + + ruby_version_is ""..."2.7" do + it "reports the appropriate FREEZE and TAINT flags for the object when reading" do + obj, _ = @data.call + initial = @specs.get_flags(obj) + obj.taint + @specs.get_flags(obj).should == @taint | initial + obj.untaint + @specs.get_flags(obj).should == initial + obj.freeze + @specs.get_flags(obj).should == @freeze | initial + + obj, _ = @data.call + obj.taint + obj.freeze + @specs.get_flags(obj).should == @freeze | @taint | initial + end + + it "supports setting the FREEZE and TAINT flags" do + obj, _ = @data.call + initial = @specs.get_flags(obj) + @specs.set_flags(obj, @taint | initial).should == @taint | initial + obj.tainted?.should == true + @specs.set_flags(obj, initial).should == initial + obj.tainted?.should == false + @specs.set_flags(obj, @freeze | initial).should == @freeze | initial + obj.frozen?.should == true + + obj, _ = @data.call + @specs.set_flags(obj, @freeze | @taint | initial).should == @freeze | @taint | initial + obj.tainted?.should == true + obj.frozen?.should == true + end + end + + it "supports user flags" do + obj, _ = @data.call + @specs.get_flags(obj) == 0 + @specs.set_flags(obj, 1 << 14 | 1 << 16).should == 1 << 14 | 1 << 16 + @specs.get_flags(obj).should == 1 << 14 | 1 << 16 + @specs.set_flags(obj, 0).should == 0 + end + + it "supports copying the flags from one object over to the other" do + obj1, obj2 = @data.call + @specs.set_flags(obj1, @taint | 1 << 14 | 1 << 16) + @specs.copy_flags(obj2, obj1) + @specs.get_flags(obj2).should == @taint | 1 << 14 | 1 << 16 + @specs.set_flags(obj1, 0) + @specs.copy_flags(obj2, obj1) + @specs.get_flags(obj2).should == 0 + end + + it "supports retrieving the (meta)class" do + obj, _ = @data.call + @specs.get_klass(obj).should == obj.class + obj.singleton_class # ensure the singleton class exists + @specs.get_klass(obj).should == obj.singleton_class + end +end diff --git a/spec/ruby/optional/capi/symbol_spec.rb b/spec/ruby/optional/capi/symbol_spec.rb index 0d71c1c7114a2b..b8fda34c0ed09f 100644 --- a/spec/ruby/optional/capi/symbol_spec.rb +++ b/spec/ruby/optional/capi/symbol_spec.rb @@ -153,4 +153,20 @@ @s.rb_sym2str(:bacon).should == "bacon" end end + + describe "rb_to_symbol" do + it "returns a Symbol for a Symbol" do + @s.rb_to_symbol(:foo).should == :foo + end + + it "returns a Symbol for a String" do + @s.rb_to_symbol("foo").should == :foo + end + + it "coerces to Symbol using to_str" do + o = mock('o') + o.should_receive(:to_str).and_return("foo") + @s.rb_to_symbol(o).should == :foo + end + end end diff --git a/spec/ruby/optional/capi/tracepoint_spec.rb b/spec/ruby/optional/capi/tracepoint_spec.rb new file mode 100644 index 00000000000000..6aeac54921426c --- /dev/null +++ b/spec/ruby/optional/capi/tracepoint_spec.rb @@ -0,0 +1,56 @@ +require_relative 'spec_helper' + +load_extension("tracepoint") + +describe "CApiTracePointSpecs" do + before :each do + @s = CApiTracePointSpecs.new + end + + after :each do + @trace.disable if @trace and @trace.enabled? + end + + describe "rb_tracepoint_new" do + it "returns a tracepoint object" do + @trace = @s.rb_tracepoint_new(7) + @trace.should be_an_instance_of(TracePoint) + @trace.enabled?.should == false + end + + it "traces lines when given RUBY_EVENT_LINE" do + @trace = @s.rb_tracepoint_new(8) + @trace.enable + @s.callback_called?.should == 8 + end + end + + describe "rb_tracepoint_disable" do + it "disables an enabled TracePoint" do + @trace = @s.rb_tracepoint_new(9) + @trace.enabled?.should == false + @trace.enable + @trace.enabled?.should == true + @s.rb_tracepoint_disable(@trace).should == false + @trace.enabled?.should == false + end + end + + describe "rb_tracepoint_enable" do + it "enables a disabled TracePoint" do + @trace = @s.rb_tracepoint_new(10) + @trace.enabled?.should == false + @s.rb_tracepoint_enable(@trace).should == true + @trace.enabled?.should == true + end + end + + describe "rb_tracepoint_enabled_p" do + it "returns correct enabled status" do + @trace = @s.rb_tracepoint_new(11) + @s.rb_tracepoint_enabled_p(@trace).should == false + @trace.enable + @s.rb_tracepoint_enabled_p(@trace).should == true + end + end +end From a2be428c5fec31b8adbd5ac087e7637ddf7e54d0 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 2 May 2020 16:08:36 +0200 Subject: [PATCH 187/234] Fix ObjectSpace::WeakMap#key? to work if the value is nil * Fixes [Bug #16826] --- gc.c | 16 ++++++++++++---- .../core/objectspace/weakmap/shared/include.rb | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/gc.c b/gc.c index 205a986271c8f4..33f38bb7ad7815 100644 --- a/gc.c +++ b/gc.c @@ -10757,7 +10757,7 @@ wmap_aset(VALUE self, VALUE wmap, VALUE orig) /* Retrieves a weakly referenced object with the given key */ static VALUE -wmap_aref(VALUE self, VALUE wmap) +wmap_lookup(VALUE self, VALUE key) { st_data_t data; VALUE obj; @@ -10765,17 +10765,25 @@ wmap_aref(VALUE self, VALUE wmap) rb_objspace_t *objspace = &rb_objspace; TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w); - if (!st_lookup(w->wmap2obj, (st_data_t)wmap, &data)) return Qnil; + if (!st_lookup(w->wmap2obj, (st_data_t)key, &data)) return Qundef; obj = (VALUE)data; - if (!wmap_live_p(objspace, obj)) return Qnil; + if (!wmap_live_p(objspace, obj)) return Qundef; return obj; } +/* Retrieves a weakly referenced object with the given key */ +static VALUE +wmap_aref(VALUE self, VALUE key) +{ + VALUE obj = wmap_lookup(self, key); + return obj != Qundef ? obj : Qnil; +} + /* Returns +true+ if +key+ is registered */ static VALUE wmap_has_key(VALUE self, VALUE key) { - return NIL_P(wmap_aref(self, key)) ? Qfalse : Qtrue; + return wmap_lookup(self, key) == Qundef ? Qfalse : Qtrue; } /* Returns the number of referenced objects */ diff --git a/spec/ruby/core/objectspace/weakmap/shared/include.rb b/spec/ruby/core/objectspace/weakmap/shared/include.rb index 370359e6caa9b8..f9c174b6d14692 100644 --- a/spec/ruby/core/objectspace/weakmap/shared/include.rb +++ b/spec/ruby/core/objectspace/weakmap/shared/include.rb @@ -21,7 +21,7 @@ end ruby_version_is "2.7" do - ruby_bug "#16826", "2.7.0"..."2.8.1" do + ruby_bug "#16826", "2.7.0"..."2.7.2" do it "reports true if the pair exists and the value is nil" do map = ObjectSpace::WeakMap.new key = Object.new From de8b8b609a387a8732bf1f86fb1fc3f0ba22cbd8 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 2 May 2020 22:42:12 +0900 Subject: [PATCH 188/234] Command failed to run just fails The exact exit status value of command failed to run is not a spec, but a platform dependent implementation detail. Just it is not "success". --- spec/ruby/core/kernel/system_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/ruby/core/kernel/system_spec.rb b/spec/ruby/core/kernel/system_spec.rb index 96c0496dd6fde4..9196a9f9f1139b 100644 --- a/spec/ruby/core/kernel/system_spec.rb +++ b/spec/ruby/core/kernel/system_spec.rb @@ -40,7 +40,7 @@ $?.should be_an_instance_of Process::Status $?.pid.should be_kind_of(Integer) - $?.exitstatus.should == 127 + $?.should_not.success? end it "does not write to stderr when command execution fails" do From e964f67b897706763f390717d8adcdbba1c04f4f Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 2 May 2020 23:15:00 +0900 Subject: [PATCH 189/234] append newline at EOF [ci skip] --- spec/ruby/optional/capi/ext/rbasic_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/ruby/optional/capi/ext/rbasic_spec.c b/spec/ruby/optional/capi/ext/rbasic_spec.c index b5779ef062e3eb..6b141de587deb5 100644 --- a/spec/ruby/optional/capi/ext/rbasic_spec.c +++ b/spec/ruby/optional/capi/ext/rbasic_spec.c @@ -68,4 +68,4 @@ void Init_rbasic_spec(void) { #ifdef __cplusplus } -#endif \ No newline at end of file +#endif From c2dc52e18bda953a5119c3e34dd5d67a281505c6 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 2 May 2020 16:13:57 +0200 Subject: [PATCH 190/234] Rename arguments for ObjectSpace::WeakMap#[]= for clarity --- gc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gc.c b/gc.c index 33f38bb7ad7815..fb167bf7d5cc00 100644 --- a/gc.c +++ b/gc.c @@ -10738,21 +10738,21 @@ wmap_aset_update(st_data_t *key, st_data_t *val, st_data_t arg, int existing) /* Creates a weak reference from the given key to the given value */ static VALUE -wmap_aset(VALUE self, VALUE wmap, VALUE orig) +wmap_aset(VALUE self, VALUE key, VALUE value) { struct weakmap *w; TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w); - if (FL_ABLE(orig)) { - define_final0(orig, w->final); + if (FL_ABLE(value)) { + define_final0(value, w->final); } - if (FL_ABLE(wmap)) { - define_final0(wmap, w->final); + if (FL_ABLE(key)) { + define_final0(key, w->final); } - st_update(w->obj2wmap, (st_data_t)orig, wmap_aset_update, wmap); - st_insert(w->wmap2obj, (st_data_t)wmap, (st_data_t)orig); - return nonspecial_obj_id(orig); + st_update(w->obj2wmap, (st_data_t)value, wmap_aset_update, key); + st_insert(w->wmap2obj, (st_data_t)key, (st_data_t)value); + return nonspecial_obj_id(value); } /* Retrieves a weakly referenced object with the given key */ From 9998161b10c8197a29d304554f3c53d6a9b44354 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 3 May 2020 00:05:19 +0900 Subject: [PATCH 191/234] Fixed missing `should` --- spec/ruby/optional/capi/shared/rbasic.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/ruby/optional/capi/shared/rbasic.rb b/spec/ruby/optional/capi/shared/rbasic.rb index efd5c85e61b036..1db03c77d3b9b9 100644 --- a/spec/ruby/optional/capi/shared/rbasic.rb +++ b/spec/ruby/optional/capi/shared/rbasic.rb @@ -56,7 +56,7 @@ it "supports user flags" do obj, _ = @data.call - @specs.get_flags(obj) == 0 + @specs.get_flags(obj).should == 0 @specs.set_flags(obj, 1 << 14 | 1 << 16).should == 1 << 14 | 1 << 16 @specs.get_flags(obj).should == 1 << 14 | 1 << 16 @specs.set_flags(obj, 0).should == 0 From 717680f197110c746bbfff599f42aa30d40b4d19 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 3 May 2020 00:11:47 +0900 Subject: [PATCH 192/234] DO NOT CORRUPT TYPE FLAGS --- spec/ruby/optional/capi/shared/rbasic.rb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/spec/ruby/optional/capi/shared/rbasic.rb b/spec/ruby/optional/capi/shared/rbasic.rb index 1db03c77d3b9b9..c58fa0c78713ef 100644 --- a/spec/ruby/optional/capi/shared/rbasic.rb +++ b/spec/ruby/optional/capi/shared/rbasic.rb @@ -56,20 +56,23 @@ it "supports user flags" do obj, _ = @data.call - @specs.get_flags(obj).should == 0 - @specs.set_flags(obj, 1 << 14 | 1 << 16).should == 1 << 14 | 1 << 16 - @specs.get_flags(obj).should == 1 << 14 | 1 << 16 - @specs.set_flags(obj, 0).should == 0 + initial = @specs.get_flags(obj) + initial.should_not == 0 + @specs.set_flags(obj, 1 << 14 | 1 << 16 | initial).should == 1 << 14 | 1 << 16 | initial + @specs.get_flags(obj).should == 1 << 14 | 1 << 16 | initial + @specs.set_flags(obj, initial).should == initial end it "supports copying the flags from one object over to the other" do obj1, obj2 = @data.call - @specs.set_flags(obj1, @taint | 1 << 14 | 1 << 16) + initial = @specs.get_flags(obj1) + @specs.get_flags(obj2).should == initial + @specs.set_flags(obj1, @taint | 1 << 14 | 1 << 16 | initial) @specs.copy_flags(obj2, obj1) - @specs.get_flags(obj2).should == @taint | 1 << 14 | 1 << 16 - @specs.set_flags(obj1, 0) + @specs.get_flags(obj2).should == @taint | 1 << 14 | 1 << 16 | initial + @specs.set_flags(obj1, initial) @specs.copy_flags(obj2, obj1) - @specs.get_flags(obj2).should == 0 + @specs.get_flags(obj2).should == initial end it "supports retrieving the (meta)class" do From cfe0e660f4ae7c8366cd8891c00e2eb303857f63 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 3 May 2020 00:15:56 +0900 Subject: [PATCH 193/234] Disable -Wswitch warning when VM_CHECK_MODE --- vm_insnhelper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 70c957cd9a9f13..0fb208446960e8 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -96,6 +96,8 @@ callable_class_p(VALUE klass) #if VM_CHECK_MODE >= 2 if (!klass) return FALSE; switch (RB_BUILTIN_TYPE(klass)) { + default: + break; case T_ICLASS: if (!RB_TYPE_P(RCLASS_SUPER(klass), T_MODULE)) break; case T_MODULE: From fe2a832acec4aba674fb99538920a8811fe2487c Mon Sep 17 00:00:00 2001 From: git Date: Sun, 3 May 2020 00:16:23 +0900 Subject: [PATCH 194/234] * 2020-05-03 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 39b64b2fb666a0..dfb18f7b7eff6c 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 2 +#define RUBY_RELEASE_DAY 3 #include "ruby/version.h" From 224f29c8e92094af10bc666c474b81a3545d6adf Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 3 May 2020 00:09:58 +0900 Subject: [PATCH 195/234] spec/ruby/core/process/clock_getres_spec.rb: lax the resolution limit Android is Linux, but the clock resolution is 10 milliseconds. I think that 1 microsecond is too strict for embedded environment. This change laxes the limit to 10 milliseconds. --- spec/ruby/core/process/clock_getres_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/ruby/core/process/clock_getres_spec.rb b/spec/ruby/core/process/clock_getres_spec.rb index b3fc9a4e31e197..85aa2b25f16b68 100644 --- a/spec/ruby/core/process/clock_getres_spec.rb +++ b/spec/ruby/core/process/clock_getres_spec.rb @@ -20,14 +20,14 @@ # These are observed platform_is :linux, :darwin, :windows do - it "with Process::CLOCK_REALTIME reports at least 1 microsecond" do - Process.clock_getres(Process::CLOCK_REALTIME, :nanosecond).should <= 1_000 + it "with Process::CLOCK_REALTIME reports at least 10 millisecond" do + Process.clock_getres(Process::CLOCK_REALTIME, :nanosecond).should <= 10_000_000 end end platform_is :linux, :darwin, :windows do - it "with Process::CLOCK_MONOTONIC reports at least 1 microsecond" do - Process.clock_getres(Process::CLOCK_MONOTONIC, :nanosecond).should <= 1_000 + it "with Process::CLOCK_MONOTONIC reports at least 10 millisecond" do + Process.clock_getres(Process::CLOCK_MONOTONIC, :nanosecond).should <= 10_000_000 end end end From cc6afff006760768feed4d2646a9af1dede4fca6 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 2 May 2020 21:30:24 -0700 Subject: [PATCH 196/234] Avoid infinite times of JIT compaction It's to avoid memory leak for actual usage (because they don't get unloaded properly), but also for fixing CI timed out due to JIT compaction taking too long time on --jit-wait (which runs every time) http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2911601 --- mjit_worker.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mjit_worker.c b/mjit_worker.c index 037aa297e28768..f479844fa3bc48 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -1303,6 +1303,11 @@ mjit_copy_cache_from_main_thread(const rb_iseq_t *iseq, union iseq_inline_storag void mjit_worker(void) { + // Allow only `max_cache_size / 10` times (default: 10) of compaction. + // Note: GC of compacted code has not been implemented yet. + int max_compact_size = mjit_opts.max_cache_size / 10; + if (max_compact_size < 10) max_compact_size = 10; + #ifndef _MSC_VER if (pch_status == PCH_NOT_READY) { make_pch(); @@ -1354,9 +1359,10 @@ mjit_worker(void) CRITICAL_SECTION_FINISH(3, "in jit func replace"); #ifndef _MSC_VER - // Combine .o files to one .so and reload all jit_func to improve memory locality - if ((!mjit_opts.wait && unit_queue.length == 0 && active_units.length > 1) - || active_units.length == mjit_opts.max_cache_size) { + // Combine .o files to one .so and reload all jit_func to improve memory locality. + if (compact_units.length < max_compact_size + && ((!mjit_opts.wait && unit_queue.length == 0 && active_units.length > 1) + || active_units.length == mjit_opts.max_cache_size)) { compact_all_jit_code(); } #endif From 8af098b40ee3788f3d13f02298eeecfb52fa0c16 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 3 May 2020 14:34:46 +0900 Subject: [PATCH 197/234] Show unreserved bits only `RUBY_FL_SEEN_OBJ_ID` can be set by #object_id. --- spec/ruby/optional/capi/ext/rbasic_spec.c | 28 +++++++++++++++-------- spec/ruby/optional/capi/shared/rbasic.rb | 1 - 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/spec/ruby/optional/capi/ext/rbasic_spec.c b/spec/ruby/optional/capi/ext/rbasic_spec.c index 6b141de587deb5..c08c821a385901 100644 --- a/spec/ruby/optional/capi/ext/rbasic_spec.c +++ b/spec/ruby/optional/capi/ext/rbasic_spec.c @@ -5,6 +5,7 @@ extern "C" { #endif +static const VALUE VISIBLE_BITS = FL_TAINT | FL_FREEZE | ~(FL_USER0 - 1); VALUE rbasic_spec_taint_flag(VALUE self) { return INT2FIX(RUBY_FL_TAINT); @@ -14,18 +15,27 @@ VALUE rbasic_spec_freeze_flag(VALUE self) { return INT2FIX(RUBY_FL_FREEZE); } +static VALUE spec_get_flags(const struct RBasic *b) { + VALUE flags = b->flags & VISIBLE_BITS; + return INT2FIX(flags); +} + +static VALUE spec_set_flags(struct RBasic *b, VALUE flags) { + flags &= VISIBLE_BITS; + b->flags = (b->flags & ~VISIBLE_BITS) | flags; + return INT2FIX(flags); +} + VALUE rbasic_spec_get_flags(VALUE self, VALUE val) { - return INT2FIX(RBASIC(val)->flags); + return spec_get_flags(RBASIC(val)); } VALUE rbasic_spec_set_flags(VALUE self, VALUE val, VALUE flags) { - RBASIC(val)->flags = FIX2INT(flags); - return INT2FIX(RBASIC(val)->flags); + return spec_set_flags(RBASIC(val), FIX2INT(flags)); } VALUE rbasic_spec_copy_flags(VALUE self, VALUE to, VALUE from) { - RBASIC(to)->flags = RBASIC(from)->flags; - return INT2FIX(RBASIC(to)->flags); + return spec_set_flags(RBASIC(to), RBASIC(from)->flags); } VALUE rbasic_spec_get_klass(VALUE self, VALUE val) { @@ -33,17 +43,15 @@ VALUE rbasic_spec_get_klass(VALUE self, VALUE val) { } VALUE rbasic_rdata_spec_get_flags(VALUE self, VALUE structure) { - return INT2FIX(RDATA(structure)->basic.flags); + return spec_get_flags(&RDATA(structure)->basic); } VALUE rbasic_rdata_spec_set_flags(VALUE self, VALUE structure, VALUE flags) { - RDATA(structure)->basic.flags = FIX2INT(flags); - return INT2FIX(RDATA(structure)->basic.flags); + return spec_set_flags(&RDATA(structure)->basic, FIX2INT(flags)); } VALUE rbasic_rdata_spec_copy_flags(VALUE self, VALUE to, VALUE from) { - RDATA(to)->basic.flags = RDATA(from)->basic.flags; - return INT2FIX(RDATA(to)->basic.flags); + return spec_set_flags(&RDATA(to)->basic, RDATA(from)->basic.flags); } VALUE rbasic_rdata_spec_get_klass(VALUE self, VALUE structure) { diff --git a/spec/ruby/optional/capi/shared/rbasic.rb b/spec/ruby/optional/capi/shared/rbasic.rb index c58fa0c78713ef..40761122ef8999 100644 --- a/spec/ruby/optional/capi/shared/rbasic.rb +++ b/spec/ruby/optional/capi/shared/rbasic.rb @@ -57,7 +57,6 @@ it "supports user flags" do obj, _ = @data.call initial = @specs.get_flags(obj) - initial.should_not == 0 @specs.set_flags(obj, 1 << 14 | 1 << 16 | initial).should == 1 << 14 | 1 << 16 | initial @specs.get_flags(obj).should == 1 << 14 | 1 << 16 | initial @specs.set_flags(obj, initial).should == initial From e49ecaed57181c10bf01e1f84b9eead65a759386 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 3 May 2020 14:38:19 +0900 Subject: [PATCH 198/234] Optimize sin/cos GCC/Clang can optimize to calculate `sin(x)` and `cos(x)` at once, when the both are closely called on the same argument. Similar optimization is possible for `__sinpi(x)` and `__cospi(x)` if available, which calculate arguments in radian, i.e. `sin(x*M_PI)` and `cos(x*M_PI)` respectively. --- complex.c | 19 +++++++++++++++---- configure.ac | 2 ++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/complex.c b/complex.c index 2a37c4212649b8..95b1abbd45e7ca 100644 --- a/complex.c +++ b/complex.c @@ -661,8 +661,9 @@ f_complex_polar(VALUE klass, VALUE x, VALUE y) y = DBL2NUM(imag); } else { - y = f_mul(x, DBL2NUM(sin(arg))); - x = f_mul(x, DBL2NUM(cos(arg))); + const double ax = sin(arg), ay = cos(arg); + y = f_mul(x, DBL2NUM(ax)); + x = f_mul(x, DBL2NUM(ay)); if (canonicalization && f_zero_p(y)) return x; } return nucomp_s_new_internal(klass, x, y); @@ -672,6 +673,16 @@ f_complex_polar(VALUE klass, VALUE x, VALUE y) f_mul(x, m_sin(y))); } +#ifdef HAVE___COSPI +# define cospi(x) __cospi(x) +#else +# define cospi(x) cos((x) * M_PI) +#endif +#ifdef HAVE___SINPI +# define sinpi(x) __sinpi(x) +#else +# define sinpi(x) sin((x) * M_PI) +#endif /* returns a Complex or Float of ang*PI-rotated abs */ VALUE rb_dbl_complex_new_polar_pi(double abs, double ang) @@ -689,8 +700,8 @@ rb_dbl_complex_new_polar_pi(double abs, double ang) return DBL2NUM(abs); } else { - ang *= M_PI; - return rb_complex_new(DBL2NUM(abs * cos(ang)), DBL2NUM(abs * sin(ang))); + const double real = abs * cospi(ang), imag = abs * sinpi(ang); + return rb_complex_new(DBL2NUM(real), DBL2NUM(imag)); } } diff --git a/configure.ac b/configure.ac index e16c3e44ed8205..f78eb38c935d89 100644 --- a/configure.ac +++ b/configure.ac @@ -1991,6 +1991,8 @@ AC_CHECK_FUNCS(utimensat) AC_CHECK_FUNCS(utimes) AC_CHECK_FUNCS(wait4) AC_CHECK_FUNCS(waitpid) +AC_CHECK_FUNCS(__cospi) +AC_CHECK_FUNCS(__sinpi) AS_IF([test "x$ac_cv_member_struct_statx_stx_btime" = xyes], [AC_CHECK_FUNCS(statx)]) From e0c023d1c8a22533b6cd3a5fa4bbcd4145f635b5 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 3 May 2020 00:33:56 -0700 Subject: [PATCH 199/234] Skip only .dSYM cleanup on macOS Fix https://github.com/ruby/ruby/runs/636020145 without skipping too many tests. It seems that .c -> .o with debug flags and .o -> .so without debug flags did not generate .dSYM but now .c -> .so with debug flags seems to generate a .dSYM directory. As --jit-debug should not be used by normal users, let me skip implementing the removal for now. --- test/ruby/test_jit.rb | 14 ++++++++++---- test/ruby/test_jit_debug.rb | 1 - 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb index a5d5fb45a96827..af96a7831efc84 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -720,7 +720,7 @@ def mjit#{i} skip 'Removing so file is randomly failing on AppVeyor/RubyCI mswin due to Permission Denied.' else # verify .c files are deleted on unload_units - assert_send([Dir, :empty?, dir], debug_info) + assert_send([Dir, :empty?, dir], debug_info) unless leave_dsym? end end end @@ -939,7 +939,7 @@ def test_clean_so Dir.mktmpdir("jit_test_clean_so_") do |dir| code = "x = 0; 10.times {|i|x+=i}" eval_with_jit({"TMPDIR"=>dir}, code) - assert_send([Dir, :empty?, dir]) + assert_send([Dir, :empty?, dir]) unless leave_dsym? eval_with_jit({"TMPDIR"=>dir}, code, save_temps: true) assert_not_send([Dir, :empty?, dir]) end @@ -957,7 +957,7 @@ def a; end; a exec "true" end; error_message = "Undeleted files:\n #{Dir.glob("#{dir}/*").join("\n ")}\n" - assert_send([Dir, :empty?, dir], error_message) + assert_send([Dir, :empty?, dir], error_message) unless leave_dsym? end end @@ -1083,7 +1083,7 @@ def after_fork; end assert_equal("Successful MJIT finish\n" * 2, err.gsub(/^#{JIT_SUCCESS_PREFIX}:[^\n]+\n/, ''), debug_info) # ensure objects are deleted - assert_send([Dir, :empty?, dir], debug_info) + assert_send([Dir, :empty?, dir], debug_info) unless leave_dsym? end end if defined?(fork) @@ -1178,4 +1178,10 @@ def collect_insns(iseq_array) end insns end + + # `clang -g` on macOS creates a .dSYM file. Because it's only created on --jit-debug, + # we're ignoring it for now. TODO: remove .dSYM file + def leave_dsym? + /darwin/ =~ RUBY_PLATFORM && @jit_debug + end end diff --git a/test/ruby/test_jit_debug.rb b/test/ruby/test_jit_debug.rb index 0d357ee7e0832a..179512fec68cd7 100644 --- a/test/ruby/test_jit_debug.rb +++ b/test/ruby/test_jit_debug.rb @@ -5,7 +5,6 @@ return if ENV.key?('RUBYCI_NICKNAME') return if ENV['RUBY_DEBUG']&.include?('ci') # ci.rvm.jp return if /mswin/ =~ RUBY_PLATFORM -return if /darwin/ =~ RUBY_PLATFORM # TODO: remove this after investigation class TestJITDebug < TestJIT def setup From a218cbdf31c30835f5785cdaf3af3f97965b77c4 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 3 May 2020 00:41:27 -0700 Subject: [PATCH 200/234] Skip pdb corruption on Visual Studio 2015 as well It turned out that the pdb corruption happens on Visual Studio 2015 as well. https://ci.appveyor.com/project/ruby/ruby/builds/32602953/job/3gj43q18wqeiy729 --- test/lib/jit_support.rb | 10 +++++----- test/ruby/test_jit.rb | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/lib/jit_support.rb b/test/lib/jit_support.rb index b443a6f3a8702f..26d3d97b8ab1c4 100644 --- a/test/lib/jit_support.rb +++ b/test/lib/jit_support.rb @@ -54,21 +54,21 @@ def eval_with_jit_without_retry(env = nil, script, verbose: 0, min_calls: 5, sav def supported? return @supported if defined?(@supported) - @supported = UNSUPPORTED_COMPILERS.all? do |regexp| + @supported = RbConfig::CONFIG["MJIT_SUPPORT"] != 'no' && UNSUPPORTED_COMPILERS.all? do |regexp| !regexp.match?(RbConfig::CONFIG['MJIT_CC']) - end && RbConfig::CONFIG["MJIT_SUPPORT"] != 'no' && !PENDING_RUBYCI_NICKNAMES.include?(ENV['RUBYCI_NICKNAME']) && !vs120_pdb_corrupted? && /mingw/ !~ RUBY_PLATFORM && /solaris/ !~ RUBY_PLATFORM # TODO: remove mingw / solaris exclusion after investigation + end && !appveyor_pdb_corrupted? && !PENDING_RUBYCI_NICKNAMES.include?(ENV['RUBYCI_NICKNAME']) && /mingw/ !~ RUBY_PLATFORM && /solaris/ !~ RUBY_PLATFORM # TODO: remove mingw / solaris exclusion after investigation end - # AppVeyor's Visual Studio 2013 is known to spuriously generate broken pch / pdb, like: + # AppVeyor's Visual Studio 2013 / 2015 are known to spuriously generate broken pch / pdb, like: # error C2859: c:\projects\ruby\x64-mswin_120\include\ruby-2.8.0\x64-mswin64_120\rb_mjit_header-2.8.0.pdb # is not the pdb file that was used when this precompiled header was created, recreate the precompiled header. # https://ci.appveyor.com/project/ruby/ruby/builds/32159878/job/l2p38snw8yxxpp8h # # Until we figure out why, this allows us to skip testing JIT when it happens. - def vs120_pdb_corrupted? + def appveyor_pdb_corrupted? return false unless ENV.key?('APPVEYOR') stdout, _stderr, _status = eval_with_jit_without_retry('proc {}.call', verbose: 2, min_calls: 1) - stdout.include?('x64-mswin64_120') && stdout.include?('.pdb is not the pdb file that was used when this precompiled header was created, recreate the precompiled header.') + stdout.include?('.pdb is not the pdb file that was used when this precompiled header was created, recreate the precompiled header.') end def remove_mjit_logs(stderr) diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb index af96a7831efc84..63579f27aadc83 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -1179,7 +1179,7 @@ def collect_insns(iseq_array) insns end - # `clang -g` on macOS creates a .dSYM file. Because it's only created on --jit-debug, + # `clang -g` on macOS creates a .dSYM directory. As it's only created on --jit-debug, # we're ignoring it for now. TODO: remove .dSYM file def leave_dsym? /darwin/ =~ RUBY_PLATFORM && @jit_debug From 4aca078bdae7e1a66f25023cd9baa9a01c289a53 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 3 May 2020 00:45:18 -0700 Subject: [PATCH 201/234] Support cc_added_args again This support was accidentally removed in 818d6d33368a396d9cd3d1a34a84015a9e76c5c8. --- mjit_worker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mjit_worker.c b/mjit_worker.c index f479844fa3bc48..59428804eb69dd 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -865,7 +865,7 @@ compile_c_to_so(const char *c_file, const char *so_file) NULL }; - char **args = form_args(6, CC_LDSHARED_ARGS, CC_CODEFLAG_ARGS, + char **args = form_args(7, CC_LDSHARED_ARGS, CC_CODEFLAG_ARGS, cc_added_args, options, CC_LIBS, CC_DLDFLAGS_ARGS, CC_LINKER_ARGS); if (args == NULL) return false; From f646d20aaeb8f02bcd3d0c5c3f5a372da654502a Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sun, 3 May 2020 12:28:27 +0200 Subject: [PATCH 202/234] Update to ruby/mspec@d419d0b --- spec/mspec/lib/mspec/helpers/tmp.rb | 9 ++++++++- spec/mspec/spec/fixtures/my_ruby | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/spec/mspec/lib/mspec/helpers/tmp.rb b/spec/mspec/lib/mspec/helpers/tmp.rb index 5062991d6354b1..b2a38ee983ea94 100644 --- a/spec/mspec/lib/mspec/helpers/tmp.rb +++ b/spec/mspec/lib/mspec/helpers/tmp.rb @@ -4,7 +4,14 @@ # directory is empty when the process exits. SPEC_TEMP_DIR_PID = Process.pid -SPEC_TEMP_DIR = File.expand_path(ENV["SPEC_TEMP_DIR"] || "rubyspec_temp/#{SPEC_TEMP_DIR_PID}") + +if spec_temp_dir = ENV["SPEC_TEMP_DIR"] + spec_temp_dir = File.realdirpath(spec_temp_dir) +else + spec_temp_dir = "#{File.realpath(Dir.pwd)}/rubyspec_temp/#{SPEC_TEMP_DIR_PID}" +end +SPEC_TEMP_DIR = spec_temp_dir + SPEC_TEMP_UNIQUIFIER = "0" at_exit do diff --git a/spec/mspec/spec/fixtures/my_ruby b/spec/mspec/spec/fixtures/my_ruby index 4d552f27fb45ca..eeda3eeeece08e 100755 --- a/spec/mspec/spec/fixtures/my_ruby +++ b/spec/mspec/spec/fixtures/my_ruby @@ -1,4 +1,4 @@ #!/usr/bin/env bash echo $RUBY_EXE -ruby "$@" +exec ruby "$@" From 5aaa75e7c1f4b7912c10ffdcb1cac581e20eda39 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sun, 3 May 2020 12:28:29 +0200 Subject: [PATCH 203/234] Update to ruby/spec@032ee74 --- spec/ruby/command_line/error_message_spec.rb | 4 +- spec/ruby/core/argf/binmode_spec.rb | 2 +- spec/ruby/core/array/any_spec.rb | 6 +-- spec/ruby/core/array/clear_spec.rb | 2 +- spec/ruby/core/array/clone_spec.rb | 4 +- spec/ruby/core/array/empty_spec.rb | 6 +-- spec/ruby/core/array/frozen_spec.rb | 6 +-- spec/ruby/core/array/multiply_spec.rb | 16 +++--- spec/ruby/core/array/shared/clone.rb | 8 +-- spec/ruby/core/array/sort_spec.rb | 10 ++-- spec/ruby/core/array/uniq_spec.rb | 8 +-- spec/ruby/core/class/allocate_spec.rb | 2 +- spec/ruby/core/class/new_spec.rb | 2 +- spec/ruby/core/complex/finite_spec.rb | 12 ++--- spec/ruby/core/dir/glob_spec.rb | 2 +- spec/ruby/core/dir/home_spec.rb | 4 +- spec/ruby/core/dir/shared/open.rb | 2 +- spec/ruby/core/enumerable/all_spec.rb | 30 +++++------ spec/ruby/core/enumerable/any_spec.rb | 36 ++++++------- spec/ruby/core/enumerable/none_spec.rb | 2 +- spec/ruby/core/enumerable/one_spec.rb | 2 +- spec/ruby/core/enumerable/uniq_spec.rb | 8 +-- .../arithmetic_sequence/exclude_end_spec.rb | 8 +-- spec/ruby/core/env/element_reference_spec.rb | 2 +- spec/ruby/core/env/empty_spec.rb | 6 +-- spec/ruby/core/env/shift_spec.rb | 2 +- spec/ruby/core/exception/success_spec.rb | 4 +- spec/ruby/core/false/to_s_spec.rb | 2 +- spec/ruby/core/file/expand_path_spec.rb | 6 +-- spec/ruby/core/file/lchmod_spec.rb | 12 ++--- spec/ruby/core/file/lstat_spec.rb | 4 +- spec/ruby/core/file/open_spec.rb | 8 +-- spec/ruby/core/file/stat/owned_spec.rb | 4 +- spec/ruby/core/file/stat/pipe_spec.rb | 4 +- spec/ruby/core/file/stat_spec.rb | 8 +-- spec/ruby/core/file/truncate_spec.rb | 6 +-- spec/ruby/core/float/finite_spec.rb | 8 +-- spec/ruby/core/float/nan_spec.rb | 6 +-- spec/ruby/core/float/next_float_spec.rb | 2 +- spec/ruby/core/float/prev_float_spec.rb | 2 +- spec/ruby/core/float/uminus_spec.rb | 2 +- spec/ruby/core/float/zero_spec.rb | 6 +-- spec/ruby/core/gc/profiler/disable_spec.rb | 2 +- spec/ruby/core/gc/profiler/enable_spec.rb | 2 +- spec/ruby/core/hash/any_spec.rb | 4 +- .../core/hash/compare_by_identity_spec.rb | 2 +- spec/ruby/core/hash/empty_spec.rb | 10 ++-- spec/ruby/core/hash/reject_spec.rb | 2 +- spec/ruby/core/hash/shared/store.rb | 2 +- spec/ruby/core/hash/to_proc_spec.rb | 4 +- spec/ruby/core/integer/integer_spec.rb | 6 +-- spec/ruby/core/io/close_on_exec_spec.rb | 12 ++--- spec/ruby/core/io/close_read_spec.rb | 2 +- spec/ruby/core/io/close_spec.rb | 2 +- spec/ruby/core/io/close_write_spec.rb | 2 +- spec/ruby/core/io/dup_spec.rb | 12 ++--- spec/ruby/core/io/eof_spec.rb | 26 +++++----- spec/ruby/core/io/gets_spec.rb | 8 +-- spec/ruby/core/io/pipe_spec.rb | 12 ++--- spec/ruby/core/io/popen_spec.rb | 4 +- spec/ruby/core/io/read_nonblock_spec.rb | 2 +- spec/ruby/core/io/read_spec.rb | 2 +- spec/ruby/core/io/reopen_spec.rb | 8 +-- spec/ruby/core/io/rewind_spec.rb | 2 +- spec/ruby/core/io/seek_spec.rb | 6 +-- spec/ruby/core/io/shared/new.rb | 12 ++--- spec/ruby/core/io/shared/pos.rb | 2 +- spec/ruby/core/io/ungetc_spec.rb | 4 +- spec/ruby/core/io/write_nonblock_spec.rb | 2 +- spec/ruby/core/kernel/backtick_spec.rb | 24 ++++----- .../ruby/core/kernel/caller_locations_spec.rb | 2 +- spec/ruby/core/kernel/caller_spec.rb | 2 +- spec/ruby/core/kernel/clone_spec.rb | 12 ++--- spec/ruby/core/kernel/dup_spec.rb | 2 +- spec/ruby/core/kernel/frozen_spec.rb | 4 +- spec/ruby/core/kernel/shared/dup_clone.rb | 8 +-- spec/ruby/core/kernel/system_spec.rb | 6 +-- spec/ruby/core/kernel/taint_spec.rb | 8 +-- spec/ruby/core/kernel/tainted_spec.rb | 4 +- spec/ruby/core/kernel/trust_spec.rb | 2 +- spec/ruby/core/kernel/untaint_spec.rb | 2 +- spec/ruby/core/kernel/untrust_spec.rb | 2 +- spec/ruby/core/kernel/untrusted_spec.rb | 10 ++-- spec/ruby/core/matchdata/string_spec.rb | 4 +- spec/ruby/core/math/tan_spec.rb | 4 +- spec/ruby/core/method/compose_spec.rb | 6 +-- spec/ruby/core/module/included_spec.rb | 2 +- spec/ruby/core/module/name_spec.rb | 2 +- spec/ruby/core/module/singleton_class_spec.rb | 10 ++-- spec/ruby/core/nil/nil_spec.rb | 2 +- spec/ruby/core/nil/to_s_spec.rb | 2 +- spec/ruby/core/numeric/integer_spec.rb | 2 +- spec/ruby/core/numeric/negative_spec.rb | 4 +- spec/ruby/core/numeric/positive_spec.rb | 4 +- spec/ruby/core/numeric/real_spec.rb | 2 +- spec/ruby/core/numeric/zero_spec.rb | 4 +- spec/ruby/core/proc/compose_spec.rb | 16 +++--- spec/ruby/core/range/dup_spec.rb | 4 +- spec/ruby/core/range/exclude_end_spec.rb | 20 +++---- spec/ruby/core/regexp/casefold_spec.rb | 4 +- spec/ruby/core/signal/trap_spec.rb | 2 +- spec/ruby/core/string/capitalize_spec.rb | 4 +- spec/ruby/core/string/center_spec.rb | 10 ++-- spec/ruby/core/string/chop_spec.rb | 8 +-- spec/ruby/core/string/crypt_spec.rb | 16 +++--- spec/ruby/core/string/delete_prefix_spec.rb | 4 +- spec/ruby/core/string/delete_spec.rb | 6 +-- spec/ruby/core/string/delete_suffix_spec.rb | 4 +- spec/ruby/core/string/downcase_spec.rb | 6 +-- spec/ruby/core/string/dump_spec.rb | 10 ++-- spec/ruby/core/string/element_set_spec.rb | 8 +-- spec/ruby/core/string/empty_spec.rb | 10 ++-- spec/ruby/core/string/gsub_spec.rb | 52 +++++++++---------- spec/ruby/core/string/insert_spec.rb | 4 +- spec/ruby/core/string/inspect_spec.rb | 8 +-- spec/ruby/core/string/ljust_spec.rb | 10 ++-- spec/ruby/core/string/lstrip_spec.rb | 6 +-- spec/ruby/core/string/modulo_spec.rb | 14 ++--- spec/ruby/core/string/reverse_spec.rb | 4 +- spec/ruby/core/string/rjust_spec.rb | 10 ++-- spec/ruby/core/string/rstrip_spec.rb | 6 +-- spec/ruby/core/string/shared/chars.rb | 4 +- spec/ruby/core/string/shared/concat.rb | 8 +-- spec/ruby/core/string/shared/each_line.rb | 4 +- spec/ruby/core/string/shared/replace.rb | 8 +-- spec/ruby/core/string/shared/slice.rb | 26 +++++----- spec/ruby/core/string/shared/succ.rb | 2 +- spec/ruby/core/string/shared/to_s.rb | 4 +- spec/ruby/core/string/shared/to_sym.rb | 2 +- spec/ruby/core/string/slice_spec.rb | 16 +++--- spec/ruby/core/string/split_spec.rb | 4 +- spec/ruby/core/string/squeeze_spec.rb | 8 +-- spec/ruby/core/string/strip_spec.rb | 6 +-- spec/ruby/core/string/sub_spec.rb | 32 ++++++------ spec/ruby/core/string/swapcase_spec.rb | 4 +- spec/ruby/core/string/tr_s_spec.rb | 6 +-- spec/ruby/core/string/tr_spec.rb | 6 +-- spec/ruby/core/string/uminus_spec.rb | 4 +- spec/ruby/core/string/undump_spec.rb | 6 +-- .../core/string/unicode_normalized_spec.rb | 8 +-- spec/ruby/core/string/upcase_spec.rb | 6 +-- spec/ruby/core/string/uplus_spec.rb | 2 +- spec/ruby/core/symbol/to_proc_spec.rb | 4 +- spec/ruby/core/systemexit/success_spec.rb | 4 +- spec/ruby/core/thread/alive_spec.rb | 20 +++---- spec/ruby/core/thread/new_spec.rb | 12 ++--- spec/ruby/core/thread/stop_spec.rb | 20 +++---- spec/ruby/core/time/_dump_spec.rb | 4 +- spec/ruby/core/time/at_spec.rb | 6 +-- spec/ruby/core/time/dup_spec.rb | 4 +- spec/ruby/core/time/friday_spec.rb | 4 +- spec/ruby/core/time/gmt_spec.rb | 4 +- spec/ruby/core/time/minus_spec.rb | 4 +- spec/ruby/core/time/monday_spec.rb | 4 +- spec/ruby/core/time/new_spec.rb | 2 +- spec/ruby/core/time/plus_spec.rb | 4 +- spec/ruby/core/time/saturday_spec.rb | 4 +- spec/ruby/core/time/sunday_spec.rb | 4 +- spec/ruby/core/time/thursday_spec.rb | 4 +- spec/ruby/core/time/tuesday_spec.rb | 4 +- spec/ruby/core/time/utc_spec.rb | 2 +- spec/ruby/core/time/wednesday_spec.rb | 4 +- spec/ruby/core/tracepoint/disable_spec.rb | 6 +-- spec/ruby/core/tracepoint/enable_spec.rb | 4 +- spec/ruby/core/tracepoint/enabled_spec.rb | 4 +- spec/ruby/core/tracepoint/trace_spec.rb | 2 +- spec/ruby/core/true/to_s_spec.rb | 2 +- spec/ruby/language/hash_spec.rb | 2 +- spec/ruby/language/predefined_spec.rb | 4 +- spec/ruby/language/regexp/encoding_spec.rb | 4 +- spec/ruby/language/regexp_spec.rb | 2 +- spec/ruby/language/variables_spec.rb | 2 +- .../library/bigdecimal/BigDecimal_spec.rb | 20 +++---- spec/ruby/library/bigdecimal/abs_spec.rb | 2 +- spec/ruby/library/bigdecimal/add_spec.rb | 8 +-- spec/ruby/library/bigdecimal/div_spec.rb | 16 +++--- spec/ruby/library/bigdecimal/divmod_spec.rb | 6 +-- spec/ruby/library/bigdecimal/finite_spec.rb | 8 +-- spec/ruby/library/bigdecimal/fix_spec.rb | 2 +- spec/ruby/library/bigdecimal/frac_spec.rb | 2 +- spec/ruby/library/bigdecimal/minus_spec.rb | 18 +++---- spec/ruby/library/bigdecimal/mode_spec.rb | 2 +- spec/ruby/library/bigdecimal/nan_spec.rb | 22 ++++---- spec/ruby/library/bigdecimal/plus_spec.rb | 6 +-- spec/ruby/library/bigdecimal/quo_spec.rb | 4 +- .../ruby/library/bigdecimal/remainder_spec.rb | 38 +++++++------- spec/ruby/library/bigdecimal/shared/modulo.rb | 28 +++++----- spec/ruby/library/bigdecimal/shared/mult.rb | 20 +++---- spec/ruby/library/bigdecimal/shared/power.rb | 4 +- spec/ruby/library/bigdecimal/shared/quo.rb | 10 ++-- spec/ruby/library/bigdecimal/sub_spec.rb | 8 +-- spec/ruby/library/bigdecimal/to_f_spec.rb | 2 +- spec/ruby/library/bigdecimal/truncate_spec.rb | 6 +-- spec/ruby/library/bigdecimal/uminus_spec.rb | 2 +- spec/ruby/library/bigdecimal/zero_spec.rb | 26 +++++----- .../library/conditionvariable/signal_spec.rb | 2 +- spec/ruby/library/csv/liberal_parsing_spec.rb | 6 +-- spec/ruby/library/date/gregorian_spec.rb | 2 +- spec/ruby/library/date/infinity_spec.rb | 14 ++--- spec/ruby/library/date/julian_spec.rb | 4 +- spec/ruby/library/date/shared/civil.rb | 8 +-- .../library/getoptlong/terminated_spec.rb | 6 +-- .../library/ipaddr/ipv4_conversion_spec.rb | 8 +-- spec/ruby/library/ipaddr/new_spec.rb | 8 +-- spec/ruby/library/logger/logger/debug_spec.rb | 4 +- spec/ruby/library/logger/logger/error_spec.rb | 4 +- spec/ruby/library/logger/logger/fatal_spec.rb | 4 +- spec/ruby/library/logger/logger/info_spec.rb | 4 +- spec/ruby/library/logger/logger/warn_spec.rb | 4 +- spec/ruby/library/matrix/normal_spec.rb | 6 +-- spec/ruby/library/matrix/orthogonal_spec.rb | 6 +-- spec/ruby/library/matrix/unitary_spec.rb | 10 ++-- spec/ruby/library/matrix/zero_spec.rb | 10 ++-- .../http/httpresponse/body_permitted_spec.rb | 12 ++--- spec/ruby/library/pathname/absolute_spec.rb | 8 +-- spec/ruby/library/pathname/new_spec.rb | 2 +- spec/ruby/library/pathname/relative_spec.rb | 8 +-- spec/ruby/library/pathname/root_spec.rb | 10 ++-- .../ruby/library/rexml/element/cdatas_spec.rb | 2 +- .../library/rexml/element/comments_spec.rb | 2 +- spec/ruby/library/rexml/node/parent_spec.rb | 6 +-- spec/ruby/library/rexml/text/empty_spec.rb | 4 +- .../library/set/compare_by_identity_spec.rb | 12 ++--- .../socket/addrinfo/ipv4_loopback_spec.rb | 8 +-- .../socket/addrinfo/ipv4_multicast_spec.rb | 10 ++-- .../socket/addrinfo/ipv4_private_spec.rb | 12 ++--- .../socket/addrinfo/ipv6_linklocal_spec.rb | 12 ++--- .../socket/addrinfo/ipv6_mc_global_spec.rb | 16 +++--- .../socket/addrinfo/ipv6_mc_linklocal_spec.rb | 14 ++--- .../socket/addrinfo/ipv6_mc_nodelocal_spec.rb | 12 ++--- .../socket/addrinfo/ipv6_mc_orglocal_spec.rb | 12 ++--- .../socket/addrinfo/ipv6_mc_sitelocal_spec.rb | 12 ++--- .../socket/addrinfo/ipv6_multicast_spec.rb | 20 +++---- .../socket/addrinfo/ipv6_sitelocal_spec.rb | 12 ++--- .../socket/addrinfo/ipv6_unique_local_spec.rb | 12 ++--- .../socket/addrinfo/ipv6_unspecified_spec.rb | 6 +-- .../socket/addrinfo/ipv6_v4compat_spec.rb | 10 ++-- .../socket/addrinfo/ipv6_v4mapped_spec.rb | 10 ++-- .../library/socket/addrinfo/listen_spec.rb | 2 +- .../socket/basicsocket/read_nonblock_spec.rb | 8 +-- .../socket/basicsocket/write_nonblock_spec.rb | 8 +-- .../socket/socket/tcp_server_sockets_spec.rb | 2 +- spec/ruby/library/socket/socket/tcp_spec.rb | 2 +- .../socket/socket/udp_server_sockets_spec.rb | 2 +- spec/ruby/library/socket/socket/unix_spec.rb | 2 +- .../library/socket/unixsocket/open_spec.rb | 2 +- .../library/socket/unixsocket/shared/new.rb | 2 +- spec/ruby/library/stringio/reopen_spec.rb | 2 +- spec/ruby/library/syslog/close_spec.rb | 2 +- spec/ruby/library/syslog/ident_spec.rb | 2 +- spec/ruby/library/syslog/mask_spec.rb | 2 +- .../library/weakref/weakref_alive_spec.rb | 2 +- .../win32ole/win32ole_param/input_spec.rb | 2 +- spec/ruby/library/zlib/gzipfile/close_spec.rb | 2 +- .../ruby/library/zlib/gzipfile/closed_spec.rb | 4 +- .../zlib/zstream/flush_next_out_spec.rb | 2 +- spec/ruby/optional/capi/kernel_spec.rb | 10 ++-- spec/ruby/optional/capi/object_spec.rb | 4 +- spec/ruby/optional/capi/shared/rbasic.rb | 12 ++--- spec/ruby/optional/capi/string_spec.rb | 10 ++-- spec/ruby/optional/capi/tracepoint_spec.rb | 12 ++--- spec/ruby/security/cve_2020_10663_spec.rb | 2 +- spec/ruby/shared/string/times.rb | 2 +- 263 files changed, 922 insertions(+), 922 deletions(-) diff --git a/spec/ruby/command_line/error_message_spec.rb b/spec/ruby/command_line/error_message_spec.rb index 5fee3ead44976e..f3f7de4fd4aa60 100644 --- a/spec/ruby/command_line/error_message_spec.rb +++ b/spec/ruby/command_line/error_message_spec.rb @@ -3,9 +3,9 @@ describe "The error message caused by an exception" do it "is not printed to stdout" do out = ruby_exe("this_does_not_exist", args: "2> #{File::NULL}") - out.chomp.empty?.should == true + out.chomp.should.empty? out = ruby_exe("end #syntax error", args: "2> #{File::NULL}") - out.chomp.empty?.should == true + out.chomp.should.empty? end end diff --git a/spec/ruby/core/argf/binmode_spec.rb b/spec/ruby/core/argf/binmode_spec.rb index bdcc6aa30ab197..e083a30a27aed1 100644 --- a/spec/ruby/core/argf/binmode_spec.rb +++ b/spec/ruby/core/argf/binmode_spec.rb @@ -34,7 +34,7 @@ it "sets the file's encoding to BINARY" do argf [@bin_file, @file1] do @argf.binmode - @argf.binmode?.should == true + @argf.should.binmode? @argf.gets.encoding.should == Encoding::BINARY @argf.skip @argf.read.encoding.should == Encoding::BINARY diff --git a/spec/ruby/core/array/any_spec.rb b/spec/ruby/core/array/any_spec.rb index 2fa5353e9925f5..09d949fe6e89d7 100644 --- a/spec/ruby/core/array/any_spec.rb +++ b/spec/ruby/core/array/any_spec.rb @@ -4,17 +4,17 @@ describe 'with no block given (a default block of { |x| x } is implicit)' do it "is false if the array is empty" do empty_array = [] - empty_array.any?.should == false + empty_array.should_not.any? end it "is false if the array is not empty, but all the members of the array are falsy" do falsy_array = [false, nil, false] - falsy_array.any?.should == false + falsy_array.should_not.any? end it "is true if the array has any truthy members" do not_empty_array = ['anything', nil] - not_empty_array.any?.should == true + not_empty_array.should.any? end end diff --git a/spec/ruby/core/array/clear_spec.rb b/spec/ruby/core/array/clear_spec.rb index 5c7a934d75b30e..bddc672d3b8f74 100644 --- a/spec/ruby/core/array/clear_spec.rb +++ b/spec/ruby/core/array/clear_spec.rb @@ -16,7 +16,7 @@ it "leaves the Array empty" do a = [1] a.clear - a.empty?.should == true + a.should.empty? a.size.should == 0 end diff --git a/spec/ruby/core/array/clone_spec.rb b/spec/ruby/core/array/clone_spec.rb index 803e746e029c42..e22a6c6d536795 100644 --- a/spec/ruby/core/array/clone_spec.rb +++ b/spec/ruby/core/array/clone_spec.rb @@ -12,8 +12,8 @@ aa = a.clone bb = b.clone - aa.frozen?.should == true - bb.frozen?.should == false + aa.should.frozen? + bb.should_not.frozen? end it "copies singleton methods" do diff --git a/spec/ruby/core/array/empty_spec.rb b/spec/ruby/core/array/empty_spec.rb index b5f3e8ed48f2b5..f70b1b6ebe03ac 100644 --- a/spec/ruby/core/array/empty_spec.rb +++ b/spec/ruby/core/array/empty_spec.rb @@ -3,8 +3,8 @@ describe "Array#empty?" do it "returns true if the array has no elements" do - [].empty?.should == true - [1].empty?.should == false - [1, 2].empty?.should == false + [].should.empty? + [1].should_not.empty? + [1, 2].should_not.empty? end end diff --git a/spec/ruby/core/array/frozen_spec.rb b/spec/ruby/core/array/frozen_spec.rb index bb4b2b4067654c..3ba54be46bb61f 100644 --- a/spec/ruby/core/array/frozen_spec.rb +++ b/spec/ruby/core/array/frozen_spec.rb @@ -4,13 +4,13 @@ describe "Array#frozen?" do it "returns true if array is frozen" do a = [1, 2, 3] - a.frozen?.should == false + a.should_not.frozen? a.freeze - a.frozen?.should == true + a.should.frozen? end it "returns false for an array being sorted by #sort" do a = [1, 2, 3] - a.sort { |x,y| a.frozen?.should == false; x <=> y } + a.sort { |x,y| a.should_not.frozen?; x <=> y } end end diff --git a/spec/ruby/core/array/multiply_spec.rb b/spec/ruby/core/array/multiply_spec.rb index 4060666d4b9613..8ccec13d429363 100644 --- a/spec/ruby/core/array/multiply_spec.rb +++ b/spec/ruby/core/array/multiply_spec.rb @@ -92,39 +92,39 @@ def obj.to_str() "2" end it "copies the taint status of the original array even if the passed count is 0" do ary = [1, 2, 3] ary.taint - (ary * 0).tainted?.should == true + (ary * 0).should.tainted? end it "copies the taint status of the original array even if the array is empty" do ary = [] ary.taint - (ary * 3).tainted?.should == true + (ary * 3).should.tainted? end it "copies the taint status of the original array if the passed count is not 0" do ary = [1, 2, 3] ary.taint - (ary * 1).tainted?.should == true - (ary * 2).tainted?.should == true + (ary * 1).should.tainted? + (ary * 2).should.tainted? end it "copies the untrusted status of the original array even if the passed count is 0" do ary = [1, 2, 3] ary.untrust - (ary * 0).untrusted?.should == true + (ary * 0).should.untrusted? end it "copies the untrusted status of the original array even if the array is empty" do ary = [] ary.untrust - (ary * 3).untrusted?.should == true + (ary * 3).should.untrusted? end it "copies the untrusted status of the original array if the passed count is not 0" do ary = [1, 2, 3] ary.untrust - (ary * 1).untrusted?.should == true - (ary * 2).untrusted?.should == true + (ary * 1).should.untrusted? + (ary * 2).should.untrusted? end end end diff --git a/spec/ruby/core/array/shared/clone.rb b/spec/ruby/core/array/shared/clone.rb index f6f581b17c2197..3c17b1f10fb02a 100644 --- a/spec/ruby/core/array/shared/clone.rb +++ b/spec/ruby/core/array/shared/clone.rb @@ -26,8 +26,8 @@ aa = a.send @method bb = b.send @method - aa.tainted?.should == true - bb.tainted?.should == false + aa.should.tainted? + bb.should_not.tainted? end it "copies untrusted status from the original" do @@ -37,8 +37,8 @@ aa = a.send @method bb = b.send @method - aa.untrusted?.should == true - bb.untrusted?.should == false + aa.should.untrusted? + bb.should_not.untrusted? end end end diff --git a/spec/ruby/core/array/sort_spec.rb b/spec/ruby/core/array/sort_spec.rb index 541f3a5964c3c7..0c5ecdcbbf6698 100644 --- a/spec/ruby/core/array/sort_spec.rb +++ b/spec/ruby/core/array/sort_spec.rb @@ -58,9 +58,9 @@ b = ArraySpecs::MockForCompared.new c = ArraySpecs::MockForCompared.new - ArraySpecs::MockForCompared.compared?.should == false + ArraySpecs::MockForCompared.should_not.compared? [a, b, c].sort.should == [c, b, a] - ArraySpecs::MockForCompared.compared?.should == true + ArraySpecs::MockForCompared.should.compared? end it "does not deal with exceptions raised by unimplemented or incorrect #<=>" do @@ -104,7 +104,7 @@ it "does not freezes self during being sorted" do a = [1, 2, 3] - a.sort { |x,y| a.frozen?.should == false; x <=> y } + a.sort { |x,y| a.should_not.frozen?; x <=> y } end it "returns the specified value when it would break in the given block" do @@ -207,9 +207,9 @@ class Bignum b = ArraySpecs::MockForCompared.new c = ArraySpecs::MockForCompared.new - ArraySpecs::MockForCompared.compared?.should == false + ArraySpecs::MockForCompared.should_not.compared? [a, b, c].sort!.should == [c, b, a] - ArraySpecs::MockForCompared.compared?.should == true + ArraySpecs::MockForCompared.should.compared? end it "does not call #<=> on contained objects when invoked with a block" do diff --git a/spec/ruby/core/array/uniq_spec.rb b/spec/ruby/core/array/uniq_spec.rb index 38e1878f10e142..fd604987c1a93b 100644 --- a/spec/ruby/core/array/uniq_spec.rb +++ b/spec/ruby/core/array/uniq_spec.rb @@ -87,8 +87,8 @@ def obj.eql?(o) end a.uniq.should == a - a[0].tainted?.should == true - a[1].tainted?.should == true + a[0].should.tainted? + a[1].should.tainted? a = Array.new(2) do obj = mock('0') @@ -106,8 +106,8 @@ def obj.eql?(o) end a.uniq.size.should == 1 - a[0].tainted?.should == true - a[1].tainted?.should == true + a[0].should.tainted? + a[1].should.tainted? end end diff --git a/spec/ruby/core/class/allocate_spec.rb b/spec/ruby/core/class/allocate_spec.rb index c426c38ff9ac34..b39622e06a4ade 100644 --- a/spec/ruby/core/class/allocate_spec.rb +++ b/spec/ruby/core/class/allocate_spec.rb @@ -30,7 +30,7 @@ def initialized? end end - klass.allocate.initialized?.should == false + klass.allocate.should_not.initialized? end it "raises TypeError for #superclass" do diff --git a/spec/ruby/core/class/new_spec.rb b/spec/ruby/core/class/new_spec.rb index 8191ce6a375df8..989d674558f20c 100644 --- a/spec/ruby/core/class/new_spec.rb +++ b/spec/ruby/core/class/new_spec.rb @@ -126,7 +126,7 @@ def initialized? end end - klass.new.initialized?.should == true + klass.new.should.initialized? klass.new(1, 2, 3).args.should == [1, 2, 3] end diff --git a/spec/ruby/core/complex/finite_spec.rb b/spec/ruby/core/complex/finite_spec.rb index 718848390cfa38..7d9f82404e7cbd 100644 --- a/spec/ruby/core/complex/finite_spec.rb +++ b/spec/ruby/core/complex/finite_spec.rb @@ -2,31 +2,31 @@ describe "Complex#finite?" do it "returns true if magnitude is finite" do - (1+1i).finite?.should == true + (1+1i).should.finite? end it "returns false for positive infinity" do value = Complex(Float::INFINITY, 42) - value.finite?.should == false + value.should_not.finite? end it "returns false for positive complex with infinite imaginary" do value = Complex(1, Float::INFINITY) - value.finite?.should == false + value.should_not.finite? end it "returns false for negative infinity" do value = -Complex(Float::INFINITY, 42) - value.finite?.should == false + value.should_not.finite? end it "returns false for negative complex with infinite imaginary" do value = -Complex(1, Float::INFINITY) - value.finite?.should == false + value.should_not.finite? end it "returns false for NaN" do value = Complex(Float::NAN, Float::NAN) - value.finite?.should == false + value.should_not.finite? end end diff --git a/spec/ruby/core/dir/glob_spec.rb b/spec/ruby/core/dir/glob_spec.rb index 4b437b0e242c1e..d4888ee14704ae 100644 --- a/spec/ruby/core/dir/glob_spec.rb +++ b/spec/ruby/core/dir/glob_spec.rb @@ -119,7 +119,7 @@ end it "handles infinite directory wildcards" do - Dir.glob('**/**/**').empty?.should == false + Dir.glob('**/**/**').should_not.empty? end it "handles simple filename patterns" do diff --git a/spec/ruby/core/dir/home_spec.rb b/spec/ruby/core/dir/home_spec.rb index 73deca2cfdfcb5..713ba9db9ad443 100644 --- a/spec/ruby/core/dir/home_spec.rb +++ b/spec/ruby/core/dir/home_spec.rb @@ -17,7 +17,7 @@ end it "returns a non-frozen string" do - Dir.home.frozen?.should == false + Dir.home.should_not.frozen? end end @@ -35,7 +35,7 @@ end it "returns a non-frozen string" do - Dir.home(ENV['USER']).frozen?.should == false + Dir.home(ENV['USER']).should_not.frozen? end end diff --git a/spec/ruby/core/dir/shared/open.rb b/spec/ruby/core/dir/shared/open.rb index 76b08dc288adef..920845cba18b3d 100644 --- a/spec/ruby/core/dir/shared/open.rb +++ b/spec/ruby/core/dir/shared/open.rb @@ -66,7 +66,7 @@ Dir.send(@method, DirSpecs.mock_dir) do |dir| io = IO.for_fd(dir.fileno) io.autoclose = false - io.close_on_exec?.should == true + io.should.close_on_exec? end end end diff --git a/spec/ruby/core/enumerable/all_spec.rb b/spec/ruby/core/enumerable/all_spec.rb index ae255c662c9473..7e9726fe87054e 100644 --- a/spec/ruby/core/enumerable/all_spec.rb +++ b/spec/ruby/core/enumerable/all_spec.rb @@ -10,13 +10,13 @@ end it "always returns true on empty enumeration" do - @empty.all?.should == true + @empty.should.all? @empty.all? { nil }.should == true - [].all?.should == true + [].should.all? [].all? { false }.should == true - {}.all?.should == true + {}.should.all? {}.all? { nil }.should == true end @@ -38,24 +38,24 @@ describe "with no block" do it "returns true if no elements are false or nil" do - @enum.all?.should == true - @enum1.all?.should == true - @enum2.all?.should == false + @enum.should.all? + @enum1.should.all? + @enum2.should_not.all? - EnumerableSpecs::Numerous.new('a','b','c').all?.should == true - EnumerableSpecs::Numerous.new(0, "x", true).all?.should == true + EnumerableSpecs::Numerous.new('a','b','c').should.all? + EnumerableSpecs::Numerous.new(0, "x", true).should.all? end it "returns false if there are false or nil elements" do - EnumerableSpecs::Numerous.new(false).all?.should == false - EnumerableSpecs::Numerous.new(false, false).all?.should == false + EnumerableSpecs::Numerous.new(false).should_not.all? + EnumerableSpecs::Numerous.new(false, false).should_not.all? - EnumerableSpecs::Numerous.new(nil).all?.should == false - EnumerableSpecs::Numerous.new(nil, nil).all?.should == false + EnumerableSpecs::Numerous.new(nil).should_not.all? + EnumerableSpecs::Numerous.new(nil, nil).should_not.all? - EnumerableSpecs::Numerous.new(1, nil, 2).all?.should == false - EnumerableSpecs::Numerous.new(0, "x", false, true).all?.should == false - @enum2.all?.should == false + EnumerableSpecs::Numerous.new(1, nil, 2).should_not.all? + EnumerableSpecs::Numerous.new(0, "x", false, true).should_not.all? + @enum2.should_not.all? end it "gathers whole arrays as elements when each yields multiple" do diff --git a/spec/ruby/core/enumerable/any_spec.rb b/spec/ruby/core/enumerable/any_spec.rb index 0202506d10b1d1..64e3159963c5dd 100644 --- a/spec/ruby/core/enumerable/any_spec.rb +++ b/spec/ruby/core/enumerable/any_spec.rb @@ -10,13 +10,13 @@ end it "always returns false on empty enumeration" do - @empty.any?.should == false + @empty.should_not.any? @empty.any? { nil }.should == false - [].any?.should == false + [].should_not.any? [].any? { false }.should == false - {}.any?.should == false + {}.should_not.any? {}.any? { nil }.should == false end @@ -38,24 +38,24 @@ describe "with no block" do it "returns true if any element is not false or nil" do - @enum.any?.should == true - @enum1.any?.should == true - @enum2.any?.should == true - EnumerableSpecs::Numerous.new(true).any?.should == true - EnumerableSpecs::Numerous.new('a','b','c').any?.should == true - EnumerableSpecs::Numerous.new('a','b','c', nil).any?.should == true - EnumerableSpecs::Numerous.new(1, nil, 2).any?.should == true - EnumerableSpecs::Numerous.new(1, false).any?.should == true - EnumerableSpecs::Numerous.new(false, nil, 1, false).any?.should == true - EnumerableSpecs::Numerous.new(false, 0, nil).any?.should == true + @enum.should.any? + @enum1.should.any? + @enum2.should.any? + EnumerableSpecs::Numerous.new(true).should.any? + EnumerableSpecs::Numerous.new('a','b','c').should.any? + EnumerableSpecs::Numerous.new('a','b','c', nil).should.any? + EnumerableSpecs::Numerous.new(1, nil, 2).should.any? + EnumerableSpecs::Numerous.new(1, false).should.any? + EnumerableSpecs::Numerous.new(false, nil, 1, false).should.any? + EnumerableSpecs::Numerous.new(false, 0, nil).should.any? end it "returns false if all elements are false or nil" do - EnumerableSpecs::Numerous.new(false).any?.should == false - EnumerableSpecs::Numerous.new(false, false).any?.should == false - EnumerableSpecs::Numerous.new(nil).any?.should == false - EnumerableSpecs::Numerous.new(nil, nil).any?.should == false - EnumerableSpecs::Numerous.new(nil, false, nil).any?.should == false + EnumerableSpecs::Numerous.new(false).should_not.any? + EnumerableSpecs::Numerous.new(false, false).should_not.any? + EnumerableSpecs::Numerous.new(nil).should_not.any? + EnumerableSpecs::Numerous.new(nil, nil).should_not.any? + EnumerableSpecs::Numerous.new(nil, false, nil).should_not.any? end it "gathers whole arrays as elements when each yields multiple" do diff --git a/spec/ruby/core/enumerable/none_spec.rb b/spec/ruby/core/enumerable/none_spec.rb index 8c886736ab4e29..ec48eaf0a73008 100644 --- a/spec/ruby/core/enumerable/none_spec.rb +++ b/spec/ruby/core/enumerable/none_spec.rb @@ -10,7 +10,7 @@ end it "always returns true on empty enumeration" do - @empty.none?.should == true + @empty.should.none? @empty.none? { true }.should == true end diff --git a/spec/ruby/core/enumerable/one_spec.rb b/spec/ruby/core/enumerable/one_spec.rb index 46a10d68ebe51c..6489c84742e7fc 100644 --- a/spec/ruby/core/enumerable/one_spec.rb +++ b/spec/ruby/core/enumerable/one_spec.rb @@ -10,7 +10,7 @@ end it "always returns false on empty enumeration" do - @empty.one?.should == false + @empty.should_not.one? @empty.one? { true }.should == false end diff --git a/spec/ruby/core/enumerable/uniq_spec.rb b/spec/ruby/core/enumerable/uniq_spec.rb index 82c041d4ef1af5..e58dd3636641ff 100644 --- a/spec/ruby/core/enumerable/uniq_spec.rb +++ b/spec/ruby/core/enumerable/uniq_spec.rb @@ -79,8 +79,8 @@ def obj.eql?(o) end a.uniq.should == a - a[0].tainted?.should == true - a[1].tainted?.should == true + a[0].should.tainted? + a[1].should.tainted? a = Array.new(2) do obj = mock('0') @@ -98,8 +98,8 @@ def obj.eql?(o) end a.to_enum.uniq.size.should == 1 - a[0].tainted?.should == true - a[1].tainted?.should == true + a[0].should.tainted? + a[1].should.tainted? end end diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/exclude_end_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/exclude_end_spec.rb index 8ce0ce0cd961c6..5be189e9934500 100644 --- a/spec/ruby/core/enumerator/arithmetic_sequence/exclude_end_spec.rb +++ b/spec/ruby/core/enumerator/arithmetic_sequence/exclude_end_spec.rb @@ -4,15 +4,15 @@ describe "Enumerator::ArithmeticSequence#exclude_end?" do context "when created using Numeric#step" do it "always returns false" do - 1.step(10).exclude_end?.should == false - 10.step(1).exclude_end?.should == false + 1.step(10).should_not.exclude_end? + 10.step(1).should_not.exclude_end? end end context "when created using Range#step" do it "mirrors range.exclude_end?" do - (1...10).step.exclude_end?.should == true - (1..10).step.exclude_end?.should == false + (1...10).step.should.exclude_end? + (1..10).step.should_not.exclude_end? end end end diff --git a/spec/ruby/core/env/element_reference_spec.rb b/spec/ruby/core/env/element_reference_spec.rb index 7d2a2d78e32770..1cd58ace5442a9 100644 --- a/spec/ruby/core/env/element_reference_spec.rb +++ b/spec/ruby/core/env/element_reference_spec.rb @@ -16,7 +16,7 @@ it "returns only frozen values" do ENV[@variable] = "a non-frozen string" - ENV[@variable].frozen?.should == true + ENV[@variable].should.frozen? end it "coerces a non-string name with #to_str" do diff --git a/spec/ruby/core/env/empty_spec.rb b/spec/ruby/core/env/empty_spec.rb index 7ef17d244ff615..afeb406a9e5c5e 100644 --- a/spec/ruby/core/env/empty_spec.rb +++ b/spec/ruby/core/env/empty_spec.rb @@ -4,12 +4,12 @@ it "returns true if the Environment is empty" do if ENV.keys.size > 0 - ENV.empty?.should == false + ENV.should_not.empty? end orig = ENV.to_hash begin ENV.clear - ENV.empty?.should == true + ENV.should.empty? ensure ENV.replace orig end @@ -17,7 +17,7 @@ it "returns false if not empty" do if ENV.keys.size > 0 - ENV.empty?.should == false + ENV.should_not.empty? end end end diff --git a/spec/ruby/core/env/shift_spec.rb b/spec/ruby/core/env/shift_spec.rb index c03b5d50c59e2d..0fe08d4f6dd6c5 100644 --- a/spec/ruby/core/env/shift_spec.rb +++ b/spec/ruby/core/env/shift_spec.rb @@ -2,7 +2,7 @@ describe "ENV.shift" do it "returns a pair and deletes it" do - ENV.empty?.should == false + ENV.should_not.empty? orig = ENV.to_hash begin pair = ENV.shift diff --git a/spec/ruby/core/exception/success_spec.rb b/spec/ruby/core/exception/success_spec.rb index 70af9c74eb56e5..6f217433401360 100644 --- a/spec/ruby/core/exception/success_spec.rb +++ b/spec/ruby/core/exception/success_spec.rb @@ -3,13 +3,13 @@ describe "SystemExit#success?" do it "returns true if the process exited successfully" do -> { exit 0 }.should raise_error(SystemExit) { |e| - e.success?.should == true + e.should.success? } end it "returns false if the process exited unsuccessfully" do -> { exit(-1) }.should raise_error(SystemExit) { |e| - e.success?.should == false + e.should_not.success? } end end diff --git a/spec/ruby/core/false/to_s_spec.rb b/spec/ruby/core/false/to_s_spec.rb index c996d87000536e..4cae27889132dd 100644 --- a/spec/ruby/core/false/to_s_spec.rb +++ b/spec/ruby/core/false/to_s_spec.rb @@ -7,7 +7,7 @@ ruby_version_is "2.7" do it "returns a frozen string" do - false.to_s.frozen?.should == true + false.to_s.should.frozen? end it "always returns the same string" do diff --git a/spec/ruby/core/file/expand_path_spec.rb b/spec/ruby/core/file/expand_path_spec.rb index 88078645abaf2d..c31f885b92f2d2 100644 --- a/spec/ruby/core/file/expand_path_spec.rb +++ b/spec/ruby/core/file/expand_path_spec.rb @@ -203,9 +203,9 @@ it "does not return a frozen string" do home = "/rubyspec_home" - File.expand_path('~').frozen?.should == false - File.expand_path('~', '/tmp/gumby/ddd').frozen?.should == false - File.expand_path('~/a', '/tmp/gumby/ddd').frozen?.should == false + File.expand_path('~').should_not.frozen? + File.expand_path('~', '/tmp/gumby/ddd').should_not.frozen? + File.expand_path('~/a', '/tmp/gumby/ddd').should_not.frozen? end end diff --git a/spec/ruby/core/file/lchmod_spec.rb b/spec/ruby/core/file/lchmod_spec.rb index bab362980a3d58..4abe42526d2b04 100644 --- a/spec/ruby/core/file/lchmod_spec.rb +++ b/spec/ruby/core/file/lchmod_spec.rb @@ -20,13 +20,13 @@ File.chmod(0222, @lname).should == 1 File.lchmod(0755, @lname).should == 1 - File.lstat(@lname).executable?.should == true - File.lstat(@lname).readable?.should == true - File.lstat(@lname).writable?.should == true + File.lstat(@lname).should.executable? + File.lstat(@lname).should.readable? + File.lstat(@lname).should.writable? - File.stat(@lname).executable?.should == false - File.stat(@lname).readable?.should == false - File.stat(@lname).writable?.should == true + File.stat(@lname).should_not.executable? + File.stat(@lname).should_not.readable? + File.stat(@lname).should.writable? end end diff --git a/spec/ruby/core/file/lstat_spec.rb b/spec/ruby/core/file/lstat_spec.rb index 918ed02163b6ca..a5ea9d15a55c21 100644 --- a/spec/ruby/core/file/lstat_spec.rb +++ b/spec/ruby/core/file/lstat_spec.rb @@ -22,8 +22,8 @@ it "returns a File::Stat object with symlink properties for a symlink" do st = File.lstat(@link) - st.symlink?.should == true - st.file?.should == false + st.should.symlink? + st.should_not.file? end end end diff --git a/spec/ruby/core/file/open_spec.rb b/spec/ruby/core/file/open_spec.rb index 7ceeb47dd83730..8faa31173eac0e 100644 --- a/spec/ruby/core/file/open_spec.rb +++ b/spec/ruby/core/file/open_spec.rb @@ -28,7 +28,7 @@ describe "with a block" do it "does not raise error when file is closed inside the block" do @fh = File.open(@file) { |fh| fh.close; fh } - @fh.closed?.should == true + @fh.should.closed? end it "invokes close on an opened file when exiting the block" do @@ -485,7 +485,7 @@ File.size(@file).should > 0 File.open(@file, "w+") do |f| f.pos.should == 0 - f.eof?.should == true + f.should.eof? end File.size(@file).should == 0 end @@ -495,7 +495,7 @@ File.size(@file).should > 0 File.open(@file, "rb+") do |f| f.pos.should == 0 - f.eof?.should == false + f.should_not.eof? end end @@ -504,7 +504,7 @@ File.size(@file).should > 0 File.open(@file, "wb+") do |f| f.pos.should == 0 - f.eof?.should == true + f.should.eof? end File.size(@file).should == 0 end diff --git a/spec/ruby/core/file/stat/owned_spec.rb b/spec/ruby/core/file/stat/owned_spec.rb index fbd473c4d7f5c6..a23ad850c5dc81 100644 --- a/spec/ruby/core/file/stat/owned_spec.rb +++ b/spec/ruby/core/file/stat/owned_spec.rb @@ -18,7 +18,7 @@ it "returns true if the file is owned by the user" do st = File.stat(@file) - st.owned?.should == true + st.should.owned? end platform_is_not :windows, :android do @@ -26,7 +26,7 @@ it "returns false if the file is not owned by the user" do system_file = '/etc/passwd' st = File.stat(system_file) - st.owned?.should == false + st.should_not.owned? end end end diff --git a/spec/ruby/core/file/stat/pipe_spec.rb b/spec/ruby/core/file/stat/pipe_spec.rb index 7abb6c742a2670..692dfbf42a4aeb 100644 --- a/spec/ruby/core/file/stat/pipe_spec.rb +++ b/spec/ruby/core/file/stat/pipe_spec.rb @@ -12,7 +12,7 @@ touch(filename) st = File.stat(filename) - st.pipe?.should == false + st.should_not.pipe? rm_r filename end @@ -23,7 +23,7 @@ File.mkfifo(filename) st = File.stat(filename) - st.pipe?.should == true + st.should.pipe? rm_r filename end diff --git a/spec/ruby/core/file/stat_spec.rb b/spec/ruby/core/file/stat_spec.rb index 275eae36d5dad1..63655000573bd6 100644 --- a/spec/ruby/core/file/stat_spec.rb +++ b/spec/ruby/core/file/stat_spec.rb @@ -23,8 +23,8 @@ st = f.stat - st.file?.should == true - st.zero?.should == false + st.should.file? + st.should_not.zero? st.size.should == 8 st.size?.should == 8 st.blksize.should >= 0 @@ -38,8 +38,8 @@ File.symlink(@file, @link) st = File.stat(@link) - st.file?.should == true - st.symlink?.should == false + st.should.file? + st.should_not.symlink? end it "returns an error when given missing non-ASCII path" do diff --git a/spec/ruby/core/file/truncate_spec.rb b/spec/ruby/core/file/truncate_spec.rb index 43b86b73821991..b4a2e3e57728c9 100644 --- a/spec/ruby/core/file/truncate_spec.rb +++ b/spec/ruby/core/file/truncate_spec.rb @@ -18,7 +18,7 @@ File.open(@name, "r") do |f| f.read(99).should == "12345" - f.eof?.should == true + f.should.eof? end end @@ -120,7 +120,7 @@ File.size(@name).should == 5 File.open(@name, "r") do |f| f.read(99).should == "12345" - f.eof?.should == true + f.should.eof? end end @@ -161,7 +161,7 @@ it "raises an IOError if file is closed" do @file.close - @file.closed?.should == true + @file.should.closed? -> { @file.truncate(42) }.should raise_error(IOError) end diff --git a/spec/ruby/core/float/finite_spec.rb b/spec/ruby/core/float/finite_spec.rb index c5fb3df849c230..d839b30e321b0a 100644 --- a/spec/ruby/core/float/finite_spec.rb +++ b/spec/ruby/core/float/finite_spec.rb @@ -2,18 +2,18 @@ describe "Float#finite?" do it "returns true for finite values" do - 3.14159.finite?.should == true + 3.14159.should.finite? end it "returns false for positive infinity" do - infinity_value.finite?.should == false + infinity_value.should_not.finite? end it "returns false for negative infinity" do - (-infinity_value).finite?.should == false + (-infinity_value).should_not.finite? end it "returns false for NaN" do - nan_value.finite?.should == false + nan_value.should_not.finite? end end diff --git a/spec/ruby/core/float/nan_spec.rb b/spec/ruby/core/float/nan_spec.rb index d09d25153ce3f1..c1043ef21b18cd 100644 --- a/spec/ruby/core/float/nan_spec.rb +++ b/spec/ruby/core/float/nan_spec.rb @@ -2,8 +2,8 @@ describe "Float#nan?" do it "returns true if self is not a valid IEEE floating-point number" do - 0.0.nan?.should == false - -1.5.nan?.should == false - nan_value.nan?.should == true + 0.0.should_not.nan? + -1.5.should_not.nan? + nan_value.should.nan? end end diff --git a/spec/ruby/core/float/next_float_spec.rb b/spec/ruby/core/float/next_float_spec.rb index 2f0eff605a58d4..29e2d311463e0a 100644 --- a/spec/ruby/core/float/next_float_spec.rb +++ b/spec/ruby/core/float/next_float_spec.rb @@ -44,6 +44,6 @@ end it "returns NAN if NAN was the receiver" do - Float::NAN.next_float.nan?.should == true + Float::NAN.next_float.should.nan? end end diff --git a/spec/ruby/core/float/prev_float_spec.rb b/spec/ruby/core/float/prev_float_spec.rb index 40fcc25a6df03b..5e50269da76055 100644 --- a/spec/ruby/core/float/prev_float_spec.rb +++ b/spec/ruby/core/float/prev_float_spec.rb @@ -44,6 +44,6 @@ end it "returns NAN if NAN was the receiver" do - Float::NAN.prev_float.nan?.should == true + Float::NAN.prev_float.should.nan? end end diff --git a/spec/ruby/core/float/uminus_spec.rb b/spec/ruby/core/float/uminus_spec.rb index e676a26ada28a7..57bae0fb4be9c5 100644 --- a/spec/ruby/core/float/uminus_spec.rb +++ b/spec/ruby/core/float/uminus_spec.rb @@ -23,6 +23,6 @@ end it "returns NaN for NaN" do - nan_value.send(:-@).nan?.should == true + nan_value.send(:-@).should.nan? end end diff --git a/spec/ruby/core/float/zero_spec.rb b/spec/ruby/core/float/zero_spec.rb index e70edc422adffb..1f3de2779352bb 100644 --- a/spec/ruby/core/float/zero_spec.rb +++ b/spec/ruby/core/float/zero_spec.rb @@ -2,8 +2,8 @@ describe "Float#zero?" do it "returns true if self is 0.0" do - 0.0.zero?.should == true - 1.0.zero?.should == false - -1.0.zero?.should == false + 0.0.should.zero? + 1.0.should_not.zero? + -1.0.should_not.zero? end end diff --git a/spec/ruby/core/gc/profiler/disable_spec.rb b/spec/ruby/core/gc/profiler/disable_spec.rb index 321a207deb5c79..74089693eb56b0 100644 --- a/spec/ruby/core/gc/profiler/disable_spec.rb +++ b/spec/ruby/core/gc/profiler/disable_spec.rb @@ -11,6 +11,6 @@ it "disables the profiler" do GC::Profiler.disable - GC::Profiler.enabled?.should == false + GC::Profiler.should_not.enabled? end end diff --git a/spec/ruby/core/gc/profiler/enable_spec.rb b/spec/ruby/core/gc/profiler/enable_spec.rb index 159451167521f9..313ca3d949d81a 100644 --- a/spec/ruby/core/gc/profiler/enable_spec.rb +++ b/spec/ruby/core/gc/profiler/enable_spec.rb @@ -12,6 +12,6 @@ it "enables the profiler" do GC::Profiler.enable - GC::Profiler.enabled?.should == true + GC::Profiler.should.enabled? end end diff --git a/spec/ruby/core/hash/any_spec.rb b/spec/ruby/core/hash/any_spec.rb index bd33e8cd8fa8df..c26dfabde68ebc 100644 --- a/spec/ruby/core/hash/any_spec.rb +++ b/spec/ruby/core/hash/any_spec.rb @@ -4,10 +4,10 @@ describe 'with no block given' do it "checks if there are any members of a Hash" do empty_hash = {} - empty_hash.any?.should == false + empty_hash.should_not.any? hash_with_members = { 'key' => 'value' } - hash_with_members.any?.should == true + hash_with_members.should.any? end end diff --git a/spec/ruby/core/hash/compare_by_identity_spec.rb b/spec/ruby/core/hash/compare_by_identity_spec.rb index 0fd41a4d581775..874cd46eb7cc7f 100644 --- a/spec/ruby/core/hash/compare_by_identity_spec.rb +++ b/spec/ruby/core/hash/compare_by_identity_spec.rb @@ -33,7 +33,7 @@ def o.hash; 123; end it "has no effect on an already compare_by_identity hash" do @idh[:foo] = :bar @idh.compare_by_identity.should equal @idh - @idh.compare_by_identity?.should == true + @idh.should.compare_by_identity? @idh[:foo].should == :bar end diff --git a/spec/ruby/core/hash/empty_spec.rb b/spec/ruby/core/hash/empty_spec.rb index e9be44bab0238e..881e1cc34b677c 100644 --- a/spec/ruby/core/hash/empty_spec.rb +++ b/spec/ruby/core/hash/empty_spec.rb @@ -3,13 +3,13 @@ describe "Hash#empty?" do it "returns true if the hash has no entries" do - {}.empty?.should == true - { 1 => 1 }.empty?.should == false + {}.should.empty? + { 1 => 1 }.should_not.empty? end it "returns true if the hash has no entries and has a default value" do - Hash.new(5).empty?.should == true - Hash.new { 5 }.empty?.should == true - Hash.new { |hsh, k| hsh[k] = k }.empty?.should == true + Hash.new(5).should.empty? + Hash.new { 5 }.should.empty? + Hash.new { |hsh, k| hsh[k] = k }.should.empty? end end diff --git a/spec/ruby/core/hash/reject_spec.rb b/spec/ruby/core/hash/reject_spec.rb index 38589fd880ff97..397000ab677992 100644 --- a/spec/ruby/core/hash/reject_spec.rb +++ b/spec/ruby/core/hash/reject_spec.rb @@ -35,7 +35,7 @@ def h.to_a() end ruby_version_is ''...'2.7' do it "does not taint the resulting hash" do h = { a: 1 }.taint - h.reject {false}.tainted?.should == false + h.reject {false}.should_not.tainted? end end end diff --git a/spec/ruby/core/hash/shared/store.rb b/spec/ruby/core/hash/shared/store.rb index 6e2557eb284e91..84ffb41e33fea0 100644 --- a/spec/ruby/core/hash/shared/store.rb +++ b/spec/ruby/core/hash/shared/store.rb @@ -50,7 +50,7 @@ def key.reverse() "bar" end key << "bar" h.should == { "foo" => 0 } - h.keys[0].frozen?.should == true + h.keys[0].should.frozen? end it "doesn't duplicate and freeze already frozen string keys" do diff --git a/spec/ruby/core/hash/to_proc_spec.rb b/spec/ruby/core/hash/to_proc_spec.rb index 700621f162ce91..8b7ddd5e001aef 100644 --- a/spec/ruby/core/hash/to_proc_spec.rb +++ b/spec/ruby/core/hash/to_proc_spec.rb @@ -21,13 +21,13 @@ ruby_version_is ""..."2.8" do it "is not a lambda" do - @proc.lambda?.should == false + @proc.should_not.lambda? end end ruby_version_is "2.8" do it "is a lambda" do - @proc.lambda?.should == true + @proc.should.lambda? end end diff --git a/spec/ruby/core/integer/integer_spec.rb b/spec/ruby/core/integer/integer_spec.rb index f8067cda06dc4f..2d5d2e3e92dc2c 100644 --- a/spec/ruby/core/integer/integer_spec.rb +++ b/spec/ruby/core/integer/integer_spec.rb @@ -13,8 +13,8 @@ describe "Integer#integer?" do it "returns true for Integers" do - 0.integer?.should == true - -1.integer?.should == true - bignum_value.integer?.should == true + 0.should.integer? + -1.should.integer? + bignum_value.should.integer? end end diff --git a/spec/ruby/core/io/close_on_exec_spec.rb b/spec/ruby/core/io/close_on_exec_spec.rb index f837bb56afd40e..91bd3c8c40f792 100644 --- a/spec/ruby/core/io/close_on_exec_spec.rb +++ b/spec/ruby/core/io/close_on_exec_spec.rb @@ -14,24 +14,24 @@ guard -> { platform_is_not :windows } do it "sets the close-on-exec flag if true" do @io.close_on_exec = true - @io.close_on_exec?.should == true + @io.should.close_on_exec? end it "sets the close-on-exec flag if non-false" do @io.close_on_exec = :true - @io.close_on_exec?.should == true + @io.should.close_on_exec? end it "unsets the close-on-exec flag if false" do @io.close_on_exec = true @io.close_on_exec = false - @io.close_on_exec?.should == false + @io.should_not.close_on_exec? end it "unsets the close-on-exec flag if nil" do @io.close_on_exec = true @io.close_on_exec = nil - @io.close_on_exec?.should == false + @io.should_not.close_on_exec? end it "ensures the IO's file descriptor is closed in exec'ed processes" do @@ -64,12 +64,12 @@ guard -> { platform_is_not :windows } do it "returns true by default" do - @io.close_on_exec?.should == true + @io.should.close_on_exec? end it "returns true if set" do @io.close_on_exec = true - @io.close_on_exec?.should == true + @io.should.close_on_exec? end it "raises IOError if called on a closed IO" do diff --git a/spec/ruby/core/io/close_read_spec.rb b/spec/ruby/core/io/close_read_spec.rb index 6fa4fc8ff84ec6..26454bfddd1635 100644 --- a/spec/ruby/core/io/close_read_spec.rb +++ b/spec/ruby/core/io/close_read_spec.rb @@ -49,7 +49,7 @@ io.close_read - io.closed?.should == true + io.should.closed? end it "does nothing on closed stream" do diff --git a/spec/ruby/core/io/close_spec.rb b/spec/ruby/core/io/close_spec.rb index 37c8ab5a122897..dda82b34de2e42 100644 --- a/spec/ruby/core/io/close_spec.rb +++ b/spec/ruby/core/io/close_spec.rb @@ -14,7 +14,7 @@ it "closes the stream" do @io.close - @io.closed?.should == true + @io.should.closed? end it "returns nil" do diff --git a/spec/ruby/core/io/close_write_spec.rb b/spec/ruby/core/io/close_write_spec.rb index 75e1577654e574..14835e4e2c08bf 100644 --- a/spec/ruby/core/io/close_write_spec.rb +++ b/spec/ruby/core/io/close_write_spec.rb @@ -45,7 +45,7 @@ io.close_write - io.closed?.should == true + io.should.closed? end it "flushes and closes the write stream" do diff --git a/spec/ruby/core/io/dup_spec.rb b/spec/ruby/core/io/dup_spec.rb index de32c5e3478993..8cadaee118cd4b 100644 --- a/spec/ruby/core/io/dup_spec.rb +++ b/spec/ruby/core/io/dup_spec.rb @@ -51,16 +51,16 @@ @i.close -> { @f.gets }.should_not raise_error(Exception) - @i.closed?.should == true - @f.closed?.should == false + @i.should.closed? + @f.should_not.closed? end it "allows closing the original IO without affecting the new one" do @f.close -> { @i.gets }.should_not raise_error(Exception) - @i.closed?.should == false - @f.closed?.should == true + @i.should_not.closed? + @f.should.closed? end it "raises IOError on closed stream" do @@ -71,7 +71,7 @@ @f.close_on_exec = true dup = @f.dup begin - dup.close_on_exec?.should == true + dup.should.close_on_exec? ensure dup.close end @@ -79,7 +79,7 @@ @f.close_on_exec = false dup = @f.dup begin - dup.close_on_exec?.should == true + dup.should.close_on_exec? ensure dup.close end diff --git a/spec/ruby/core/io/eof_spec.rb b/spec/ruby/core/io/eof_spec.rb index 8fd3c3713235bd..315345d942ab27 100644 --- a/spec/ruby/core/io/eof_spec.rb +++ b/spec/ruby/core/io/eof_spec.rb @@ -12,7 +12,7 @@ end it "returns true on an empty stream that has just been opened" do - File.open(@name) { |empty| empty.eof?.should == true } + File.open(@name) { |empty| empty.should.eof? } end it "raises IOError on stream not opened for reading" do @@ -34,35 +34,35 @@ it "returns false when not at end of file" do @io.read 1 - @io.eof?.should == false + @io.should_not.eof? end it "returns true after reading with read with no parameters" do @io.read() - @io.eof?.should == true + @io.should.eof? end it "returns true after reading with read" do @io.read(File.size(@name)) - @io.eof?.should == true + @io.should.eof? end it "returns true after reading with sysread" do @io.sysread(File.size(@name)) - @io.eof?.should == true + @io.should.eof? end it "returns true after reading with readlines" do @io.readlines - @io.eof?.should == true + @io.should.eof? end it "returns false on just opened non-empty stream" do - @io.eof?.should == false + @io.should_not.eof? end it "does not consume the data from the stream" do - @io.eof?.should == false + @io.should_not.eof? @io.getc.should == 'V' end @@ -78,7 +78,7 @@ it "returns true on one-byte stream after single-byte read" do File.open(File.dirname(__FILE__) + '/fixtures/one_byte.txt') { |one_byte| one_byte.read(1) - one_byte.eof?.should == true + one_byte.should.eof? } end end @@ -92,16 +92,16 @@ it "returns true on receiving side of Pipe when writing side is closed" do @r, @w = IO.pipe @w.close - @r.eof?.should == true + @r.should.eof? end it "returns false on receiving side of Pipe when writing side wrote some data" do @r, @w = IO.pipe @w.puts "hello" - @r.eof?.should == false + @r.should_not.eof? @w.close - @r.eof?.should == false + @r.should_not.eof? @r.read - @r.eof?.should == true + @r.should.eof? end end diff --git a/spec/ruby/core/io/gets_spec.rb b/spec/ruby/core/io/gets_spec.rb index 39b2108476d22c..a3cd180b66c930 100644 --- a/spec/ruby/core/io/gets_spec.rb +++ b/spec/ruby/core/io/gets_spec.rb @@ -41,7 +41,7 @@ ruby_version_is ''...'2.7' do it "returns tainted strings" do while line = @io.gets - line.tainted?.should == true + line.should.tainted? end end end @@ -67,7 +67,7 @@ ruby_version_is ''...'2.7' do it "returns tainted strings" do while line = @io.gets(nil) - line.tainted?.should == true + line.should.tainted? end end end @@ -103,7 +103,7 @@ ruby_version_is ''...'2.7' do it "returns tainted strings" do while line = @io.gets("") - line.tainted?.should == true + line.should.tainted? end end end @@ -129,7 +129,7 @@ ruby_version_is ''...'2.7' do it "returns tainted strings" do while line = @io.gets("la") - line.tainted?.should == true + line.should.tainted? end end end diff --git a/spec/ruby/core/io/pipe_spec.rb b/spec/ruby/core/io/pipe_spec.rb index a7dcb7fab8329d..2f2cf06f4d32c1 100644 --- a/spec/ruby/core/io/pipe_spec.rb +++ b/spec/ruby/core/io/pipe_spec.rb @@ -44,8 +44,8 @@ r, w = IO.pipe do |_r, _w| [_r, _w] end - r.closed?.should == true - w.closed?.should == true + r.should.closed? + w.should.closed? end it "closes both IO objects when the block raises" do @@ -57,8 +57,8 @@ raise RuntimeError end end.should raise_error(RuntimeError) - r.closed?.should == true - w.closed?.should == true + r.should.closed? + w.should.closed? end it "allows IO objects to be closed within the block" do @@ -67,8 +67,8 @@ _w.close [_r, _w] end - r.closed?.should == true - w.closed?.should == true + r.should.closed? + w.should.closed? end end end diff --git a/spec/ruby/core/io/popen_spec.rb b/spec/ruby/core/io/popen_spec.rb index 4f873e61cd715c..e9d32c5c7dcc6a 100644 --- a/spec/ruby/core/io/popen_spec.rb +++ b/spec/ruby/core/io/popen_spec.rb @@ -77,10 +77,10 @@ Process.kill "KILL", pid @io.close platform_is_not :windows do - $?.signaled?.should == true + $?.should.signaled? end platform_is :windows do - $?.exited?.should == true + $?.should.exited? end end diff --git a/spec/ruby/core/io/read_nonblock_spec.rb b/spec/ruby/core/io/read_nonblock_spec.rb index 63ccab5a44d124..e50531d336cee2 100644 --- a/spec/ruby/core/io/read_nonblock_spec.rb +++ b/spec/ruby/core/io/read_nonblock_spec.rb @@ -46,7 +46,7 @@ require 'io/nonblock' @write.write "abc" @read.read_nonblock(1).should == "a" - @read.nonblock?.should == true + @read.should.nonblock? end end diff --git a/spec/ruby/core/io/read_spec.rb b/spec/ruby/core/io/read_spec.rb index 1e9a8d2a4f8828..841e693f373c47 100644 --- a/spec/ruby/core/io/read_spec.rb +++ b/spec/ruby/core/io/read_spec.rb @@ -216,7 +216,7 @@ it "is at end-of-file when everything has been read" do @io.read - @io.eof?.should == true + @io.should.eof? end it "reads the contents of a file" do diff --git a/spec/ruby/core/io/reopen_spec.rb b/spec/ruby/core/io/reopen_spec.rb index faef80f51398b9..8ff0f217f4410a 100644 --- a/spec/ruby/core/io/reopen_spec.rb +++ b/spec/ruby/core/io/reopen_spec.rb @@ -150,11 +150,11 @@ @io.close_on_exec = true @io.reopen @other_name - @io.close_on_exec?.should == true + @io.should.close_on_exec? @io.close_on_exec = false @io.reopen @other_name - @io.close_on_exec?.should == true + @io.should.close_on_exec? end it "creates the file if it doesn't exist if the IO is opened in write mode" do @@ -293,12 +293,12 @@ def @io.to_io; flunk; end @other_io.close_on_exec = true @io.close_on_exec = true @io.reopen @other_io - @io.close_on_exec?.should == true + @io.should.close_on_exec? @other_io.close_on_exec = false @io.close_on_exec = false @io.reopen @other_io - @io.close_on_exec?.should == true + @io.should.close_on_exec? end it "may change the class of the instance" do diff --git a/spec/ruby/core/io/rewind_spec.rb b/spec/ruby/core/io/rewind_spec.rb index 954d56d30c1f74..649041afafba0b 100644 --- a/spec/ruby/core/io/rewind_spec.rb +++ b/spec/ruby/core/io/rewind_spec.rb @@ -21,7 +21,7 @@ it "positions the instance to the beginning of input and clears EOF" do value = @io.read @io.rewind - @io.eof?.should == false + @io.should_not.eof? value.should == @io.read end diff --git a/spec/ruby/core/io/seek_spec.rb b/spec/ruby/core/io/seek_spec.rb index 7e9c308272293d..2fa4a73ac9e661 100644 --- a/spec/ruby/core/io/seek_spec.rb +++ b/spec/ruby/core/io/seek_spec.rb @@ -44,21 +44,21 @@ it "moves the read position and clears EOF with SEEK_SET" do value = @io.read @io.seek(0, IO::SEEK_SET) - @io.eof?.should == false + @io.should_not.eof? value.should == @io.read end it "moves the read position and clears EOF with SEEK_CUR" do value = @io.read @io.seek(-1, IO::SEEK_CUR) - @io.eof?.should == false + @io.should_not.eof? value[-1].should == @io.read[0] end it "moves the read position and clears EOF with SEEK_END" do value = @io.read @io.seek(-1, IO::SEEK_END) - @io.eof?.should == false + @io.should_not.eof? value[-1].should == @io.read[0] end diff --git a/spec/ruby/core/io/shared/new.rb b/spec/ruby/core/io/shared/new.rb index 27d32f97eda6d8..87f30018626567 100644 --- a/spec/ruby/core/io/shared/new.rb +++ b/spec/ruby/core/io/shared/new.rb @@ -148,22 +148,22 @@ it "sets binmode from mode string" do @io = IO.send(@method, @fd, 'wb') - @io.binmode?.should == true + @io.should.binmode? end it "does not set binmode without being asked" do @io = IO.send(@method, @fd, 'w') - @io.binmode?.should == false + @io.should_not.binmode? end it "sets binmode from :binmode option" do @io = IO.send(@method, @fd, 'w', binmode: true) - @io.binmode?.should == true + @io.should.binmode? end it "does not set binmode from false :binmode" do @io = IO.send(@method, @fd, 'w', binmode: false) - @io.binmode?.should == false + @io.should_not.binmode? end it "sets external encoding to binary with binmode in mode string" do @@ -270,13 +270,13 @@ it "accepts an :autoclose option" do @io = IO.send(@method, @fd, 'w', autoclose: false) - @io.autoclose?.should == false + @io.should_not.autoclose? @io.autoclose = true end it "accepts any truthy option :autoclose" do @io = IO.send(@method, @fd, 'w', autoclose: 42) - @io.autoclose?.should == true + @io.should.autoclose? end end diff --git a/spec/ruby/core/io/shared/pos.rb b/spec/ruby/core/io/shared/pos.rb index fb6d8087bc9afe..0b4d1e13b31cd3 100644 --- a/spec/ruby/core/io/shared/pos.rb +++ b/spec/ruby/core/io/shared/pos.rb @@ -27,7 +27,7 @@ io.read 1 io.read 1 io.send(@method) - io.eof?.should == false + io.should_not.eof? end end end diff --git a/spec/ruby/core/io/ungetc_spec.rb b/spec/ruby/core/io/ungetc_spec.rb index 4be0e3aa8ba533..85c15b5a71d093 100644 --- a/spec/ruby/core/io/ungetc_spec.rb +++ b/spec/ruby/core/io/ungetc_spec.rb @@ -74,10 +74,10 @@ touch(@empty) File.open(@empty) { |empty| - empty.eof?.should == true + empty.should.eof? empty.getc.should == nil empty.ungetc(100) - empty.eof?.should == false + empty.should_not.eof? } end diff --git a/spec/ruby/core/io/write_nonblock_spec.rb b/spec/ruby/core/io/write_nonblock_spec.rb index 5474e5c6cedf87..a8b9ce0a36234f 100644 --- a/spec/ruby/core/io/write_nonblock_spec.rb +++ b/spec/ruby/core/io/write_nonblock_spec.rb @@ -79,7 +79,7 @@ it 'sets the IO in nonblock mode' do require 'io/nonblock' @write.write_nonblock('a') - @write.nonblock?.should == true + @write.should.nonblock? end end end diff --git a/spec/ruby/core/kernel/backtick_spec.rb b/spec/ruby/core/kernel/backtick_spec.rb index 5ab0fb0eea8dad..391583b5390739 100644 --- a/spec/ruby/core/kernel/backtick_spec.rb +++ b/spec/ruby/core/kernel/backtick_spec.rb @@ -40,16 +40,16 @@ ip = 'world' `echo disc #{ip}` $?.should be_kind_of(Process::Status) - $?.stopped?.should == false - $?.exited?.should == true + $?.should_not.stopped? + $?.should.exited? $?.exitstatus.should == 0 - $?.success?.should == true + $?.should.success? `echo disc #{ip}; exit 99` $?.should be_kind_of(Process::Status) - $?.stopped?.should == false - $?.exited?.should == true + $?.should_not.stopped? + $?.should.exited? $?.exitstatus.should == 99 - $?.success?.should == false + $?.should_not.success? end end @@ -58,16 +58,16 @@ ip = 'world' `echo disc #{ip}` $?.should be_kind_of(Process::Status) - $?.stopped?.should == false - $?.exited?.should == true + $?.should_not.stopped? + $?.should.exited? $?.exitstatus.should == 0 - $?.success?.should == true + $?.should.success? `echo disc #{ip}& exit 99` $?.should be_kind_of(Process::Status) - $?.stopped?.should == false - $?.exited?.should == true + $?.should_not.stopped? + $?.should.exited? $?.exitstatus.should == 99 - $?.success?.should == false + $?.should_not.success? end end end diff --git a/spec/ruby/core/kernel/caller_locations_spec.rb b/spec/ruby/core/kernel/caller_locations_spec.rb index cb344e16a0faee..c4e008408592b5 100644 --- a/spec/ruby/core/kernel/caller_locations_spec.rb +++ b/spec/ruby/core/kernel/caller_locations_spec.rb @@ -7,7 +7,7 @@ end it 'returns an Array of caller locations' do - KernelSpecs::CallerLocationsTest.locations.empty?.should == false + KernelSpecs::CallerLocationsTest.locations.should_not.empty? end it 'returns an Array of caller locations using a custom offset' do diff --git a/spec/ruby/core/kernel/caller_spec.rb b/spec/ruby/core/kernel/caller_spec.rb index e943e36dc29058..b71060770c5bc7 100644 --- a/spec/ruby/core/kernel/caller_spec.rb +++ b/spec/ruby/core/kernel/caller_spec.rb @@ -7,7 +7,7 @@ end it 'returns an Array of caller locations' do - KernelSpecs::CallerTest.locations.empty?.should == false + KernelSpecs::CallerTest.locations.should_not.empty? end it 'returns an Array of caller locations using a custom offset' do diff --git a/spec/ruby/core/kernel/clone_spec.rb b/spec/ruby/core/kernel/clone_spec.rb index 1bbef64f852ebf..6aeb57f55b2b01 100644 --- a/spec/ruby/core/kernel/clone_spec.rb +++ b/spec/ruby/core/kernel/clone_spec.rb @@ -33,22 +33,22 @@ def klass.allocate @obj.freeze o3 = @obj.clone - o2.frozen?.should == false - o3.frozen?.should == true + o2.should_not.frozen? + o3.should.frozen? end ruby_version_is '2.8' do it 'takes an freeze: true option to frozen copy' do - @obj.clone(freeze: true).frozen?.should == true + @obj.clone(freeze: true).should.frozen? @obj.freeze - @obj.clone(freeze: true).frozen?.should == true + @obj.clone(freeze: true).should.frozen? end end it 'takes an freeze: false option to not return frozen copy' do - @obj.clone(freeze: false).frozen?.should == false + @obj.clone(freeze: false).should_not.frozen? @obj.freeze - @obj.clone(freeze: false).frozen?.should == false + @obj.clone(freeze: false).should_not.frozen? end it "copies instance variables" do diff --git a/spec/ruby/core/kernel/dup_spec.rb b/spec/ruby/core/kernel/dup_spec.rb index fe0a269d69d161..70198abdb7554b 100644 --- a/spec/ruby/core/kernel/dup_spec.rb +++ b/spec/ruby/core/kernel/dup_spec.rb @@ -32,7 +32,7 @@ def klass.allocate @obj.freeze dup = @obj.dup - dup.frozen?.should == false + dup.should_not.frozen? end it "copies instance variables" do diff --git a/spec/ruby/core/kernel/frozen_spec.rb b/spec/ruby/core/kernel/frozen_spec.rb index 54edae15b15e51..a4cec4263db472 100644 --- a/spec/ruby/core/kernel/frozen_spec.rb +++ b/spec/ruby/core/kernel/frozen_spec.rb @@ -6,8 +6,8 @@ o = mock('o') p = mock('p') p.freeze - o.frozen?.should == false - p.frozen?.should == true + o.should_not.frozen? + p.should.frozen? end describe "on true, false and nil" do diff --git a/spec/ruby/core/kernel/shared/dup_clone.rb b/spec/ruby/core/kernel/shared/dup_clone.rb index 968efd80f3d230..84ad49cbde59d7 100644 --- a/spec/ruby/core/kernel/shared/dup_clone.rb +++ b/spec/ruby/core/kernel/shared/dup_clone.rb @@ -59,8 +59,8 @@ def initialize_copy(original) o.taint o3 = o.send(@method) - o2.tainted?.should == false - o3.tainted?.should == true + o2.should_not.tainted? + o3.should.tainted? end end @@ -78,8 +78,8 @@ def initialize_copy(original) o.untrust o3 = o.send(@method) - o2.untrusted?.should == false - o3.untrusted?.should == true + o2.should_not.untrusted? + o3.should.untrusted? end end diff --git a/spec/ruby/core/kernel/system_spec.rb b/spec/ruby/core/kernel/system_spec.rb index 9196a9f9f1139b..696e6ae3d7c38c 100644 --- a/spec/ruby/core/kernel/system_spec.rb +++ b/spec/ruby/core/kernel/system_spec.rb @@ -6,14 +6,14 @@ -> { @object.system("echo a") }.should output_to_fd("a\n") $?.should be_an_instance_of Process::Status - $?.success?.should == true + $?.should.success? end it "returns true when the command exits with a zero exit status" do @object.system(ruby_cmd('exit 0')).should == true $?.should be_an_instance_of Process::Status - $?.success?.should == true + $?.should.success? $?.exitstatus.should == 0 end @@ -21,7 +21,7 @@ @object.system(ruby_cmd('exit 1')).should == false $?.should be_an_instance_of Process::Status - $?.success?.should == false + $?.should_not.success? $?.exitstatus.should == 1 end diff --git a/spec/ruby/core/kernel/taint_spec.rb b/spec/ruby/core/kernel/taint_spec.rb index 2d2b34d0d04c2d..060e73963e09a8 100644 --- a/spec/ruby/core/kernel/taint_spec.rb +++ b/spec/ruby/core/kernel/taint_spec.rb @@ -11,7 +11,7 @@ it "sets the tainted bit" do o = Object.new o.taint - o.tainted?.should == true + o.should.tainted? end it "raises FrozenError on an untainted, frozen object" do @@ -27,20 +27,20 @@ it "has no effect on immediate values" do [nil, true, false].each do |v| v.taint - v.tainted?.should == false + v.should_not.tainted? end end it "no raises a RuntimeError on symbols" do v = :sym -> { v.taint }.should_not raise_error(RuntimeError) - v.tainted?.should == false + v.should_not.tainted? end it "no raises error on fixnum values" do [1].each do |v| -> { v.taint }.should_not raise_error(RuntimeError) - v.tainted?.should == false + v.should_not.tainted? end end end diff --git a/spec/ruby/core/kernel/tainted_spec.rb b/spec/ruby/core/kernel/tainted_spec.rb index 72ce346dda3314..dbd6bc939ac17e 100644 --- a/spec/ruby/core/kernel/tainted_spec.rb +++ b/spec/ruby/core/kernel/tainted_spec.rb @@ -7,8 +7,8 @@ o = mock('o') p = mock('p') p.taint - o.tainted?.should == false - p.tainted?.should == true + o.should_not.tainted? + p.should.tainted? end end end diff --git a/spec/ruby/core/kernel/trust_spec.rb b/spec/ruby/core/kernel/trust_spec.rb index dbc05b45d42a1a..1d209ea1dc450e 100644 --- a/spec/ruby/core/kernel/trust_spec.rb +++ b/spec/ruby/core/kernel/trust_spec.rb @@ -11,7 +11,7 @@ it "clears the untrusted bit" do o = Object.new.untrust o.trust - o.untrusted?.should == false + o.should_not.untrusted? end it "raises FrozenError on an untrusted, frozen object" do diff --git a/spec/ruby/core/kernel/untaint_spec.rb b/spec/ruby/core/kernel/untaint_spec.rb index df9e3144a0432b..171d32b35694ca 100644 --- a/spec/ruby/core/kernel/untaint_spec.rb +++ b/spec/ruby/core/kernel/untaint_spec.rb @@ -11,7 +11,7 @@ it "clears the tainted bit" do o = Object.new.taint o.untaint - o.tainted?.should == false + o.should_not.tainted? end it "raises FrozenError on a tainted, frozen object" do diff --git a/spec/ruby/core/kernel/untrust_spec.rb b/spec/ruby/core/kernel/untrust_spec.rb index c5a36e1a1d302f..fca7c9ea4727fa 100644 --- a/spec/ruby/core/kernel/untrust_spec.rb +++ b/spec/ruby/core/kernel/untrust_spec.rb @@ -11,7 +11,7 @@ it "sets the untrusted bit" do o = Object.new o.untrust - o.untrusted?.should == true + o.should.untrusted? end it "raises FrozenError on a trusted, frozen object" do diff --git a/spec/ruby/core/kernel/untrusted_spec.rb b/spec/ruby/core/kernel/untrusted_spec.rb index ccebfe38bea8a2..65cbffa3add483 100644 --- a/spec/ruby/core/kernel/untrusted_spec.rb +++ b/spec/ruby/core/kernel/untrusted_spec.rb @@ -5,9 +5,9 @@ ruby_version_is ''...'2.7' do it "returns the untrusted status of an object" do o = mock('o') - o.untrusted?.should == false + o.should_not.untrusted? o.untrust - o.untrusted?.should == true + o.should.untrusted? end it "has no effect on immediate values" do @@ -17,9 +17,9 @@ a.untrust b.untrust c.untrust - a.untrusted?.should == false - b.untrusted?.should == false - c.untrusted?.should == false + a.should_not.untrusted? + b.should_not.untrusted? + c.should_not.untrusted? end it "has effect on immediate values" do diff --git a/spec/ruby/core/matchdata/string_spec.rb b/spec/ruby/core/matchdata/string_spec.rb index db0d5dfbdca301..420233e1f39b2a 100644 --- a/spec/ruby/core/matchdata/string_spec.rb +++ b/spec/ruby/core/matchdata/string_spec.rb @@ -9,7 +9,7 @@ it "returns a frozen copy of the match string" do str = /(.)(.)(\d+)(\d)/.match("THX1138.").string str.should == "THX1138." - str.frozen?.should == true + str.should.frozen? end it "returns the same frozen string for every call" do @@ -20,6 +20,6 @@ it "returns a frozen copy of the matched string for gsub(String)" do 'he[[o'.gsub!('[', ']') $~.string.should == 'he[[o' - $~.string.frozen?.should == true + $~.string.should.frozen? end end diff --git a/spec/ruby/core/math/tan_spec.rb b/spec/ruby/core/math/tan_spec.rb index c7b188cd810670..67307f1e6e3be7 100644 --- a/spec/ruby/core/math/tan_spec.rb +++ b/spec/ruby/core/math/tan_spec.rb @@ -14,8 +14,8 @@ end it "returns NaN if called with +-Infinity" do - Math.tan(infinity_value).nan?.should == true - Math.tan(-infinity_value).nan?.should == true + Math.tan(infinity_value).should.nan? + Math.tan(-infinity_value).should.nan? end it "raises a TypeError if the argument cannot be coerced with Float()" do diff --git a/spec/ruby/core/method/compose_spec.rb b/spec/ruby/core/method/compose_spec.rb index 2cf5b21670fa25..0e2a0eeea2315b 100644 --- a/spec/ruby/core/method/compose_spec.rb +++ b/spec/ruby/core/method/compose_spec.rb @@ -39,8 +39,8 @@ def double.call(n); n * 2; end double = proc { |x| x + x } (pow_2 << double).is_a?(Proc).should == true - ruby_version_is(''...'2.8') { (pow_2 << double).lambda?.should == true } - ruby_version_is('2.8') { (pow_2 << double).lambda?.should == false } + ruby_version_is(''...'2.8') { (pow_2 << double).should.lambda? } + ruby_version_is('2.8') { (pow_2 << double).should_not.lambda? } end it "may accept multiple arguments" do @@ -88,7 +88,7 @@ def double.call(n); n * 2; end double = proc { |x| x + x } (pow_2 >> double).is_a?(Proc).should == true - (pow_2 >> double).lambda?.should == true + (pow_2 >> double).should.lambda? end it "may accept multiple arguments" do diff --git a/spec/ruby/core/module/included_spec.rb b/spec/ruby/core/module/included_spec.rb index f8dbad1d31c6b9..2fdd4325f2ddd7 100644 --- a/spec/ruby/core/module/included_spec.rb +++ b/spec/ruby/core/module/included_spec.rb @@ -39,6 +39,6 @@ def test it "works with super using a singleton class" do ModuleSpecs::SingletonOnModuleCase::Bar.include ModuleSpecs::SingletonOnModuleCase::Foo - ModuleSpecs::SingletonOnModuleCase::Bar.included_called?.should == true + ModuleSpecs::SingletonOnModuleCase::Bar.should.included_called? end end diff --git a/spec/ruby/core/module/name_spec.rb b/spec/ruby/core/module/name_spec.rb index 9a4730313fe961..ae8037555bb348 100644 --- a/spec/ruby/core/module/name_spec.rb +++ b/spec/ruby/core/module/name_spec.rb @@ -122,7 +122,7 @@ module ModuleSpecs::Anonymous ruby_version_is "2.7" do it "returns a frozen String" do - ModuleSpecs.name.frozen?.should == true + ModuleSpecs.name.should.frozen? end it "always returns the same String for a given Module" do diff --git a/spec/ruby/core/module/singleton_class_spec.rb b/spec/ruby/core/module/singleton_class_spec.rb index b9f78eeb21cdca..052755b73b3d24 100644 --- a/spec/ruby/core/module/singleton_class_spec.rb +++ b/spec/ruby/core/module/singleton_class_spec.rb @@ -3,25 +3,25 @@ describe "Module#singleton_class?" do it "returns true for singleton classes" do xs = self.singleton_class - xs.singleton_class?.should == true + xs.should.singleton_class? end it "returns false for other classes" do c = Class.new - c.singleton_class?.should == false + c.should_not.singleton_class? end describe "with singleton values" do it "returns false for nil's singleton class" do - NilClass.singleton_class?.should == false + NilClass.should_not.singleton_class? end it "returns false for true's singleton class" do - TrueClass.singleton_class?.should == false + TrueClass.should_not.singleton_class? end it "returns false for false's singleton class" do - FalseClass.singleton_class?.should == false + FalseClass.should_not.singleton_class? end end end diff --git a/spec/ruby/core/nil/nil_spec.rb b/spec/ruby/core/nil/nil_spec.rb index 47db0c5cf0b2a0..2cf97621c6ce15 100644 --- a/spec/ruby/core/nil/nil_spec.rb +++ b/spec/ruby/core/nil/nil_spec.rb @@ -2,6 +2,6 @@ describe "NilClass#nil?" do it "returns true" do - nil.nil?.should == true + nil.should.nil? end end diff --git a/spec/ruby/core/nil/to_s_spec.rb b/spec/ruby/core/nil/to_s_spec.rb index 4b61f589f7c4e0..283d26477a3119 100644 --- a/spec/ruby/core/nil/to_s_spec.rb +++ b/spec/ruby/core/nil/to_s_spec.rb @@ -7,7 +7,7 @@ ruby_version_is "2.7" do it "returns a frozen string" do - nil.to_s.frozen?.should == true + nil.to_s.should.frozen? end it "always returns the same string" do diff --git a/spec/ruby/core/numeric/integer_spec.rb b/spec/ruby/core/numeric/integer_spec.rb index 5d4bf003609bcf..adbac4d7aac1ff 100644 --- a/spec/ruby/core/numeric/integer_spec.rb +++ b/spec/ruby/core/numeric/integer_spec.rb @@ -3,6 +3,6 @@ describe "Numeric#integer?" do it "returns false" do - NumericSpecs::Subclass.new.integer?.should == false + NumericSpecs::Subclass.new.should_not.integer? end end diff --git a/spec/ruby/core/numeric/negative_spec.rb b/spec/ruby/core/numeric/negative_spec.rb index da464a90949a16..9c6f95fd873f55 100644 --- a/spec/ruby/core/numeric/negative_spec.rb +++ b/spec/ruby/core/numeric/negative_spec.rb @@ -31,11 +31,11 @@ it "returns true if self is less than 0" do @obj.should_receive(:<).with(0).and_return(true) - @obj.negative?.should == true + @obj.should.negative? end it "returns false if self is greater than 0" do @obj.should_receive(:<).with(0).and_return(false) - @obj.negative?.should == false + @obj.should_not.negative? end end diff --git a/spec/ruby/core/numeric/positive_spec.rb b/spec/ruby/core/numeric/positive_spec.rb index 8f98fbfa26a141..3b831b4d3417b2 100644 --- a/spec/ruby/core/numeric/positive_spec.rb +++ b/spec/ruby/core/numeric/positive_spec.rb @@ -31,11 +31,11 @@ it "returns true if self is greater than 0" do @obj.should_receive(:>).with(0).and_return(true) - @obj.positive?.should == true + @obj.should.positive? end it "returns false if self is less than 0" do @obj.should_receive(:>).with(0).and_return(false) - @obj.positive?.should == false + @obj.should_not.positive? end end diff --git a/spec/ruby/core/numeric/real_spec.rb b/spec/ruby/core/numeric/real_spec.rb index caa8dcec6de121..2d2499bcce5193 100644 --- a/spec/ruby/core/numeric/real_spec.rb +++ b/spec/ruby/core/numeric/real_spec.rb @@ -32,6 +32,6 @@ describe "Numeric#real?" do it "returns true" do - NumericSpecs::Subclass.new.real?.should == true + NumericSpecs::Subclass.new.should.real? end end diff --git a/spec/ruby/core/numeric/zero_spec.rb b/spec/ruby/core/numeric/zero_spec.rb index 9de71d1dc973b4..0fb7619bcdc3d8 100644 --- a/spec/ruby/core/numeric/zero_spec.rb +++ b/spec/ruby/core/numeric/zero_spec.rb @@ -8,11 +8,11 @@ it "returns true if self is 0" do @obj.should_receive(:==).with(0).and_return(true) - @obj.zero?.should == true + @obj.should.zero? end it "returns false if self is not 0" do @obj.should_receive(:==).with(0).and_return(false) - @obj.zero?.should == false + @obj.should_not.zero? end end diff --git a/spec/ruby/core/proc/compose_spec.rb b/spec/ruby/core/proc/compose_spec.rb index ef9c125ae9df43..efdbdeacf44ef5 100644 --- a/spec/ruby/core/proc/compose_spec.rb +++ b/spec/ruby/core/proc/compose_spec.rb @@ -35,7 +35,7 @@ def double.call(n); n * 2; end g = proc { |x| x + x } (f << g).is_a?(Proc).should == true - (f << g).lambda?.should == false + (f << g).should_not.lambda? end ruby_version_is(''...'2.8') do @@ -44,7 +44,7 @@ def double.call(n); n * 2; end g = -> x { x + x } (f << g).is_a?(Proc).should == true - (f << g).lambda?.should == false + (f << g).should_not.lambda? end it "is a lambda when self is lambda" do @@ -52,7 +52,7 @@ def double.call(n); n * 2; end g = proc { |x| x + x } (f << g).is_a?(Proc).should == true - (f << g).lambda?.should == true + (f << g).should.lambda? end end @@ -63,8 +63,8 @@ def double.call(n); n * 2; end lambda_proc = -> x { x } (f << g).is_a?(Proc).should == true - (f << g).lambda?.should == false - (f << lambda_proc).lambda?.should == true + (f << g).should_not.lambda? + (f << lambda_proc).should.lambda? end end @@ -118,7 +118,7 @@ def double.call(n); n * 2; end g = proc { |x| x + x } (f >> g).is_a?(Proc).should == true - (f >> g).lambda?.should == false + (f >> g).should_not.lambda? end it "is a Proc when other is lambda" do @@ -126,7 +126,7 @@ def double.call(n); n * 2; end g = -> x { x + x } (f >> g).is_a?(Proc).should == true - (f >> g).lambda?.should == false + (f >> g).should_not.lambda? end it "is a lambda when self is lambda" do @@ -134,7 +134,7 @@ def double.call(n); n * 2; end g = proc { |x| x + x } (f >> g).is_a?(Proc).should == true - (f >> g).lambda?.should == true + (f >> g).should.lambda? end it "may accept multiple arguments" do diff --git a/spec/ruby/core/range/dup_spec.rb b/spec/ruby/core/range/dup_spec.rb index d1c029c6b73cb4..6c9d0c954a177e 100644 --- a/spec/ruby/core/range/dup_spec.rb +++ b/spec/ruby/core/range/dup_spec.rb @@ -5,11 +5,11 @@ copy = (1..3).dup copy.begin.should == 1 copy.end.should == 3 - copy.exclude_end?.should == false + copy.should_not.exclude_end? copy = ("a"..."z").dup copy.begin.should == "a" copy.end.should == "z" - copy.exclude_end?.should == true + copy.should.exclude_end? end end diff --git a/spec/ruby/core/range/exclude_end_spec.rb b/spec/ruby/core/range/exclude_end_spec.rb index a209603d18eb50..c4006fea78afaf 100644 --- a/spec/ruby/core/range/exclude_end_spec.rb +++ b/spec/ruby/core/range/exclude_end_spec.rb @@ -2,18 +2,18 @@ describe "Range#exclude_end?" do it "returns false if the range does not exclude the end value" do - (-2..2).exclude_end?.should == false - ('A'..'B').exclude_end?.should == false - (0.5..2.4).exclude_end?.should == false - (0xfffd..0xffff).exclude_end?.should == false - Range.new(0, 1).exclude_end?.should == false + (-2..2).should_not.exclude_end? + ('A'..'B').should_not.exclude_end? + (0.5..2.4).should_not.exclude_end? + (0xfffd..0xffff).should_not.exclude_end? + Range.new(0, 1).should_not.exclude_end? end it "returns true if the range excludes the end value" do - (0...5).exclude_end?.should == true - ('A'...'B').exclude_end?.should == true - (0.5...2.4).exclude_end?.should == true - (0xfffd...0xffff).exclude_end?.should == true - Range.new(0, 1, true).exclude_end?.should == true + (0...5).should.exclude_end? + ('A'...'B').should.exclude_end? + (0.5...2.4).should.exclude_end? + (0xfffd...0xffff).should.exclude_end? + Range.new(0, 1, true).should.exclude_end? end end diff --git a/spec/ruby/core/regexp/casefold_spec.rb b/spec/ruby/core/regexp/casefold_spec.rb index d84a2d63c9027b..d36467a9897ca4 100644 --- a/spec/ruby/core/regexp/casefold_spec.rb +++ b/spec/ruby/core/regexp/casefold_spec.rb @@ -2,7 +2,7 @@ describe "Regexp#casefold?" do it "returns the value of the case-insensitive flag" do - /abc/i.casefold?.should == true - /xyz/.casefold?.should == false + /abc/i.should.casefold? + /xyz/.should_not.casefold? end end diff --git a/spec/ruby/core/signal/trap_spec.rb b/spec/ruby/core/signal/trap_spec.rb index 91ce1f1348496e..831a5ee23e44fc 100644 --- a/spec/ruby/core/signal/trap_spec.rb +++ b/spec/ruby/core/signal/trap_spec.rb @@ -155,7 +155,7 @@ out = ruby_exe(code) status = $? out.should == "nil\n" - status.signaled?.should == true + status.should.signaled? status.termsig.should be_kind_of(Integer) Signal.signame(status.termsig).should == "PIPE" end diff --git a/spec/ruby/core/string/capitalize_spec.rb b/spec/ruby/core/string/capitalize_spec.rb index 66d3b75f48d3cd..e6cf365ac32f39 100644 --- a/spec/ruby/core/string/capitalize_spec.rb +++ b/spec/ruby/core/string/capitalize_spec.rb @@ -14,8 +14,8 @@ ruby_version_is ''...'2.7' do it "taints resulting string when self is tainted" do - "".taint.capitalize.tainted?.should == true - "hello".taint.capitalize.tainted?.should == true + "".taint.capitalize.should.tainted? + "hello".taint.capitalize.should.tainted? end end diff --git a/spec/ruby/core/string/center_spec.rb b/spec/ruby/core/string/center_spec.rb index 0284fc28dc48e8..8a4be0a81e538e 100644 --- a/spec/ruby/core/string/center_spec.rb +++ b/spec/ruby/core/string/center_spec.rb @@ -49,11 +49,11 @@ ruby_version_is ''...'2.7' do it "taints result when self or padstr is tainted" do - "x".taint.center(4).tainted?.should == true - "x".taint.center(0).tainted?.should == true - "".taint.center(0).tainted?.should == true - "x".taint.center(4, "*").tainted?.should == true - "x".center(4, "*".taint).tainted?.should == true + "x".taint.center(4).should.tainted? + "x".taint.center(0).should.tainted? + "".taint.center(0).should.tainted? + "x".taint.center(4, "*").should.tainted? + "x".center(4, "*".taint).should.tainted? end end diff --git a/spec/ruby/core/string/chop_spec.rb b/spec/ruby/core/string/chop_spec.rb index e9cd8f51d24436..582d3c58c5ce50 100644 --- a/spec/ruby/core/string/chop_spec.rb +++ b/spec/ruby/core/string/chop_spec.rb @@ -51,13 +51,13 @@ ruby_version_is ''...'2.7' do it "taints result when self is tainted" do - "hello".taint.chop.tainted?.should == true - "".taint.chop.tainted?.should == true + "hello".taint.chop.should.tainted? + "".taint.chop.should.tainted? end it "untrusts result when self is untrusted" do - "hello".untrust.chop.untrusted?.should == true - "".untrust.chop.untrusted?.should == true + "hello".untrust.chop.should.untrusted? + "".untrust.chop.should.untrusted? end end diff --git a/spec/ruby/core/string/crypt_spec.rb b/spec/ruby/core/string/crypt_spec.rb index 6a9a4ae2357b82..b947702492899e 100644 --- a/spec/ruby/core/string/crypt_spec.rb +++ b/spec/ruby/core/string/crypt_spec.rb @@ -33,10 +33,10 @@ tainted_salt.taint tainted_str.taint - "mypassword".crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu").tainted?.should == false - tainted_str.crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu").tainted?.should == true - "mypassword".crypt(tainted_salt).tainted?.should == true - tainted_str.crypt(tainted_salt).tainted?.should == true + "mypassword".crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu").should_not.tainted? + tainted_str.crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu").should.tainted? + "mypassword".crypt(tainted_salt).should.tainted? + tainted_str.crypt(tainted_salt).should.tainted? end end @@ -93,10 +93,10 @@ tainted_salt.taint tainted_str.taint - "hello".crypt("aa").tainted?.should == false - tainted_str.crypt("aa").tainted?.should == true - "hello".crypt(tainted_salt).tainted?.should == true - tainted_str.crypt(tainted_salt).tainted?.should == true + "hello".crypt("aa").should_not.tainted? + tainted_str.crypt("aa").should.tainted? + "hello".crypt(tainted_salt).should.tainted? + tainted_str.crypt(tainted_salt).should.tainted? end end diff --git a/spec/ruby/core/string/delete_prefix_spec.rb b/spec/ruby/core/string/delete_prefix_spec.rb index fb00d808b24987..bd5b56a312bff4 100644 --- a/spec/ruby/core/string/delete_prefix_spec.rb +++ b/spec/ruby/core/string/delete_prefix_spec.rb @@ -23,8 +23,8 @@ ruby_version_is ''...'2.7' do it "taints resulting strings when other is tainted" do - 'hello'.taint.delete_prefix('hell').tainted?.should == true - 'hello'.taint.delete_prefix('').tainted?.should == true + 'hello'.taint.delete_prefix('hell').should.tainted? + 'hello'.taint.delete_prefix('').should.tainted? end end diff --git a/spec/ruby/core/string/delete_spec.rb b/spec/ruby/core/string/delete_spec.rb index ded63f1719dff6..b6e54f8386b619 100644 --- a/spec/ruby/core/string/delete_spec.rb +++ b/spec/ruby/core/string/delete_spec.rb @@ -70,10 +70,10 @@ ruby_version_is ''...'2.7' do it "taints result when self is tainted" do - "hello".taint.delete("e").tainted?.should == true - "hello".taint.delete("a-z").tainted?.should == true + "hello".taint.delete("e").should.tainted? + "hello".taint.delete("a-z").should.tainted? - "hello".delete("e".taint).tainted?.should == false + "hello".delete("e".taint).should_not.tainted? end end diff --git a/spec/ruby/core/string/delete_suffix_spec.rb b/spec/ruby/core/string/delete_suffix_spec.rb index d5b6880193608f..dbb5f9df9e5d94 100644 --- a/spec/ruby/core/string/delete_suffix_spec.rb +++ b/spec/ruby/core/string/delete_suffix_spec.rb @@ -23,8 +23,8 @@ ruby_version_is ''...'2.7' do it "taints resulting strings when other is tainted" do - 'hello'.taint.delete_suffix('ello').tainted?.should == true - 'hello'.taint.delete_suffix('').tainted?.should == true + 'hello'.taint.delete_suffix('ello').should.tainted? + 'hello'.taint.delete_suffix('').should.tainted? end end diff --git a/spec/ruby/core/string/downcase_spec.rb b/spec/ruby/core/string/downcase_spec.rb index 32e04e8a2c8003..8c840bdcc4e17e 100644 --- a/spec/ruby/core/string/downcase_spec.rb +++ b/spec/ruby/core/string/downcase_spec.rb @@ -70,9 +70,9 @@ ruby_version_is ''...'2.7' do it "taints result when self is tainted" do - "".taint.downcase.tainted?.should == true - "x".taint.downcase.tainted?.should == true - "X".taint.downcase.tainted?.should == true + "".taint.downcase.should.tainted? + "x".taint.downcase.should.tainted? + "X".taint.downcase.should.tainted? end end diff --git a/spec/ruby/core/string/dump_spec.rb b/spec/ruby/core/string/dump_spec.rb index 260ee37adbf02e..ebdd0167aa5db5 100644 --- a/spec/ruby/core/string/dump_spec.rb +++ b/spec/ruby/core/string/dump_spec.rb @@ -5,18 +5,18 @@ describe "String#dump" do ruby_version_is ''...'2.7' do it "taints the result if self is tainted" do - "foo".taint.dump.tainted?.should == true - "foo\n".taint.dump.tainted?.should == true + "foo".taint.dump.should.tainted? + "foo\n".taint.dump.should.tainted? end it "untrusts the result if self is untrusted" do - "foo".untrust.dump.untrusted?.should == true - "foo\n".untrust.dump.untrusted?.should == true + "foo".untrust.dump.should.untrusted? + "foo\n".untrust.dump.should.untrusted? end end it "does not take into account if a string is frozen" do - "foo".freeze.dump.frozen?.should == false + "foo".freeze.dump.should_not.frozen? end it "returns a subclass instance" do diff --git a/spec/ruby/core/string/element_set_spec.rb b/spec/ruby/core/string/element_set_spec.rb index e375b4570ebc8b..641d46bc911e06 100644 --- a/spec/ruby/core/string/element_set_spec.rb +++ b/spec/ruby/core/string/element_set_spec.rb @@ -18,11 +18,11 @@ it "taints self if other_str is tainted" do a = "hello" a[0] = "".taint - a.tainted?.should == true + a.should.tainted? a = "hello" a[0] = "x".taint - a.tainted?.should == true + a.should.tainted? end end @@ -491,11 +491,11 @@ it "taints self if other_str is tainted" do a = "hello" a[0, 0] = "".taint - a.tainted?.should == true + a.should.tainted? a = "hello" a[1, 4] = "x".taint - a.tainted?.should == true + a.should.tainted? end end diff --git a/spec/ruby/core/string/empty_spec.rb b/spec/ruby/core/string/empty_spec.rb index fb52070723e40b..8e53a16afc2909 100644 --- a/spec/ruby/core/string/empty_spec.rb +++ b/spec/ruby/core/string/empty_spec.rb @@ -3,10 +3,10 @@ describe "String#empty?" do it "returns true if the string has a length of zero" do - "hello".empty?.should == false - " ".empty?.should == false - "\x00".empty?.should == false - "".empty?.should == true - StringSpecs::MyString.new("").empty?.should == true + "hello".should_not.empty? + " ".should_not.empty? + "\x00".should_not.empty? + "".should.empty? + StringSpecs::MyString.new("").should.empty? end end diff --git a/spec/ruby/core/string/gsub_spec.rb b/spec/ruby/core/string/gsub_spec.rb index 8193464d48abfb..23e0ad2260fa7a 100644 --- a/spec/ruby/core/string/gsub_spec.rb +++ b/spec/ruby/core/string/gsub_spec.rb @@ -171,14 +171,14 @@ hello_t.taint; a_t.taint; empty_t.taint - hello_t.gsub(/./, a).tainted?.should == true - hello_t.gsub(/./, empty).tainted?.should == true + hello_t.gsub(/./, a).should.tainted? + hello_t.gsub(/./, empty).should.tainted? - hello.gsub(/./, a_t).tainted?.should == true - hello.gsub(/./, empty_t).tainted?.should == true - hello.gsub(//, empty_t).tainted?.should == true + hello.gsub(/./, a_t).should.tainted? + hello.gsub(/./, empty_t).should.tainted? + hello.gsub(//, empty_t).should.tainted? - hello.gsub(//.taint, "foo").tainted?.should == false + hello.gsub(//.taint, "foo").should_not.tainted? end end @@ -199,14 +199,14 @@ hello_t.untrust; a_t.untrust; empty_t.untrust - hello_t.gsub(/./, a).untrusted?.should == true - hello_t.gsub(/./, empty).untrusted?.should == true + hello_t.gsub(/./, a).should.untrusted? + hello_t.gsub(/./, empty).should.untrusted? - hello.gsub(/./, a_t).untrusted?.should == true - hello.gsub(/./, empty_t).untrusted?.should == true - hello.gsub(//, empty_t).untrusted?.should == true + hello.gsub(/./, a_t).should.untrusted? + hello.gsub(/./, empty_t).should.untrusted? + hello.gsub(//, empty_t).should.untrusted? - hello.gsub(//.untrust, "foo").untrusted?.should == false + hello.gsub(//.untrust, "foo").should_not.untrusted? end end @@ -521,14 +521,14 @@ def obj.to_s() "ok" end hello_t.untrust; a_t.untrust; empty_t.untrust - hello_t.gsub(/./) { a }.untrusted?.should == true - hello_t.gsub(/./) { empty }.untrusted?.should == true + hello_t.gsub(/./) { a }.should.untrusted? + hello_t.gsub(/./) { empty }.should.untrusted? - hello.gsub(/./) { a_t }.untrusted?.should == true - hello.gsub(/./) { empty_t }.untrusted?.should == true - hello.gsub(//) { empty_t }.untrusted?.should == true + hello.gsub(/./) { a_t }.should.untrusted? + hello.gsub(/./) { empty_t }.should.untrusted? + hello.gsub(//) { empty_t }.should.untrusted? - hello.gsub(//.untrust) { "foo" }.untrusted?.should == false + hello.gsub(//.untrust) { "foo" }.should_not.untrusted? end end @@ -594,14 +594,14 @@ def obj.to_s() "ok" end ruby_version_is ''...'2.7' do it "taints self if replacement is tainted" do a = "hello" - a.gsub!(/./.taint, "foo").tainted?.should == false - a.gsub!(/./, "foo".taint).tainted?.should == true + a.gsub!(/./.taint, "foo").should_not.tainted? + a.gsub!(/./, "foo".taint).should.tainted? end it "untrusts self if replacement is untrusted" do a = "hello" - a.gsub!(/./.untrust, "foo").untrusted?.should == false - a.gsub!(/./, "foo".untrust).untrusted?.should == true + a.gsub!(/./.untrust, "foo").should_not.untrusted? + a.gsub!(/./, "foo".untrust).should.untrusted? end end @@ -633,14 +633,14 @@ def obj.to_s() "ok" end ruby_version_is ''...'2.7' do it "taints self if block's result is tainted" do a = "hello" - a.gsub!(/./.taint) { "foo" }.tainted?.should == false - a.gsub!(/./) { "foo".taint }.tainted?.should == true + a.gsub!(/./.taint) { "foo" }.should_not.tainted? + a.gsub!(/./) { "foo".taint }.should.tainted? end it "untrusts self if block's result is untrusted" do a = "hello" - a.gsub!(/./.untrust) { "foo" }.untrusted?.should == false - a.gsub!(/./) { "foo".untrust }.untrusted?.should == true + a.gsub!(/./.untrust) { "foo" }.should_not.untrusted? + a.gsub!(/./) { "foo".untrust }.should.untrusted? end end diff --git a/spec/ruby/core/string/insert_spec.rb b/spec/ruby/core/string/insert_spec.rb index b26845419f9c12..752cbb2f376f7a 100644 --- a/spec/ruby/core/string/insert_spec.rb +++ b/spec/ruby/core/string/insert_spec.rb @@ -44,12 +44,12 @@ ruby_version_is ''...'2.7' do it "taints self if string to insert is tainted" do str = "abcd" - str.insert(0, "T".taint).tainted?.should == true + str.insert(0, "T".taint).should.tainted? str = "abcd" other = mock('T') def other.to_str() "T".taint end - str.insert(0, other).tainted?.should == true + str.insert(0, other).should.tainted? end end diff --git a/spec/ruby/core/string/inspect_spec.rb b/spec/ruby/core/string/inspect_spec.rb index e63d89ead5e647..9818796c83133f 100644 --- a/spec/ruby/core/string/inspect_spec.rb +++ b/spec/ruby/core/string/inspect_spec.rb @@ -5,13 +5,13 @@ describe "String#inspect" do ruby_version_is ''...'2.7' do it "taints the result if self is tainted" do - "foo".taint.inspect.tainted?.should == true - "foo\n".taint.inspect.tainted?.should == true + "foo".taint.inspect.should.tainted? + "foo\n".taint.inspect.should.tainted? end it "untrusts the result if self is untrusted" do - "foo".untrust.inspect.untrusted?.should == true - "foo\n".untrust.inspect.untrusted?.should == true + "foo".untrust.inspect.should.untrusted? + "foo\n".untrust.inspect.should.untrusted? end end diff --git a/spec/ruby/core/string/ljust_spec.rb b/spec/ruby/core/string/ljust_spec.rb index f377e397759907..481ef77ca85b6f 100644 --- a/spec/ruby/core/string/ljust_spec.rb +++ b/spec/ruby/core/string/ljust_spec.rb @@ -33,11 +33,11 @@ ruby_version_is ''...'2.7' do it "taints result when self or padstr is tainted" do - "x".taint.ljust(4).tainted?.should == true - "x".taint.ljust(0).tainted?.should == true - "".taint.ljust(0).tainted?.should == true - "x".taint.ljust(4, "*").tainted?.should == true - "x".ljust(4, "*".taint).tainted?.should == true + "x".taint.ljust(4).should.tainted? + "x".taint.ljust(0).should.tainted? + "".taint.ljust(0).should.tainted? + "x".taint.ljust(4, "*").should.tainted? + "x".ljust(4, "*".taint).should.tainted? end end diff --git a/spec/ruby/core/string/lstrip_spec.rb b/spec/ruby/core/string/lstrip_spec.rb index 902d660455fb42..12c7b132005774 100644 --- a/spec/ruby/core/string/lstrip_spec.rb +++ b/spec/ruby/core/string/lstrip_spec.rb @@ -16,9 +16,9 @@ ruby_version_is ''...'2.7' do it "taints the result when self is tainted" do - "".taint.lstrip.tainted?.should == true - "ok".taint.lstrip.tainted?.should == true - " ok".taint.lstrip.tainted?.should == true + "".taint.lstrip.should.tainted? + "ok".taint.lstrip.should.tainted? + " ok".taint.lstrip.should.tainted? end end end diff --git a/spec/ruby/core/string/modulo_spec.rb b/spec/ruby/core/string/modulo_spec.rb index ad4b85e3c3c641..dc11ced4e285eb 100644 --- a/spec/ruby/core/string/modulo_spec.rb +++ b/spec/ruby/core/string/modulo_spec.rb @@ -319,8 +319,8 @@ def universal.to_f() 0.0 end subcls_format.taint format.taint - (format % universal).tainted?.should == true - (subcls_format % universal).tainted?.should == true + (format % universal).should.tainted? + (subcls_format % universal).should.tainted? end end end @@ -583,12 +583,12 @@ def obj.inspect() "obj" end obj = mock('x') def obj.inspect() "x".taint end - ("%p" % obj).tainted?.should == true + ("%p" % obj).should.tainted? obj = mock('x'); obj.taint def obj.inspect() "x" end - ("%p" % obj).tainted?.should == false + ("%p" % obj).should_not.tainted? end end @@ -622,8 +622,8 @@ def obj.to_s() "obj" end ruby_version_is ''...'2.7' do it "taints result for %s when argument is tainted" do - ("%s" % "x".taint).tainted?.should == true - ("%s" % mock('x').taint).tainted?.should == true + ("%s" % "x".taint).should.tainted? + ("%s" % mock('x').taint).should.tainted? end end @@ -789,7 +789,7 @@ def obj.to_s() "obj" end ruby_version_is ''...'2.7' do it "doesn't taint the result for #{format} when argument is tainted" do - (format % "5".taint).tainted?.should == false + (format % "5".taint).should_not.tainted? end end end diff --git a/spec/ruby/core/string/reverse_spec.rb b/spec/ruby/core/string/reverse_spec.rb index 30d5385c838723..cf4956a5285b11 100644 --- a/spec/ruby/core/string/reverse_spec.rb +++ b/spec/ruby/core/string/reverse_spec.rb @@ -12,8 +12,8 @@ ruby_version_is ''...'2.7' do it "taints the result if self is tainted" do - "".taint.reverse.tainted?.should == true - "m".taint.reverse.tainted?.should == true + "".taint.reverse.should.tainted? + "m".taint.reverse.should.tainted? end end diff --git a/spec/ruby/core/string/rjust_spec.rb b/spec/ruby/core/string/rjust_spec.rb index 9285ecb6a73d49..bf39f4fdb9bc61 100644 --- a/spec/ruby/core/string/rjust_spec.rb +++ b/spec/ruby/core/string/rjust_spec.rb @@ -33,11 +33,11 @@ ruby_version_is ''...'2.7' do it "taints result when self or padstr is tainted" do - "x".taint.rjust(4).tainted?.should == true - "x".taint.rjust(0).tainted?.should == true - "".taint.rjust(0).tainted?.should == true - "x".taint.rjust(4, "*").tainted?.should == true - "x".rjust(4, "*".taint).tainted?.should == true + "x".taint.rjust(4).should.tainted? + "x".taint.rjust(0).should.tainted? + "".taint.rjust(0).should.tainted? + "x".taint.rjust(4, "*").should.tainted? + "x".rjust(4, "*".taint).should.tainted? end end diff --git a/spec/ruby/core/string/rstrip_spec.rb b/spec/ruby/core/string/rstrip_spec.rb index 0a01ffad7303e4..57e1867956bdfe 100644 --- a/spec/ruby/core/string/rstrip_spec.rb +++ b/spec/ruby/core/string/rstrip_spec.rb @@ -16,9 +16,9 @@ ruby_version_is ''...'2.7' do it "taints the result when self is tainted" do - "".taint.rstrip.tainted?.should == true - "ok".taint.rstrip.tainted?.should == true - "ok ".taint.rstrip.tainted?.should == true + "".taint.rstrip.should.tainted? + "ok".taint.rstrip.should.tainted? + "ok ".taint.rstrip.should.tainted? end end end diff --git a/spec/ruby/core/string/shared/chars.rb b/spec/ruby/core/string/shared/chars.rb index 9c7a4deb8b08f2..1f045e45303385 100644 --- a/spec/ruby/core/string/shared/chars.rb +++ b/spec/ruby/core/string/shared/chars.rb @@ -69,11 +69,11 @@ str = "hello" str.send(@method) do |x| - x.tainted?.should == false + x.should_not.tainted? end str.dup.taint.send(@method) do |x| - x.tainted?.should == true + x.should.tainted? end end end diff --git a/spec/ruby/core/string/shared/concat.rb b/spec/ruby/core/string/shared/concat.rb index d127b08e9cffa2..d6ffad7d4d9683 100644 --- a/spec/ruby/core/string/shared/concat.rb +++ b/spec/ruby/core/string/shared/concat.rb @@ -41,13 +41,13 @@ ruby_version_is ''...'2.7' do it "taints self if other is tainted" do - "x".send(@method, "".taint).tainted?.should == true - "x".send(@method, "y".taint).tainted?.should == true + "x".send(@method, "".taint).should.tainted? + "x".send(@method, "y".taint).should.tainted? end it "untrusts self if other is untrusted" do - "x".send(@method, "".untrust).untrusted?.should == true - "x".send(@method, "y".untrust).untrusted?.should == true + "x".send(@method, "".untrust).should.untrusted? + "x".send(@method, "y".untrust).should.untrusted? end end diff --git a/spec/ruby/core/string/shared/each_line.rb b/spec/ruby/core/string/shared/each_line.rb index c82e63cfe8a088..156565ff138a33 100644 --- a/spec/ruby/core/string/shared/each_line.rb +++ b/spec/ruby/core/string/shared/each_line.rb @@ -42,9 +42,9 @@ ruby_version_is ''...'2.7' do it "taints substrings that are passed to the block if self is tainted" do - "one\ntwo\r\nthree".taint.send(@method) { |s| s.tainted?.should == true } + "one\ntwo\r\nthree".taint.send(@method) { |s| s.should.tainted? } - "x.y.".send(@method, ".".taint) { |s| s.tainted?.should == false } + "x.y.".send(@method, ".".taint) { |s| s.should_not.tainted? } end end diff --git a/spec/ruby/core/string/shared/replace.rb b/spec/ruby/core/string/shared/replace.rb index 3c5a15e12dae45..8dfac49f029855 100644 --- a/spec/ruby/core/string/shared/replace.rb +++ b/spec/ruby/core/string/shared/replace.rb @@ -15,28 +15,28 @@ a = "" b = "".taint a.send(@method, b) - a.tainted?.should == true + a.should.tainted? end it "does not untaint self if other is untainted" do a = "".taint b = "" a.send(@method, b) - a.tainted?.should == true + a.should.tainted? end it "untrusts self if other is untrusted" do a = "" b = "".untrust a.send(@method, b) - a.untrusted?.should == true + a.should.untrusted? end it "does not trust self if other is trusted" do a = "".untrust b = "" a.send(@method, b) - a.untrusted?.should == true + a.should.untrusted? end end diff --git a/spec/ruby/core/string/shared/slice.rb b/spec/ruby/core/string/shared/slice.rb index 1c438bc48d0e5a..6b6f37217a58a8 100644 --- a/spec/ruby/core/string/shared/slice.rb +++ b/spec/ruby/core/string/shared/slice.rb @@ -85,9 +85,9 @@ str = "hello world" str.taint - str.send(@method, 0,0).tainted?.should == true - str.send(@method, 0,1).tainted?.should == true - str.send(@method, 2,1).tainted?.should == true + str.send(@method, 0,0).should.tainted? + str.send(@method, 0,1).should.tainted? + str.send(@method, 2,1).should.tainted? end end @@ -243,12 +243,12 @@ str = "hello world" str.taint - str.send(@method, 0..0).tainted?.should == true - str.send(@method, 0...0).tainted?.should == true - str.send(@method, 0..1).tainted?.should == true - str.send(@method, 0...1).tainted?.should == true - str.send(@method, 2..3).tainted?.should == true - str.send(@method, 2..0).tainted?.should == true + str.send(@method, 0..0).should.tainted? + str.send(@method, 0...0).should.tainted? + str.send(@method, 0..1).should.tainted? + str.send(@method, 0...1).should.tainted? + str.send(@method, 2..3).should.tainted? + str.send(@method, 2..0).should.tainted? end end @@ -338,7 +338,7 @@ tainted_re = /./ tainted_re.taint - str.send(@method, tainted_re).tainted?.should == true + str.send(@method, tainted_re).should.tainted? end end @@ -395,9 +395,9 @@ tainted_re = /(.)(.)(.)/ tainted_re.taint - str.send(@method, tainted_re, 0).tainted?.should == true - str.send(@method, tainted_re, 1).tainted?.should == true - str.send(@method, tainted_re, -1).tainted?.should == true + str.send(@method, tainted_re, 0).should.tainted? + str.send(@method, tainted_re, 1).should.tainted? + str.send(@method, tainted_re, -1).should.tainted? end end diff --git a/spec/ruby/core/string/shared/succ.rb b/spec/ruby/core/string/shared/succ.rb index 346ccee4093f95..7ca488dd882daf 100644 --- a/spec/ruby/core/string/shared/succ.rb +++ b/spec/ruby/core/string/shared/succ.rb @@ -68,7 +68,7 @@ ruby_version_is ''...'2.7' do it "taints the result if self is tainted" do ["", "a", "z", "Z", "9", "\xFF", "\xFF\xFF"].each do |s| - s.taint.send(@method).tainted?.should == true + s.taint.send(@method).should.tainted? end end end diff --git a/spec/ruby/core/string/shared/to_s.rb b/spec/ruby/core/string/shared/to_s.rb index 36283be4d04caf..b8c9b8ab441571 100644 --- a/spec/ruby/core/string/shared/to_s.rb +++ b/spec/ruby/core/string/shared/to_s.rb @@ -13,8 +13,8 @@ ruby_version_is ''...'2.7' do it "taints the result when self is tainted" do - "x".taint.send(@method).tainted?.should == true - StringSpecs::MyString.new("x").taint.send(@method).tainted?.should == true + "x".taint.send(@method).should.tainted? + StringSpecs::MyString.new("x").taint.send(@method).should.tainted? end end end diff --git a/spec/ruby/core/string/shared/to_sym.rb b/spec/ruby/core/string/shared/to_sym.rb index 1180d647123e3d..416f302aefd211 100644 --- a/spec/ruby/core/string/shared/to_sym.rb +++ b/spec/ruby/core/string/shared/to_sym.rb @@ -55,7 +55,7 @@ it "raises an EncodingError for UTF-8 String containing invalid bytes" do invalid_utf8 = "\xC3" - invalid_utf8.valid_encoding?.should == false + invalid_utf8.should_not.valid_encoding? -> { invalid_utf8.send(@method) }.should raise_error(EncodingError, /invalid/) diff --git a/spec/ruby/core/string/slice_spec.rb b/spec/ruby/core/string/slice_spec.rb index a34dd1b8d4a923..bd0a63971b848a 100644 --- a/spec/ruby/core/string/slice_spec.rb +++ b/spec/ruby/core/string/slice_spec.rb @@ -99,8 +99,8 @@ str = "hello world" str.taint - str.slice!(0, 0).tainted?.should == true - str.slice!(2, 1).tainted?.should == true + str.slice!(0, 0).should.tainted? + str.slice!(2, 1).should.tainted? end end @@ -191,8 +191,8 @@ def obj.method_missing(name, *) name == :to_int ? 2 : super; end str = "hello world" str.taint - str.slice!(0..0).tainted?.should == true - str.slice!(2..3).tainted?.should == true + str.slice!(0..0).should.tainted? + str.slice!(2..3).should.tainted? end end @@ -288,14 +288,14 @@ def to.method_missing(name) name == :to_int ? -2 : super; end tainted_re = /./ tainted_re.taint - str.slice!(tainted_re).tainted?.should == true + str.slice!(tainted_re).should.tainted? end end it "doesn't taint self when regexp is tainted" do s = "hello" s.slice!(/./.taint) - s.tainted?.should == false + s.should_not.tainted? end end @@ -349,14 +349,14 @@ def to.method_missing(name) name == :to_int ? -2 : super; end tainted_re = /(.)(.)(.)/ tainted_re.taint - str.slice!(tainted_re, 1).tainted?.should == true + str.slice!(tainted_re, 1).should.tainted? end end it "doesn't taint self when regexp is tainted" do s = "hello" s.slice!(/(.)(.)/.taint, 1) - s.tainted?.should == false + s.should_not.tainted? end end diff --git a/spec/ruby/core/string/split_spec.rb b/spec/ruby/core/string/split_spec.rb index 8a740b04caaaa3..34a50a5f131f66 100644 --- a/spec/ruby/core/string/split_spec.rb +++ b/spec/ruby/core/string/split_spec.rb @@ -189,11 +189,11 @@ ["", ".", " "].each do |pat| [-1, 0, 1, 2].each do |limit| str.dup.taint.split(pat).each do |x| - x.tainted?.should == true + x.should.tainted? end str.split(pat.dup.taint).each do |x| - x.tainted?.should == false + x.should_not.tainted? end end end diff --git a/spec/ruby/core/string/squeeze_spec.rb b/spec/ruby/core/string/squeeze_spec.rb index e54ed42b49e60e..5a7fbb59def7ae 100644 --- a/spec/ruby/core/string/squeeze_spec.rb +++ b/spec/ruby/core/string/squeeze_spec.rb @@ -56,11 +56,11 @@ ruby_version_is ''...'2.7' do it "taints the result when self is tainted" do - "hello".taint.squeeze("e").tainted?.should == true - "hello".taint.squeeze("a-z").tainted?.should == true + "hello".taint.squeeze("e").should.tainted? + "hello".taint.squeeze("a-z").should.tainted? - "hello".squeeze("e".taint).tainted?.should == false - "hello".squeeze("l".taint).tainted?.should == false + "hello".squeeze("e".taint).should_not.tainted? + "hello".squeeze("l".taint).should_not.tainted? end end diff --git a/spec/ruby/core/string/strip_spec.rb b/spec/ruby/core/string/strip_spec.rb index 1838e07f32085a..252d4a9cc3b4f0 100644 --- a/spec/ruby/core/string/strip_spec.rb +++ b/spec/ruby/core/string/strip_spec.rb @@ -15,9 +15,9 @@ ruby_version_is ''...'2.7' do it "taints the result when self is tainted" do - "".taint.strip.tainted?.should == true - "ok".taint.strip.tainted?.should == true - " ok ".taint.strip.tainted?.should == true + "".taint.strip.should.tainted? + "ok".taint.strip.should.tainted? + " ok ".taint.strip.should.tainted? end end end diff --git a/spec/ruby/core/string/sub_spec.rb b/spec/ruby/core/string/sub_spec.rb index f240cd8cffe921..80cf8622d5496a 100644 --- a/spec/ruby/core/string/sub_spec.rb +++ b/spec/ruby/core/string/sub_spec.rb @@ -148,14 +148,14 @@ hello_t.taint; a_t.taint; empty_t.taint - hello_t.sub(/./, a).tainted?.should == true - hello_t.sub(/./, empty).tainted?.should == true + hello_t.sub(/./, a).should.tainted? + hello_t.sub(/./, empty).should.tainted? - hello.sub(/./, a_t).tainted?.should == true - hello.sub(/./, empty_t).tainted?.should == true - hello.sub(//, empty_t).tainted?.should == true + hello.sub(/./, a_t).should.tainted? + hello.sub(/./, empty_t).should.tainted? + hello.sub(//, empty_t).should.tainted? - hello.sub(//.taint, "foo").tainted?.should == false + hello.sub(//.taint, "foo").should_not.tainted? end end @@ -298,14 +298,14 @@ hello_t.taint; a_t.taint; empty_t.taint - hello_t.sub(/./) { a }.tainted?.should == true - hello_t.sub(/./) { empty }.tainted?.should == true + hello_t.sub(/./) { a }.should.tainted? + hello_t.sub(/./) { empty }.should.tainted? - hello.sub(/./) { a_t }.tainted?.should == true - hello.sub(/./) { empty_t }.tainted?.should == true - hello.sub(//) { empty_t }.tainted?.should == true + hello.sub(/./) { a_t }.should.tainted? + hello.sub(/./) { empty_t }.should.tainted? + hello.sub(//) { empty_t }.should.tainted? - hello.sub(//.taint) { "foo" }.tainted?.should == false + hello.sub(//.taint) { "foo" }.should_not.tainted? end end end @@ -320,8 +320,8 @@ ruby_version_is ''...'2.7' do it "taints self if replacement is tainted" do a = "hello" - a.sub!(/./.taint, "foo").tainted?.should == false - a.sub!(/./, "foo".taint).tainted?.should == true + a.sub!(/./.taint, "foo").should_not.tainted? + a.sub!(/./, "foo".taint).should.tainted? end end @@ -370,8 +370,8 @@ ruby_version_is ''...'2.7' do it "taints self if block's result is tainted" do a = "hello" - a.sub!(/./.taint) { "foo" }.tainted?.should == false - a.sub!(/./) { "foo".taint }.tainted?.should == true + a.sub!(/./.taint) { "foo" }.should_not.tainted? + a.sub!(/./) { "foo".taint }.should.tainted? end end diff --git a/spec/ruby/core/string/swapcase_spec.rb b/spec/ruby/core/string/swapcase_spec.rb index d1e908d71dd5cb..0b50cc35c48882 100644 --- a/spec/ruby/core/string/swapcase_spec.rb +++ b/spec/ruby/core/string/swapcase_spec.rb @@ -11,8 +11,8 @@ ruby_version_is ''...'2.7' do it "taints resulting string when self is tainted" do - "".taint.swapcase.tainted?.should == true - "hello".taint.swapcase.tainted?.should == true + "".taint.swapcase.should.tainted? + "hello".taint.swapcase.should.tainted? end end diff --git a/spec/ruby/core/string/tr_s_spec.rb b/spec/ruby/core/string/tr_s_spec.rb index e004ab713c5477..cdf5667ea3701a 100644 --- a/spec/ruby/core/string/tr_s_spec.rb +++ b/spec/ruby/core/string/tr_s_spec.rb @@ -54,10 +54,10 @@ ["h", "hello"].each do |str| tainted_str = str.dup.taint - tainted_str.tr_s("e", "a").tainted?.should == true + tainted_str.tr_s("e", "a").should.tainted? - str.tr_s("e".taint, "a").tainted?.should == false - str.tr_s("e", "a".taint).tainted?.should == false + str.tr_s("e".taint, "a").should_not.tainted? + str.tr_s("e", "a".taint).should_not.tainted? end end end diff --git a/spec/ruby/core/string/tr_spec.rb b/spec/ruby/core/string/tr_spec.rb index 0e4da398d54d8e..212d06f6790c8a 100644 --- a/spec/ruby/core/string/tr_spec.rb +++ b/spec/ruby/core/string/tr_spec.rb @@ -66,10 +66,10 @@ ["h", "hello"].each do |str| tainted_str = str.dup.taint - tainted_str.tr("e", "a").tainted?.should == true + tainted_str.tr("e", "a").should.tainted? - str.tr("e".taint, "a").tainted?.should == false - str.tr("e", "a".taint).tainted?.should == false + str.tr("e".taint, "a").should_not.tainted? + str.tr("e", "a".taint).should_not.tainted? end end end diff --git a/spec/ruby/core/string/uminus_spec.rb b/spec/ruby/core/string/uminus_spec.rb index 85b484b6df7509..91f91fdb1ec354 100644 --- a/spec/ruby/core/string/uminus_spec.rb +++ b/spec/ruby/core/string/uminus_spec.rb @@ -6,14 +6,14 @@ output = -input output.should equal(input) - output.frozen?.should == true + output.should.frozen? end it 'returns a frozen copy if the String is not frozen' do input = 'foo' output = -input - output.frozen?.should == true + output.should.frozen? output.should_not equal(input) output.should == 'foo' end diff --git a/spec/ruby/core/string/undump_spec.rb b/spec/ruby/core/string/undump_spec.rb index 81deb6fa58234f..b990aa25eed90c 100644 --- a/spec/ruby/core/string/undump_spec.rb +++ b/spec/ruby/core/string/undump_spec.rb @@ -5,16 +5,16 @@ describe "String#undump" do ruby_version_is ''...'2.7' do it "taints the result if self is tainted" do - '"foo"'.taint.undump.tainted?.should == true + '"foo"'.taint.undump.should.tainted? end it "untrusts the result if self is untrusted" do - '"foo"'.untrust.undump.untrusted?.should == true + '"foo"'.untrust.undump.should.untrusted? end end it "does not take into account if a string is frozen" do - '"foo"'.freeze.undump.frozen?.should == false + '"foo"'.freeze.undump.should_not.frozen? end it "always returns String instance" do diff --git a/spec/ruby/core/string/unicode_normalized_spec.rb b/spec/ruby/core/string/unicode_normalized_spec.rb index 25c810a98f6569..87f3740459bb0b 100644 --- a/spec/ruby/core/string/unicode_normalized_spec.rb +++ b/spec/ruby/core/string/unicode_normalized_spec.rb @@ -24,16 +24,16 @@ end it "defaults to the nfc normalization form if no forms are specified" do - @nfc_normalized_str.unicode_normalized?.should == true - @nfd_normalized_str.unicode_normalized?.should == false + @nfc_normalized_str.should.unicode_normalized? + @nfd_normalized_str.should_not.unicode_normalized? end it "returns true if string is empty" do - "".unicode_normalized?.should == true + "".should.unicode_normalized? end it "returns true if string does not contain any unicode codepoints" do - "abc".unicode_normalized?.should == true + "abc".should.unicode_normalized? end it "raises an Encoding::CompatibilityError if the string is not in an unicode encoding" do diff --git a/spec/ruby/core/string/upcase_spec.rb b/spec/ruby/core/string/upcase_spec.rb index c440b1b0aa8ed7..13ebd09a95078d 100644 --- a/spec/ruby/core/string/upcase_spec.rb +++ b/spec/ruby/core/string/upcase_spec.rb @@ -67,9 +67,9 @@ ruby_version_is ''...'2.7' do it "taints result when self is tainted" do - "".taint.upcase.tainted?.should == true - "X".taint.upcase.tainted?.should == true - "x".taint.upcase.tainted?.should == true + "".taint.upcase.should.tainted? + "X".taint.upcase.should.tainted? + "x".taint.upcase.should.tainted? end end diff --git a/spec/ruby/core/string/uplus_spec.rb b/spec/ruby/core/string/uplus_spec.rb index a7402b45498cdb..038b283c90eff0 100644 --- a/spec/ruby/core/string/uplus_spec.rb +++ b/spec/ruby/core/string/uplus_spec.rb @@ -5,7 +5,7 @@ input = 'foo'.freeze output = +input - output.frozen?.should == false + output.should_not.frozen? output.should == 'foo' end diff --git a/spec/ruby/core/symbol/to_proc_spec.rb b/spec/ruby/core/symbol/to_proc_spec.rb index 6651022375f17b..32f996d63c373c 100644 --- a/spec/ruby/core/symbol/to_proc_spec.rb +++ b/spec/ruby/core/symbol/to_proc_spec.rb @@ -15,7 +15,7 @@ ruby_version_is ""..."2.8" do it "returns a Proc with #lambda? false" do pr = :to_s.to_proc - pr.lambda?.should == false + pr.should_not.lambda? end it "produces a Proc with arity -1" do @@ -32,7 +32,7 @@ ruby_version_is "2.8" do it "returns a Proc with #lambda? true" do pr = :to_s.to_proc - pr.lambda?.should == true + pr.should.lambda? end it "produces a Proc with arity -2" do diff --git a/spec/ruby/core/systemexit/success_spec.rb b/spec/ruby/core/systemexit/success_spec.rb index 6d36509c808a7b..ba2fd22ded4f97 100644 --- a/spec/ruby/core/systemexit/success_spec.rb +++ b/spec/ruby/core/systemexit/success_spec.rb @@ -3,11 +3,11 @@ describe "SystemExit#success?" do it "returns true when the status is 0" do s = SystemExit.new 0 - s.success?.should == true + s.should.success? end it "returns false when the status is not 0" do s = SystemExit.new 1 - s.success?.should == false + s.should_not.success? end end diff --git a/spec/ruby/core/thread/alive_spec.rb b/spec/ruby/core/thread/alive_spec.rb index d4ba149d87beb4..c2f5f5371df5df 100644 --- a/spec/ruby/core/thread/alive_spec.rb +++ b/spec/ruby/core/thread/alive_spec.rb @@ -3,39 +3,39 @@ describe "Thread#alive?" do it "can check it's own status" do - ThreadSpecs.status_of_current_thread.alive?.should == true + ThreadSpecs.status_of_current_thread.should.alive? end it "describes a running thread" do - ThreadSpecs.status_of_running_thread.alive?.should == true + ThreadSpecs.status_of_running_thread.should.alive? end it "describes a sleeping thread" do - ThreadSpecs.status_of_sleeping_thread.alive?.should == true + ThreadSpecs.status_of_sleeping_thread.should.alive? end it "describes a blocked thread" do - ThreadSpecs.status_of_blocked_thread.alive?.should == true + ThreadSpecs.status_of_blocked_thread.should.alive? end it "describes a completed thread" do - ThreadSpecs.status_of_completed_thread.alive?.should == false + ThreadSpecs.status_of_completed_thread.should_not.alive? end it "describes a killed thread" do - ThreadSpecs.status_of_killed_thread.alive?.should == false + ThreadSpecs.status_of_killed_thread.should_not.alive? end it "describes a thread with an uncaught exception" do - ThreadSpecs.status_of_thread_with_uncaught_exception.alive?.should == false + ThreadSpecs.status_of_thread_with_uncaught_exception.should_not.alive? end it "describes a dying running thread" do - ThreadSpecs.status_of_dying_running_thread.alive?.should == true + ThreadSpecs.status_of_dying_running_thread.should.alive? end it "describes a dying sleeping thread" do - ThreadSpecs.status_of_dying_sleeping_thread.alive?.should == true + ThreadSpecs.status_of_dying_sleeping_thread.should.alive? end it "returns true for a killed but still running thread" do @@ -51,7 +51,7 @@ ThreadSpecs.spin_until_sleeping(t) t.kill - t.alive?.should == true + t.should.alive? exit = true t.join end diff --git a/spec/ruby/core/thread/new_spec.rb b/spec/ruby/core/thread/new_spec.rb index 3a57149381e06a..47a836201c0a0d 100644 --- a/spec/ruby/core/thread/new_spec.rb +++ b/spec/ruby/core/thread/new_spec.rb @@ -58,13 +58,13 @@ def initialize m2 = Mutex.new t = Thread.new { m1.lock - m1.locked?.should == true + m1.should.locked? m2.lock - m2.locked?.should == true + m2.should.locked? } t.join - m1.locked?.should == false - m2.locked?.should == false + m1.should_not.locked? + m2.should_not.locked? end it "releases Mutexes held by the Thread when the Thread finishes, also with Mutex#synchronize" do @@ -75,9 +75,9 @@ def initialize m.lock } m.lock - m.locked?.should == true + m.should.locked? } t.join - m.locked?.should == false + m.should_not.locked? end end diff --git a/spec/ruby/core/thread/stop_spec.rb b/spec/ruby/core/thread/stop_spec.rb index 33cf8f7b5c0f52..084ab46ef655c0 100644 --- a/spec/ruby/core/thread/stop_spec.rb +++ b/spec/ruby/core/thread/stop_spec.rb @@ -13,42 +13,42 @@ describe "Thread#stop?" do it "can check it's own status" do - ThreadSpecs.status_of_current_thread.stop?.should == false + ThreadSpecs.status_of_current_thread.should_not.stop? end it "describes a running thread" do - ThreadSpecs.status_of_running_thread.stop?.should == false + ThreadSpecs.status_of_running_thread.should_not.stop? end it "describes a sleeping thread" do - ThreadSpecs.status_of_sleeping_thread.stop?.should == true + ThreadSpecs.status_of_sleeping_thread.should.stop? end it "describes a blocked thread" do - ThreadSpecs.status_of_blocked_thread.stop?.should == true + ThreadSpecs.status_of_blocked_thread.should.stop? end it "describes a completed thread" do - ThreadSpecs.status_of_completed_thread.stop?.should == true + ThreadSpecs.status_of_completed_thread.should.stop? end it "describes a killed thread" do - ThreadSpecs.status_of_killed_thread.stop?.should == true + ThreadSpecs.status_of_killed_thread.should.stop? end it "describes a thread with an uncaught exception" do - ThreadSpecs.status_of_thread_with_uncaught_exception.stop?.should == true + ThreadSpecs.status_of_thread_with_uncaught_exception.should.stop? end it "describes a dying running thread" do - ThreadSpecs.status_of_dying_running_thread.stop?.should == false + ThreadSpecs.status_of_dying_running_thread.should_not.stop? end it "describes a dying sleeping thread" do - ThreadSpecs.status_of_dying_sleeping_thread.stop?.should == true + ThreadSpecs.status_of_dying_sleeping_thread.should.stop? end it "describes a dying thread after sleep" do - ThreadSpecs.status_of_dying_thread_after_sleep.stop?.should == false + ThreadSpecs.status_of_dying_thread_after_sleep.should_not.stop? end end diff --git a/spec/ruby/core/time/_dump_spec.rb b/spec/ruby/core/time/_dump_spec.rb index 6941a1531f0191..4dc1c43cd2d941 100644 --- a/spec/ruby/core/time/_dump_spec.rb +++ b/spec/ruby/core/time/_dump_spec.rb @@ -15,11 +15,11 @@ # http://redmine.ruby-lang.org/issues/show/627 it "preserves the GMT flag" do - @t.gmt?.should == true + @t.should.gmt? dump = @t.send(:_dump).unpack("VV").first ((dump >> 30) & 0x1).should == 1 - @local.gmt?.should == false + @local.should_not.gmt? dump = @local.send(:_dump).unpack("VV").first ((dump >> 30) & 0x1).should == 0 end diff --git a/spec/ruby/core/time/at_spec.rb b/spec/ruby/core/time/at_spec.rb index 28a3d7b34c84fa..6f4d83f9ad450c 100644 --- a/spec/ruby/core/time/at_spec.rb +++ b/spec/ruby/core/time/at_spec.rb @@ -14,7 +14,7 @@ end it "returns a non-UTC Time" do - Time.at(1184027924).utc?.should == false + Time.at(1184027924).should_not.utc? end it "returns a subclass instance on a Time subclass" do @@ -54,12 +54,12 @@ it "returns a UTC time if the argument is UTC" do t = Time.now.getgm - Time.at(t).utc?.should == true + Time.at(t).should.utc? end it "returns a non-UTC time if the argument is non-UTC" do t = Time.now - Time.at(t).utc?.should == false + Time.at(t).should_not.utc? end it "returns a subclass instance" do diff --git a/spec/ruby/core/time/dup_spec.rb b/spec/ruby/core/time/dup_spec.rb index ee2ff7dbba81d3..5d6621beaa84f7 100644 --- a/spec/ruby/core/time/dup_spec.rb +++ b/spec/ruby/core/time/dup_spec.rb @@ -7,7 +7,7 @@ end it "copies the gmt state flag" do - Time.now.gmtime.dup.gmt?.should == true + Time.now.gmtime.dup.should.gmt? end it "returns an independent Time object" do @@ -15,7 +15,7 @@ t2 = t.dup t.gmtime - t2.gmt?.should == false + t2.should_not.gmt? end it "returns a subclass instance" do diff --git a/spec/ruby/core/time/friday_spec.rb b/spec/ruby/core/time/friday_spec.rb index 27f9e1dbe5e4a3..8bee7f755837b1 100644 --- a/spec/ruby/core/time/friday_spec.rb +++ b/spec/ruby/core/time/friday_spec.rb @@ -2,10 +2,10 @@ describe "Time#friday?" do it "returns true if time represents Friday" do - Time.local(2000, 1, 7).friday?.should == true + Time.local(2000, 1, 7).should.friday? end it "returns false if time doesn't represent Friday" do - Time.local(2000, 1, 1).friday?.should == false + Time.local(2000, 1, 1).should_not.friday? end end diff --git a/spec/ruby/core/time/gmt_spec.rb b/spec/ruby/core/time/gmt_spec.rb index 7e85749d5b249e..840f59e0e84abc 100644 --- a/spec/ruby/core/time/gmt_spec.rb +++ b/spec/ruby/core/time/gmt_spec.rb @@ -2,7 +2,7 @@ describe "Time#gmt?" do it "returns true if time represents a time in UTC (GMT)" do - Time.now.gmt?.should == false - Time.now.gmtime.gmt?.should == true + Time.now.should_not.gmt? + Time.now.gmtime.should.gmt? end end diff --git a/spec/ruby/core/time/minus_spec.rb b/spec/ruby/core/time/minus_spec.rb index 65613d11e90b9b..995dac846283d1 100644 --- a/spec/ruby/core/time/minus_spec.rb +++ b/spec/ruby/core/time/minus_spec.rb @@ -79,11 +79,11 @@ end it "returns a UTC time if self is UTC" do - (Time.utc(2012) - 10).utc?.should == true + (Time.utc(2012) - 10).should.utc? end it "returns a non-UTC time if self is non-UTC" do - (Time.local(2012) - 10).utc?.should == false + (Time.local(2012) - 10).should_not.utc? end it "returns a time with the same fixed offset as self" do diff --git a/spec/ruby/core/time/monday_spec.rb b/spec/ruby/core/time/monday_spec.rb index c5c43a5c3ef246..47ecaeb1db2a22 100644 --- a/spec/ruby/core/time/monday_spec.rb +++ b/spec/ruby/core/time/monday_spec.rb @@ -2,10 +2,10 @@ describe "Time#monday?" do it "returns true if time represents Monday" do - Time.local(2000, 1, 3).monday?.should == true + Time.local(2000, 1, 3).should.monday? end it "returns false if time doesn't represent Monday" do - Time.local(2000, 1, 1).monday?.should == false + Time.local(2000, 1, 1).should_not.monday? end end diff --git a/spec/ruby/core/time/new_spec.rb b/spec/ruby/core/time/new_spec.rb index a5cfa2a7dfe574..3cafd46db7dce4 100644 --- a/spec/ruby/core/time/new_spec.rb +++ b/spec/ruby/core/time/new_spec.rb @@ -15,7 +15,7 @@ describe "Time.new with a utc_offset argument" do it "returns a non-UTC time" do - Time.new(2000, 1, 1, 0, 0, 0, 0).utc?.should == false + Time.new(2000, 1, 1, 0, 0, 0, 0).should_not.utc? end it "returns a Time with a UTC offset of the specified number of Integer seconds" do diff --git a/spec/ruby/core/time/plus_spec.rb b/spec/ruby/core/time/plus_spec.rb index 6c29baf1247c97..c59d9a32bb6cf7 100644 --- a/spec/ruby/core/time/plus_spec.rb +++ b/spec/ruby/core/time/plus_spec.rb @@ -37,11 +37,11 @@ end it "returns a UTC time if self is UTC" do - (Time.utc(2012) + 10).utc?.should == true + (Time.utc(2012) + 10).should.utc? end it "returns a non-UTC time if self is non-UTC" do - (Time.local(2012) + 10).utc?.should == false + (Time.local(2012) + 10).should_not.utc? end it "returns a time with the same fixed offset as self" do diff --git a/spec/ruby/core/time/saturday_spec.rb b/spec/ruby/core/time/saturday_spec.rb index 60ffea41986a87..0e51407366bbf0 100644 --- a/spec/ruby/core/time/saturday_spec.rb +++ b/spec/ruby/core/time/saturday_spec.rb @@ -2,10 +2,10 @@ describe "Time#saturday?" do it "returns true if time represents Saturday" do - Time.local(2000, 1, 1).saturday?.should == true + Time.local(2000, 1, 1).should.saturday? end it "returns false if time doesn't represent Saturday" do - Time.local(2000, 1, 2).saturday?.should == false + Time.local(2000, 1, 2).should_not.saturday? end end diff --git a/spec/ruby/core/time/sunday_spec.rb b/spec/ruby/core/time/sunday_spec.rb index 2285583579d2e2..0d46421132dded 100644 --- a/spec/ruby/core/time/sunday_spec.rb +++ b/spec/ruby/core/time/sunday_spec.rb @@ -2,10 +2,10 @@ describe "Time#sunday?" do it "returns true if time represents Sunday" do - Time.local(2000, 1, 2).sunday?.should == true + Time.local(2000, 1, 2).should.sunday? end it "returns false if time doesn't represent Sunday" do - Time.local(2000, 1, 1).sunday?.should == false + Time.local(2000, 1, 1).should_not.sunday? end end diff --git a/spec/ruby/core/time/thursday_spec.rb b/spec/ruby/core/time/thursday_spec.rb index c82d5175194486..c11e79d2fa9427 100644 --- a/spec/ruby/core/time/thursday_spec.rb +++ b/spec/ruby/core/time/thursday_spec.rb @@ -2,10 +2,10 @@ describe "Time#thursday?" do it "returns true if time represents Thursday" do - Time.local(2000, 1, 6).thursday?.should == true + Time.local(2000, 1, 6).should.thursday? end it "returns false if time doesn't represent Thursday" do - Time.local(2000, 1, 1).thursday?.should == false + Time.local(2000, 1, 1).should_not.thursday? end end diff --git a/spec/ruby/core/time/tuesday_spec.rb b/spec/ruby/core/time/tuesday_spec.rb index 7abbdc92c0a96c..0e7b9e75063bd9 100644 --- a/spec/ruby/core/time/tuesday_spec.rb +++ b/spec/ruby/core/time/tuesday_spec.rb @@ -2,10 +2,10 @@ describe "Time#tuesday?" do it "returns true if time represents Tuesday" do - Time.local(2000, 1, 4).tuesday?.should == true + Time.local(2000, 1, 4).should.tuesday? end it "returns false if time doesn't represent Tuesday" do - Time.local(2000, 1, 1).tuesday?.should == false + Time.local(2000, 1, 1).should_not.tuesday? end end diff --git a/spec/ruby/core/time/utc_spec.rb b/spec/ruby/core/time/utc_spec.rb index 5074c8d54d980f..74c17a93d167ab 100644 --- a/spec/ruby/core/time/utc_spec.rb +++ b/spec/ruby/core/time/utc_spec.rb @@ -5,7 +5,7 @@ describe "Time#utc?" do it "returns true if time represents a time in UTC (GMT)" do - Time.now.utc?.should == false + Time.now.should_not.utc? end end diff --git a/spec/ruby/core/time/wednesday_spec.rb b/spec/ruby/core/time/wednesday_spec.rb index 6a52c3577bfd81..cc686681d7fafb 100644 --- a/spec/ruby/core/time/wednesday_spec.rb +++ b/spec/ruby/core/time/wednesday_spec.rb @@ -2,10 +2,10 @@ describe "Time#wednesday?" do it "returns true if time represents Wednesday" do - Time.local(2000, 1, 5).wednesday?.should == true + Time.local(2000, 1, 5).should.wednesday? end it "returns false if time doesn't represent Wednesday" do - Time.local(2000, 1, 1).wednesday?.should == false + Time.local(2000, 1, 1).should_not.wednesday? end end diff --git a/spec/ruby/core/tracepoint/disable_spec.rb b/spec/ruby/core/tracepoint/disable_spec.rb index 612ca3c25ab67f..2ab9b987f4b0bf 100644 --- a/spec/ruby/core/tracepoint/disable_spec.rb +++ b/spec/ruby/core/tracepoint/disable_spec.rb @@ -41,7 +41,7 @@ begin trace.disable { enabled = trace.enabled? } enabled.should == false - trace.enabled?.should == true + trace.should.enabled? ensure trace.disable end @@ -52,7 +52,7 @@ trace.enable begin trace.disable { 42 }.should == 42 - trace.enabled?.should == true + trace.should.enabled? ensure trace.disable end @@ -65,7 +65,7 @@ trace.disable do |*args| args.should == [] end - trace.enabled?.should == true + trace.should.enabled? ensure trace.disable end diff --git a/spec/ruby/core/tracepoint/enable_spec.rb b/spec/ruby/core/tracepoint/enable_spec.rb index b0fe38c559e8b8..15eb2f1616a4d5 100644 --- a/spec/ruby/core/tracepoint/enable_spec.rb +++ b/spec/ruby/core/tracepoint/enable_spec.rb @@ -65,7 +65,7 @@ event_name.should equal(:line) args.should == [] end - trace.enabled?.should == false + trace.should_not.enabled? end it 'enables trace object on calling with a block if it was already enabled' do @@ -92,7 +92,7 @@ line_event = true } called.should == true - trace.enabled?.should == false + trace.should_not.enabled? end end diff --git a/spec/ruby/core/tracepoint/enabled_spec.rb b/spec/ruby/core/tracepoint/enabled_spec.rb index 0167d32fb0eeaa..dbc3c214c53a55 100644 --- a/spec/ruby/core/tracepoint/enabled_spec.rb +++ b/spec/ruby/core/tracepoint/enabled_spec.rb @@ -4,11 +4,11 @@ it 'returns true when current status of the trace is enable' do trace = TracePoint.new(:line) {} trace.enable do - trace.enabled?.should == true + trace.should.enabled? end end it 'returns false when current status of the trace is disabled' do - TracePoint.new(:line) {}.enabled?.should == false + TracePoint.new(:line) {}.should_not.enabled? end end diff --git a/spec/ruby/core/tracepoint/trace_spec.rb b/spec/ruby/core/tracepoint/trace_spec.rb index ea6c85bcc55762..c39721e69298b5 100644 --- a/spec/ruby/core/tracepoint/trace_spec.rb +++ b/spec/ruby/core/tracepoint/trace_spec.rb @@ -3,7 +3,7 @@ describe 'TracePoint.trace' do it 'activates the trace automatically' do trace = TracePoint.trace(:line) {} - trace.enabled?.should == true + trace.should.enabled? trace.disable end end diff --git a/spec/ruby/core/true/to_s_spec.rb b/spec/ruby/core/true/to_s_spec.rb index 68b0052c5d5300..f26cd138e2e521 100644 --- a/spec/ruby/core/true/to_s_spec.rb +++ b/spec/ruby/core/true/to_s_spec.rb @@ -7,7 +7,7 @@ ruby_version_is "2.7" do it "returns a frozen string" do - true.to_s.frozen?.should == true + true.to_s.should.frozen? end it "always returns the same string" do diff --git a/spec/ruby/language/hash_spec.rb b/spec/ruby/language/hash_spec.rb index 6f2e8e5cf0cbbc..630c9d2364bca0 100644 --- a/spec/ruby/language/hash_spec.rb +++ b/spec/ruby/language/hash_spec.rb @@ -38,7 +38,7 @@ key.reverse! h["foo"].should == "bar" h.keys.first.should == "foo" - h.keys.first.frozen?.should == true + h.keys.first.should.frozen? key.should == "oof" end diff --git a/spec/ruby/language/predefined_spec.rb b/spec/ruby/language/predefined_spec.rb index b0616da19b7dc4..5ce4e77906ce9b 100644 --- a/spec/ruby/language/predefined_spec.rb +++ b/spec/ruby/language/predefined_spec.rb @@ -53,10 +53,10 @@ it "is set to nil if the last match was unsuccessful" do /foo/ =~ 'foo' - $~.nil?.should == false + $~.should_not.nil? /foo/ =~ 'bar' - $~.nil?.should == true + $~.should.nil? end it "is set at the method-scoped level rather than block-scoped" do diff --git a/spec/ruby/language/regexp/encoding_spec.rb b/spec/ruby/language/regexp/encoding_spec.rb index 2db09fdda859da..8e2a294b9581a4 100644 --- a/spec/ruby/language/regexp/encoding_spec.rb +++ b/spec/ruby/language/regexp/encoding_spec.rb @@ -121,11 +121,11 @@ make_regexp = -> str { /#{str}/ } r = make_regexp.call("été".force_encoding(Encoding::UTF_8)) - r.fixed_encoding?.should == true + r.should.fixed_encoding? r.encoding.should == Encoding::UTF_8 r = make_regexp.call("abc".force_encoding(Encoding::UTF_8)) - r.fixed_encoding?.should == false + r.should_not.fixed_encoding? r.encoding.should == Encoding::US_ASCII end end diff --git a/spec/ruby/language/regexp_spec.rb b/spec/ruby/language/regexp_spec.rb index cd71d543386ae0..ac3f773c492d2e 100644 --- a/spec/ruby/language/regexp_spec.rb +++ b/spec/ruby/language/regexp_spec.rb @@ -20,7 +20,7 @@ ruby_version_is "2.8" do it "is frozen" do - /Hello/.frozen?.should == true + /Hello/.should.frozen? end end diff --git a/spec/ruby/language/variables_spec.rb b/spec/ruby/language/variables_spec.rb index 7c2c7889f1b6ac..8b67289df4d6bb 100644 --- a/spec/ruby/language/variables_spec.rb +++ b/spec/ruby/language/variables_spec.rb @@ -361,7 +361,7 @@ def obj.to_a end res = *obj res.should == [1,2] - res.frozen?.should == false + res.should_not.frozen? end it "consumes values for an anonymous splat" do diff --git a/spec/ruby/library/bigdecimal/BigDecimal_spec.rb b/spec/ruby/library/bigdecimal/BigDecimal_spec.rb index faa8dc610c96a1..4e839e21a3f4a0 100644 --- a/spec/ruby/library/bigdecimal/BigDecimal_spec.rb +++ b/spec/ruby/library/bigdecimal/BigDecimal_spec.rb @@ -41,7 +41,7 @@ it "ignores leading and trailing whitespace" do BigDecimal(" \t\n \r1234\t\r\n ").should == BigDecimal("1234") - BigDecimal(" \t\n \rNaN \n").nan?.should == true + BigDecimal(" \t\n \rNaN \n").should.nan? BigDecimal(" \t\n \rInfinity \n").infinite?.should == 1 BigDecimal(" \t\n \r-Infinity \n").infinite?.should == -1 end @@ -100,42 +100,42 @@ end it "accepts NaN and [+-]Infinity" do - BigDecimal("NaN").nan?.should == true + BigDecimal("NaN").should.nan? pos_inf = BigDecimal("Infinity") - pos_inf.finite?.should == false + pos_inf.should_not.finite? pos_inf.should > 0 pos_inf.should == BigDecimal("+Infinity") neg_inf = BigDecimal("-Infinity") - neg_inf.finite?.should == false + neg_inf.should_not.finite? neg_inf.should < 0 end describe "accepts NaN and [+-]Infinity as Float values" do it "works without an explicit precision" do - BigDecimal(Float::NAN).nan?.should == true + BigDecimal(Float::NAN).should.nan? pos_inf = BigDecimal(Float::INFINITY) - pos_inf.finite?.should == false + pos_inf.should_not.finite? pos_inf.should > 0 pos_inf.should == BigDecimal("+Infinity") neg_inf = BigDecimal(-Float::INFINITY) - neg_inf.finite?.should == false + neg_inf.should_not.finite? neg_inf.should < 0 end it "works with an explicit precision" do - BigDecimal(Float::NAN, Float::DIG).nan?.should == true + BigDecimal(Float::NAN, Float::DIG).should.nan? pos_inf = BigDecimal(Float::INFINITY, Float::DIG) - pos_inf.finite?.should == false + pos_inf.should_not.finite? pos_inf.should > 0 pos_inf.should == BigDecimal("+Infinity") neg_inf = BigDecimal(-Float::INFINITY, Float::DIG) - neg_inf.finite?.should == false + neg_inf.should_not.finite? neg_inf.should < 0 end end diff --git a/spec/ruby/library/bigdecimal/abs_spec.rb b/spec/ruby/library/bigdecimal/abs_spec.rb index ddd2bae9a9fa8f..95dc45a90589e0 100644 --- a/spec/ruby/library/bigdecimal/abs_spec.rb +++ b/spec/ruby/library/bigdecimal/abs_spec.rb @@ -38,7 +38,7 @@ it "properly handles special values" do @infinity.abs.should == @infinity @infinity_minus.abs.should == @infinity - @nan.abs.nan?.should == true # have to do it this way, since == doesn't work on NaN + @nan.abs.should.nan? # have to do it this way, since == doesn't work on NaN @zero.abs.should == 0 @zero.abs.sign.should == BigDecimal::SIGN_POSITIVE_ZERO @zero_pos.abs.should == 0 diff --git a/spec/ruby/library/bigdecimal/add_spec.rb b/spec/ruby/library/bigdecimal/add_spec.rb index 5b874687fea6a3..bea8b8f7640560 100644 --- a/spec/ruby/library/bigdecimal/add_spec.rb +++ b/spec/ruby/library/bigdecimal/add_spec.rb @@ -136,8 +136,8 @@ end it "returns NaN if NaN is involved" do - @one.add(@nan, 10000).nan?.should == true - @nan.add(@one, 1).nan?.should == true + @one.add(@nan, 10000).should.nan? + @nan.add(@one, 1).should.nan? end it "returns Infinity or -Infinity if these are involved" do @@ -166,8 +166,8 @@ end it "returns NaN if Infinity + (- Infinity)" do - @infinity.add(@infinity_minus, 10000).nan?.should == true - @infinity_minus.add(@infinity, 10000).nan?.should == true + @infinity.add(@infinity_minus, 10000).should.nan? + @infinity_minus.add(@infinity, 10000).should.nan? end it "raises TypeError when adds nil" do diff --git a/spec/ruby/library/bigdecimal/div_spec.rb b/spec/ruby/library/bigdecimal/div_spec.rb index 0c9eb2ddec6275..53ad6d04184d87 100644 --- a/spec/ruby/library/bigdecimal/div_spec.rb +++ b/spec/ruby/library/bigdecimal/div_spec.rb @@ -80,13 +80,13 @@ end it "returns NaN if zero is divided by zero" do - @zero.div(@zero, 0).nan?.should == true - @zero_minus.div(@zero_plus, 0).nan?.should == true - @zero_plus.div(@zero_minus, 0).nan?.should == true + @zero.div(@zero, 0).should.nan? + @zero_minus.div(@zero_plus, 0).should.nan? + @zero_plus.div(@zero_minus, 0).should.nan? - @zero.div(@zero, 10).nan?.should == true - @zero_minus.div(@zero_plus, 10).nan?.should == true - @zero_plus.div(@zero_minus, 10).nan?.should == true + @zero.div(@zero, 10).should.nan? + @zero_minus.div(@zero_plus, 10).should.nan? + @zero_plus.div(@zero_minus, 10).should.nan? end it "raises FloatDomainError if (+|-) Infinity divided by 1 and no precision given" do @@ -102,8 +102,8 @@ end it "returns NaN if Infinity / ((+|-) Infinity)" do - @infinity.div(@infinity_minus, 100000).nan?.should == true - @infinity_minus.div(@infinity, 1).nan?.should == true + @infinity.div(@infinity_minus, 100000).should.nan? + @infinity_minus.div(@infinity, 1).should.nan? end diff --git a/spec/ruby/library/bigdecimal/divmod_spec.rb b/spec/ruby/library/bigdecimal/divmod_spec.rb index ae8b84983abcac..294f01cba01484 100644 --- a/spec/ruby/library/bigdecimal/divmod_spec.rb +++ b/spec/ruby/library/bigdecimal/divmod_spec.rb @@ -5,8 +5,8 @@ module DivmodSpecs def self.check_both_nan(array) array.length.should == 2 - array[0].nan?.should == true - array[1].nan?.should == true + array[0].should.nan? + array[1].should.nan? end def self.check_both_bigdecimal(array) array.length.should == 2 @@ -150,7 +150,7 @@ class BigDecimal array = @infinity.divmod(val) array.length.should == 2 array[0].infinite?.should == (val > 0 ? 1 : -1) - array[1].nan?.should == true + array[1].should.nan? end end diff --git a/spec/ruby/library/bigdecimal/finite_spec.rb b/spec/ruby/library/bigdecimal/finite_spec.rb index 6685d589b6a307..8fc06029bb3d76 100644 --- a/spec/ruby/library/bigdecimal/finite_spec.rb +++ b/spec/ruby/library/bigdecimal/finite_spec.rb @@ -21,14 +21,14 @@ end it "is false if Infinity or NaN" do - @infinity.finite?.should == false - @infinity_minus.finite?.should == false - @nan.finite?.should == false + @infinity.should_not.finite? + @infinity_minus.should_not.finite? + @nan.should_not.finite? end it "returns true for finite values" do @finite_vals.each do |val| - val.finite?.should == true + val.should.finite? end end end diff --git a/spec/ruby/library/bigdecimal/fix_spec.rb b/spec/ruby/library/bigdecimal/fix_spec.rb index 53b30cbf8beb38..231c9a587e3cae 100644 --- a/spec/ruby/library/bigdecimal/fix_spec.rb +++ b/spec/ruby/library/bigdecimal/fix_spec.rb @@ -34,7 +34,7 @@ it "correctly handles special values" do @infinity.fix.should == @infinity @infinity_neg.fix.should == @infinity_neg - @nan.fix.nan?.should == true + @nan.fix.should.nan? end it "returns 0 if the absolute value is < 1" do diff --git a/spec/ruby/library/bigdecimal/frac_spec.rb b/spec/ruby/library/bigdecimal/frac_spec.rb index 4a023b4ff696a6..11ccf03c2f0606 100644 --- a/spec/ruby/library/bigdecimal/frac_spec.rb +++ b/spec/ruby/library/bigdecimal/frac_spec.rb @@ -42,7 +42,7 @@ it "correctly handles special values" do @infinity.frac.should == @infinity @infinity_neg.frac.should == @infinity_neg - @nan.frac.nan?.should == true + @nan.frac.should.nan? end end diff --git a/spec/ruby/library/bigdecimal/minus_spec.rb b/spec/ruby/library/bigdecimal/minus_spec.rb index 267a0f7eabbc22..bd3c19584b84b8 100644 --- a/spec/ruby/library/bigdecimal/minus_spec.rb +++ b/spec/ruby/library/bigdecimal/minus_spec.rb @@ -26,18 +26,18 @@ end it "returns NaN if NaN is involved" do - (@one - @nan).nan?.should == true - (@nan - @one).nan?.should == true - (@nan - @nan).nan?.should == true - (@nan - @infinity).nan?.should == true - (@nan - @infinity_minus).nan?.should == true - (@infinity - @nan).nan?.should == true - (@infinity_minus - @nan).nan?.should == true + (@one - @nan).should.nan? + (@nan - @one).should.nan? + (@nan - @nan).should.nan? + (@nan - @infinity).should.nan? + (@nan - @infinity_minus).should.nan? + (@infinity - @nan).should.nan? + (@infinity_minus - @nan).should.nan? end it "returns NaN both operands are infinite with the same sign" do - (@infinity - @infinity).nan?.should == true - (@infinity_minus - @infinity_minus).nan?.should == true + (@infinity - @infinity).should.nan? + (@infinity_minus - @infinity_minus).should.nan? end it "returns Infinity or -Infinity if these are involved" do diff --git a/spec/ruby/library/bigdecimal/mode_spec.rb b/spec/ruby/library/bigdecimal/mode_spec.rb index f57028ae5dd600..73fa1a118eaf41 100644 --- a/spec/ruby/library/bigdecimal/mode_spec.rb +++ b/spec/ruby/library/bigdecimal/mode_spec.rb @@ -12,7 +12,7 @@ end it "returns the appropriate value and continue the computation if the flag is false" do - BigDecimal("NaN").add(BigDecimal("1"),0).nan?.should == true + BigDecimal("NaN").add(BigDecimal("1"),0).should.nan? BigDecimal("0").add(BigDecimal("Infinity"),0).should == BigDecimal("Infinity") BigDecimal("1").quo(BigDecimal("0")).should == BigDecimal("Infinity") end diff --git a/spec/ruby/library/bigdecimal/nan_spec.rb b/spec/ruby/library/bigdecimal/nan_spec.rb index 705492614bd7a4..9eaf69b6106c00 100644 --- a/spec/ruby/library/bigdecimal/nan_spec.rb +++ b/spec/ruby/library/bigdecimal/nan_spec.rb @@ -4,20 +4,20 @@ describe "BigDecimal#nan?" do it "returns true if self is not a number" do - BigDecimal("NaN").nan?.should == true + BigDecimal("NaN").should.nan? end it "returns false if self is not a NaN" do - BigDecimal("Infinity").nan?.should == false - BigDecimal("-Infinity").nan?.should == false - BigDecimal("0").nan?.should == false - BigDecimal("+0").nan?.should == false - BigDecimal("-0").nan?.should == false - BigDecimal("2E40001").nan?.should == false - BigDecimal("3E-20001").nan?.should == false - BigDecimal("0E-200000000").nan?.should == false - BigDecimal("0E200000000000").nan?.should == false - BigDecimal("0.000000000000000000000000").nan?.should == false + BigDecimal("Infinity").should_not.nan? + BigDecimal("-Infinity").should_not.nan? + BigDecimal("0").should_not.nan? + BigDecimal("+0").should_not.nan? + BigDecimal("-0").should_not.nan? + BigDecimal("2E40001").should_not.nan? + BigDecimal("3E-20001").should_not.nan? + BigDecimal("0E-200000000").should_not.nan? + BigDecimal("0E200000000000").should_not.nan? + BigDecimal("0.000000000000000000000000").should_not.nan? end end diff --git a/spec/ruby/library/bigdecimal/plus_spec.rb b/spec/ruby/library/bigdecimal/plus_spec.rb index cefc43aeaa8c46..d1934841c8ded7 100644 --- a/spec/ruby/library/bigdecimal/plus_spec.rb +++ b/spec/ruby/library/bigdecimal/plus_spec.rb @@ -30,8 +30,8 @@ end it "returns NaN if NaN is involved" do - (@one + @nan).nan?.should == true - (@nan + @one).nan?.should == true + (@one + @nan).should.nan? + (@nan + @one).should.nan? end it "returns Infinity or -Infinity if these are involved" do @@ -41,7 +41,7 @@ end it "returns NaN if Infinity + (- Infinity)" do - (@infinity + @infinity_minus).nan?.should == true + (@infinity + @infinity_minus).should.nan? end describe "with Object" do diff --git a/spec/ruby/library/bigdecimal/quo_spec.rb b/spec/ruby/library/bigdecimal/quo_spec.rb index a5c56517787302..65a4330303d5ef 100644 --- a/spec/ruby/library/bigdecimal/quo_spec.rb +++ b/spec/ruby/library/bigdecimal/quo_spec.rb @@ -6,7 +6,7 @@ it_behaves_like :bigdecimal_quo, :quo, [] it "returns NaN if NaN is involved" do - BigDecimal("1").quo(BigDecimal("NaN")).nan?.should == true - BigDecimal("NaN").quo(BigDecimal("1")).nan?.should == true + BigDecimal("1").quo(BigDecimal("NaN")).should.nan? + BigDecimal("NaN").quo(BigDecimal("1")).should.nan? end end diff --git a/spec/ruby/library/bigdecimal/remainder_spec.rb b/spec/ruby/library/bigdecimal/remainder_spec.rb index 04233edece7565..1866f665cd326f 100644 --- a/spec/ruby/library/bigdecimal/remainder_spec.rb +++ b/spec/ruby/library/bigdecimal/remainder_spec.rb @@ -38,8 +38,8 @@ end it "returns NaN used with zero" do - @mixed.remainder(@zero).nan?.should == true - @zero.remainder(@zero).nan?.should == true + @mixed.remainder(@zero).should.nan? + @zero.remainder(@zero).should.nan? end it "returns zero if used on zero" do @@ -47,28 +47,28 @@ end it "returns NaN if NaN is involved" do - @nan.remainder(@nan).nan?.should == true - @nan.remainder(@one).nan?.should == true - @one.remainder(@nan).nan?.should == true - @infinity.remainder(@nan).nan?.should == true - @nan.remainder(@infinity).nan?.should == true + @nan.remainder(@nan).should.nan? + @nan.remainder(@one).should.nan? + @one.remainder(@nan).should.nan? + @infinity.remainder(@nan).should.nan? + @nan.remainder(@infinity).should.nan? end it "returns NaN if Infinity is involved" do - @infinity.remainder(@infinity).nan?.should == true - @infinity.remainder(@one).nan?.should == true - @infinity.remainder(@mixed).nan?.should == true - @infinity.remainder(@one_minus).nan?.should == true - @infinity.remainder(@frac_1).nan?.should == true - @one.remainder(@infinity).nan?.should == true + @infinity.remainder(@infinity).should.nan? + @infinity.remainder(@one).should.nan? + @infinity.remainder(@mixed).should.nan? + @infinity.remainder(@one_minus).should.nan? + @infinity.remainder(@frac_1).should.nan? + @one.remainder(@infinity).should.nan? - @infinity_minus.remainder(@infinity_minus).nan?.should == true - @infinity_minus.remainder(@one).nan?.should == true - @one.remainder(@infinity_minus).nan?.should == true - @frac_2.remainder(@infinity_minus).nan?.should == true + @infinity_minus.remainder(@infinity_minus).should.nan? + @infinity_minus.remainder(@one).should.nan? + @one.remainder(@infinity_minus).should.nan? + @frac_2.remainder(@infinity_minus).should.nan? - @infinity.remainder(@infinity_minus).nan?.should == true - @infinity_minus.remainder(@infinity).nan?.should == true + @infinity.remainder(@infinity_minus).should.nan? + @infinity_minus.remainder(@infinity).should.nan? end it "coerces arguments to BigDecimal if possible" do diff --git a/spec/ruby/library/bigdecimal/shared/modulo.rb b/spec/ruby/library/bigdecimal/shared/modulo.rb index 67c0ecf2fccc59..aa5c5a640b2cc2 100644 --- a/spec/ruby/library/bigdecimal/shared/modulo.rb +++ b/spec/ruby/library/bigdecimal/shared/modulo.rb @@ -80,25 +80,25 @@ end it "returns NaN if NaN is involved" do - @nan.send(@method, @nan).nan?.should == true - @nan.send(@method, @one).nan?.should == true - @one.send(@method, @nan).nan?.should == true - @infinity.send(@method, @nan).nan?.should == true - @nan.send(@method, @infinity).nan?.should == true + @nan.send(@method, @nan).should.nan? + @nan.send(@method, @one).should.nan? + @one.send(@method, @nan).should.nan? + @infinity.send(@method, @nan).should.nan? + @nan.send(@method, @infinity).should.nan? end it "returns NaN if the dividend is Infinity" do - @infinity.send(@method, @infinity).nan?.should == true - @infinity.send(@method, @one).nan?.should == true - @infinity.send(@method, @mixed).nan?.should == true - @infinity.send(@method, @one_minus).nan?.should == true - @infinity.send(@method, @frac_1).nan?.should == true + @infinity.send(@method, @infinity).should.nan? + @infinity.send(@method, @one).should.nan? + @infinity.send(@method, @mixed).should.nan? + @infinity.send(@method, @one_minus).should.nan? + @infinity.send(@method, @frac_1).should.nan? - @infinity_minus.send(@method, @infinity_minus).nan?.should == true - @infinity_minus.send(@method, @one).nan?.should == true + @infinity_minus.send(@method, @infinity_minus).should.nan? + @infinity_minus.send(@method, @one).should.nan? - @infinity.send(@method, @infinity_minus).nan?.should == true - @infinity_minus.send(@method, @infinity).nan?.should == true + @infinity.send(@method, @infinity_minus).should.nan? + @infinity_minus.send(@method, @infinity).should.nan? end it "returns the dividend if the divisor is Infinity" do diff --git a/spec/ruby/library/bigdecimal/shared/mult.rb b/spec/ruby/library/bigdecimal/shared/mult.rb index b94c9385de73b8..c613df04c47683 100644 --- a/spec/ruby/library/bigdecimal/shared/mult.rb +++ b/spec/ruby/library/bigdecimal/shared/mult.rb @@ -51,8 +51,8 @@ values = @regular_vals + @zeroes values.each do |val| - @nan.send(@method, val, *@object).nan?.should == true - val.send(@method, @nan, *@object).nan?.should == true + @nan.send(@method, val, *@object).should.nan? + val.send(@method, @nan, *@object).should.nan? end end @@ -62,9 +62,9 @@ values.each do |val| @zeroes.each do |zero| zero.send(@method, val, *@object).should == 0 - zero.send(@method, val, *@object).zero?.should == true + zero.send(@method, val, *@object).should.zero? val.send(@method, zero, *@object).should == 0 - val.send(@method, zero, *@object).zero?.should == true + val.send(@method, zero, *@object).should.zero? end end end @@ -75,8 +75,8 @@ values.each do |val| infs.each do |inf| - inf.send(@method, val, *@object).finite?.should == false - val.send(@method, inf, *@object).finite?.should == false + inf.send(@method, val, *@object).should_not.finite? + val.send(@method, inf, *@object).should_not.finite? end end @@ -89,9 +89,9 @@ end it "returns NaN if the result is undefined" do - @zero.send(@method, @infinity, *@object).nan?.should == true - @zero.send(@method, @infinity_minus, *@object).nan?.should == true - @infinity.send(@method, @zero, *@object).nan?.should == true - @infinity_minus.send(@method, @zero, *@object).nan?.should == true + @zero.send(@method, @infinity, *@object).should.nan? + @zero.send(@method, @infinity_minus, *@object).should.nan? + @infinity.send(@method, @zero, *@object).should.nan? + @infinity_minus.send(@method, @zero, *@object).should.nan? end end diff --git a/spec/ruby/library/bigdecimal/shared/power.rb b/spec/ruby/library/bigdecimal/shared/power.rb index a4848fb2e2b6c4..568a08589b494f 100644 --- a/spec/ruby/library/bigdecimal/shared/power.rb +++ b/spec/ruby/library/bigdecimal/shared/power.rb @@ -53,8 +53,8 @@ end it "returns NaN if self is NaN" do - BigDecimal("NaN").send(@method, -5).nan?.should == true - BigDecimal("NaN").send(@method, 5).nan?.should == true + BigDecimal("NaN").send(@method, -5).should.nan? + BigDecimal("NaN").send(@method, 5).should.nan? end it "returns 0.0 if self is infinite and argument is negative" do diff --git a/spec/ruby/library/bigdecimal/shared/quo.rb b/spec/ruby/library/bigdecimal/shared/quo.rb index 4d6d64b7870b5d..46e6d62bf4bffd 100644 --- a/spec/ruby/library/bigdecimal/shared/quo.rb +++ b/spec/ruby/library/bigdecimal/shared/quo.rb @@ -49,8 +49,8 @@ end it "returns NaN if Infinity / ((+|-) Infinity)" do - @infinity.send(@method, @infinity_minus, *@object).nan?.should == true - @infinity_minus.send(@method, @infinity, *@object).nan?.should == true + @infinity.send(@method, @infinity_minus, *@object).should.nan? + @infinity_minus.send(@method, @infinity, *@object).should.nan? end it "returns (+|-) Infinity if divided by zero" do @@ -60,8 +60,8 @@ end it "returns NaN if zero is divided by zero" do - @zero.send(@method, @zero, *@object).nan?.should == true - @zero_minus.send(@method, @zero_plus, *@object).nan?.should == true - @zero_plus.send(@method, @zero_minus, *@object).nan?.should == true + @zero.send(@method, @zero, *@object).should.nan? + @zero_minus.send(@method, @zero_plus, *@object).should.nan? + @zero_plus.send(@method, @zero_minus, *@object).should.nan? end end diff --git a/spec/ruby/library/bigdecimal/sub_spec.rb b/spec/ruby/library/bigdecimal/sub_spec.rb index 29ec851193e1d5..bddfec2186d6a4 100644 --- a/spec/ruby/library/bigdecimal/sub_spec.rb +++ b/spec/ruby/library/bigdecimal/sub_spec.rb @@ -50,13 +50,13 @@ end it "returns NaN if NaN is involved" do - @one.sub(@nan, 1).nan?.should == true - @nan.sub(@one, 1).nan?.should == true + @one.sub(@nan, 1).should.nan? + @nan.sub(@one, 1).should.nan? end it "returns NaN if both values are infinite with the same signs" do - @infinity.sub(@infinity, 1).nan?.should == true - @infinity_minus.sub(@infinity_minus, 1).nan?.should == true + @infinity.sub(@infinity, 1).should.nan? + @infinity_minus.sub(@infinity_minus, 1).should.nan? end it "returns Infinity or -Infinity if these are involved" do diff --git a/spec/ruby/library/bigdecimal/to_f_spec.rb b/spec/ruby/library/bigdecimal/to_f_spec.rb index 1cc25d5c40c97c..84d4d49de23c15 100644 --- a/spec/ruby/library/bigdecimal/to_f_spec.rb +++ b/spec/ruby/library/bigdecimal/to_f_spec.rb @@ -41,7 +41,7 @@ @zero.to_f.should == 0 @zero.to_f.to_s.should == "0.0" - @nan.to_f.nan?.should == true + @nan.to_f.should.nan? @infinity.to_f.infinite?.should == 1 @infinity_minus.to_f.infinite?.should == -1 diff --git a/spec/ruby/library/bigdecimal/truncate_spec.rb b/spec/ruby/library/bigdecimal/truncate_spec.rb index d3a15f62c749e7..4ad9eb92d1e760 100644 --- a/spec/ruby/library/bigdecimal/truncate_spec.rb +++ b/spec/ruby/library/bigdecimal/truncate_spec.rb @@ -58,9 +58,9 @@ end it "returns NaN if self is NaN" do - @nan.truncate(-1).nan?.should == true - @nan.truncate(+1).nan?.should == true - @nan.truncate(0).nan?.should == true + @nan.truncate(-1).should.nan? + @nan.truncate(+1).should.nan? + @nan.truncate(0).should.nan? end it "returns Infinity if self is infinite" do diff --git a/spec/ruby/library/bigdecimal/uminus_spec.rb b/spec/ruby/library/bigdecimal/uminus_spec.rb index 5e2a786c4c66b6..c780cdfac5acae 100644 --- a/spec/ruby/library/bigdecimal/uminus_spec.rb +++ b/spec/ruby/library/bigdecimal/uminus_spec.rb @@ -53,6 +53,6 @@ @zero_neg.send(:-@).should == @zero @zero_neg.send(:-@).sign.should == 1 - @nan.send(:-@).nan?.should == true + @nan.send(:-@).should.nan? end end diff --git a/spec/ruby/library/bigdecimal/zero_spec.rb b/spec/ruby/library/bigdecimal/zero_spec.rb index c5d3acb8c3c56a..2563210939e251 100644 --- a/spec/ruby/library/bigdecimal/zero_spec.rb +++ b/spec/ruby/library/bigdecimal/zero_spec.rb @@ -6,22 +6,22 @@ it "returns true if self does equal zero" do really_small_zero = BigDecimal("0E-200000000") really_big_zero = BigDecimal("0E200000000000") - really_small_zero.zero?.should == true - really_big_zero.zero?.should == true - BigDecimal("0.000000000000000000000000").zero?.should == true - BigDecimal("0").zero?.should == true - BigDecimal("0E0").zero?.should == true - BigDecimal("+0").zero?.should == true - BigDecimal("-0").zero?.should == true + really_small_zero.should.zero? + really_big_zero.should.zero? + BigDecimal("0.000000000000000000000000").should.zero? + BigDecimal("0").should.zero? + BigDecimal("0E0").should.zero? + BigDecimal("+0").should.zero? + BigDecimal("-0").should.zero? end it "returns false otherwise" do - BigDecimal("0000000001").zero?.should == false - BigDecimal("2E40001").zero?.should == false - BigDecimal("3E-20001").zero?.should == false - BigDecimal("Infinity").zero?.should == false - BigDecimal("-Infinity").zero?.should == false - BigDecimal("NaN").zero?.should == false + BigDecimal("0000000001").should_not.zero? + BigDecimal("2E40001").should_not.zero? + BigDecimal("3E-20001").should_not.zero? + BigDecimal("Infinity").should_not.zero? + BigDecimal("-Infinity").should_not.zero? + BigDecimal("NaN").should_not.zero? end end diff --git a/spec/ruby/library/conditionvariable/signal_spec.rb b/spec/ruby/library/conditionvariable/signal_spec.rb index 11e49095013a08..86383073f1bde2 100644 --- a/spec/ruby/library/conditionvariable/signal_spec.rb +++ b/spec/ruby/library/conditionvariable/signal_spec.rb @@ -72,6 +72,6 @@ # Check that both threads terminated without exception t1.join t2.join - m.locked?.should == false + m.should_not.locked? end end diff --git a/spec/ruby/library/csv/liberal_parsing_spec.rb b/spec/ruby/library/csv/liberal_parsing_spec.rb index 2929d6e2aa7aa8..98786580271979 100644 --- a/spec/ruby/library/csv/liberal_parsing_spec.rb +++ b/spec/ruby/library/csv/liberal_parsing_spec.rb @@ -4,16 +4,16 @@ describe "CSV#liberal_parsing?" do it "returns true if illegal input is handled" do csv = CSV.new("", liberal_parsing: true) - csv.liberal_parsing?.should == true + csv.should.liberal_parsing? end it "returns false if illegal input is not handled" do csv = CSV.new("", liberal_parsing: false) - csv.liberal_parsing?.should == false + csv.should_not.liberal_parsing? end it "returns false by default" do csv = CSV.new("") - csv.liberal_parsing?.should == false + csv.should_not.liberal_parsing? end end diff --git a/spec/ruby/library/date/gregorian_spec.rb b/spec/ruby/library/date/gregorian_spec.rb index 8b7033fe754ffe..ea7ece2adef4f3 100644 --- a/spec/ruby/library/date/gregorian_spec.rb +++ b/spec/ruby/library/date/gregorian_spec.rb @@ -9,7 +9,7 @@ end it "marks a day after the calendar reform as Julian" do - Date.civil(2007, 2, 27).gregorian?.should == true + Date.civil(2007, 2, 27).should.gregorian? Date.civil(1607, 2, 27, Date.civil(1582, 1, 1).jd).gregorian?.should be_true end diff --git a/spec/ruby/library/date/infinity_spec.rb b/spec/ruby/library/date/infinity_spec.rb index 81d67ae249e774..721fd760664ecc 100644 --- a/spec/ruby/library/date/infinity_spec.rb +++ b/spec/ruby/library/date/infinity_spec.rb @@ -5,16 +5,16 @@ it "should be able to check whether Infinity is zero" do i = Date::Infinity.new - i.zero?.should == false + i.should_not.zero? end it "should be able to check whether Infinity is finite" do i1 = Date::Infinity.new - i1.finite?.should == false + i1.should_not.finite? i2 = Date::Infinity.new(-1) - i2.finite?.should == false + i2.should_not.finite? i3 = Date::Infinity.new(0) - i3.finite?.should == false + i3.should_not.finite? end it "should be able to check whether Infinity is infinite" do @@ -28,11 +28,11 @@ it "should be able to check whether Infinity is not a number" do i1 = Date::Infinity.new - i1.nan?.should == false + i1.should_not.nan? i2 = Date::Infinity.new(-1) - i2.nan?.should == false + i2.should_not.nan? i3 = Date::Infinity.new(0) - i3.nan?.should == true + i3.should.nan? end it "should be able to compare Infinity objects" do diff --git a/spec/ruby/library/date/julian_spec.rb b/spec/ruby/library/date/julian_spec.rb index 637a4739e5f519..db2629d1e733b6 100644 --- a/spec/ruby/library/date/julian_spec.rb +++ b/spec/ruby/library/date/julian_spec.rb @@ -4,12 +4,12 @@ describe "Date#julian?" do it "marks a day before the calendar reform as Julian" do - Date.civil(1007, 2, 27).julian?.should == true + Date.civil(1007, 2, 27).should.julian? Date.civil(1907, 2, 27, Date.civil(1930, 1, 1).jd).julian?.should be_true end it "marks a day after the calendar reform as Julian" do - Date.civil(2007, 2, 27).julian?.should == false + Date.civil(2007, 2, 27).should_not.julian? Date.civil(1607, 2, 27, Date.civil(1582, 1, 1).jd).julian?.should be_false end diff --git a/spec/ruby/library/date/shared/civil.rb b/spec/ruby/library/date/shared/civil.rb index 4c8ba23622def2..bbed4a88662eb4 100644 --- a/spec/ruby/library/date/shared/civil.rb +++ b/spec/ruby/library/date/shared/civil.rb @@ -5,7 +5,7 @@ d.year.should == -4712 d.month.should == 1 d.day.should == 1 - d.julian?.should == true + d.should.julian? d.jd.should == 0 end @@ -14,7 +14,7 @@ d.year.should == 2000 d.month.should == 3 d.day.should == 5 - d.julian?.should == false + d.should_not.julian? d.jd.should == 2451609 # Should also work with years far in the past and future @@ -23,14 +23,14 @@ d.year.should == -9000 d.month.should == 7 d.day.should == 5 - d.julian?.should == true + d.should.julian? d.jd.should == -1566006 d = Date.send(@method, 9000, 10, 14) d.year.should == 9000 d.month.should == 10 d.day.should == 14 - d.julian?.should == false + d.should_not.julian? d.jd.should == 5008529 end diff --git a/spec/ruby/library/getoptlong/terminated_spec.rb b/spec/ruby/library/getoptlong/terminated_spec.rb index 01a8feddeade89..6108a7f6e908e8 100644 --- a/spec/ruby/library/getoptlong/terminated_spec.rb +++ b/spec/ruby/library/getoptlong/terminated_spec.rb @@ -5,13 +5,13 @@ it "returns true if option processing has terminated" do argv [ "--size", "10k" ] do opts = GetoptLong.new(["--size", GetoptLong::REQUIRED_ARGUMENT]) - opts.terminated?.should == false + opts.should_not.terminated? opts.get.should == ["--size", "10k"] - opts.terminated?.should == false + opts.should_not.terminated? opts.get.should == nil - opts.terminated?.should == true + opts.should.terminated? end end end diff --git a/spec/ruby/library/ipaddr/ipv4_conversion_spec.rb b/spec/ruby/library/ipaddr/ipv4_conversion_spec.rb index 9d45055d76840c..1128c16dd20b0e 100644 --- a/spec/ruby/library/ipaddr/ipv4_conversion_spec.rb +++ b/spec/ruby/library/ipaddr/ipv4_conversion_spec.rb @@ -8,11 +8,11 @@ a.to_s.should == "::192.168.1.2" a.to_string.should == "0000:0000:0000:0000:0000:0000:c0a8:0102" a.family.should == Socket::AF_INET6 - a.ipv4_compat?.should == true + a.should.ipv4_compat? b = a.native b.to_s.should == "192.168.1.2" b.family.should == Socket::AF_INET - b.ipv4_compat?.should == false + b.should_not.ipv4_compat? a = IPAddr.new("192.168.1.2") b = a.ipv4_compat @@ -29,11 +29,11 @@ a.to_s.should == "::ffff:192.168.1.2" a.to_string.should == "0000:0000:0000:0000:0000:ffff:c0a8:0102" a.family.should == Socket::AF_INET6 - a.ipv4_mapped?.should == true + a.should.ipv4_mapped? b = a.native b.to_s.should == "192.168.1.2" b.family.should == Socket::AF_INET - b.ipv4_mapped?.should == false + b.should_not.ipv4_mapped? a = IPAddr.new("192.168.1.2") b = a.ipv4_mapped diff --git a/spec/ruby/library/ipaddr/new_spec.rb b/spec/ruby/library/ipaddr/new_spec.rb index c8c8bc80b3d0df..3148d6e39ca46e 100644 --- a/spec/ruby/library/ipaddr/new_spec.rb +++ b/spec/ruby/library/ipaddr/new_spec.rb @@ -27,8 +27,8 @@ a.to_s.should == "3ffe:505:2::" a.to_string.should == "3ffe:0505:0002:0000:0000:0000:0000:0000" a.family.should == Socket::AF_INET6 - a.ipv4?.should == false - a.ipv6?.should == true + a.should_not.ipv4? + a.should.ipv6? a.inspect.should == "#" end @@ -51,8 +51,8 @@ a.to_s.should == "192.168.1.2" a.to_string.should == "192.168.1.2" a.family.should == Socket::AF_INET - a.ipv4?.should == true - a.ipv6?.should == false + a.should.ipv4? + a.should_not.ipv6? end it "initializes IPAddr ipv4 address with / subnet notation" do diff --git a/spec/ruby/library/logger/logger/debug_spec.rb b/spec/ruby/library/logger/logger/debug_spec.rb index d92c3392324f41..9375ab0cc6a9b2 100644 --- a/spec/ruby/library/logger/logger/debug_spec.rb +++ b/spec/ruby/library/logger/logger/debug_spec.rb @@ -16,12 +16,12 @@ it "returns true if severity level allows debug messages" do @logger.level = Logger::DEBUG - @logger.debug?.should == true + @logger.should.debug? end it "returns false if severity level does not allow debug messages" do @logger.level = Logger::WARN - @logger.debug?.should == false + @logger.should_not.debug? end end diff --git a/spec/ruby/library/logger/logger/error_spec.rb b/spec/ruby/library/logger/logger/error_spec.rb index d5d0bd2d2f35dd..42f1dbd8832693 100644 --- a/spec/ruby/library/logger/logger/error_spec.rb +++ b/spec/ruby/library/logger/logger/error_spec.rb @@ -16,12 +16,12 @@ it "returns true if severity level allows printing errors" do @logger.level = Logger::INFO - @logger.error?.should == true + @logger.should.error? end it "returns false if severity level does not allow errors" do @logger.level = Logger::FATAL - @logger.error?.should == false + @logger.should_not.error? end end diff --git a/spec/ruby/library/logger/logger/fatal_spec.rb b/spec/ruby/library/logger/logger/fatal_spec.rb index 42d4341319286a..f12fa3a89fa9f3 100644 --- a/spec/ruby/library/logger/logger/fatal_spec.rb +++ b/spec/ruby/library/logger/logger/fatal_spec.rb @@ -16,12 +16,12 @@ it "returns true if severity level allows fatal messages" do @logger.level = Logger::FATAL - @logger.fatal?.should == true + @logger.should.fatal? end it "returns false if severity level does not allow fatal messages" do @logger.level = Logger::UNKNOWN - @logger.fatal?.should == false + @logger.should_not.fatal? end end diff --git a/spec/ruby/library/logger/logger/info_spec.rb b/spec/ruby/library/logger/logger/info_spec.rb index 21eacbbb318118..eb5dca48dd170b 100644 --- a/spec/ruby/library/logger/logger/info_spec.rb +++ b/spec/ruby/library/logger/logger/info_spec.rb @@ -16,12 +16,12 @@ it "returns true if severity level allows info messages" do @logger.level = Logger::INFO - @logger.info?.should == true + @logger.should.info? end it "returns false if severity level does not allow info messages" do @logger.level = Logger::FATAL - @logger.info?.should == false + @logger.should_not.info? end end diff --git a/spec/ruby/library/logger/logger/warn_spec.rb b/spec/ruby/library/logger/logger/warn_spec.rb index 6617b2b41a624b..0bca34824ade69 100644 --- a/spec/ruby/library/logger/logger/warn_spec.rb +++ b/spec/ruby/library/logger/logger/warn_spec.rb @@ -16,12 +16,12 @@ it "returns true if severity level allows printing warn messages" do @logger.level = Logger::WARN - @logger.warn?.should == true + @logger.should.warn? end it "returns false if severity level does not allow printing warn messages" do @logger.level = Logger::FATAL - @logger.warn?.should == false + @logger.should_not.warn? end end diff --git a/spec/ruby/library/matrix/normal_spec.rb b/spec/ruby/library/matrix/normal_spec.rb index ebd73aaf405714..a9e6c645faf75e 100644 --- a/spec/ruby/library/matrix/normal_spec.rb +++ b/spec/ruby/library/matrix/normal_spec.rb @@ -3,12 +3,12 @@ describe "Matrix.normal?" do # it "returns false for non normal matrices" do - # Matrix[[0, 1], [1, 2]].normal?.should == false + # Matrix[[0, 1], [1, 2]].should_not.normal? # end it "returns true for normal matrices" do - Matrix[[1, 1, 0], [0, 1, 1], [1, 0, 1]].normal?.should == true - Matrix[[0, Complex(0, 2)], [Complex(0, -2), 0]].normal?.should == true + Matrix[[1, 1, 0], [0, 1, 1], [1, 0, 1]].should.normal? + Matrix[[0, Complex(0, 2)], [Complex(0, -2), 0]].should.normal? end it "raises an error for rectangular matrices" do diff --git a/spec/ruby/library/matrix/orthogonal_spec.rb b/spec/ruby/library/matrix/orthogonal_spec.rb index 07b098a58d51e0..26afe89ff08e75 100644 --- a/spec/ruby/library/matrix/orthogonal_spec.rb +++ b/spec/ruby/library/matrix/orthogonal_spec.rb @@ -3,12 +3,12 @@ describe "Matrix.orthogonal?" do it "returns false for non orthogonal matrices" do - Matrix[[0, 1], [1, 2]].orthogonal?.should == false - Matrix[[1, 1, 0], [0, 1, 1], [1, 0, 1]].orthogonal?.should == false + Matrix[[0, 1], [1, 2]].should_not.orthogonal? + Matrix[[1, 1, 0], [0, 1, 1], [1, 0, 1]].should_not.orthogonal? end it "returns true for orthogonal matrices" do - Matrix[[0, 1], [1, 0]].orthogonal?.should == true + Matrix[[0, 1], [1, 0]].should.orthogonal? end it "raises an error for rectangular matrices" do diff --git a/spec/ruby/library/matrix/unitary_spec.rb b/spec/ruby/library/matrix/unitary_spec.rb index c52f9d97d92ae8..af4b2bb442857e 100644 --- a/spec/ruby/library/matrix/unitary_spec.rb +++ b/spec/ruby/library/matrix/unitary_spec.rb @@ -3,18 +3,18 @@ describe "Matrix.unitary?" do it "returns false for non unitary matrices" do - Matrix[[0, 1], [1, 2]].unitary?.should == false - Matrix[[0, Complex(0, 2)], [Complex(0, 2), 0]].unitary?.should == false - Matrix[[1, 1, 0], [0, 1, 1], [1, 0, 1]].unitary?.should == false + Matrix[[0, 1], [1, 2]].should_not.unitary? + Matrix[[0, Complex(0, 2)], [Complex(0, 2), 0]].should_not.unitary? + Matrix[[1, 1, 0], [0, 1, 1], [1, 0, 1]].should_not.unitary? end it "returns true for unitary matrices" do - Matrix[[0, Complex(0, 1)], [Complex(0, 1), 0]].unitary?.should == true + Matrix[[0, Complex(0, 1)], [Complex(0, 1), 0]].should.unitary? end version_is((Matrix::const_defined?(:VERSION) ? Matrix::VERSION : "0.1.0"), "0.3.0") do it "returns true for unitary matrices with a Complex and a negative #imag" do - Matrix[[0, Complex(0, 1)], [Complex(0, -1), 0]].unitary?.should == true + Matrix[[0, Complex(0, 1)], [Complex(0, -1), 0]].should.unitary? end end diff --git a/spec/ruby/library/matrix/zero_spec.rb b/spec/ruby/library/matrix/zero_spec.rb index 643c57acba1ce2..68e8567c260256 100644 --- a/spec/ruby/library/matrix/zero_spec.rb +++ b/spec/ruby/library/matrix/zero_spec.rb @@ -37,16 +37,16 @@ describe "Matrix.zero?" do it "returns true for empty matrices" do - Matrix.empty.zero?.should == true - Matrix.empty(3,0).zero?.should == true - Matrix.empty(0,3).zero?.should == true + Matrix.empty.should.zero? + Matrix.empty(3,0).should.zero? + Matrix.empty(0,3).should.zero? end it "returns true for matrices with zero entries" do - Matrix.zero(2,3).zero?.should == true + Matrix.zero(2,3).should.zero? end it "returns false for matrices with non zero entries" do - Matrix[[1]].zero?.should == false + Matrix[[1]].should_not.zero? end end diff --git a/spec/ruby/library/net/http/httpresponse/body_permitted_spec.rb b/spec/ruby/library/net/http/httpresponse/body_permitted_spec.rb index 68a0454f79974b..8ade46689fa9b1 100644 --- a/spec/ruby/library/net/http/httpresponse/body_permitted_spec.rb +++ b/spec/ruby/library/net/http/httpresponse/body_permitted_spec.rb @@ -3,11 +3,11 @@ describe "Net::HTTPResponse.body_permitted?" do it "returns true if this response type can have a response body" do - Net::HTTPUnknownResponse.body_permitted?.should == true - Net::HTTPInformation.body_permitted?.should == false - Net::HTTPSuccess.body_permitted?.should == true - Net::HTTPRedirection.body_permitted?.should == true - Net::HTTPClientError.body_permitted?.should == true - Net::HTTPServerError.body_permitted?.should == true + Net::HTTPUnknownResponse.should.body_permitted? + Net::HTTPInformation.should_not.body_permitted? + Net::HTTPSuccess.should.body_permitted? + Net::HTTPRedirection.should.body_permitted? + Net::HTTPClientError.should.body_permitted? + Net::HTTPServerError.should.body_permitted? end end diff --git a/spec/ruby/library/pathname/absolute_spec.rb b/spec/ruby/library/pathname/absolute_spec.rb index dce3ae72eee10d..109abb8ee9e49b 100644 --- a/spec/ruby/library/pathname/absolute_spec.rb +++ b/spec/ruby/library/pathname/absolute_spec.rb @@ -4,19 +4,19 @@ describe "Pathname#absolute?" do it "returns true for the root directory" do - Pathname.new('/').absolute?.should == true + Pathname.new('/').should.absolute? end it "returns true for a dir starting with a slash" do - Pathname.new('/usr/local/bin').absolute?.should == true + Pathname.new('/usr/local/bin').should.absolute? end it "returns false for a dir not starting with a slash" do - Pathname.new('fish').absolute?.should == false + Pathname.new('fish').should_not.absolute? end it "returns false for a dir not starting with a slash" do - Pathname.new('fish/dog/cow').absolute?.should == false + Pathname.new('fish/dog/cow').should_not.absolute? end end diff --git a/spec/ruby/library/pathname/new_spec.rb b/spec/ruby/library/pathname/new_spec.rb index dcb770149ff243..760fd8638f19aa 100644 --- a/spec/ruby/library/pathname/new_spec.rb +++ b/spec/ruby/library/pathname/new_spec.rb @@ -13,7 +13,7 @@ ruby_version_is ''...'2.7' do it "is tainted if path is tainted" do path = '/usr/local/bin'.taint - Pathname.new(path).tainted?.should == true + Pathname.new(path).should.tainted? end end diff --git a/spec/ruby/library/pathname/relative_spec.rb b/spec/ruby/library/pathname/relative_spec.rb index 1a08891e6cfee5..0fab9a7b9f19f8 100644 --- a/spec/ruby/library/pathname/relative_spec.rb +++ b/spec/ruby/library/pathname/relative_spec.rb @@ -4,19 +4,19 @@ describe "Pathname#relative?" do it "returns false for the root directory" do - Pathname.new('/').relative?.should == false + Pathname.new('/').should_not.relative? end it "returns false for a dir starting with a slash" do - Pathname.new('/usr/local/bin').relative?.should == false + Pathname.new('/usr/local/bin').should_not.relative? end it "returns true for a dir not starting with a slash" do - Pathname.new('fish').relative?.should == true + Pathname.new('fish').should.relative? end it "returns true for a dir not starting with a slash" do - Pathname.new('fish/dog/cow').relative?.should == true + Pathname.new('fish/dog/cow').should.relative? end end diff --git a/spec/ruby/library/pathname/root_spec.rb b/spec/ruby/library/pathname/root_spec.rb index 5fec0ee95699f3..cd2be24516e4d3 100644 --- a/spec/ruby/library/pathname/root_spec.rb +++ b/spec/ruby/library/pathname/root_spec.rb @@ -4,23 +4,23 @@ describe "Pathname#root?" do it "returns true for root directories" do - Pathname.new('/').root?.should == true + Pathname.new('/').should.root? end it "returns false for empty string" do - Pathname.new('').root?.should == false + Pathname.new('').should_not.root? end it "returns false for a top level directory" do - Pathname.new('/usr').root?.should == false + Pathname.new('/usr').should_not.root? end it "returns false for a top level with .. appended directory" do - Pathname.new('/usr/..').root?.should == false + Pathname.new('/usr/..').should_not.root? end it "returns false for a directory below top level" do - Pathname.new('/usr/local/bin/').root?.should == false + Pathname.new('/usr/local/bin/').should_not.root? end end diff --git a/spec/ruby/library/rexml/element/cdatas_spec.rb b/spec/ruby/library/rexml/element/cdatas_spec.rb index 4cc592aae374eb..ecbca94f62814b 100644 --- a/spec/ruby/library/rexml/element/cdatas_spec.rb +++ b/spec/ruby/library/rexml/element/cdatas_spec.rb @@ -17,7 +17,7 @@ end it "freezes the returned array" do - @e.cdatas.frozen?.should == true + @e.cdatas.should.frozen? end it "returns an empty array if element has no cdata" do diff --git a/spec/ruby/library/rexml/element/comments_spec.rb b/spec/ruby/library/rexml/element/comments_spec.rb index 59a0b3e4fb33bb..26043366d3ef7d 100644 --- a/spec/ruby/library/rexml/element/comments_spec.rb +++ b/spec/ruby/library/rexml/element/comments_spec.rb @@ -17,7 +17,7 @@ end it "returns a frozen object" do - @e.comments.frozen?.should == true + @e.comments.should.frozen? end end end diff --git a/spec/ruby/library/rexml/node/parent_spec.rb b/spec/ruby/library/rexml/node/parent_spec.rb index 693ee9d5c200a9..0a31abaf0f4e95 100644 --- a/spec/ruby/library/rexml/node/parent_spec.rb +++ b/spec/ruby/library/rexml/node/parent_spec.rb @@ -6,18 +6,18 @@ describe "REXML::Node#parent?" do it "returns true for Elements" do e = REXML::Element.new("foo") - e.parent?.should == true + e.should.parent? end it "returns true for Documents" do e = REXML::Document.new - e.parent?.should == true + e.should.parent? end # This includes attributes, CDatas and declarations. it "returns false for Texts" do e = REXML::Text.new("foo") - e.parent?.should == false + e.should_not.parent? end end end diff --git a/spec/ruby/library/rexml/text/empty_spec.rb b/spec/ruby/library/rexml/text/empty_spec.rb index 392b536a4cf24c..18f31580adc255 100644 --- a/spec/ruby/library/rexml/text/empty_spec.rb +++ b/spec/ruby/library/rexml/text/empty_spec.rb @@ -5,11 +5,11 @@ describe "REXML::Text#empty?" do it "returns true if the text is empty" do - REXML::Text.new("").empty?.should == true + REXML::Text.new("").should.empty? end it "returns false if the text is not empty" do - REXML::Text.new("some_text").empty?.should == false + REXML::Text.new("some_text").should_not.empty? end end end diff --git a/spec/ruby/library/set/compare_by_identity_spec.rb b/spec/ruby/library/set/compare_by_identity_spec.rb index 28fe91309f1d4a..9ed16021897f2d 100644 --- a/spec/ruby/library/set/compare_by_identity_spec.rb +++ b/spec/ruby/library/set/compare_by_identity_spec.rb @@ -42,7 +42,7 @@ def o.hash; 123; end set = Set.new.compare_by_identity set << :foo set.compare_by_identity.should equal(set) - set.compare_by_identity?.should == true + set.should.compare_by_identity? set.to_a.should == [:foo] end @@ -124,20 +124,20 @@ def o.hash; 123; end describe "Set#compare_by_identity?" do it "returns false by default" do - Set.new.compare_by_identity?.should == false + Set.new.should_not.compare_by_identity? end it "returns true once #compare_by_identity has been invoked on self" do set = Set.new set.compare_by_identity - set.compare_by_identity?.should == true + set.should.compare_by_identity? end it "returns true when called multiple times on the same set" do set = Set.new set.compare_by_identity - set.compare_by_identity?.should == true - set.compare_by_identity?.should == true - set.compare_by_identity?.should == true + set.should.compare_by_identity? + set.should.compare_by_identity? + set.should.compare_by_identity? end end diff --git a/spec/ruby/library/socket/addrinfo/ipv4_loopback_spec.rb b/spec/ruby/library/socket/addrinfo/ipv4_loopback_spec.rb index f5bab711db4058..10ad084fc93bb4 100644 --- a/spec/ruby/library/socket/addrinfo/ipv4_loopback_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv4_loopback_spec.rb @@ -3,10 +3,10 @@ describe "Addrinfo#ipv4_loopback?" do describe "for an ipv4 socket" do it "returns true for the loopback address" do - Addrinfo.ip('127.0.0.1').ipv4_loopback?.should == true - Addrinfo.ip('127.0.0.2').ipv4_loopback?.should == true - Addrinfo.ip('127.255.0.1').ipv4_loopback?.should == true - Addrinfo.ip('127.255.255.255').ipv4_loopback?.should == true + Addrinfo.ip('127.0.0.1').should.ipv4_loopback? + Addrinfo.ip('127.0.0.2').should.ipv4_loopback? + Addrinfo.ip('127.255.0.1').should.ipv4_loopback? + Addrinfo.ip('127.255.255.255').should.ipv4_loopback? end it "returns false for another address" do diff --git a/spec/ruby/library/socket/addrinfo/ipv4_multicast_spec.rb b/spec/ruby/library/socket/addrinfo/ipv4_multicast_spec.rb index bdd14c1b000a00..f7fead86409680 100644 --- a/spec/ruby/library/socket/addrinfo/ipv4_multicast_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv4_multicast_spec.rb @@ -2,17 +2,17 @@ describe "Addrinfo#ipv4_multicast?" do it 'returns true for a multicast address' do - Addrinfo.ip('224.0.0.0').ipv4_multicast?.should == true - Addrinfo.ip('224.0.0.9').ipv4_multicast?.should == true - Addrinfo.ip('239.255.255.250').ipv4_multicast?.should == true + Addrinfo.ip('224.0.0.0').should.ipv4_multicast? + Addrinfo.ip('224.0.0.9').should.ipv4_multicast? + Addrinfo.ip('239.255.255.250').should.ipv4_multicast? end it 'returns false for a regular address' do - Addrinfo.ip('8.8.8.8').ipv4_multicast?.should == false + Addrinfo.ip('8.8.8.8').should_not.ipv4_multicast? end it 'returns false for an IPv6 address' do - Addrinfo.ip('::1').ipv4_multicast?.should == false + Addrinfo.ip('::1').should_not.ipv4_multicast? end with_feature :unix_socket do diff --git a/spec/ruby/library/socket/addrinfo/ipv4_private_spec.rb b/spec/ruby/library/socket/addrinfo/ipv4_private_spec.rb index 733577609e746a..e5a33b4953f38f 100644 --- a/spec/ruby/library/socket/addrinfo/ipv4_private_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv4_private_spec.rb @@ -8,14 +8,14 @@ end it "returns true for a private address" do - Addrinfo.ip('10.0.0.0').ipv4_private?.should == true - Addrinfo.ip('10.0.0.5').ipv4_private?.should == true + Addrinfo.ip('10.0.0.0').should.ipv4_private? + Addrinfo.ip('10.0.0.5').should.ipv4_private? - Addrinfo.ip('172.16.0.0').ipv4_private?.should == true - Addrinfo.ip('172.16.0.5').ipv4_private?.should == true + Addrinfo.ip('172.16.0.0').should.ipv4_private? + Addrinfo.ip('172.16.0.5').should.ipv4_private? - Addrinfo.ip('192.168.0.0').ipv4_private?.should == true - Addrinfo.ip('192.168.0.5').ipv4_private?.should == true + Addrinfo.ip('192.168.0.0').should.ipv4_private? + Addrinfo.ip('192.168.0.5').should.ipv4_private? end it "returns false for a public address" do diff --git a/spec/ruby/library/socket/addrinfo/ipv6_linklocal_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_linklocal_spec.rb index 291b4d7d6b7737..bfef3963813cf7 100644 --- a/spec/ruby/library/socket/addrinfo/ipv6_linklocal_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv6_linklocal_spec.rb @@ -5,19 +5,19 @@ describe 'Addrinfo#ipv6_linklocal?' do platform_is_not :aix do it 'returns true for a link-local address' do - Addrinfo.ip('fe80::').ipv6_linklocal?.should == true - Addrinfo.ip('fe81::').ipv6_linklocal?.should == true - Addrinfo.ip('fe8f::').ipv6_linklocal?.should == true - Addrinfo.ip('fe80::1').ipv6_linklocal?.should == true + Addrinfo.ip('fe80::').should.ipv6_linklocal? + Addrinfo.ip('fe81::').should.ipv6_linklocal? + Addrinfo.ip('fe8f::').should.ipv6_linklocal? + Addrinfo.ip('fe80::1').should.ipv6_linklocal? end end it 'returns false for a regular address' do - Addrinfo.ip('::1').ipv6_linklocal?.should == false + Addrinfo.ip('::1').should_not.ipv6_linklocal? end it 'returns false for an IPv4 address' do - Addrinfo.ip('127.0.0.1').ipv6_linklocal?.should == false + Addrinfo.ip('127.0.0.1').should_not.ipv6_linklocal? end end end diff --git a/spec/ruby/library/socket/addrinfo/ipv6_mc_global_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_mc_global_spec.rb index 9c8e4dccb446f5..01fa0992ba8ce0 100644 --- a/spec/ruby/library/socket/addrinfo/ipv6_mc_global_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv6_mc_global_spec.rb @@ -2,19 +2,19 @@ describe 'Addrinfo#ipv6_mc_global?' do it 'returns true for a multi-cast address in the global scope' do - Addrinfo.ip('ff1e::').ipv6_mc_global?.should == true - Addrinfo.ip('fffe::').ipv6_mc_global?.should == true - Addrinfo.ip('ff0e::').ipv6_mc_global?.should == true - Addrinfo.ip('ff1e::1').ipv6_mc_global?.should == true + Addrinfo.ip('ff1e::').should.ipv6_mc_global? + Addrinfo.ip('fffe::').should.ipv6_mc_global? + Addrinfo.ip('ff0e::').should.ipv6_mc_global? + Addrinfo.ip('ff1e::1').should.ipv6_mc_global? end it 'returns false for a regular IPv6 address' do - Addrinfo.ip('::1').ipv6_mc_global?.should == false - Addrinfo.ip('ff1a::').ipv6_mc_global?.should == false - Addrinfo.ip('ff1f::1').ipv6_mc_global?.should == false + Addrinfo.ip('::1').should_not.ipv6_mc_global? + Addrinfo.ip('ff1a::').should_not.ipv6_mc_global? + Addrinfo.ip('ff1f::1').should_not.ipv6_mc_global? end it 'returns false for an IPv4 address' do - Addrinfo.ip('127.0.0.1').ipv6_mc_global?.should == false + Addrinfo.ip('127.0.0.1').should_not.ipv6_mc_global? end end diff --git a/spec/ruby/library/socket/addrinfo/ipv6_mc_linklocal_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_mc_linklocal_spec.rb index dd52a9ad8bd4dd..a1298919eb4a45 100644 --- a/spec/ruby/library/socket/addrinfo/ipv6_mc_linklocal_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv6_mc_linklocal_spec.rb @@ -2,18 +2,18 @@ describe 'Addrinfo#ipv6_mc_linklocal?' do it 'returns true for a multi-cast link-local address' do - Addrinfo.ip('ff12::').ipv6_mc_linklocal?.should == true - Addrinfo.ip('ff02::').ipv6_mc_linklocal?.should == true - Addrinfo.ip('fff2::').ipv6_mc_linklocal?.should == true - Addrinfo.ip('ff12::1').ipv6_mc_linklocal?.should == true + Addrinfo.ip('ff12::').should.ipv6_mc_linklocal? + Addrinfo.ip('ff02::').should.ipv6_mc_linklocal? + Addrinfo.ip('fff2::').should.ipv6_mc_linklocal? + Addrinfo.ip('ff12::1').should.ipv6_mc_linklocal? end it 'returns false for a regular IPv6 address' do - Addrinfo.ip('::1').ipv6_mc_linklocal?.should == false - Addrinfo.ip('fff1::').ipv6_mc_linklocal?.should == false + Addrinfo.ip('::1').should_not.ipv6_mc_linklocal? + Addrinfo.ip('fff1::').should_not.ipv6_mc_linklocal? end it 'returns false for an IPv4 address' do - Addrinfo.ip('127.0.0.1').ipv6_mc_linklocal?.should == false + Addrinfo.ip('127.0.0.1').should_not.ipv6_mc_linklocal? end end diff --git a/spec/ruby/library/socket/addrinfo/ipv6_mc_nodelocal_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_mc_nodelocal_spec.rb index b3cf5ffbabb3aa..0aee952d88df3d 100644 --- a/spec/ruby/library/socket/addrinfo/ipv6_mc_nodelocal_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv6_mc_nodelocal_spec.rb @@ -2,17 +2,17 @@ describe 'Addrinfo#ipv6_mc_nodelocal?' do it 'returns true for a multi-cast node-local address' do - Addrinfo.ip('ff11::').ipv6_mc_nodelocal?.should == true - Addrinfo.ip('ff01::').ipv6_mc_nodelocal?.should == true - Addrinfo.ip('fff1::').ipv6_mc_nodelocal?.should == true - Addrinfo.ip('ff11::1').ipv6_mc_nodelocal?.should == true + Addrinfo.ip('ff11::').should.ipv6_mc_nodelocal? + Addrinfo.ip('ff01::').should.ipv6_mc_nodelocal? + Addrinfo.ip('fff1::').should.ipv6_mc_nodelocal? + Addrinfo.ip('ff11::1').should.ipv6_mc_nodelocal? end it 'returns false for a regular IPv6 address' do - Addrinfo.ip('::1').ipv6_mc_nodelocal?.should == false + Addrinfo.ip('::1').should_not.ipv6_mc_nodelocal? end it 'returns false for an IPv4 address' do - Addrinfo.ip('127.0.0.1').ipv6_mc_nodelocal?.should == false + Addrinfo.ip('127.0.0.1').should_not.ipv6_mc_nodelocal? end end diff --git a/spec/ruby/library/socket/addrinfo/ipv6_mc_orglocal_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_mc_orglocal_spec.rb index 90653dd49c9ddd..2977a98d30e2bf 100644 --- a/spec/ruby/library/socket/addrinfo/ipv6_mc_orglocal_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv6_mc_orglocal_spec.rb @@ -2,17 +2,17 @@ describe 'Addrinfo#ipv6_mc_orglocal?' do it 'returns true for a multi-cast org-local address' do - Addrinfo.ip('ff18::').ipv6_mc_orglocal?.should == true - Addrinfo.ip('ff08::').ipv6_mc_orglocal?.should == true - Addrinfo.ip('fff8::').ipv6_mc_orglocal?.should == true - Addrinfo.ip('ff18::1').ipv6_mc_orglocal?.should == true + Addrinfo.ip('ff18::').should.ipv6_mc_orglocal? + Addrinfo.ip('ff08::').should.ipv6_mc_orglocal? + Addrinfo.ip('fff8::').should.ipv6_mc_orglocal? + Addrinfo.ip('ff18::1').should.ipv6_mc_orglocal? end it 'returns false for a regular IPv6 address' do - Addrinfo.ip('::1').ipv6_mc_orglocal?.should == false + Addrinfo.ip('::1').should_not.ipv6_mc_orglocal? end it 'returns false for an IPv4 address' do - Addrinfo.ip('127.0.0.1').ipv6_mc_orglocal?.should == false + Addrinfo.ip('127.0.0.1').should_not.ipv6_mc_orglocal? end end diff --git a/spec/ruby/library/socket/addrinfo/ipv6_mc_sitelocal_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_mc_sitelocal_spec.rb index 686b625e0d98ac..58e5976a409b39 100644 --- a/spec/ruby/library/socket/addrinfo/ipv6_mc_sitelocal_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv6_mc_sitelocal_spec.rb @@ -2,17 +2,17 @@ describe 'Addrinfo#ipv6_mc_sitelocal?' do it 'returns true for a multi-cast site-local address' do - Addrinfo.ip('ff15::').ipv6_mc_sitelocal?.should == true - Addrinfo.ip('ff05::').ipv6_mc_sitelocal?.should == true - Addrinfo.ip('fff5::').ipv6_mc_sitelocal?.should == true - Addrinfo.ip('ff15::1').ipv6_mc_sitelocal?.should == true + Addrinfo.ip('ff15::').should.ipv6_mc_sitelocal? + Addrinfo.ip('ff05::').should.ipv6_mc_sitelocal? + Addrinfo.ip('fff5::').should.ipv6_mc_sitelocal? + Addrinfo.ip('ff15::1').should.ipv6_mc_sitelocal? end it 'returns false for a regular IPv6 address' do - Addrinfo.ip('::1').ipv6_mc_sitelocal?.should == false + Addrinfo.ip('::1').should_not.ipv6_mc_sitelocal? end it 'returns false for an IPv4 address' do - Addrinfo.ip('127.0.0.1').ipv6_mc_sitelocal?.should == false + Addrinfo.ip('127.0.0.1').should_not.ipv6_mc_sitelocal? end end diff --git a/spec/ruby/library/socket/addrinfo/ipv6_multicast_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_multicast_spec.rb index c25322869c4c8b..2c987b59210acf 100644 --- a/spec/ruby/library/socket/addrinfo/ipv6_multicast_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv6_multicast_spec.rb @@ -18,19 +18,19 @@ describe "for an ipv6 socket" do it "returns true for a multicast address" do - Addrinfo.ip('ff00::').ipv6_multicast?.should == true - Addrinfo.ip('ff00::1').ipv6_multicast?.should == true - Addrinfo.ip('ff08::1').ipv6_multicast?.should == true - Addrinfo.ip('fff8::1').ipv6_multicast?.should == true - - Addrinfo.ip('ff02::').ipv6_multicast?.should == true - Addrinfo.ip('ff02::1').ipv6_multicast?.should == true - Addrinfo.ip('ff0f::').ipv6_multicast?.should == true + Addrinfo.ip('ff00::').should.ipv6_multicast? + Addrinfo.ip('ff00::1').should.ipv6_multicast? + Addrinfo.ip('ff08::1').should.ipv6_multicast? + Addrinfo.ip('fff8::1').should.ipv6_multicast? + + Addrinfo.ip('ff02::').should.ipv6_multicast? + Addrinfo.ip('ff02::1').should.ipv6_multicast? + Addrinfo.ip('ff0f::').should.ipv6_multicast? end it "returns false for another address" do - Addrinfo.ip('::1').ipv6_multicast?.should == false - Addrinfo.ip('fe80::').ipv6_multicast?.should == false + Addrinfo.ip('::1').should_not.ipv6_multicast? + Addrinfo.ip('fe80::').should_not.ipv6_multicast? end end diff --git a/spec/ruby/library/socket/addrinfo/ipv6_sitelocal_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_sitelocal_spec.rb index dd202a1749f2f0..9158eb58099efa 100644 --- a/spec/ruby/library/socket/addrinfo/ipv6_sitelocal_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv6_sitelocal_spec.rb @@ -5,19 +5,19 @@ describe 'Addrinfo#ipv6_sitelocal?' do platform_is_not :aix do it 'returns true for a site-local address' do - Addrinfo.ip('feef::').ipv6_sitelocal?.should == true - Addrinfo.ip('fee0::').ipv6_sitelocal?.should == true - Addrinfo.ip('fee2::').ipv6_sitelocal?.should == true - Addrinfo.ip('feef::1').ipv6_sitelocal?.should == true + Addrinfo.ip('feef::').should.ipv6_sitelocal? + Addrinfo.ip('fee0::').should.ipv6_sitelocal? + Addrinfo.ip('fee2::').should.ipv6_sitelocal? + Addrinfo.ip('feef::1').should.ipv6_sitelocal? end end it 'returns false for a regular IPv6 address' do - Addrinfo.ip('::1').ipv6_sitelocal?.should == false + Addrinfo.ip('::1').should_not.ipv6_sitelocal? end it 'returns false for an IPv4 address' do - Addrinfo.ip('127.0.0.1').ipv6_sitelocal?.should == false + Addrinfo.ip('127.0.0.1').should_not.ipv6_sitelocal? end end end diff --git a/spec/ruby/library/socket/addrinfo/ipv6_unique_local_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_unique_local_spec.rb index b80a15fcb0db3e..22f0fa3b75ccbe 100644 --- a/spec/ruby/library/socket/addrinfo/ipv6_unique_local_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv6_unique_local_spec.rb @@ -2,17 +2,17 @@ describe 'Addrinfo#ipv6_unique_local?' do it 'returns true for an unique local IPv6 address' do - Addrinfo.ip('fc00::').ipv6_unique_local?.should == true - Addrinfo.ip('fd00::').ipv6_unique_local?.should == true - Addrinfo.ip('fcff::').ipv6_unique_local?.should == true + Addrinfo.ip('fc00::').should.ipv6_unique_local? + Addrinfo.ip('fd00::').should.ipv6_unique_local? + Addrinfo.ip('fcff::').should.ipv6_unique_local? end it 'returns false for a regular IPv6 address' do - Addrinfo.ip('::1').ipv6_unique_local?.should == false - Addrinfo.ip('fe00::').ipv6_unique_local?.should == false + Addrinfo.ip('::1').should_not.ipv6_unique_local? + Addrinfo.ip('fe00::').should_not.ipv6_unique_local? end it 'returns false for an IPv4 address' do - Addrinfo.ip('127.0.0.1').ipv6_unique_local?.should == false + Addrinfo.ip('127.0.0.1').should_not.ipv6_unique_local? end end diff --git a/spec/ruby/library/socket/addrinfo/ipv6_unspecified_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_unspecified_spec.rb index dd79d57503a670..d63979cedaa8b1 100644 --- a/spec/ruby/library/socket/addrinfo/ipv6_unspecified_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv6_unspecified_spec.rb @@ -2,14 +2,14 @@ describe 'Addrinfo#ipv6_unspecified?' do it 'returns true for an unspecified IPv6 address' do - Addrinfo.ip('::').ipv6_unspecified?.should == true + Addrinfo.ip('::').should.ipv6_unspecified? end it 'returns false for a regular IPv6 address' do - Addrinfo.ip('::1').ipv6_unspecified?.should == false + Addrinfo.ip('::1').should_not.ipv6_unspecified? end it 'returns false for an IPv4 address' do - Addrinfo.ip('127.0.0.1').ipv6_unspecified?.should == false + Addrinfo.ip('127.0.0.1').should_not.ipv6_unspecified? end end diff --git a/spec/ruby/library/socket/addrinfo/ipv6_v4compat_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_v4compat_spec.rb index ab8388a21bc2b4..21ca85af999912 100644 --- a/spec/ruby/library/socket/addrinfo/ipv6_v4compat_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv6_v4compat_spec.rb @@ -2,19 +2,19 @@ describe 'Addrinfo#ipv6_v4compat?' do it 'returns true for an IPv4 compatible address' do - Addrinfo.ip('::127.0.0.1').ipv6_v4compat?.should == true - Addrinfo.ip('::192.168.1.1').ipv6_v4compat?.should == true + Addrinfo.ip('::127.0.0.1').should.ipv6_v4compat? + Addrinfo.ip('::192.168.1.1').should.ipv6_v4compat? end it 'returns false for an IPv4 mapped address' do - Addrinfo.ip('::ffff:192.168.1.1').ipv6_v4compat?.should == false + Addrinfo.ip('::ffff:192.168.1.1').should_not.ipv6_v4compat? end it 'returns false for a regular IPv6 address' do - Addrinfo.ip('::1').ipv6_v4compat?.should == false + Addrinfo.ip('::1').should_not.ipv6_v4compat? end it 'returns false for an IPv4 address' do - Addrinfo.ip('127.0.0.1').ipv6_v4compat?.should == false + Addrinfo.ip('127.0.0.1').should_not.ipv6_v4compat? end end diff --git a/spec/ruby/library/socket/addrinfo/ipv6_v4mapped_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_v4mapped_spec.rb index 82b272c1650d9c..7dac0e75dbbe84 100644 --- a/spec/ruby/library/socket/addrinfo/ipv6_v4mapped_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv6_v4mapped_spec.rb @@ -2,19 +2,19 @@ describe 'Addrinfo#ipv6_v4mapped?' do it 'returns true for an IPv4 compatible address' do - Addrinfo.ip('::ffff:192.168.1.1').ipv6_v4mapped?.should == true + Addrinfo.ip('::ffff:192.168.1.1').should.ipv6_v4mapped? end it 'returns false for an IPv4 compatible address' do - Addrinfo.ip('::192.168.1.1').ipv6_v4mapped?.should == false - Addrinfo.ip('::127.0.0.1').ipv6_v4mapped?.should == false + Addrinfo.ip('::192.168.1.1').should_not.ipv6_v4mapped? + Addrinfo.ip('::127.0.0.1').should_not.ipv6_v4mapped? end it 'returns false for a regular IPv6 address' do - Addrinfo.ip('::1').ipv6_v4mapped?.should == false + Addrinfo.ip('::1').should_not.ipv6_v4mapped? end it 'returns false for an IPv4 address' do - Addrinfo.ip('127.0.0.1').ipv6_v4mapped?.should == false + Addrinfo.ip('127.0.0.1').should_not.ipv6_v4mapped? end end diff --git a/spec/ruby/library/socket/addrinfo/listen_spec.rb b/spec/ruby/library/socket/addrinfo/listen_spec.rb index 714a96ed6c0759..931093f7325c85 100644 --- a/spec/ruby/library/socket/addrinfo/listen_spec.rb +++ b/spec/ruby/library/socket/addrinfo/listen_spec.rb @@ -29,6 +29,6 @@ socket = sock end - socket.closed?.should == true + socket.should.closed? end end diff --git a/spec/ruby/library/socket/basicsocket/read_nonblock_spec.rb b/spec/ruby/library/socket/basicsocket/read_nonblock_spec.rb index 4986fffbc5fdc9..b8def7e93033ba 100644 --- a/spec/ruby/library/socket/basicsocket/read_nonblock_spec.rb +++ b/spec/ruby/library/socket/basicsocket/read_nonblock_spec.rb @@ -24,20 +24,20 @@ platform_is :linux do it 'does not set the IO in nonblock mode' do require 'io/nonblock' - @r.nonblock?.should == false + @r.should_not.nonblock? IO.select([@r], nil, nil, 2) @r.read_nonblock(3).should == "aaa" - @r.nonblock?.should == false + @r.should_not.nonblock? end end platform_is_not :linux, :windows do it 'sets the IO in nonblock mode' do require 'io/nonblock' - @r.nonblock?.should == false + @r.should_not.nonblock? IO.select([@r], nil, nil, 2) @r.read_nonblock(3).should == "aaa" - @r.nonblock?.should == true + @r.should.nonblock? end end end diff --git a/spec/ruby/library/socket/basicsocket/write_nonblock_spec.rb b/spec/ruby/library/socket/basicsocket/write_nonblock_spec.rb index 95ec08a6c7be1c..c385beab24a589 100644 --- a/spec/ruby/library/socket/basicsocket/write_nonblock_spec.rb +++ b/spec/ruby/library/socket/basicsocket/write_nonblock_spec.rb @@ -25,18 +25,18 @@ platform_is :linux do it 'does not set the IO in nonblock mode' do require 'io/nonblock' - @w.nonblock?.should == false + @w.should_not.nonblock? @w.write_nonblock("aaa").should == 3 - @w.nonblock?.should == false + @w.should_not.nonblock? end end platform_is_not :linux, :windows do it 'sets the IO in nonblock mode' do require 'io/nonblock' - @w.nonblock?.should == false + @w.should_not.nonblock? @w.write_nonblock("aaa").should == 3 - @w.nonblock?.should == true + @w.should.nonblock? end end end diff --git a/spec/ruby/library/socket/socket/tcp_server_sockets_spec.rb b/spec/ruby/library/socket/socket/tcp_server_sockets_spec.rb index 10c030a8ce89e4..bd496d301560b3 100644 --- a/spec/ruby/library/socket/socket/tcp_server_sockets_spec.rb +++ b/spec/ruby/library/socket/socket/tcp_server_sockets_spec.rb @@ -32,7 +32,7 @@ Socket.tcp_server_sockets(0) { |socks| sockets = socks } sockets.each do |socket| - socket.closed?.should == true + socket.should.closed? end end end diff --git a/spec/ruby/library/socket/socket/tcp_spec.rb b/spec/ruby/library/socket/socket/tcp_spec.rb index d36e3e6adb66dd..faf020b1ead615 100644 --- a/spec/ruby/library/socket/socket/tcp_spec.rb +++ b/spec/ruby/library/socket/socket/tcp_spec.rb @@ -36,7 +36,7 @@ @socket = socket end - @socket.closed?.should == true + @socket.should.closed? end it 'binds to a local address and port when specified' do diff --git a/spec/ruby/library/socket/socket/udp_server_sockets_spec.rb b/spec/ruby/library/socket/socket/udp_server_sockets_spec.rb index 3aeb472dda5a51..f8be672612aa8f 100644 --- a/spec/ruby/library/socket/socket/udp_server_sockets_spec.rb +++ b/spec/ruby/library/socket/socket/udp_server_sockets_spec.rb @@ -32,7 +32,7 @@ Socket.udp_server_sockets(0) { |socks| sockets = socks } sockets.each do |socket| - socket.closed?.should == true + socket.should.closed? end end end diff --git a/spec/ruby/library/socket/socket/unix_spec.rb b/spec/ruby/library/socket/socket/unix_spec.rb index add54a097d4560..4bff59bd4b3d44 100644 --- a/spec/ruby/library/socket/socket/unix_spec.rb +++ b/spec/ruby/library/socket/socket/unix_spec.rb @@ -38,7 +38,7 @@ socket = sock end - socket.closed?.should == true + socket.should.closed? end end end diff --git a/spec/ruby/library/socket/unixsocket/open_spec.rb b/spec/ruby/library/socket/unixsocket/open_spec.rb index ad5048fedd15a6..99ad151bb83072 100644 --- a/spec/ruby/library/socket/unixsocket/open_spec.rb +++ b/spec/ruby/library/socket/unixsocket/open_spec.rb @@ -21,7 +21,7 @@ it "opens a unix socket on the specified file and yields it to the block" do UNIXSocket.open(@path) do |client| client.addr[0].should == "AF_UNIX" - client.closed?.should == false + client.should_not.closed? end end end diff --git a/spec/ruby/library/socket/unixsocket/shared/new.rb b/spec/ruby/library/socket/unixsocket/shared/new.rb index 76a4e1701ece0f..bfb7ed3886f5f6 100644 --- a/spec/ruby/library/socket/unixsocket/shared/new.rb +++ b/spec/ruby/library/socket/unixsocket/shared/new.rb @@ -18,7 +18,7 @@ @client = UNIXSocket.send(@method, @path) @client.addr[0].should == "AF_UNIX" - @client.closed?.should == false + @client.should_not.closed? end end end diff --git a/spec/ruby/library/stringio/reopen_spec.rb b/spec/ruby/library/stringio/reopen_spec.rb index ab0a3331d25930..99439783777103 100644 --- a/spec/ruby/library/stringio/reopen_spec.rb +++ b/spec/ruby/library/stringio/reopen_spec.rb @@ -283,7 +283,7 @@ new_io = StringIO.new("tainted") new_io.taint @io.reopen(new_io) - @io.tainted?.should == true + @io.should.tainted? end end diff --git a/spec/ruby/library/syslog/close_spec.rb b/spec/ruby/library/syslog/close_spec.rb index 8186ecf1257365..8c3b67c05bd8d6 100644 --- a/spec/ruby/library/syslog/close_spec.rb +++ b/spec/ruby/library/syslog/close_spec.rb @@ -30,7 +30,7 @@ -> { Syslog.open { |s| s.close } }.should raise_error(RuntimeError) - Syslog.opened?.should == false + Syslog.should_not.opened? end it "sets the identity to nil" do diff --git a/spec/ruby/library/syslog/ident_spec.rb b/spec/ruby/library/syslog/ident_spec.rb index e8345ebb490029..3b083271406a68 100644 --- a/spec/ruby/library/syslog/ident_spec.rb +++ b/spec/ruby/library/syslog/ident_spec.rb @@ -21,7 +21,7 @@ end it "returns nil if the log is closed" do - Syslog.opened?.should == false + Syslog.should_not.opened? Syslog.ident.should == nil end diff --git a/spec/ruby/library/syslog/mask_spec.rb b/spec/ruby/library/syslog/mask_spec.rb index 6581f6a756f7f0..b3f1250b24ac9d 100644 --- a/spec/ruby/library/syslog/mask_spec.rb +++ b/spec/ruby/library/syslog/mask_spec.rb @@ -32,7 +32,7 @@ end it "returns nil if the log is closed" do - Syslog.opened?.should == false + Syslog.should_not.opened? Syslog.mask.should == nil end diff --git a/spec/ruby/library/weakref/weakref_alive_spec.rb b/spec/ruby/library/weakref/weakref_alive_spec.rb index 173ea0148592a1..1ebf9c1ee39821 100644 --- a/spec/ruby/library/weakref/weakref_alive_spec.rb +++ b/spec/ruby/library/weakref/weakref_alive_spec.rb @@ -5,7 +5,7 @@ it "returns true if the object is reachable" do obj = Object.new ref = WeakRef.new(obj) - ref.weakref_alive?.should == true + ref.weakref_alive?.should be_true end it "returns a falsy value if the object is no longer reachable" do diff --git a/spec/ruby/library/win32ole/win32ole_param/input_spec.rb b/spec/ruby/library/win32ole/win32ole_param/input_spec.rb index a0022fef131d2e..e2a90daa5663fd 100644 --- a/spec/ruby/library/win32ole/win32ole_param/input_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_param/input_spec.rb @@ -13,7 +13,7 @@ end it "returns true for 3rd parameter of FileSystemObject's 'CopyFile' method" do - @param_overwritefiles.input?.should == true + @param_overwritefiles.should.input? end end diff --git a/spec/ruby/library/zlib/gzipfile/close_spec.rb b/spec/ruby/library/zlib/gzipfile/close_spec.rb index 870870f2fa4306..964b5ffb4dcd44 100644 --- a/spec/ruby/library/zlib/gzipfile/close_spec.rb +++ b/spec/ruby/library/zlib/gzipfile/close_spec.rb @@ -8,7 +8,7 @@ Zlib::GzipWriter.wrap io do |gzio| gzio.close - gzio.closed?.should == true + gzio.should.closed? -> { gzio.orig_name }.should \ raise_error(Zlib::GzipFile::Error, 'closed gzip stream') diff --git a/spec/ruby/library/zlib/gzipfile/closed_spec.rb b/spec/ruby/library/zlib/gzipfile/closed_spec.rb index b885add485d0db..726f391b4150e1 100644 --- a/spec/ruby/library/zlib/gzipfile/closed_spec.rb +++ b/spec/ruby/library/zlib/gzipfile/closed_spec.rb @@ -6,11 +6,11 @@ it "returns the closed status" do io = StringIO.new Zlib::GzipWriter.wrap io do |gzio| - gzio.closed?.should == false + gzio.should_not.closed? gzio.close - gzio.closed?.should == true + gzio.should.closed? end end end diff --git a/spec/ruby/library/zlib/zstream/flush_next_out_spec.rb b/spec/ruby/library/zlib/zstream/flush_next_out_spec.rb index 59a0622903eb07..63676a82032ae4 100644 --- a/spec/ruby/library/zlib/zstream/flush_next_out_spec.rb +++ b/spec/ruby/library/zlib/zstream/flush_next_out_spec.rb @@ -8,7 +8,7 @@ zs << [120, 156, 75, 203, 207, 7, 0, 2, 130, 1, 69].pack('C*') zs.flush_next_out.should == 'foo' - zs.finished?.should == true + zs.should.finished? zs.flush_next_out.should == '' end end diff --git a/spec/ruby/optional/capi/kernel_spec.rb b/spec/ruby/optional/capi/kernel_spec.rb index ff882035010726..cbd0a50deaaba4 100644 --- a/spec/ruby/optional/capi/kernel_spec.rb +++ b/spec/ruby/optional/capi/kernel_spec.rb @@ -9,7 +9,7 @@ describe "rb_block_given_p" do it "returns false if no block is passed" do - @s.rb_block_given_p.should == false + @s.should_not.rb_block_given_p end it "returns true if a block is passed" do @@ -483,7 +483,7 @@ def proc_caller proc = @s.rb_block_proc { 1+1 } proc.should be_kind_of(Proc) proc.call.should == 2 - proc.lambda?.should == false + proc.should_not.lambda? end it "passes through an existing lambda and does not convert to a proc" do @@ -491,7 +491,7 @@ def proc_caller proc = @s.rb_block_proc(&b) proc.should equal(b) proc.call.should == 2 - proc.lambda?.should == true + proc.should.lambda? end end @@ -500,7 +500,7 @@ def proc_caller proc = @s.rb_block_lambda { 1+1 } proc.should be_kind_of(Proc) proc.call.should == 2 - proc.lambda?.should == true + proc.should.lambda? end it "passes through an existing Proc and does not convert to a lambda" do @@ -508,7 +508,7 @@ def proc_caller proc = @s.rb_block_lambda(&b) proc.should equal(b) proc.call.should == 2 - proc.lambda?.should == false + proc.should_not.lambda? end end diff --git a/spec/ruby/optional/capi/object_spec.rb b/spec/ruby/optional/capi/object_spec.rb index 8b9e8bbc251174..bbcaec2ba8a05d 100644 --- a/spec/ruby/optional/capi/object_spec.rb +++ b/spec/ruby/optional/capi/object_spec.rb @@ -675,9 +675,9 @@ def reach ruby_version_is ''...'2.7' do it "marks the object passed as tainted" do obj = "" - obj.tainted?.should == false + obj.should_not.tainted? @o.rb_obj_taint(obj) - obj.tainted?.should == true + obj.should.tainted? end it "raises a FrozenError if the object passed is frozen" do diff --git a/spec/ruby/optional/capi/shared/rbasic.rb b/spec/ruby/optional/capi/shared/rbasic.rb index 40761122ef8999..c25733f862bef6 100644 --- a/spec/ruby/optional/capi/shared/rbasic.rb +++ b/spec/ruby/optional/capi/shared/rbasic.rb @@ -17,7 +17,7 @@ obj, _ = @data.call initial = @specs.get_flags(obj) @specs.set_flags(obj, @freeze | initial).should == @freeze | initial - obj.frozen?.should == true + obj.should.frozen? end ruby_version_is ""..."2.7" do @@ -41,16 +41,16 @@ obj, _ = @data.call initial = @specs.get_flags(obj) @specs.set_flags(obj, @taint | initial).should == @taint | initial - obj.tainted?.should == true + obj.should.tainted? @specs.set_flags(obj, initial).should == initial - obj.tainted?.should == false + obj.should_not.tainted? @specs.set_flags(obj, @freeze | initial).should == @freeze | initial - obj.frozen?.should == true + obj.should.frozen? obj, _ = @data.call @specs.set_flags(obj, @freeze | @taint | initial).should == @freeze | @taint | initial - obj.tainted?.should == true - obj.frozen?.should == true + obj.should.tainted? + obj.should.frozen? end end diff --git a/spec/ruby/optional/capi/string_spec.rb b/spec/ruby/optional/capi/string_spec.rb index 224d63f8860fe5..57ac9545f44155 100644 --- a/spec/ruby/optional/capi/string_spec.rb +++ b/spec/ruby/optional/capi/string_spec.rb @@ -76,7 +76,7 @@ def inspect it "invalidates the code range" do @s.rb_str_set_len(@str, 4) - @str.ascii_only?.should == true + @str.should.ascii_only? end it "updates the string's attributes visible in C code" do @@ -183,7 +183,7 @@ def inspect ruby_version_is ''...'2.7' do it "returns a non-tainted string" do - @s.rb_str_new("hello", 5).tainted?.should == false + @s.rb_str_new("hello", 5).should_not.tainted? end end @@ -288,8 +288,8 @@ def inspect str2 = @s.rb_str_new4 str1 str1.should == str2 str1.should equal(str2) - str1.frozen?.should == true - str2.frozen?.should == true + str1.should.frozen? + str2.should.frozen? end it "returns a frozen copy of the string" do @@ -297,7 +297,7 @@ def inspect str2 = @s.rb_str_new4 str1 str1.should == str2 str1.should_not equal(str2) - str2.frozen?.should == true + str2.should.frozen? end end diff --git a/spec/ruby/optional/capi/tracepoint_spec.rb b/spec/ruby/optional/capi/tracepoint_spec.rb index 6aeac54921426c..2043b7c9418d71 100644 --- a/spec/ruby/optional/capi/tracepoint_spec.rb +++ b/spec/ruby/optional/capi/tracepoint_spec.rb @@ -15,7 +15,7 @@ it "returns a tracepoint object" do @trace = @s.rb_tracepoint_new(7) @trace.should be_an_instance_of(TracePoint) - @trace.enabled?.should == false + @trace.should_not.enabled? end it "traces lines when given RUBY_EVENT_LINE" do @@ -28,20 +28,20 @@ describe "rb_tracepoint_disable" do it "disables an enabled TracePoint" do @trace = @s.rb_tracepoint_new(9) - @trace.enabled?.should == false + @trace.should_not.enabled? @trace.enable - @trace.enabled?.should == true + @trace.should.enabled? @s.rb_tracepoint_disable(@trace).should == false - @trace.enabled?.should == false + @trace.should_not.enabled? end end describe "rb_tracepoint_enable" do it "enables a disabled TracePoint" do @trace = @s.rb_tracepoint_new(10) - @trace.enabled?.should == false + @trace.should_not.enabled? @s.rb_tracepoint_enable(@trace).should == true - @trace.enabled?.should == true + @trace.should.enabled? end end diff --git a/spec/ruby/security/cve_2020_10663_spec.rb b/spec/ruby/security/cve_2020_10663_spec.rb index e305c0b593d4d2..634afda52557c6 100644 --- a/spec/ruby/security/cve_2020_10663_spec.rb +++ b/spec/ruby/security/cve_2020_10663_spec.rb @@ -26,7 +26,7 @@ def to_json(*args) describe "CVE-2020-10663 is resisted by" do it "only creating custom objects if passed create_additions: true or using JSON.load" do obj = JSONSpecs::MyClass.new("bar") - JSONSpecs::MyClass.json_creatable?.should == true + JSONSpecs::MyClass.should.json_creatable? json = JSON.dump(obj) JSON.parse(json, create_additions: true).class.should == JSONSpecs::MyClass diff --git a/spec/ruby/shared/string/times.rb b/spec/ruby/shared/string/times.rb index 6b45f7aa1e7e83..6827db22713844 100644 --- a/spec/ruby/shared/string/times.rb +++ b/spec/ruby/shared/string/times.rb @@ -38,7 +38,7 @@ class MyString < String; end str.taint [0, 1, 2].each do |arg| - @object.call(str, arg).tainted?.should == true + @object.call(str, arg).should.tainted? end end end From 5b28f01d77aaf02dc3717c986b8b90f8e99b7f5a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 4 May 2020 00:00:27 +0900 Subject: [PATCH 204/234] Make int-pair-to-real conversion more portable And utilize more bits even if DBL_MANT_DIG > 53. --- random.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/random.c b/random.c index e5676656cccb0a..de2767a93d9c86 100644 --- a/random.c +++ b/random.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #ifdef HAVE_UNISTD_H @@ -75,12 +76,22 @@ genrand_real(struct MT *mt) return int_pair_to_real_exclusive(a, b); } +static const double dbl_reduce_scale = /* 2**(-DBL_MANT_DIG) */ + (1.0 + / (double)(DBL_MANT_DIG > 2*31 ? (1ul<<31) : 1.0) + / (double)(DBL_MANT_DIG > 1*31 ? (1ul<<31) : 1.0) + / (double)(1ul<<(DBL_MANT_DIG%31))); + static double int_pair_to_real_exclusive(uint32_t a, uint32_t b) { - a >>= 5; - b >>= 6; - return(a*67108864.0+b)*(1.0/9007199254740992.0); + static const int a_shift = DBL_MANT_DIG < 64 ? + (64-DBL_MANT_DIG)/2 : 0; + static const int b_shift = DBL_MANT_DIG < 64 ? + (64-DBL_MANT_DIG)-a_shift : 0; + a >>= a_shift; + b >>= b_shift; + return (a*(double)(1ul<<(32-b_shift))+b)*dbl_reduce_scale; } /* generates a random number on [0,1] with 53-bit resolution*/ @@ -148,7 +159,7 @@ static double int_pair_to_real_inclusive(uint32_t a, uint32_t b) { double r; - enum {dig = 53}; + enum {dig = DBL_MANT_DIG}; enum {dig_u = dig-32, dig_r64 = 64-dig, bmask = ~(~0u<<(dig_r64))}; #if defined HAVE_UINT128_T const uint128_t m = ((uint128_t)1 << dig) | 1; @@ -163,7 +174,7 @@ int_pair_to_real_inclusive(uint32_t a, uint32_t b) b = (b >> dig_r64) + (((a >> dig_u) + (b & bmask)) >> dig_r64); r = (double)a * (1 << dig_u) + b; #endif - return ldexp(r, -dig); + return r * dbl_reduce_scale; } VALUE rb_cRandom; From dfbbd94ec171dbf276ccc6d9c5adb6d4e8b347fc Mon Sep 17 00:00:00 2001 From: git Date: Mon, 4 May 2020 00:00:54 +0900 Subject: [PATCH 205/234] * 2020-05-04 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index dfb18f7b7eff6c..35a2d1a93a59d5 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 3 +#define RUBY_RELEASE_DAY 4 #include "ruby/version.h" From 41e547e60cffcaaa2a5a9aeb54df3295b8d88426 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 4 May 2020 00:27:14 +0900 Subject: [PATCH 206/234] Fixed constant initializer An expression using `static const` value seems not considered as `static const` by Visual C. --- random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/random.c b/random.c index de2767a93d9c86..dc4ad760e4f980 100644 --- a/random.c +++ b/random.c @@ -88,7 +88,7 @@ int_pair_to_real_exclusive(uint32_t a, uint32_t b) static const int a_shift = DBL_MANT_DIG < 64 ? (64-DBL_MANT_DIG)/2 : 0; static const int b_shift = DBL_MANT_DIG < 64 ? - (64-DBL_MANT_DIG)-a_shift : 0; + (65-DBL_MANT_DIG)/2 : 0; a >>= a_shift; b >>= b_shift; return (a*(double)(1ul<<(32-b_shift))+b)*dbl_reduce_scale; From f72bec2cea313f7a72a6f907f3dd64f766e917f6 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 3 May 2020 13:58:54 -0700 Subject: [PATCH 207/234] Travis s390x-linux is too unstable It has caused errors by ENOSPC like https://travis-ci.org/github/ruby/ruby/jobs/682520961 too often. I cleared all cache of Travis yesterday, but it didn't help it. Until somebody figures out how to fix it, let me exclude it from CI status reports to avoid false alerts. --- .travis.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index c720cb354daa32..20a70a2fc17db8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -426,10 +426,7 @@ matrix: include: # Build every commit: - <<: *x86_64-linux - - <<: *arm64-linux - <<: *i686-linux - - <<: *arm32-linux - - <<: *s390x-linux - <<: *pedanticism - <<: *assertions - <<: *baseruby @@ -437,6 +434,9 @@ matrix: - <<: *rubyspec27 - <<: *dependency # Build every commit (Allowed Failures): + - <<: *arm32-linux + - <<: *arm64-linux + - <<: *s390x-linux - <<: *ASAN - <<: *MSAN - <<: *UBSAN @@ -451,10 +451,11 @@ matrix: - <<: *CALL_THREADED_CODE - <<: *NO_THREADED_CODE allow_failures: - - name: -fsanitize=address - - name: -fsanitize=memory - name: arm32-linux - name: arm64-linux + - name: s390x-linux + - name: -fsanitize=address + - name: -fsanitize=memory fast_finish: true before_script: From 077619848623e9c7f8d6d8041596199115b7fc68 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 3 May 2020 15:49:48 -0700 Subject: [PATCH 208/234] Debug Solaris's MJIT failure using -Winvalid-pch https://rubyci.org/logs/rubyci.s3.amazonaws.com/solaris10-gcc/ruby-master/log/20200501T170004Z.fail.html.gz --- mjit_worker.c | 6 +++++- test/lib/jit_support.rb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mjit_worker.c b/mjit_worker.c index 59428804eb69dd..145ad54383ddbe 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -266,7 +266,11 @@ static char *libruby_pathflag; #if defined(__GNUC__) && \ (!defined(__clang__) || \ (defined(__clang__) && (defined(__FreeBSD__) || defined(__GLIBC__)))) -# define GCC_PIC_FLAGS "-Wfatal-errors", "-fPIC", "-shared", "-w", "-pipe", +# ifdef __sun +# define GCC_PIC_FLAGS "-Winvalid-pch", "-fPIC", "-shared", "-w", "-pipe", +# else +# define GCC_PIC_FLAGS "-Wfatal-errors", "-fPIC", "-shared", "-w", "-pipe", +# endif # define MJIT_CFLAGS_PIPE 1 #else # define GCC_PIC_FLAGS /* empty */ diff --git a/test/lib/jit_support.rb b/test/lib/jit_support.rb index 26d3d97b8ab1c4..60944527f3df95 100644 --- a/test/lib/jit_support.rb +++ b/test/lib/jit_support.rb @@ -56,7 +56,7 @@ def supported? return @supported if defined?(@supported) @supported = RbConfig::CONFIG["MJIT_SUPPORT"] != 'no' && UNSUPPORTED_COMPILERS.all? do |regexp| !regexp.match?(RbConfig::CONFIG['MJIT_CC']) - end && !appveyor_pdb_corrupted? && !PENDING_RUBYCI_NICKNAMES.include?(ENV['RUBYCI_NICKNAME']) && /mingw/ !~ RUBY_PLATFORM && /solaris/ !~ RUBY_PLATFORM # TODO: remove mingw / solaris exclusion after investigation + end && !appveyor_pdb_corrupted? && !PENDING_RUBYCI_NICKNAMES.include?(ENV['RUBYCI_NICKNAME']) && /mingw/ !~ RUBY_PLATFORM # TODO: remove mingw exclusion after investigation end # AppVeyor's Visual Studio 2013 / 2015 are known to spuriously generate broken pch / pdb, like: From 9aa5fe1bf89db8cd215b24d8ddfb668714681b83 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 3 May 2020 16:15:45 -0700 Subject: [PATCH 209/234] Split compile and link for MinGW support MinGW test_jit fails with no error message. Perhaps linker flags should not be passed when compilation is happening. Anyway splitting these stages doesn't matter for performance. So let me just split it to fix the issue. Probably this helps Solaris's issue too. --- mjit_worker.c | 41 ++++++++++++++++++++++++++++------------- test/lib/jit_support.rb | 2 +- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/mjit_worker.c b/mjit_worker.c index 145ad54383ddbe..49903f2cd47bdc 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -855,30 +855,45 @@ make_pch(void) } // Compile .c file to .so file. It returns true if it succeeds. (non-mswin) +// Not compiling .c to .so directly because it fails on MinGW. static bool compile_c_to_so(const char *c_file, const char *so_file) { - const char *options[] = { - "-o", so_file, c_file, + char* o_file = alloca(strlen(c_file) + 1); + strcpy(o_file, c_file); + o_file[strlen(c_file) - 1] = 'o'; + + const char *o_args[] = { + "-o", o_file, c_file, # ifdef __clang__ "-include-pch", pch_file, # endif + "-c", NULL + }; + char **args = form_args(5, cc_common_args, CC_CODEFLAG_ARGS, cc_added_args, o_args, CC_LINKER_ARGS); + if (args == NULL) return false; + int exit_code = exec_process(cc_path, args); + free(args); + if (exit_code != 0) { + verbose(2, "compile_c_to_so: failed to compile .c to .o: %d", exit_code); + return false; + } + + const char *so_args[] = { + "-o", so_file, # ifdef _WIN32 libruby_pathflag, # endif - NULL + o_file, NULL }; - - char **args = form_args(7, CC_LDSHARED_ARGS, CC_CODEFLAG_ARGS, cc_added_args, - options, CC_LIBS, CC_DLDFLAGS_ARGS, CC_LINKER_ARGS); - if (args == NULL) - return false; - - int exit_code = exec_process(cc_path, args); + args = form_args(6, CC_LDSHARED_ARGS, CC_CODEFLAG_ARGS, so_args, CC_LIBS, CC_DLDFLAGS_ARGS, CC_LINKER_ARGS); + if (args == NULL) return false; + exit_code = exec_process(cc_path, args); free(args); - - if (exit_code != 0) - verbose(2, "compile_c_to_so: compile error: %d", exit_code); + if (!mjit_opts.save_temps) remove_file(o_file); + if (exit_code != 0) { + verbose(2, "compile_c_to_so: failed to link .o to .so: %d", exit_code); + } return exit_code == 0; } diff --git a/test/lib/jit_support.rb b/test/lib/jit_support.rb index 60944527f3df95..4232f01a8e2011 100644 --- a/test/lib/jit_support.rb +++ b/test/lib/jit_support.rb @@ -56,7 +56,7 @@ def supported? return @supported if defined?(@supported) @supported = RbConfig::CONFIG["MJIT_SUPPORT"] != 'no' && UNSUPPORTED_COMPILERS.all? do |regexp| !regexp.match?(RbConfig::CONFIG['MJIT_CC']) - end && !appveyor_pdb_corrupted? && !PENDING_RUBYCI_NICKNAMES.include?(ENV['RUBYCI_NICKNAME']) && /mingw/ !~ RUBY_PLATFORM # TODO: remove mingw exclusion after investigation + end && !appveyor_pdb_corrupted? && !PENDING_RUBYCI_NICKNAMES.include?(ENV['RUBYCI_NICKNAME']) end # AppVeyor's Visual Studio 2013 / 2015 are known to spuriously generate broken pch / pdb, like: From a8d39a051c3489a04c8088f7fefac56f0e5b7fef Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 3 May 2020 16:49:30 -0700 Subject: [PATCH 210/234] Test no .dSYM on macOS I think 9aa5fe1bf89db8cd215b24d8ddfb668714681b83 helps this issue too. --- mjit_worker.c | 3 ++- test/ruby/test_jit.rb | 14 ++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/mjit_worker.c b/mjit_worker.c index 49903f2cd47bdc..63f0d649818093 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -855,7 +855,8 @@ make_pch(void) } // Compile .c file to .so file. It returns true if it succeeds. (non-mswin) -// Not compiling .c to .so directly because it fails on MinGW. +// Not compiling .c to .so directly because it fails on MinGW, and this helps +// to generate no .dSYM on macOS. static bool compile_c_to_so(const char *c_file, const char *so_file) { diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb index 63579f27aadc83..a5d5fb45a96827 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -720,7 +720,7 @@ def mjit#{i} skip 'Removing so file is randomly failing on AppVeyor/RubyCI mswin due to Permission Denied.' else # verify .c files are deleted on unload_units - assert_send([Dir, :empty?, dir], debug_info) unless leave_dsym? + assert_send([Dir, :empty?, dir], debug_info) end end end @@ -939,7 +939,7 @@ def test_clean_so Dir.mktmpdir("jit_test_clean_so_") do |dir| code = "x = 0; 10.times {|i|x+=i}" eval_with_jit({"TMPDIR"=>dir}, code) - assert_send([Dir, :empty?, dir]) unless leave_dsym? + assert_send([Dir, :empty?, dir]) eval_with_jit({"TMPDIR"=>dir}, code, save_temps: true) assert_not_send([Dir, :empty?, dir]) end @@ -957,7 +957,7 @@ def a; end; a exec "true" end; error_message = "Undeleted files:\n #{Dir.glob("#{dir}/*").join("\n ")}\n" - assert_send([Dir, :empty?, dir], error_message) unless leave_dsym? + assert_send([Dir, :empty?, dir], error_message) end end @@ -1083,7 +1083,7 @@ def after_fork; end assert_equal("Successful MJIT finish\n" * 2, err.gsub(/^#{JIT_SUCCESS_PREFIX}:[^\n]+\n/, ''), debug_info) # ensure objects are deleted - assert_send([Dir, :empty?, dir], debug_info) unless leave_dsym? + assert_send([Dir, :empty?, dir], debug_info) end end if defined?(fork) @@ -1178,10 +1178,4 @@ def collect_insns(iseq_array) end insns end - - # `clang -g` on macOS creates a .dSYM directory. As it's only created on --jit-debug, - # we're ignoring it for now. TODO: remove .dSYM file - def leave_dsym? - /darwin/ =~ RUBY_PLATFORM && @jit_debug - end end From 39bd1244b49aa1fcf93d3163bfd97d94b109f2ee Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 3 May 2020 17:39:57 -0700 Subject: [PATCH 211/234] Revert 0776198486 for Solaris debug For some reason 0776198486 didn't fail https://rubyci.org/logs/rubyci.s3.amazonaws.com/solaris10-gcc/ruby-master/log/20200503T230004Z.log.html.gz even while it was before 9aa5fe1bf8. Anyway, there's no need to keep the change anymore. --- mjit_worker.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mjit_worker.c b/mjit_worker.c index 63f0d649818093..cebb9ce4f6e7b4 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -266,11 +266,7 @@ static char *libruby_pathflag; #if defined(__GNUC__) && \ (!defined(__clang__) || \ (defined(__clang__) && (defined(__FreeBSD__) || defined(__GLIBC__)))) -# ifdef __sun -# define GCC_PIC_FLAGS "-Winvalid-pch", "-fPIC", "-shared", "-w", "-pipe", -# else -# define GCC_PIC_FLAGS "-Wfatal-errors", "-fPIC", "-shared", "-w", "-pipe", -# endif +# define GCC_PIC_FLAGS "-Wfatal-errors", "-fPIC", "-shared", "-w", "-pipe", # define MJIT_CFLAGS_PIPE 1 #else # define GCC_PIC_FLAGS /* empty */ From b7e1eda932c74196d58e6b63644200b764b5453e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 4 May 2020 12:10:04 +0900 Subject: [PATCH 212/234] Suppress warnings by gcc 10.1.0-RC-20200430 * Folding results should not be empty. If `OnigCodePointCount(to->n)` were 0, `for` loop using `fn` wouldn't execute and `ncs` elements are not initialized. ``` enc/unicode.c:557:21: warning: 'ncs[0]' may be used uninitialized in this function [-Wmaybe-uninitialized] 557 | for (i = 0; i < ncs[0]; i++) { | ~~~^~~ ``` * Cast to `enum yytokentype` Additional enums for scanner events by ripper are not included in `yytokentype`. ``` ripper.y:7274:28: warning: implicit conversion from 'enum ' to 'enum yytokentype' [-Wenum-conversion] ``` --- enc/unicode.c | 4 ++++ ext/ripper/eventids2.c | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/enc/unicode.c b/enc/unicode.c index 6e8c3d8816aa91..18fba02476af66 100644 --- a/enc/unicode.c +++ b/enc/unicode.c @@ -493,6 +493,10 @@ onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc, #endif if ((to = onigenc_unicode_fold_lookup(code)) != 0) { + if (OnigCodePointCount(to->n) == 0) { + /* any codepoint should not be empty */ + UNREACHABLE_RETURN(0); + } if (OnigCodePointCount(to->n) == 1) { OnigCodePoint orig_code = code; diff --git a/ext/ripper/eventids2.c b/ext/ripper/eventids2.c index cdac2081e64b09..ac38663f2d2398 100644 --- a/ext/ripper/eventids2.c +++ b/ext/ripper/eventids2.c @@ -1,12 +1,20 @@ enum { tIGNORED_NL = tLAST_TOKEN + 1, +# define tIGNORED_NL ((enum yytokentype)tIGNORED_NL) tCOMMENT, +# define tCOMMENT ((enum yytokentype)tCOMMENT) tEMBDOC_BEG, +# define tEMBDOC_BEG ((enum yytokentype)tEMBDOC_BEG) tEMBDOC, +# define tEMBDOC ((enum yytokentype)tEMBDOC) tEMBDOC_END, +# define tEMBDOC_END ((enum yytokentype)tEMBDOC_END) tHEREDOC_BEG, +# define tHEREDOC_BEG ((enum yytokentype)tHEREDOC_BEG) tHEREDOC_END, - k__END__ +# define tHEREDOC_END ((enum yytokentype)tHEREDOC_END) + k__END__, +# define k__END__ ((enum yytokentype)k__END__) }; typedef struct { From d6389224da5aac0b36299cc6d968837407fdfe2c Mon Sep 17 00:00:00 2001 From: Kazuki Tsujimoto Date: Mon, 4 May 2020 13:17:45 +0900 Subject: [PATCH 213/234] Fix pseudo code for NODE_ARYPTN, NODE_HSHPTN Due to the change in 3893a8dd42fb3bbd71750648c3c0de118955a6ea, there is no longer a need to put true/false. --- compile.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/compile.c b/compile.c index 3c948186410231..97548b422fa953 100644 --- a/compile.c +++ b/compile.c @@ -5635,7 +5635,6 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c * goto match_failed * end * end - * true * goto matched * type_error: * FrozenCore.raise TypeError @@ -5806,7 +5805,6 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c * end * end * end - * true * goto matched * type_error: * FrozenCore.raise TypeError From 6ed7bc83ec077f691e79414fa0a2638ea3edbf7d Mon Sep 17 00:00:00 2001 From: Kazuki Tsujimoto Date: Mon, 4 May 2020 13:24:53 +0900 Subject: [PATCH 214/234] Fix indentation --- ext/objspace/objspace.c | 8 ++++---- node.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c index f470f74c5a2bf6..0799944a5b6ffe 100644 --- a/ext/objspace/objspace.c +++ b/ext/objspace/objspace.c @@ -382,9 +382,9 @@ count_nodes(int argc, VALUE *argv, VALUE os) COUNT_NODE(NODE_UNLESS); COUNT_NODE(NODE_CASE); COUNT_NODE(NODE_CASE2); - COUNT_NODE(NODE_CASE3); + COUNT_NODE(NODE_CASE3); COUNT_NODE(NODE_WHEN); - COUNT_NODE(NODE_IN); + COUNT_NODE(NODE_IN); COUNT_NODE(NODE_WHILE); COUNT_NODE(NODE_UNTIL); COUNT_NODE(NODE_ITER); @@ -478,8 +478,8 @@ count_nodes(int argc, VALUE *argv, VALUE os) COUNT_NODE(NODE_DSYM); COUNT_NODE(NODE_ATTRASGN); COUNT_NODE(NODE_LAMBDA); - COUNT_NODE(NODE_ARYPTN); - COUNT_NODE(NODE_HSHPTN); + COUNT_NODE(NODE_ARYPTN); + COUNT_NODE(NODE_HSHPTN); #undef COUNT_NODE case NODE_LAST: break; } diff --git a/node.h b/node.h index 40a5dd5de8eead..504153ab14d6c6 100644 --- a/node.h +++ b/node.h @@ -165,7 +165,7 @@ typedef struct RNode { long state; struct rb_global_entry *entry; struct rb_args_info *args; - struct rb_ary_pattern_info *apinfo; + struct rb_ary_pattern_info *apinfo; VALUE value; } u3; rb_code_location_t nd_loc; From 47720e2255f34ecad49763c66a7ea02a55a3f60a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 4 May 2020 13:35:38 +0900 Subject: [PATCH 215/234] Bison 3.59.1 folds yydestruct function header --- tool/ytab.sed | 1 + 1 file changed, 1 insertion(+) diff --git a/tool/ytab.sed b/tool/ytab.sed index ba7566ac7fab57..95a9b3e1eb3315 100755 --- a/tool/ytab.sed +++ b/tool/ytab.sed @@ -14,6 +14,7 @@ a\ } /^yydestruct.*yymsg/,/{/{ /^yydestruct/{ + /,$/N /[, *]p)/!{ H s/^/ruby_parser_&/ From 5c2508060b79b4299a18d05511d3530ad14b1b7a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 4 May 2020 18:10:02 +0900 Subject: [PATCH 216/234] Bison 3.5.91 now defaults parse.error to "simple" --- parse.y | 1 + tool/pure_parser.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/parse.y b/parse.y index 09ba4621240172..9f6bda35bab2f5 100644 --- a/parse.y +++ b/parse.y @@ -1014,6 +1014,7 @@ static int looking_at_eol_p(struct parser_params *p); %expect 0 %define api.pure +%define parse.error verbose %lex-param {struct parser_params *p} %parse-param {struct parser_params *p} %initial-action diff --git a/tool/pure_parser.rb b/tool/pure_parser.rb index e4aedfa81b775c..d07df681be9c3b 100755 --- a/tool/pure_parser.rb +++ b/tool/pure_parser.rb @@ -18,3 +18,4 @@ ARGV.push(file) } $_.sub!(/^%define\s+api\.pure/, '%pure-parser') +$_.sub!(/^%define\s+.*/, '') From 5ef019e8afca25442c7c12eea8822d88978141bb Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 4 May 2020 11:33:00 -0700 Subject: [PATCH 217/234] Output compaction stats in one loop / eliminate 0 counts We only need to loop `T_MASK` times once. Also, not every value between 0 and `T_MASK` is an actual Ruby type. Before this change, some integers were being added to the result hash even though they aren't actual types. This patch omits considered / moved entries that total 0, cleaning up the result hash and eliminating these "fake types". --- gc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gc.c b/gc.c index fb167bf7d5cc00..a3f2de74aa9bdb 100644 --- a/gc.c +++ b/gc.c @@ -8509,11 +8509,13 @@ gc_compact_stats(rb_objspace_t *objspace) VALUE moved = rb_hash_new(); for (i=0; ircompactor.considered_count_table[i])); - } + if(objspace->rcompactor.considered_count_table[i]) { + rb_hash_aset(considered, type_sym(i), SIZET2NUM(objspace->rcompactor.considered_count_table[i])); + } - for (i=0; ircompactor.moved_count_table[i])); + if(objspace->rcompactor.moved_count_table[i]) { + rb_hash_aset(moved, type_sym(i), SIZET2NUM(objspace->rcompactor.moved_count_table[i])); + } } rb_hash_aset(h, ID2SYM(rb_intern("considered")), considered); From dc13a980654c86f864434f077a4f1001f0d77afd Mon Sep 17 00:00:00 2001 From: git Date: Tue, 5 May 2020 05:50:47 +0900 Subject: [PATCH 218/234] * 2020-05-05 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 35a2d1a93a59d5..3dac54f4198791 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 4 +#define RUBY_RELEASE_DAY 5 #include "ruby/version.h" From f0b5629c8cc485753ad0af2ed414bc6ae70c629f Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 5 May 2020 13:53:44 +0900 Subject: [PATCH 219/234] envutil.rb: Also alias to #name --- tool/lib/envutil.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tool/lib/envutil.rb b/tool/lib/envutil.rb index 07d76c0e5329b5..0dd86dff5cfa75 100644 --- a/tool/lib/envutil.rb +++ b/tool/lib/envutil.rb @@ -244,7 +244,11 @@ def with_default_internal(enc) def labeled_module(name, &block) Module.new do - singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s} + singleton_class.class_eval { + define_method(:to_s) {name} + alias inspect to_s + alias name to_s + } class_eval(&block) if block end end @@ -252,7 +256,11 @@ def labeled_module(name, &block) def labeled_class(name, superclass = Object, &block) Class.new(superclass) do - singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s} + singleton_class.class_eval { + define_method(:to_s) {name} + alias inspect to_s + alias name to_s + } class_eval(&block) if block end end From e04418bb16cd99b4a4402e7457d3bdc967284f98 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 5 May 2020 23:23:39 +0900 Subject: [PATCH 220/234] [ruby/uri] Check if DN exists https://bugs.ruby-lang.org/issues/16830 https://github.com/ruby/uri/commit/b4bf8c1217 --- lib/uri/ldap.rb | 1 + test/uri/test_ldap.rb | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/uri/ldap.rb b/lib/uri/ldap.rb index a2043ccdf593f6..14e6163292dc50 100644 --- a/lib/uri/ldap.rb +++ b/lib/uri/ldap.rb @@ -118,6 +118,7 @@ def initialize(*arg) # Private method to cleanup +dn+ from using the +path+ component attribute. def parse_dn + raise InvalidURIError, 'bad LDAP URL' unless @path @dn = @path[1..-1] end private :parse_dn diff --git a/test/uri/test_ldap.rb b/test/uri/test_ldap.rb index adad4454b594e4..64845e487ac3e3 100644 --- a/test/uri/test_ldap.rb +++ b/test/uri/test_ldap.rb @@ -95,6 +95,10 @@ def test_select u.select(:scheme, :host, :not_exist, :port) end end + + def test_parse_invalid_uri + assert_raise(URI::InvalidURIError) {URI.parse("ldap:https://example.com")} + end end From 77f19d26b9abde74ec03a6d2a51688c49cad20f4 Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Fri, 1 May 2020 03:36:50 -0400 Subject: [PATCH 221/234] Fix gemspec --- lib/matrix/matrix.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matrix/matrix.gemspec b/lib/matrix/matrix.gemspec index 75f6b69a98f452..24e2d596740cdb 100644 --- a/lib/matrix/matrix.gemspec +++ b/lib/matrix/matrix.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| spec.homepage = "https://github.com/ruby/matrix" spec.license = "BSD-2-Clause" - spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/matrix.rb", "lib/matrix/eigenvalue_decomposition.rb", "lib/matrix/lup_decomposition.rb", "lib/matrix/version.rb", "matrix.gemspec"] + spec.files = [".gitignore", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/matrix.rb", "lib/matrix/eigenvalue_decomposition.rb", "lib/matrix/lup_decomposition.rb", "lib/matrix/version.rb", "matrix.gemspec"] spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] From 7bde98125e7f99cab6fe80b59189561bf66fcd0e Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Tue, 5 May 2020 17:02:59 -0400 Subject: [PATCH 222/234] Improve documentation for Enumerator#next, next_values, peek and peek_values. [DOC] [#16829] --- enumerator.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/enumerator.c b/enumerator.c index 9632b026981dbd..cc0cce8fae4a80 100644 --- a/enumerator.c +++ b/enumerator.c @@ -81,6 +81,14 @@ * puts e.next # => 3 * puts e.next # raises StopIteration * + * Note that enumeration sequence by +next+, +next_values+, +peek+ and + * +peek_values+ do not affect other non-external + * enumeration methods, unless the underlying iteration method itself has + * side-effect, e.g. IO#each_line. + * + * Moreover, implementation typically uses fibers so performance could be + * slower and exception stacktraces different than expected. + * * You can use this to implement an internal iterator as follows: * * def ext_each(e) @@ -804,6 +812,8 @@ get_next_values(VALUE obj, struct enumerator *e) * internal position forward. When the position reached at the end, * StopIteration is raised. * + * See class-level notes about external iterators. + * * This method can be used to distinguish yield and yield * nil. * @@ -837,10 +847,6 @@ get_next_values(VALUE obj, struct enumerator *e) * # yield nil [nil] nil * # yield [1, 2] [[1, 2]] [1, 2] * - * Note that +next_values+ does not affect other non-external enumeration - * methods unless underlying iteration method itself has side-effect, e.g. - * IO#each_line. - * */ static VALUE @@ -894,9 +900,7 @@ ary2sv(VALUE args, int dup) * p e.next #=> 3 * p e.next #raises StopIteration * - * Note that enumeration sequence by +next+ does not affect other non-external - * enumeration methods, unless the underlying iteration methods itself has - * side-effect, e.g. IO#each_line. + * See class-level notes about external iterators. * */ @@ -926,6 +930,8 @@ enumerator_peek_values(VALUE obj) * doesn't move the internal position forward. If the position is already at * the end, StopIteration is raised. * + * See class-level notes about external iterators. + * * === Example * * o = Object.new @@ -960,6 +966,8 @@ enumerator_peek_values_m(VALUE obj) * position forward. If the position is already at the end, StopIteration * is raised. * + * See class-level notes about external iterators. + * * === Example * * a = [1,2,3] From 86391a551737a4bafc8f30413da1a02daf58e180 Mon Sep 17 00:00:00 2001 From: git Date: Wed, 6 May 2020 06:04:39 +0900 Subject: [PATCH 223/234] * 2020-05-06 [ci skip] --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index 3dac54f4198791..8f72bf9cdedd44 100644 --- a/version.h +++ b/version.h @@ -16,7 +16,7 @@ #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 5 +#define RUBY_RELEASE_DAY 6 #include "ruby/version.h" From 00a9d697a86325cbc97cc9adc41b0829d21c3ea1 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Wed, 6 May 2020 00:09:56 +0200 Subject: [PATCH 224/234] Remove redundant check in rb_obj_cmp() * rb_equal() already checks using `obj1 == obj2`. --- object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/object.c b/object.c index 61a9d6200cc067..fead8419ea0586 100644 --- a/object.c +++ b/object.c @@ -1726,7 +1726,7 @@ rb_obj_not_match(VALUE obj1, VALUE obj2) static VALUE rb_obj_cmp(VALUE obj1, VALUE obj2) { - if (obj1 == obj2 || rb_equal(obj1, obj2)) + if (rb_equal(obj1, obj2)) return INT2FIX(0); return Qnil; } From 48d509cefc376df8af0ad0e08a09aecbd78f4f10 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Wed, 6 May 2020 00:11:42 +0200 Subject: [PATCH 225/234] Document rb_equal() and clarify the relation with Kernel#=== * Multiple times people have been confused and believed rb_equal() called #=== but it does not, it calls #==. * This optimization has a subtle side effect for Float::NAN, which is now documented. --- object.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/object.c b/object.c index fead8419ea0586..1e314e14a90420 100644 --- a/object.c +++ b/object.c @@ -141,7 +141,22 @@ rb_obj_setup(VALUE obj, VALUE klass, VALUE type) * Same as \c Object#===, case equality. *++ */ +static VALUE +case_equal(VALUE obj1, VALUE obj2) { + /* The default implementation of #=== is + * to call #== with the rb_equal() optimization. */ + return rb_equal(obj1, obj2); +} +/*! + * This function is an optimized version of calling #==. + * It checks equality between two objects by first doing a fast + * identity check using using C's == (same as BasicObject#equal?). + * If that check fails, it calls #== dynamically. + * This optimization actually affects semantics, + * as Float::NAN == Float::NAN is false, + * but rb_equal(Float::NAN, Float::NAN) is true! + */ VALUE rb_equal(VALUE obj1, VALUE obj2) { @@ -4598,7 +4613,7 @@ InitVM_Object(void) rb_define_private_method(rb_cModule, "method_undefined", rb_obj_dummy1, 1); rb_define_method(rb_mKernel, "nil?", rb_false, 0); - rb_define_method(rb_mKernel, "===", rb_equal, 1); + rb_define_method(rb_mKernel, "===", case_equal, 1); rb_define_method(rb_mKernel, "=~", rb_obj_match, 1); rb_define_method(rb_mKernel, "!~", rb_obj_not_match, 1); rb_define_method(rb_mKernel, "eql?", rb_obj_equal, 1); @@ -4665,7 +4680,7 @@ InitVM_Object(void) rb_define_method(rb_cNilClass, "&", false_and, 1); rb_define_method(rb_cNilClass, "|", false_or, 1); rb_define_method(rb_cNilClass, "^", false_xor, 1); - rb_define_method(rb_cNilClass, "===", rb_equal, 1); + rb_define_method(rb_cNilClass, "===", case_equal, 1); rb_define_method(rb_cNilClass, "nil?", rb_true, 0); rb_undef_alloc_func(rb_cNilClass); @@ -4751,7 +4766,7 @@ InitVM_Object(void) rb_define_method(rb_cTrueClass, "&", true_and, 1); rb_define_method(rb_cTrueClass, "|", true_or, 1); rb_define_method(rb_cTrueClass, "^", true_xor, 1); - rb_define_method(rb_cTrueClass, "===", rb_equal, 1); + rb_define_method(rb_cTrueClass, "===", case_equal, 1); rb_undef_alloc_func(rb_cTrueClass); rb_undef_method(CLASS_OF(rb_cTrueClass), "new"); @@ -4763,7 +4778,7 @@ InitVM_Object(void) rb_define_method(rb_cFalseClass, "&", false_and, 1); rb_define_method(rb_cFalseClass, "|", false_or, 1); rb_define_method(rb_cFalseClass, "^", false_xor, 1); - rb_define_method(rb_cFalseClass, "===", rb_equal, 1); + rb_define_method(rb_cFalseClass, "===", case_equal, 1); rb_undef_alloc_func(rb_cFalseClass); rb_undef_method(CLASS_OF(rb_cFalseClass), "new"); } From e79e5e0b40d28d0a7eaa06dbfd6b7812bbea2d1e Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Wed, 6 May 2020 00:24:29 +0200 Subject: [PATCH 226/234] Generalize the explanation of the side effect of the rb_equal() optimization --- object.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/object.c b/object.c index 1e314e14a90420..9830feff1093b8 100644 --- a/object.c +++ b/object.c @@ -154,8 +154,10 @@ case_equal(VALUE obj1, VALUE obj2) { * identity check using using C's == (same as BasicObject#equal?). * If that check fails, it calls #== dynamically. * This optimization actually affects semantics, - * as Float::NAN == Float::NAN is false, - * but rb_equal(Float::NAN, Float::NAN) is true! + * because when #== returns false for the same object obj, + * rb_equal(obj, obj) would still return true. + * This happens for Float::NAN, where Float::NAN == Float::NAN + * is false, but rb_equal(Float::NAN, Float::NAN) is true. */ VALUE rb_equal(VALUE obj1, VALUE obj2) From b0498caa7e92e3f53affb822ba73394624808c98 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 6 May 2020 09:43:49 +0900 Subject: [PATCH 227/234] Removed unnecessary duplicate code `rb_equal` may be inlined in `case_equal` and actually same code is generated twice. --- object.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/object.c b/object.c index 9830feff1093b8..30c3ba203010d0 100644 --- a/object.c +++ b/object.c @@ -141,12 +141,9 @@ rb_obj_setup(VALUE obj, VALUE klass, VALUE type) * Same as \c Object#===, case equality. *++ */ -static VALUE -case_equal(VALUE obj1, VALUE obj2) { +#define case_equal rb_equal /* The default implementation of #=== is * to call #== with the rb_equal() optimization. */ - return rb_equal(obj1, obj2); -} /*! * This function is an optimized version of calling #==. From 3a6dad9d8bcd973fc05d19f70702cba486195bc0 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 6 May 2020 09:51:01 +0900 Subject: [PATCH 228/234] [DOC] Removed no longer meaningful part [ci skip] As now `Object#===` document is separated from `rb_equal`, this note no longer makes sense. --- object.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/object.c b/object.c index 30c3ba203010d0..d3e100d11f0338 100644 --- a/object.c +++ b/object.c @@ -137,9 +137,6 @@ rb_obj_setup(VALUE obj, VALUE klass, VALUE type) * Case Equality -- For class Object, effectively the same as calling * #==, but typically overridden by descendants to provide * meaningful semantics in +case+ statements. - *-- - * Same as \c Object#===, case equality. - *++ */ #define case_equal rb_equal /* The default implementation of #=== is From 039a8ef78673f851e39b43980376c2af40d5cbbc Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 6 May 2020 10:09:29 +0900 Subject: [PATCH 229/234] leakchecker.rb: search /dev/fd too It is more popular than /proc/self/fd. --- tool/lib/leakchecker.rb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tool/lib/leakchecker.rb b/tool/lib/leakchecker.rb index 03eb5391c49f93..293ebe6a9adff7 100644 --- a/tool/lib/leakchecker.rb +++ b/tool/lib/leakchecker.rb @@ -35,19 +35,19 @@ def find_fds if IO.respond_to?(:console) and (m = IO.method(:console)).arity.nonzero? m[:close] end - fd_dir = "/proc/self/fd" - if File.directory?(fd_dir) - fds = Dir.open(fd_dir) {|d| - a = d.grep(/\A\d+\z/, &:to_i) - if d.respond_to? :fileno - a -= [d.fileno] - end - a - } - fds.sort - else - [] + %w"/proc/self/fd /dev/fd".each do |fd_dir| + if File.directory?(fd_dir) + fds = Dir.open(fd_dir) {|d| + a = d.grep(/\A\d+\z/, &:to_i) + if d.respond_to? :fileno + a -= [d.fileno] + end + a + } + return fds.sort + end end + [] end def check_fd_leak(test_name) From 7397b9f7867b787280c1a5c955c40bd44fcb8f35 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 6 May 2020 12:45:01 +0900 Subject: [PATCH 230/234] Fixed leaked fds --- test/socket/test_unix.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb index 6efb1d60ee87cb..e9c90be1673743 100644 --- a/test/socket/test_unix.rb +++ b/test/socket/test_unix.rb @@ -542,16 +542,20 @@ def test_getcred_ucred def test_getcred_xucred return if /freebsd|darwin/ !~ RUBY_PLATFORM - Dir.mktmpdir {|d| + Dir.mktmpdir do |d| sockpath = "#{d}/sock" serv = Socket.unix_server_socket(sockpath) - Socket.unix(sockpath) + u = Socket.unix(sockpath) s, = serv.accept cred = s.getsockopt(0, Socket::LOCAL_PEERCRED) inspect = cred.inspect assert_match(/ euid=#{Process.euid} /, inspect) assert_match(/ \(xucred\)/, inspect) - } + ensure + s&.close + u&.close + serv&.close + end end def test_sendcred_ucred From b247ac086e60a6cee99ea1989277c5c66b0541de Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 6 May 2020 13:13:10 +0900 Subject: [PATCH 231/234] Ignore FDs kept by system library `getaddrinfo` on macOS seems keeping FDs to query host names internally. --- tool/lib/leakchecker.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tool/lib/leakchecker.rb b/tool/lib/leakchecker.rb index 293ebe6a9adff7..bd0e24ba2e8f74 100644 --- a/tool/lib/leakchecker.rb +++ b/tool/lib/leakchecker.rb @@ -89,6 +89,19 @@ def check_fd_leak(test_name) }.sort.each {|s| str << s } + else + begin + io = IO.for_fd(fd, autoclose: false) + s = io.stat + rescue Errno::EBADF + # something un-stat-able + next + else + next if /darwin/ =~ RUBY_PLATFORM and [0, -1].include?(s.dev) + str << ' ' << s.inspect + ensure + io.close + end end puts "Leaked file descriptor: #{test_name}: #{fd}#{str}" puts " The IO was created at #{pos}" if pos From de3f725978730d16ee51401d40fa75ac12c871a0 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 6 May 2020 14:08:26 +0900 Subject: [PATCH 232/234] Makes nil-safe --- tool/lib/leakchecker.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/lib/leakchecker.rb b/tool/lib/leakchecker.rb index bd0e24ba2e8f74..a94d7a79b262f0 100644 --- a/tool/lib/leakchecker.rb +++ b/tool/lib/leakchecker.rb @@ -100,7 +100,7 @@ def check_fd_leak(test_name) next if /darwin/ =~ RUBY_PLATFORM and [0, -1].include?(s.dev) str << ' ' << s.inspect ensure - io.close + io&.close end end puts "Leaked file descriptor: #{test_name}: #{fd}#{str}" From 46b93175ed9fe061f309fe5538f23dc13aa1de0b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 6 May 2020 16:06:25 +0900 Subject: [PATCH 233/234] Fakes IPSocket.getaddress in the whole method To get rid of calling `getaddrinfo`, which may keep FDs internally. --- test/uri/test_generic.rb | 49 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb index 90f779c88c2cbe..b449a0a0d1fb6c 100644 --- a/test/uri/test_generic.rb +++ b/test/uri/test_generic.rb @@ -865,34 +865,30 @@ def test_find_proxy_get end def test_find_proxy_no_proxy + getaddress = IPSocket.method(:getaddress) + example_address = nil + IPSocket.singleton_class.class_eval do + undef getaddress + define_method(:getaddress) do |host| + case host + when "example.org", "www.example.org" + example_address + when /\A\d+(?:\.\d+){3}\z/ + host + else + raise host + end + end + end + with_proxy_env('http_proxy'=>'http://127.0.0.1:8080', 'no_proxy'=>'192.0.2.2') {|env| assert_equal(URI('http://127.0.0.1:8080'), URI("http://192.0.2.1/").find_proxy(env)) assert_nil(URI("http://192.0.2.2/").find_proxy(env)) - getaddress = IPSocket.method(:getaddress) - begin - class << IPSocket - undef getaddress - def getaddress(host) - host == "example.org" or raise - "192.0.2.1" - end - end - assert_equal(URI('http://127.0.0.1:8080'), URI.parse("http://example.org").find_proxy(env)) - class << IPSocket - undef getaddress - def getaddress(host) - host == "example.org" or raise - "192.0.2.2" - end - end - assert_nil(URI.parse("http://example.org").find_proxy(env)) - ensure - IPSocket.singleton_class.class_eval do - undef getaddress - define_method(:getaddress, getaddress) - end - end + example_address = "192.0.2.1" + assert_equal(URI('http://127.0.0.1:8080'), URI.parse("http://example.org").find_proxy(env)) + example_address = "192.0.2.2" + assert_nil(URI.parse("http://example.org").find_proxy(env)) } with_proxy_env('http_proxy'=>'http://127.0.0.1:8080', 'no_proxy'=>'example.org') {|env| assert_nil(URI("http://example.org/").find_proxy(env)) @@ -902,6 +898,11 @@ def getaddress(host) assert_equal(URI('http://127.0.0.1:8080'), URI("http://example.org/").find_proxy(env)) assert_nil(URI("http://www.example.org/").find_proxy(env)) } + ensure + IPSocket.singleton_class.class_eval do + undef getaddress + define_method(:getaddress, getaddress) + end end def test_find_proxy_no_proxy_cidr From 641a56ab47296db1c3f9198a189823b875310d64 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Wed, 6 May 2020 18:49:25 +0200 Subject: [PATCH 234/234] Add a test case for module name in rb_profile_frame_classpath --- test/-ext-/debug/test_profile_frames.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/-ext-/debug/test_profile_frames.rb b/test/-ext-/debug/test_profile_frames.rb index 5ea506046e45d7..f2e28b7ce95ef9 100644 --- a/test/-ext-/debug/test_profile_frames.rb +++ b/test/-ext-/debug/test_profile_frames.rb @@ -5,11 +5,19 @@ class SampleClassForTestProfileFrames class Sample2 def baz(block) - instance_eval "def zab(block) block.call end" + instance_eval "def zab(block) Sample3.qux(block) end" [self, zab(block)] end end + module Sample3 + class << self + def qux(block) + block.call + end + end + end + def self.bar(block) Sample2.new.baz(block) end