Skip to content

Instantly share code, notes, and snippets.

@bbuchalter
bbuchalter / case_test.rb
Last active May 25, 2022 11:31
Ruby can only parse 2498 case statement branches
case_statements = 10000
program = <<-RUBY
case(ARGV[1])
#{case_statements.times.map { |n| "when #{n+1} \n puts #{n+1}"}.join("\n")}
end
RUBY
File.write('test.rb', program)
puts "RUBY_VERSION=#{RUBY_VERSION}"
puts system('ruby test.rb')