Project

General

Profile

Feature #18242 ยป driver.rb

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

 
1
#!/usr/bin/env ruby
2

    
3
lines = [
4
  "a, b = 2, 1     if 1 < 2",
5
  "a, b = [2, 1]   if 1 < 2",
6
  "(a, b) = 2, 1   if 1 < 2",
7
  "(a, b) = [2, 1] if 1 < 2",
8
  "(a, b = [2, 1]) if 1 < 2",
9
  "a, b = 2, 1     unless 2 < 1",
10
  "a, b = [2, 1]   unless 2 < 1",
11
  "(a, b) = 2, 1   unless 2 < 1",
12
  "(a, b) = [2, 1] unless 2 < 1",
13
  "(a, b = [2, 1]) unless 2 < 1",
14
  "1 < 2   and a, b = 2, 1",
15
  "1 < 2   and a, b = [2, 1]",
16
  "1 < 2   and (a, b) = 2, 1",
17
  "1 < 2   and (a, b) = [2, 1]",
18
  "(1 < 2) and a, b = 2, 1",
19
  "(1 < 2) and a, b = [2, 1]",
20
  "(1 < 2) and (a, b) = 2, 1",
21
  "(1 < 2) and (a, b) = [2, 1]",
22
  "1 < 2   and (a, b = 2, 1)",
23
  "1 < 2   and (a, b = [2, 1])",
24
  "2 < 1   or a, b = 2, 1",
25
  "2 < 1   or a, b = [2, 1]",
26
  "2 < 1   or (a, b) = 2, 1",
27
  "2 < 1   or (a, b) = [2, 1]",
28
  "(2 < 1) or a, b = 2, 1",
29
  "(2 < 1) or a, b = [2, 1]",
30
  "(2 < 1) or (a, b) = 2, 1",
31
  "(2 < 1) or (a, b) = [2, 1]",
32
  "2 < 1   or (a, b = 2, 1)",
33
  "2 < 1   or (a, b = [2, 1])"
34
]
35

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

    
38
for line in lines
39
  begin
40
    a = b = nil
41
    eval line
42
    raise if [a, b] != [2, 1]
43
    comment = "Works"
44
  rescue Exception => e
45
    comment = e.class
46
  end
47
  puts "%-#{width}s # #{comment}" % line
48
end