Skip to content

Commit

Permalink
Ensure opt_*array_send tests include method chains
Browse files Browse the repository at this point in the history
  • Loading branch information
rwstauner committed Dec 18, 2024
1 parent 9b59159 commit 767d41d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/ruby/test_optimization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1112,9 +1112,9 @@ def test_opt_duparray_send_include_p
[
'x = :b; [:a, :b].include?(x)',
'@c = :b; [:a, :b].include?(@c)',
'@c = "b"; %i[a b].include?(@c.to_sym)',
'@c = "B"; %i[a b].include?(@c.downcase.to_sym)',
'hash = {B: :b}; %i[a b].include?(hash[:B])',
'arr = Array(:b); %i[a b].include?(arr[0])',
'arr = Array("b"); %i[a b].include?(arr[0].to_sym)',
'response = {"status_code" => 200}; [100, 200].include? response["status_code"].to_i',
# Test passing ENV var but don't leak ENV modifications.
'begin; old = ENV["VAR"]; ENV["VAR"] = "1"; [1, 10].include? ENV["VAR"].to_i; ensure ENV["VAR"] = old; end',
Expand Down Expand Up @@ -1172,8 +1172,8 @@ def test_opt_newarray_send_include_p
'b = :b; [:a, b].include?(:b)',
# Use Object.new to ensure that we get newarray rather than duparray.
'value = 1; [Object.new, true, "true", 1].include?(value)',
'value = 1; [Object.new, "1"].include?(value.to_s)',
'hash = {a: "1"}; [Object.new, "1"].include?(hash[:a])',
'value = 1.1; [Object.new, "1"].include?(value.to_i.to_s)',
'hash = {a: 1}; [Object.new, "1"].include?(hash[:a].to_s)',
'arr = [1]; [Object.new, 1].include?(arr[0])',
'response = {"status_code" => "200"}; [Object.new, "200"].include? response["status_code"].to_s',
'[Object.new, "1", "true", ENV["VAR"]].include? ENV["VAR"]', # Test passing ENV var but don't modify ENV.
Expand Down

0 comments on commit 767d41d

Please sign in to comment.