From c047e961236ac318827583fc4bd6dc7e07377378 Mon Sep 17 00:00:00 2001 From: Herwin Date: Mon, 2 Feb 2026 14:22:22 +0100 Subject: [PATCH 1/3] Validate error message for IO.select with negative timeout --- core/io/select_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/io/select_spec.rb b/core/io/select_spec.rb index 9fdb7e12c..b4535cc9d 100644 --- a/core/io/select_spec.rb +++ b/core/io/select_spec.rb @@ -112,7 +112,7 @@ end it "raises an ArgumentError when passed a negative timeout" do - -> { IO.select(nil, nil, nil, -5)}.should raise_error(ArgumentError) + -> { IO.select(nil, nil, nil, -5)}.should raise_error(ArgumentError, "time interval must not be negative") end describe "returns the available descriptors when the file descriptor" do From 1fbb6bc6e1e06c9ea6d4a28e343bcfefdebc37eb Mon Sep 17 00:00:00 2001 From: Herwin Date: Wed, 28 Jan 2026 18:51:51 +0100 Subject: [PATCH 2/3] Add spec for IO.select with -INFINITY as timeout Since `(-Float::INFINITY).infinite?` returns a truthy value, this should probably be covered. --- core/io/select_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/io/select_spec.rb b/core/io/select_spec.rb index b4535cc9d..f85459612 100644 --- a/core/io/select_spec.rb +++ b/core/io/select_spec.rb @@ -115,6 +115,12 @@ -> { IO.select(nil, nil, nil, -5)}.should raise_error(ArgumentError, "time interval must not be negative") end + ruby_version_is "4.0" do + it "raises an ArgumentError when passed negative infinity as timeout" do + -> { IO.select(nil, nil, nil, -Float::INFINITY)}.should raise_error(ArgumentError, "time interval must not be negative") + end + end + describe "returns the available descriptors when the file descriptor" do it "is in both read and error arrays" do @wr.write("foobar") From c5ad958999be3556910be56d772a1b83334e37a9 Mon Sep 17 00:00:00 2001 From: Herwin Date: Wed, 28 Jan 2026 18:58:01 +0100 Subject: [PATCH 3/3] Add spec for IO.select with NaN as timeout --- core/io/select_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/io/select_spec.rb b/core/io/select_spec.rb index f85459612..8e0b89c05 100644 --- a/core/io/select_spec.rb +++ b/core/io/select_spec.rb @@ -121,6 +121,10 @@ end end + it "raises an RangeError when passed NaN as timeout" do + -> { IO.select(nil, nil, nil, Float::NAN)}.should raise_error(RangeError, "NaN out of Time range") + end + describe "returns the available descriptors when the file descriptor" do it "is in both read and error arrays" do @wr.write("foobar")