summaryrefslogtreecommitdiff
path: root/ext/ripper/test/check-event-arity.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/ripper/test/check-event-arity.rb')
-rw-r--r--ext/ripper/test/check-event-arity.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/ext/ripper/test/check-event-arity.rb b/ext/ripper/test/check-event-arity.rb
new file mode 100644
index 0000000000..00e1b98dbc
--- /dev/null
+++ b/ext/ripper/test/check-event-arity.rb
@@ -0,0 +1,24 @@
+def main
+ invalid = false
+ table = {}
+ ARGF.each do |line|
+ next if /\A\#\s*define\s+s?dispatch\d/ === line
+ next if /ripper_dispatch\d/ === line
+ line.scan(/dispatch(\d)\((\w+)/) do |num, ev|
+ num = num.to_i
+ if data = table[ev]
+ locations, arity = data
+ unless num == arity
+ invalid = true
+ puts "arity differ [#{ev}]: #{ARGF.lineno}->#{num}; #{locations.join(',')}->#{arity}"
+ end
+ locations.push ARGF.lineno
+ else
+ table[ev] = [[ARGF.lineno], num.to_i]
+ end
+ end
+ end
+ exit 1 if invalid
+end
+
+main