Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ task :typecheck_test => :compile do
end

task :raap => :compile do
sh %q[ruby test/raap.rb | xargs bundle exec raap -r digest/bubblebabble --library digest --allow-private]
sh "ruby test/raap/core.rb"
sh "ruby test/raap/digest.rb"
sh "ruby test/raap/openssl.rb"
end

task :rubocop do
Expand Down
32 changes: 16 additions & 16 deletions stdlib/openssl/0/openssl.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -1527,28 +1527,28 @@ module OpenSSL
# - bn % bn2 => aBN
# -->
#
def %: (int) -> instance
def %: (bn) -> instance

# <!--
# rdoc-file=ext/openssl/ossl_bn.c
# - bn * bn2 => aBN
# -->
#
def *: (int) -> instance
def *: (bn) -> instance

# <!--
# rdoc-file=ext/openssl/ossl_bn.c
# - bn ** bn2 => aBN
# -->
#
def **: (int) -> instance
def **: (bn) -> instance

# <!--
# rdoc-file=ext/openssl/ossl_bn.c
# - bn + bn2 => aBN
# -->
#
def +: (int) -> instance
def +: (bn) -> instance

# <!--
# rdoc-file=ext/openssl/ossl_bn.c
Expand All @@ -1562,7 +1562,7 @@ module OpenSSL
# - bn - bn2 => aBN
# -->
#
def -: (int) -> instance
def -: (bn) -> instance

# <!--
# rdoc-file=ext/openssl/ossl_bn.c
Expand All @@ -1577,7 +1577,7 @@ module OpenSSL
# -->
# Division of OpenSSL::BN instances
#
def /: (int) -> [ instance, instance ]
def /: (bn) -> [ instance, instance ]

# <!--
# rdoc-file=ext/openssl/ossl_bn.c
Expand Down Expand Up @@ -1635,7 +1635,7 @@ module OpenSSL
# - bn.cmp(bn2) => integer
# -->
#
def cmp: (Integer) -> Integer
def cmp: (bn) -> Integer

# <!--
# rdoc-file=ext/openssl/ossl_bn.c
Expand All @@ -1650,7 +1650,7 @@ module OpenSSL
# - copy(p1)
# -->
#
def copy: (int) -> instance
def copy: (bn) -> instance

# <!--
# rdoc-file=ext/openssl/ossl_bn.c
Expand All @@ -1666,7 +1666,7 @@ module OpenSSL
# - bn.gcd(bn2) => aBN
# -->
#
def gcd: (int) -> instance
def gcd: (bn) -> instance

# <!--
# rdoc-file=ext/openssl/ossl_bn.c
Expand All @@ -1692,42 +1692,42 @@ module OpenSSL
# - bn.mod_add(bn1, bn2) -> aBN
# -->
#
def mod_add: (int, int) -> instance
def mod_add: (bn, bn) -> instance

# <!--
# rdoc-file=ext/openssl/ossl_bn.c
# - bn.mod_exp(bn1, bn2) -> aBN
# -->
#
def mod_exp: (int, int) -> instance
def mod_exp: (bn, bn) -> instance

# <!--
# rdoc-file=ext/openssl/ossl_bn.c
# - bn.mod_inverse(bn2) => aBN
# -->
#
def mod_inverse: (int) -> instance
def mod_inverse: (bn) -> instance

# <!--
# rdoc-file=ext/openssl/ossl_bn.c
# - bn.mod_mul(bn1, bn2) -> aBN
# -->
#
def mod_mul: (int, int) -> instance
def mod_mul: (bn, bn) -> instance

# <!--
# rdoc-file=ext/openssl/ossl_bn.c
# - bn.mod_sqr(bn2) => aBN
# -->
#
def mod_sqr: (int) -> instance
def mod_sqr: (bn) -> instance

# <!--
# rdoc-file=ext/openssl/ossl_bn.c
# - bn.mod_sub(bn1, bn2) -> aBN
# -->
#
def mod_sub: (int, int) -> instance
def mod_sub: (bn, bn) -> instance

# <!--
# rdoc-file=ext/openssl/ossl_bn.c
Expand Down Expand Up @@ -1868,7 +1868,7 @@ module OpenSSL
# - bn.ucmp(bn2) => integer
# -->
#
def ucmp: (int bn2) -> ::Integer
def ucmp: (bn bn2) -> ::Integer

# <!--
# rdoc-file=ext/openssl/ossl_bn.c
Expand Down
11 changes: 11 additions & 0 deletions test/raap/core.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'raap'

argv = [
'--size-by', '2',
'--allow-private'
]

argv << 'Set[Integer]'
argv << 'Enumerable[Integer]#to_set'

RaaP::CLI.new(argv).load.run
17 changes: 11 additions & 6 deletions test/raap.rb → test/raap/digest.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Specify the class/module and method names to be executed by RaaP.
# By prefixing with `!`, you can skip testing a method.
require 'raap'

puts 'Set[Integer]'
puts 'Enumerable[Integer]#to_set'
argv = [
'-r', 'digest/bubblebabble',
'--library', 'digest',
'--size-by', '2',
'--allow-private'
]

%w[
MD5
Expand All @@ -18,7 +21,7 @@
digest
hexdigest
].each do |singleton_method|
puts "Digest::#{klass}.#{singleton_method}"
argv << "Digest::#{klass}.#{singleton_method}"
end

%w[
Expand Down Expand Up @@ -47,6 +50,8 @@
finish
initialize_copy
].each do |instance_method|
puts "Digest::#{klass}##{instance_method}"
argv << "Digest::#{klass}##{instance_method}"
end
end

RaaP::CLI.new(argv).load.run
36 changes: 36 additions & 0 deletions test/raap/openssl.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require 'raap'

RaaP::Type.register('OpenSSL::BN') do
sized do |size|
[:call, OpenSSL::BN, :new, [integer.pick(size: size)], {}, nil]
end
end

argv = [
'--require', 'openssl',
'--library', 'openssl',
'--size-by', '2',
'--log-level', 'info',
]

%w[
+
-
*
/
%
**
cmp
copy
gcd
mod_add
mod_exp
mod_mul
mod_sqr
mod_sub
ucmp
].each do |instance_method|
argv << "OpenSSL::BN##{instance_method}"
end

RaaP::CLI.new(argv).load.run
36 changes: 19 additions & 17 deletions test/stdlib/OpenSSL_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,23 +241,25 @@ class OpenSSLBNTest < Test::Unit::TestCase
library "openssl"
testing "::OpenSSL::BN"

def test_operations
assert_send_type "(::Integer) -> OpenSSL::BN",
OpenSSL::BN.new(2), :%, 2
assert_send_type "(::Integer) -> OpenSSL::BN",
OpenSSL::BN.new(2), :*, 2
assert_send_type "(::Integer) -> OpenSSL::BN",
OpenSSL::BN.new(2), :**, 2
assert_send_type "(::Integer) -> OpenSSL::BN",
OpenSSL::BN.new(2), :+, 2
assert_send_type "(::Integer) -> OpenSSL::BN",
OpenSSL::BN.new(2), :-, 2
assert_send_type "(::Integer) -> [OpenSSL::BN, OpenSSL::BN]",
OpenSSL::BN.new(2), :/, 2
assert_send_type "(::Integer) -> OpenSSL::BN",
OpenSSL::BN.new(2), :<<, 2
assert_send_type "(::Integer) -> OpenSSL::BN",
OpenSSL::BN.new(2), :>>, 2
def test_mod_inverse
assert_send_type "(OpenSSL::BN) -> OpenSSL::BN",
OpenSSL::BN.new(3), :mod_inverse, OpenSSL::BN.new(5)
assert_send_type "(Integer) -> OpenSSL::BN",
OpenSSL::BN.new(3), :mod_inverse, 5
end

def test_lshift
assert_send_type "(Integer) -> OpenSSL::BN",
OpenSSL::BN.new(3), :<<, 1
assert_send_type "(_ToInt) -> OpenSSL::BN",
OpenSSL::BN.new(3), :<<, ToInt.new(1)
end

def test_rshift
assert_send_type "(Integer) -> OpenSSL::BN",
OpenSSL::BN.new(3), :>>, 1
assert_send_type "(_ToInt) -> OpenSSL::BN",
OpenSSL::BN.new(3), :>>, ToInt.new(1)
end
end

Expand Down