-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsofterror.rb
56 lines (51 loc) · 1.25 KB
/
softerror.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#
# At the moment, there isn't a published list of expected results for
# "soft" errors. For the moment, compare the reference implementation
# against galimatias.
#
# Note: this script only tests for the presence or absence of errors;
# it makes no attempt to compare the error message.
require 'json'
RESULTS = File.expand_path("../useragent-results", __FILE__)
galimatias = File.open("#{RESULTS}/galimatias") do |f|
f.gets
f.gets
JSON.parse(f.read)
end
refimpl = File.open("#{RESULTS}/refimpl") do |f|
f.gets
f.gets
JSON.parse(f.read)
end
additional = []
galimatias.zip(refimpl).each_with_index do |(g, r), i|
if r['exception'] and not g['exception']
additional << [g, r, i]
end
end
unless additional.empty?
puts '*** additional soft errors'
puts
additional.each do |g, r, i|
puts "Test #{i}:"
puts ' ' + r['input'].inspect
puts ' ' + r['exception'].inspect
puts
end
end
missing = []
galimatias.zip(refimpl).each_with_index do |(g, r), i|
if g['exception'] and not r['exception']
missing << [g, r, i]
end
end
unless missing.empty?
puts '*** missing soft errors'
puts
missing.each do |g, r, i|
puts "Test #{i}:"
puts ' ' + r['input'].inspect
puts ' ' + g['exception'].inspect
puts
end
end