Project

General

Profile

Feature #18242 » driver.rb

Reproduce the errors - danh337 (Dan H), 10/06/2021 04:37 AM

 
#!/usr/bin/env ruby

lines = [
"a, b = 2, 1 if 1 < 2",
"a, b = [2, 1] if 1 < 2",
"(a, b) = 2, 1 if 1 < 2",
"(a, b) = [2, 1] if 1 < 2",
"(a, b = [2, 1]) if 1 < 2",
"a, b = 2, 1 unless 2 < 1",
"a, b = [2, 1] unless 2 < 1",
"(a, b) = 2, 1 unless 2 < 1",
"(a, b) = [2, 1] unless 2 < 1",
"(a, b = [2, 1]) unless 2 < 1",
"1 < 2 and a, b = 2, 1",
"1 < 2 and a, b = [2, 1]",
"1 < 2 and (a, b) = 2, 1",
"1 < 2 and (a, b) = [2, 1]",
"(1 < 2) and a, b = 2, 1",
"(1 < 2) and a, b = [2, 1]",
"(1 < 2) and (a, b) = 2, 1",
"(1 < 2) and (a, b) = [2, 1]",
"1 < 2 and (a, b = 2, 1)",
"1 < 2 and (a, b = [2, 1])",
"2 < 1 or a, b = 2, 1",
"2 < 1 or a, b = [2, 1]",
"2 < 1 or (a, b) = 2, 1",
"2 < 1 or (a, b) = [2, 1]",
"(2 < 1) or a, b = 2, 1",
"(2 < 1) or a, b = [2, 1]",
"(2 < 1) or (a, b) = 2, 1",
"(2 < 1) or (a, b) = [2, 1]",
"2 < 1 or (a, b = 2, 1)",
"2 < 1 or (a, b = [2, 1])"
]

width = lines.map(&:size).max

for line in lines
begin
a = b = nil
eval line
raise if [a, b] != [2, 1]
comment = "Works"
rescue Exception => e
comment = e.class
end
puts "%-#{width}s # #{comment}" % line
end
(1-1/3)