Skip to content

Commit

Permalink
Update stdlib tests
Browse files Browse the repository at this point in the history
  • Loading branch information
soutaro committed Dec 5, 2023
1 parent 4ad1f5c commit d5f9dca
Show file tree
Hide file tree
Showing 128 changed files with 562 additions and 555 deletions.
54 changes: 27 additions & 27 deletions test/stdlib/ARGF_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Unnamed
end

class ARGFTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper
testing "::RBS::Unnamed::ARGFClass"

def argf_for_write
Expand Down Expand Up @@ -96,7 +96,7 @@ def test_argv
end

def test_binmode
assert_send_type "() -> self",
assert_send_type "() -> RBS::Unnamed::ARGFClass",
ARGF.class.new(__FILE__), :binmode
end

Expand All @@ -106,7 +106,7 @@ def test_binmode?
end

def test_close
assert_send_type "() -> self",
assert_send_type "() -> RBS::Unnamed::ARGFClass",
ARGF.class.new(__FILE__), :close
end

Expand All @@ -116,55 +116,55 @@ def test_closed?
end

def test_each
assert_send_type "() { (::String line) -> untyped } -> self",
assert_send_type "() { (::String line) -> untyped } -> RBS::Unnamed::ARGFClass",
ARGF.class.new(__FILE__), :each do |line| line end
assert_send_type "(::String sep) { (::String line) -> untyped } -> self",
assert_send_type "(::String sep) { (::String line) -> untyped } -> RBS::Unnamed::ARGFClass",
ARGF.class.new(__FILE__), :each, "\n" do |line| line end
assert_send_type "(::String sep, ::Integer limit) { (::String line) -> untyped } -> self",
assert_send_type "(::String sep, ::Integer limit) { (::String line) -> untyped } -> RBS::Unnamed::ARGFClass",
ARGF.class.new(__FILE__), :each, "\n", 1 do |line| line end

assert_send_type "() -> ::Enumerator[::String, self]",
assert_send_type "() -> ::Enumerator[::String, RBS::Unnamed::ARGFClass]",
ARGF.class.new(__FILE__), :each
assert_send_type "(::String sep) -> ::Enumerator[::String, self]",
assert_send_type "(::String sep) -> ::Enumerator[::String, RBS::Unnamed::ARGFClass]",
ARGF.class.new(__FILE__), :each, "\n"
assert_send_type "(::String sep, ::Integer limit) -> ::Enumerator[::String, self]",
assert_send_type "(::String sep, ::Integer limit) -> ::Enumerator[::String, RBS::Unnamed::ARGFClass]",
ARGF.class.new(__FILE__), :each, "\n", 1
end

def test_each_byte
assert_send_type "() { (::Integer byte) -> untyped } -> self",
assert_send_type "() { (::Integer byte) -> untyped } -> RBS::Unnamed::ARGFClass",
ARGF.class.new(__FILE__), :each_byte do |byte| byte end
assert_send_type "() -> ::Enumerator[::Integer, self]",
assert_send_type "() -> ::Enumerator[::Integer, RBS::Unnamed::ARGFClass]",
ARGF.class.new(__FILE__), :each_byte
end

def test_each_char
assert_send_type "() { (::String char) -> untyped } -> self",
assert_send_type "() { (::String char) -> untyped } -> RBS::Unnamed::ARGFClass",
ARGF.class.new(__FILE__), :each_char do |char| char end
assert_send_type "() -> ::Enumerator[::String, self]",
assert_send_type "() -> ::Enumerator[::String, RBS::Unnamed::ARGFClass]",
ARGF.class.new(__FILE__), :each_char
end

def test_each_codepoint
assert_send_type "() { (::Integer codepoint) -> untyped } -> self",
assert_send_type "() { (::Integer codepoint) -> untyped } -> RBS::Unnamed::ARGFClass",
ARGF.class.new(__FILE__), :each_codepoint do |codepoint| end
assert_send_type "() -> ::Enumerator[::Integer, self]",
assert_send_type "() -> ::Enumerator[::Integer, RBS::Unnamed::ARGFClass]",
ARGF.class.new(__FILE__), :each_codepoint
end

def test_each_line
assert_send_type "() { (::String line) -> untyped } -> self",
assert_send_type "() { (::String line) -> untyped } -> RBS::Unnamed::ARGFClass",
ARGF.class.new(__FILE__), :each_line do |line| line end
assert_send_type "(::String sep) { (::String line) -> untyped } -> self",
assert_send_type "(::String sep) { (::String line) -> untyped } -> RBS::Unnamed::ARGFClass",
ARGF.class.new(__FILE__), :each_line, "\n" do |line| line end
assert_send_type "(::String sep, ::Integer limit) { (::String line) -> untyped } -> self",
assert_send_type "(::String sep, ::Integer limit) { (::String line) -> untyped } -> RBS::Unnamed::ARGFClass",
ARGF.class.new(__FILE__), :each_line, "\n", 1 do |line| line end

assert_send_type "() -> ::Enumerator[::String, self]",
assert_send_type "() -> ::Enumerator[::String, RBS::Unnamed::ARGFClass]",
ARGF.class.new(__FILE__), :each_line
assert_send_type "(::String sep) -> ::Enumerator[::String, self]",
assert_send_type "(::String sep) -> ::Enumerator[::String, RBS::Unnamed::ARGFClass]",
ARGF.class.new(__FILE__), :each_line, "\n"
assert_send_type "(::String sep, ::Integer limit) -> ::Enumerator[::String, self]",
assert_send_type "(::String sep, ::Integer limit) -> ::Enumerator[::String, RBS::Unnamed::ARGFClass]",
ARGF.class.new(__FILE__), :each_line, "\n", 1
end

Expand Down Expand Up @@ -223,7 +223,7 @@ def test_inplace_mode
end

def test_inplace_mode=()
assert_send_type "(::String) -> self",
assert_send_type "(::String) -> RBS::Unnamed::ARGFClass",
ARGF.class.new(__FILE__), :inplace_mode=, ".bak"
end

Expand Down Expand Up @@ -305,18 +305,18 @@ def test_seek

end
def test_set_encoding
assert_send_type "(::String) -> self",
assert_send_type "(::String) -> RBS::Unnamed::ARGFClass",
ARGF.class.new(__FILE__), :set_encoding, "utf-8"
assert_send_type "(::Encoding) -> self",
assert_send_type "(::Encoding) -> RBS::Unnamed::ARGFClass",
ARGF.class.new(__FILE__), :set_encoding, Encoding::UTF_8
assert_send_type "(::String, ::String) -> self",
assert_send_type "(::String, ::String) -> RBS::Unnamed::ARGFClass",
ARGF.class.new(__FILE__), :set_encoding, "utf-8", "utf-8"
assert_send_type "(::Encoding, ::Encoding) -> self",
assert_send_type "(::Encoding, ::Encoding) -> RBS::Unnamed::ARGFClass",
ARGF.class.new(__FILE__), :set_encoding, Encoding::UTF_8, Encoding::UTF_8
end

def test_skip
assert_send_type "() -> self",
assert_send_type "() -> RBS::Unnamed::ARGFClass",
ARGF.class.new(__FILE__), :skip
end

Expand Down
13 changes: 8 additions & 5 deletions test/stdlib/Array_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative "test_helper"

class ArraySingletonTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper

testing "singleton(::Array)"

Expand Down Expand Up @@ -36,7 +36,7 @@ def test_try_convert
end

class ArrayInstanceTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper

testing "::Array[::Integer]"

Expand Down Expand Up @@ -226,7 +226,7 @@ def test_compact
def test_concat
assert_send_type "(Array[Integer], Array[Integer]) -> Array[Integer]",
[1,2,3], :concat, [4,5,6], [7,8,9]
assert_send_type "(Array[Integer], Array[Integer]) -> self",
assert_send_type "(Array[Integer], Array[Integer]) -> Array[Integer]",
Class.new(Array).new, :concat, [4,5,6], [7,8,9]
end

Expand All @@ -240,8 +240,11 @@ def test_count
end

def test_cycle
assert_send_type "() { (Integer) -> void } -> nil",
[1,2,3], :cycle do break end
assert_send_type(
"() { (Integer) -> void } -> nil",
[1,2,3], :cycle, &proc { break_from_block }
)

assert_send_type "(Integer) { (Integer) -> void } -> nil",
[1,2,3], :cycle, 3 do end
assert_send_type "(ToInt) { (Integer) -> void } -> nil",
Expand Down
6 changes: 3 additions & 3 deletions test/stdlib/BasicObject_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


class BasicObjectSingletonTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper

testing 'BasicObject'

Expand Down Expand Up @@ -62,12 +62,12 @@ def test_instance_eval
end
end

assert_send_type '() { (self) [self: self] -> Integer } -> Integer',
assert_send_type '() { (BasicObject) [self: BasicObject] -> Integer } -> Integer',
BOBJ, :instance_eval do _1.__id__ end
end

def test_instance_exec
assert_send_type '(*String) { (*String) [self: self] -> Integer } -> Integer',
assert_send_type '(*String) { (*String) [self: BasicObject] -> Integer } -> Integer',
BOBJ, :instance_exec, '1', '2' do |*x| x.join.to_i end
end
end
22 changes: 11 additions & 11 deletions test/stdlib/BigDecimal_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "bigdecimal/util"

class BigDecimalSingletonTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper
library "bigdecimal"
testing "singleton(::BigDecimal)"

Expand Down Expand Up @@ -76,7 +76,7 @@ def test_kernel
end

class BigDecimalTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper
library "bigdecimal"
testing "::BigDecimal"

Expand All @@ -96,12 +96,12 @@ def test_triple_equal
end

def test_clone
assert_send_type "() -> self",
assert_send_type "() -> BigDecimal",
BigDecimal("1.23"), :clone
end

def test_dup
assert_send_type "() -> self",
assert_send_type "() -> BigDecimal",
BigDecimal("1.23"), :dup
end

Expand Down Expand Up @@ -216,7 +216,7 @@ def test_modulo
end

def test_nonzero?
assert_send_type "() -> self?",
assert_send_type "() -> BigDecimal",
BigDecimal("1.23"), :nonzero?
end

Expand Down Expand Up @@ -365,7 +365,7 @@ def test_to_r
end

class IntegerToBigDecimalTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper

library "bigdecimal"
testing "::Integer"
Expand Down Expand Up @@ -396,7 +396,7 @@ def test_multiply_with_integer
end

class FloatToBigDecimalTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper

library "bigdecimal"
testing "::Float"
Expand Down Expand Up @@ -427,7 +427,7 @@ def test_multiply_with_float
end

class StringToBigDecimalTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper

library "bigdecimal"
testing "::String"
Expand All @@ -438,7 +438,7 @@ def test_to_d_with_string
end

class RationalToBigDecimalTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper

library "bigdecimal"
testing "::Rational"
Expand Down Expand Up @@ -469,7 +469,7 @@ def test_multiply_with_rational
end

class ComplexToBigDecimalTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper

library "bigdecimal"
testing "::Complex"
Expand Down Expand Up @@ -500,7 +500,7 @@ def test_multiply_with_complex
end

class NilToBigDecimalTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper

library "bigdecimal"
testing "::NilClass"
Expand Down
4 changes: 2 additions & 2 deletions test/stdlib/BigMath_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "bigdecimal/math"

class BigMathSingletonTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper
library "bigdecimal", "bigdecimal-math"
testing "singleton(::BigMath)"

Expand Down Expand Up @@ -49,7 +49,7 @@ def test_sqrt
end

class BigMathTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper
library "bigdecimal", "bigdecimal-math"
testing "::BigMath"

Expand Down
2 changes: 1 addition & 1 deletion test/stdlib/Binding_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative "test_helper"

class BindingInstanceTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper

testing 'Binding'

Expand Down
4 changes: 2 additions & 2 deletions test/stdlib/CGI_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require "cgi"

class CGISingletonTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper

library "cgi"
testing "singleton(::CGI)"
Expand Down Expand Up @@ -60,7 +60,7 @@ def test_unescapeURIComponent
end

class CGITest < Test::Unit::TestCase
include TypeAssertions
include TestHelper

library "cgi"
testing "::CGI"
Expand Down
2 changes: 1 addition & 1 deletion test/stdlib/Comparable_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative "test_helper"

class ComparableTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper

class Test
include Comparable
Expand Down
6 changes: 3 additions & 3 deletions test/stdlib/DBM_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require "dbm"

class DBMSingletonTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper
library "dbm"
testing "singleton(::DBM)"

Expand All @@ -19,7 +19,7 @@ def test_open
end

class DBMTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper
library "dbm"
testing "::DBM"

Expand All @@ -38,7 +38,7 @@ def teardown
end

def test_clear
assert_send_type "() -> self", @dbm, :clear
assert_send_type "() -> DBM", @dbm, :clear
end

def test_closed?
Expand Down
4 changes: 2 additions & 2 deletions test/stdlib/Data_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative "test_helper"

class DataSingletonTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper
testing "singleton(::Data)"

def test_define
Expand All @@ -18,7 +18,7 @@ def test_define
end

class DataInstanceTest < Test::Unit::TestCase
include TypeAssertions
include TestHelper
testing "::Data"

D = Data.define(:email, :name)
Expand Down
Loading

0 comments on commit d5f9dca

Please sign in to comment.