Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine Digest #1779

Closed
wants to merge 1 commit into from
Closed
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
183 changes: 135 additions & 48 deletions stdlib/digest/0/digest.rbs

Large diffs are not rendered by default.

86 changes: 55 additions & 31 deletions test/stdlib/digest/DigestMD5_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,38 @@ class DigestMD5SingletonTest < Test::Unit::TestCase
testing 'singleton(::Digest::MD5)'

def test_base64digest
assert_send_type '(::String str) -> ::String',
::Digest::MD5, :base64digest, '_base64digest_'
with_string('_base64digest_') do |str|
assert_send_type '(::string str) -> ::String',
::Digest::MD5, :base64digest, str
end
end

def test_bubblebabble
assert_send_type '(::String) -> ::String',
::Digest::MD5, :bubblebabble, '_bubblebabble_'
with_string('_bubblebabble_') do |str|
assert_send_type '(::string) -> ::String',
::Digest::MD5, :bubblebabble, str
end
end

def test_digest
assert_send_type '(::String) -> ::String',
::Digest::MD5, :digest, '_digest_'
with_string('_digest_') do |str|
assert_send_type '(::string) -> ::String',
::Digest::MD5, :digest, str
end
end

def test_file
assert_send_type '(::String) -> ::Digest::Class',
::Digest::MD5, :file, 'README.md'
with_string('README.md') do |str|
assert_send_type '(::string) -> ::Digest::MD5',
::Digest::MD5, :file, str
end
end

def test_hexdigest
assert_send_type '(::String) -> ::String',
::Digest::MD5, :hexdigest, '_hexdigest_'
with_string('_hexdigest_') do |str|
assert_send_type '(::string) -> ::String',
::Digest::MD5, :hexdigest, str
end
end
end

Expand All @@ -41,8 +51,10 @@ class DigestMD5InstanceTest < Test::Unit::TestCase
testing '::Digest::MD5'

def test_left_shift
assert_send_type '(::String) -> Digest::MD5',
::Digest::MD5.new, :<<, '_binary_left_shift_'
with_string('_binary_left_shift_') do |str|
assert_send_type '(::string) -> Digest::MD5',
::Digest::MD5.new, :<<, str
end
end

def test_block_length
Expand All @@ -61,8 +73,10 @@ def test_reset
end

def test_update
assert_send_type '(::String) -> Digest::MD5',
::Digest::MD5.new, :update, '_update_'
with_string('_update_') do |str|
assert_send_type '(::string) -> Digest::MD5',
::Digest::MD5.new, :update, str
end
end

def test_finish
Expand All @@ -71,27 +85,31 @@ def test_finish
end

def test_initialize_copy
assert_send_type '(::Digest::Base) -> Digest::MD5',
assert_send_type '(Digest::MD5) -> Digest::MD5',
::Digest::MD5.new, :initialize_copy, ::Digest::MD5.new
end

def test_equal
assert_send_type '(::Digest::Instance | ::String) -> bool',
assert_send_type '(::Digest::MD5) -> bool',
::Digest::MD5.new, :==, ::Digest::MD5.new

assert_send_type '(::Digest::Instance | ::String) -> bool',
::Digest::MD5.new, :==, '_equal_'
with_string('_equal_') do |str|
assert_send_type '(::string) -> bool',
::Digest::MD5.new, :==, str
end
end

def test_base64digest
assert_send_type '(?::String? str) -> ::String',
assert_send_type '() -> ::String',
::Digest::MD5.new, :base64digest

assert_send_type '(?::String? str) -> ::String',
assert_send_type '(nil) -> ::String',
::Digest::MD5.new, :base64digest, nil

assert_send_type '(?::String? str) -> ::String',
::Digest::MD5.new, :base64digest, '_base64digest_'
with_string('_base64digest_') do |str|
assert_send_type '(::string str) -> ::String',
::Digest::MD5.new, :base64digest, str
end
end

def test_base64digest_bang
Expand All @@ -105,29 +123,35 @@ def test_bubblebabble
end

def test_digest
assert_send_type '(?::String) -> ::String',
assert_send_type '() -> ::String',
::Digest::MD5.new, :digest

assert_send_type '(?::String) -> ::String',
::Digest::MD5.new, :digest, '_digest_'
with_string('_digest_') do |str|
assert_send_type '(::string) -> ::String',
::Digest::MD5.new, :digest, str
end
end

def test_digest_bang
assert_send_type '() -> ::String',
::Digest::MD5.new, :digest
::Digest::MD5.new, :digest!
end

def test_file
assert_send_type '(::String) -> Digest::MD5',
::Digest::MD5.new, :file, 'README.md'
with_string('README.md') do |str|
assert_send_type '(::string) -> Digest::MD5',
::Digest::MD5.new, :file, str
end
end

def test_hexdigest
assert_send_type '(?::String) -> ::String',
assert_send_type '() -> ::String',
::Digest::MD5.new, :hexdigest

assert_send_type '(?::String) -> ::String',
::Digest::MD5.new, :hexdigest, '_hexdigest_'
with_string('_hexdigest_') do |str|
assert_send_type '(::string) -> ::String',
::Digest::MD5.new, :hexdigest, str
end
end

def test_hexdigest_bang
Expand Down
86 changes: 55 additions & 31 deletions test/stdlib/digest/DigestRMD160_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,38 @@ class DigestRMD160SingletonTest < Test::Unit::TestCase
testing 'singleton(::Digest::RMD160)'

def test_base64digest
assert_send_type '(::String str) -> ::String',
::Digest::RMD160, :base64digest, '_base64digest_'
with_string('_base64digest_') do |str|
assert_send_type '(::string str) -> ::String',
::Digest::RMD160, :base64digest, str
end
end

def test_bubblebabble
assert_send_type '(::String) -> ::String',
::Digest::RMD160, :bubblebabble, '_bubblebabble_'
with_string('_bubblebabble_') do |str|
assert_send_type '(::string) -> ::String',
::Digest::RMD160, :bubblebabble, str
end
end

def test_digest
assert_send_type '(::String) -> ::String',
::Digest::RMD160, :digest, '_digest_'
with_string('_digest_') do |str|
assert_send_type '(::string) -> ::String',
::Digest::RMD160, :digest, str
end
end

def test_file
assert_send_type '(::String) -> ::Digest::Class',
::Digest::RMD160, :file, 'README.md'
with_string('README.md') do |str|
assert_send_type '(::string) -> ::Digest::RMD160',
::Digest::RMD160, :file, str
end
end

def test_hexdigest
assert_send_type '(::String) -> ::String',
::Digest::RMD160, :hexdigest, '_hexdigest_'
with_string('_hexdigest_') do |str|
assert_send_type '(::string) -> ::String',
::Digest::RMD160, :hexdigest, str
end
end
end

Expand All @@ -41,8 +51,10 @@ class DigestRMD160InstanceTest < Test::Unit::TestCase
testing '::Digest::RMD160'

def test_left_shift
assert_send_type '(::String) -> Digest::RMD160',
::Digest::RMD160.new, :<<, '_binary_left_shift_'
with_string('_binary_left_shift_') do |str|
assert_send_type '(::string) -> Digest::RMD160',
::Digest::RMD160.new, :<<, str
end
end

def test_block_length
Expand All @@ -61,8 +73,10 @@ def test_reset
end

def test_update
assert_send_type '(::String) -> Digest::RMD160',
::Digest::RMD160.new, :update, '_update_'
with_string('_update_') do |str|
assert_send_type '(::string) -> Digest::RMD160',
::Digest::RMD160.new, :update, str
end
end

def test_finish
Expand All @@ -71,27 +85,31 @@ def test_finish
end

def test_initialize_copy
assert_send_type '(::Digest::Base) -> Digest::RMD160',
assert_send_type '(Digest::RMD160) -> Digest::RMD160',
::Digest::RMD160.new, :initialize_copy, ::Digest::RMD160.new
end

def test_equal
assert_send_type '(::Digest::Instance | ::String) -> bool',
assert_send_type '(::Digest::RMD160) -> bool',
::Digest::RMD160.new, :==, ::Digest::RMD160.new

assert_send_type '(::Digest::Instance | ::String) -> bool',
::Digest::RMD160.new, :==, '_equal_'
with_string('_equal_') do |str|
assert_send_type '(::string) -> bool',
::Digest::RMD160.new, :==, str
end
end

def test_base64digest
assert_send_type '(?::String? str) -> ::String',
assert_send_type '() -> ::String',
::Digest::RMD160.new, :base64digest

assert_send_type '(?::String? str) -> ::String',
assert_send_type '(nil) -> ::String',
::Digest::RMD160.new, :base64digest, nil

assert_send_type '(?::String? str) -> ::String',
::Digest::RMD160.new, :base64digest, '_base64digest_'
with_string('_base64digest_') do |str|
assert_send_type '(::string str) -> ::String',
::Digest::RMD160.new, :base64digest, str
end
end

def test_base64digest_bang
Expand All @@ -105,29 +123,35 @@ def test_bubblebabble
end

def test_digest
assert_send_type '(?::String) -> ::String',
assert_send_type '() -> ::String',
::Digest::RMD160.new, :digest

assert_send_type '(?::String) -> ::String',
::Digest::RMD160.new, :digest, '_digest_'
with_string('_digest_') do |str|
assert_send_type '(::string) -> ::String',
::Digest::RMD160.new, :digest, str
end
end

def test_digest_bang
assert_send_type '() -> ::String',
::Digest::RMD160.new, :digest
::Digest::RMD160.new, :digest!
end

def test_file
assert_send_type '(::String) -> Digest::RMD160',
::Digest::RMD160.new, :file, 'README.md'
with_string('README.md') do |str|
assert_send_type '(::string) -> Digest::RMD160',
::Digest::RMD160.new, :file, str
end
end

def test_hexdigest
assert_send_type '(?::String) -> ::String',
assert_send_type '() -> ::String',
::Digest::RMD160.new, :hexdigest

assert_send_type '(?::String) -> ::String',
::Digest::RMD160.new, :hexdigest, '_hexdigest_'
with_string('_hexdigest_') do |str|
assert_send_type '(::string) -> ::String',
::Digest::RMD160.new, :hexdigest, str
end
end

def test_hexdigest_bang
Expand Down
Loading