Skip to content

Commit 3baa2ca

Browse files
committed
[Truffle] Add a script to check methods parity with MRI.
1 parent e58231a commit 3baa2ca

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ target
6666
test/prawn
6767
test/rails
6868
test/testapp/testapp
69+
test/truffle/*.methods
6970
tool/nailgun/Makefile
7071
tool/nailgun/config.log
7172
tool/nailgun/config.status

test/truffle/test_methods_parity.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
=begin
2+
Run first with JRuby+Truffle, then with MRI:
3+
4+
$ .../jruby -X+T test_methods_parity.rb > truffle.methods
5+
$ .../ruby test_methods_parity.rb truffle.methods > mri.methods
6+
Compare with:
7+
$ git diff -U10 --no-index mri.methods truffle.methods
8+
Red is what we don't implement yet,
9+
Green is methods not existing in MRI (which should be fixed!)
10+
=end
11+
12+
start = BasicObject # Numeric
13+
14+
modules = Object.constants.sort.map { |c|
15+
Object.const_get(c)
16+
}.select { |v|
17+
Module === v and !v.instance_methods(false).empty?
18+
}.select { |mod|
19+
!mod.name.end_with?("Error")
20+
}.select { |mod|
21+
mod <= start
22+
}
23+
24+
if RUBY_ENGINE == "ruby" and truffle_file = ARGV.first
25+
truffle_modules = File.readlines(truffle_file).map(&:chomp).grep(/^[A-Z]/)
26+
modules = modules.select { |mod| truffle_modules.include? mod.name }
27+
end
28+
29+
modules.each do |mod|
30+
puts
31+
puts mod.name
32+
puts mod.instance_methods(false).sort
33+
end

0 commit comments

Comments
 (0)