diff --git a/test/stdlib/Abbrev_test.rb b/test/stdlib/Abbrev_test.rb deleted file mode 100644 index b0424d8e6..000000000 --- a/test/stdlib/Abbrev_test.rb +++ /dev/null @@ -1,15 +0,0 @@ -require_relative "test_helper" -require "abbrev" - -class AbbrevTest < StdlibTest - target Abbrev - library "abbrev" - - def test_abbrev - Abbrev.abbrev([]) - Abbrev.abbrev(%w(abbrev)) - Abbrev.abbrev(%w(abbrev), 'abb') - Abbrev.abbrev(%w(abbrev), /^abb/) - Abbrev.abbrev(%w(abbrev), nil) - end -end diff --git a/test/stdlib/Base64_test.rb b/test/stdlib/Base64_test.rb deleted file mode 100644 index fb373f057..000000000 --- a/test/stdlib/Base64_test.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative "test_helper" -require "base64" - -class Base64Test < StdlibTest - target Base64 - library "base64" - - include Base64 - - def test_encode64_decode64 - Base64.decode64(Base64.encode64("")) - decode64(encode64("")) - end - - def test_strict_encode64_strict_decode64 - Base64.strict_decode64(Base64.strict_encode64("")) - strict_decode64(strict_encode64("")) - end - - def test_urlsafe_encode64_urlsafe_decode64 - Base64.urlsafe_decode64(Base64.urlsafe_encode64("")) - Base64.urlsafe_decode64(Base64.urlsafe_encode64("", padding: "true")) - urlsafe_decode64(urlsafe_encode64("")) - urlsafe_decode64(urlsafe_encode64("", padding: 30)) - end -end diff --git a/test/stdlib/BigDecimal_test.rb b/test/stdlib/BigDecimal_test.rb deleted file mode 100644 index 9cb09516b..000000000 --- a/test/stdlib/BigDecimal_test.rb +++ /dev/null @@ -1,506 +0,0 @@ -require_relative "test_helper" -require "bigdecimal" -require "bigdecimal/util" - -class BigDecimalSingletonTest < Test::Unit::TestCase - include TestHelper - library "bigdecimal" - testing "singleton(::BigDecimal)" - - def test__load - assert_send_type "(::String) -> ::BigDecimal", - BigDecimal, :_load, "18:0.123e1" - end - - def test_double_fig - assert_send_type "() -> ::Integer", - BigDecimal, :double_fig - end - - def test_interpret_loosely - assert_send_type "(String) -> BigDecimal", - BigDecimal, :interpret_loosely, "1.23" - assert_send_type "(ToStr) -> BigDecimal", - BigDecimal, :interpret_loosely, ToStr.new("1.23") - end - - def test_limit - assert_send_type "(?::Integer? digits) -> ::Integer", - BigDecimal, :limit - assert_send_type "(?::Integer? digits) -> ::Integer", - BigDecimal, :limit, 5 - end - - def test_mode - assert_send_type "(::Integer mode, ?::Integer? value) -> ::Integer?", - BigDecimal, :mode, BigDecimal::EXCEPTION_ALL - assert_send_type "(::Integer mode, ?::Integer? value) -> ::Integer?", - BigDecimal, :mode, BigDecimal::ROUND_MODE, BigDecimal::ROUND_DOWN - end - - def test_save_exception_mode - assert_send_type "() { (?nil) -> void } -> void", - BigDecimal, :save_exception_mode do end - end - - def test_save_limit - assert_send_type "() { (?nil) -> void } -> void", - BigDecimal, :save_limit do end - end - - def test_save_rounding_mode - assert_send_type "() { (?nil) -> void } -> void", - BigDecimal, :save_rounding_mode do end - end - - def test_kernel - assert_send_type "(::String) -> ::BigDecimal", - Kernel, :BigDecimal, "1.23" - assert_send_type "(::ToStr) -> ::BigDecimal", - Kernel, :BigDecimal, ToStr.new("1.23") - assert_send_type "(::Integer) -> ::BigDecimal", - Kernel, :BigDecimal, 123 - assert_send_type "(::BigDecimal) -> ::BigDecimal", - Kernel, :BigDecimal, BigDecimal("1.23") - assert_send_type "(::Float, ::Integer) -> ::BigDecimal", - Kernel, :BigDecimal, 1.23, 1 - assert_send_type "(::Float, ::ToInt) -> ::BigDecimal", - Kernel, :BigDecimal, 1.23, ToInt.new(1) - assert_send_type "(::Rational, ::Integer) -> ::BigDecimal", - Kernel, :BigDecimal, Rational(1.23), 1 - assert_send_type "(::String, exception: bool) -> ::BigDecimal", - Kernel, :BigDecimal, "1.23", exception: false - assert_send_type "(::Float, ::Integer, exception: bool) -> ::BigDecimal", - Kernel, :BigDecimal, 1.23, 1, exception: true - end -end - -class BigDecimalTest < Test::Unit::TestCase - include TestHelper - library "bigdecimal" - testing "::BigDecimal" - - def test_double_equal - assert_send_type "(untyped) -> bool", - BigDecimal("1.23"), :==, BigDecimal("1.234") - end - - def test_spaceship - assert_send_type "(::Numeric) -> ::Integer?", - BigDecimal("1.23"), :<=>, BigDecimal("1.234") - end - - def test_triple_equal - assert_send_type "(untyped) -> bool", - BigDecimal("1.23"), :===, BigDecimal("1.234") - end - - def test_clone - assert_send_type "() -> BigDecimal", - BigDecimal("1.23"), :clone - end - - def test_dup - assert_send_type "() -> BigDecimal", - BigDecimal("1.23"), :dup - end - - def test_eql? - assert_send_type "(untyped) -> bool", - BigDecimal("1.23"), :eql?, BigDecimal("1.234") - end - - def test_hash - assert_send_type "() -> ::Integer", - BigDecimal("1.23"), :hash - end - - def test_inspect - assert_send_type "() -> ::String", - BigDecimal("1.23"), :inspect - end - - def test_to_s - assert_send_type "() -> ::String", - BigDecimal("1.23"), :to_s - assert_send_type "(::String s) -> ::String", - BigDecimal("1.23"), :to_s, "2F" - assert_send_type "(::int s) -> ::String", - BigDecimal("1.23"), :to_s, 2 - end - - def test_less_than - assert_send_type "(::Numeric) -> bool", - BigDecimal("1.23"), :<, BigDecimal("1.234") - end - - def test_less_than_equal_to - assert_send_type "(::Numeric) -> bool", - BigDecimal("1.23"), :<=, BigDecimal("1.234") - end - - def test_greater_than - assert_send_type "(::Numeric) -> bool", - BigDecimal("1.23"), :>, BigDecimal("1.234") - end - - def test_greater_than_equal_to - assert_send_type "(::Numeric) -> bool", - BigDecimal("1.23"), :>=, BigDecimal("1.234") - end - - def test_modulus - assert_send_type "(::Numeric) -> ::BigDecimal", - BigDecimal("1.23"), :%, BigDecimal("1.234") - end - - def test_unary_plus - assert_send_type "() -> ::BigDecimal", - BigDecimal("1.23"), :+@ - end - - def test_unary_minus - assert_send_type "() -> ::BigDecimal", - BigDecimal("1.23"), :-@ - end - - def test_abs - assert_send_type "() -> ::BigDecimal", - BigDecimal("1.23"), :abs - end - - def test_ceil - assert_send_type "() -> ::Integer", - BigDecimal("1.23"), :ceil - assert_send_type "(::int n) -> ::BigDecimal", - BigDecimal("1.23"), :ceil, 2 - end - - def test_coerce - assert_send_type "(::Numeric) -> [ ::BigDecimal, ::BigDecimal ]", - BigDecimal("1.23"), :coerce, BigDecimal("1.234") - end - - def test_div - assert_send_type "(::Numeric value) -> ::Integer", - BigDecimal("1.23"), :div, 2 - assert_send_type "(::Numeric value, ::int digits) -> ::BigDecimal", - BigDecimal("1.23"), :div, 2 , 3 - end - - def test_divmod - assert_send_type "(::Numeric) -> [ ::Integer, ::BigDecimal ]", - BigDecimal("1.23"), :divmod, 2 - end - - def test_finite? - assert_send_type "() -> bool", - BigDecimal("1.23"), :finite? - end - - def test_floor - assert_send_type "() -> ::Integer", - BigDecimal("1.23"), :floor - assert_send_type "(::int n) -> ::BigDecimal", - BigDecimal("1.23"), :floor, 2 - end - - def test_infinite? - assert_send_type "() -> ::Integer?", - BigDecimal("1.23"), :infinite? - end - - def test_modulo - assert_send_type "(::Numeric b) -> ::BigDecimal", - BigDecimal("1.23"), :modulo, 2 - end - - def test_nonzero? - assert_send_type "() -> BigDecimal", - BigDecimal("1.23"), :nonzero? - end - - def test_quo - assert_send_type "(::Numeric) -> ::BigDecimal", - BigDecimal("1.23"), :quo, 2 - end - - def test_remainder - assert_send_type "(::Numeric) -> ::BigDecimal", - BigDecimal("1.23"), :remainder, 2 - end - - def test_round - assert_send_type "() -> ::Integer", - BigDecimal("1.23"), :round - assert_send_type "(::Numeric n, ?::Integer mode) -> ::BigDecimal", - BigDecimal("1.23"), :round, 2 - assert_send_type "(::Numeric n, ?::Integer mode) -> ::BigDecimal", - BigDecimal("1.23"), :round, 2, BigDecimal::ROUND_UP - end - - def test_to_int - assert_send_type "() -> ::Integer", - BigDecimal("1.23"), :to_int - end - - def test_truncate - assert_send_type "() -> ::Integer", - BigDecimal("1.23"), :truncate - assert_send_type "(::int n) -> ::BigDecimal", - BigDecimal("1.23"), :truncate, 2 - end - - def test_zero? - assert_send_type "() -> bool", - BigDecimal("1.23"), :zero? - end - - def test_multiply - assert_send_type "(::Numeric) -> ::BigDecimal", - BigDecimal("1.23"), :*, BigDecimal("1.234") - end - - def test_plus - assert_send_type "(::Numeric) -> ::BigDecimal", - BigDecimal("1.23"), :+, BigDecimal("1.23") - end - - def test_minus - assert_send_type "(::Numeric) -> ::BigDecimal", - BigDecimal("1.23"), :-, BigDecimal("1.23") - end - - def test_divide - assert_send_type "(::Numeric) -> ::BigDecimal", - BigDecimal("1.23"), :/, BigDecimal("1.23") - end - - def test__dump - assert_send_type "(?untyped) -> String", - BigDecimal("1.23"), :_dump - end - - def test_add - assert_send_type "(::Numeric value, ::Integer digits) -> ::BigDecimal", - BigDecimal("1.23"), :add, BigDecimal("1.23"), 2 - end - - def test_exponent - assert_send_type "() -> ::Integer", - BigDecimal("1.23"), :exponent - end - - def test_fix - assert_send_type "() -> ::BigDecimal", - BigDecimal("1.23"), :fix - end - - def test_frac - assert_send_type "() -> ::BigDecimal", - BigDecimal("1.23"), :frac - end - - def test_mult - assert_send_type "(::Numeric value, ::int digits) -> ::BigDecimal", - BigDecimal("1.23"), :mult, BigDecimal("1.23"), 2 - end - - def test_nan? - assert_send_type "() -> bool", - BigDecimal("1.23"), :nan? - end - - def test_power - assert_send_type "(::Numeric n, ::int prec) -> ::BigDecimal", - BigDecimal("1.23"), :power, BigDecimal("1.23"), 2 - assert_send_type "(::Numeric) -> ::BigDecimal", - BigDecimal("1.23"), :**, BigDecimal("1.23") - end - - def test_sign - assert_send_type "() -> ::Integer", - BigDecimal("1.23"), :sign - end - - def test_split - assert_send_type "() -> [ ::Integer, ::String, ::Integer, ::Integer ]", - BigDecimal("1.23"), :split - end - - def test_sqrt - assert_send_type "(::int n) -> ::BigDecimal", - BigDecimal("1.23"), :sqrt, 2 - end - - def test_sub - assert_send_type "(::Numeric value, ::int digits) -> ::BigDecimal", - BigDecimal("1.23"), :sub, BigDecimal("1.23"), 2 - end - - def test_to_d - assert_send_type "() -> ::BigDecimal", - BigDecimal("1.23"), :to_d - end - - def test_to_f - assert_send_type "() -> ::Float", - BigDecimal("1.23"), :to_f - end - - def test_to_i - assert_send_type "() -> ::Integer", - BigDecimal("1.23"), :to_i - end - - def test_to_r - assert_send_type "() -> ::Rational", - BigDecimal("1.23"), :to_r - end -end - -class IntegerToBigDecimalTest < Test::Unit::TestCase - include TestHelper - - library "bigdecimal" - testing "::Integer" - - def test_to_d_with_integer - assert_send_type "() -> ::BigDecimal", 123, :to_d - end - - def test_plus_with_integer - assert_send_type "(::BigDecimal) -> ::BigDecimal", - 123, :+, BigDecimal("1.23") - end - - def test_minus_with_integer - assert_send_type "(::BigDecimal) -> ::BigDecimal", - 123, :-, BigDecimal("1.23") - end - - def test_divide_with_integer - assert_send_type "(::BigDecimal) -> ::BigDecimal", - 123, :/, BigDecimal("1.23") - end - - def test_multiply_with_integer - assert_send_type "(::BigDecimal) -> ::BigDecimal", - 123, :*, BigDecimal("1.23") - end -end - -class FloatToBigDecimalTest < Test::Unit::TestCase - include TestHelper - - library "bigdecimal" - testing "::Float" - - def test_to_d_with_float - assert_send_type "() -> ::BigDecimal", 12.3, :to_d - end - - def test_plus_with_float - assert_send_type "(::BigDecimal) -> ::BigDecimal", - 1.23, :+, BigDecimal("1.23") - end - - def test_minus_with_float - assert_send_type "(::BigDecimal) -> ::BigDecimal", - 1.23, :-, BigDecimal("1.23") - end - - def test_divide_with_float - assert_send_type "(::BigDecimal) -> ::BigDecimal", - 1.23, :/, BigDecimal("1.23") - end - - def test_multiply_with_float - assert_send_type "(::BigDecimal) -> ::BigDecimal", - 1.23, :*, BigDecimal("1.23") - end -end - -class StringToBigDecimalTest < Test::Unit::TestCase - include TestHelper - - library "bigdecimal" - testing "::String" - - def test_to_d_with_string - assert_send_type "() -> ::BigDecimal", "123", :to_d - end -end - -class RationalToBigDecimalTest < Test::Unit::TestCase - include TestHelper - - library "bigdecimal" - testing "::Rational" - - def test_to_d_with_rational - assert_send_type "(Integer) -> ::BigDecimal", Rational(22, 7), :to_d, 3 - end - - def test_plus_with_rational - assert_send_type "(::BigDecimal) -> ::BigDecimal", - 123r, :+, BigDecimal("1.23") - end - - def test_minus_with_rational - assert_send_type "(::BigDecimal) -> ::BigDecimal", - 123r, :-, BigDecimal("1.23") - end - - def test_divide_with_rational - assert_send_type "(::BigDecimal) -> ::BigDecimal", - 123r, :/, BigDecimal("1.23") - end - - def test_multiply_with_rational - assert_send_type "(::BigDecimal) -> ::BigDecimal", - 123r, :*, BigDecimal("1.23") - end -end - -class ComplexToBigDecimalTest < Test::Unit::TestCase - include TestHelper - - library "bigdecimal" - testing "::Complex" - - def test_to_d_with_complex - assert_send_type "() -> ::BigDecimal", Complex(0.1234567, 0), :to_d - end - - def test_plus_with_complex - assert_send_type "(::BigDecimal) -> ::Complex", - Complex(0.1234567, 0), :+, BigDecimal("1.23") - end - - def test_minus_with_complex - assert_send_type "(::BigDecimal) -> ::Complex", - Complex(0.1234567, 0), :-, BigDecimal("1.23") - end - - def test_divide_with_complex - assert_send_type "(::BigDecimal) -> ::Complex", - Complex(0.1234567, 0), :/, BigDecimal("1.23") - end - - def test_multiply_with_complex - assert_send_type "(::BigDecimal) -> ::Complex", - Complex(0.1234567, 0), :*, BigDecimal("1.23") - end -end - -class NilToBigDecimalTest < Test::Unit::TestCase - include TestHelper - - library "bigdecimal" - testing "::NilClass" - - def test_to_d_with_nil - assert_send_type "() -> ::BigDecimal", nil, :to_d - end -end diff --git a/test/stdlib/BigMath_test.rb b/test/stdlib/BigMath_test.rb deleted file mode 100644 index 32fc96bbf..000000000 --- a/test/stdlib/BigMath_test.rb +++ /dev/null @@ -1,278 +0,0 @@ -require_relative "test_helper" -require "bigdecimal" -require "bigdecimal/math" - -class BigMathSingletonTest < Test::Unit::TestCase - include TestHelper - library "bigdecimal", "bigdecimal-math" - testing "singleton(::BigMath)" - - def test_E - assert_send_type "(::Numeric prec) -> ::BigDecimal", - BigMath, :E, 10 - end - - def test_PI - assert_send_type "(::Numeric prec) -> ::BigDecimal", - BigMath, :PI, 10 - end - - def test_acos - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - BigMath, :acos, BigDecimal('0.5'), 32 - end - - def test_acosh - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - BigMath, :acosh, BigDecimal('2'), 32 - end - - def test_asin - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - BigMath, :asin, BigDecimal('0.5'), 32 - end - - def test_asinh - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - BigMath, :asinh, BigDecimal('1'), 32 - end - - def test_atan - assert_send_type "(::BigDecimal x, ::Numeric prec) -> ::BigDecimal", - BigMath, :atan, BigDecimal('1.23'), 10 - end - - def test_atan2 - assert_send_type "(::BigDecimal, ::BigDecimal, ::Numeric) -> ::BigDecimal", - BigMath, :atan2, BigDecimal('-1'), BigDecimal('1'), 32 - end - - def test_atanh - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - BigMath, :atanh, BigDecimal('0.5'), 32 - end - - def test_cbrt - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - BigMath, :cbrt, BigDecimal('2'), 32 - end - - def test_cos - assert_send_type "(::BigDecimal x, ::Numeric prec) -> ::BigDecimal", - BigMath, :cos, BigDecimal('1.23'), 10 - end - - def test_cosh - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - BigMath, :cosh, BigDecimal('1'), 32 - end - - def test_erf - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - BigMath, :erf, BigDecimal('1'), 32 - end - - def test_erfc - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - BigMath, :erfc, BigDecimal('10'), 32 - end - - def test_exp - assert_send_type "(::BigDecimal, ::Numeric prec) -> ::BigDecimal", - BigMath, :exp, BigDecimal('1.23'), 10 - end - - def test_frexp - assert_send_type "(::BigDecimal) -> [::BigDecimal, ::Integer]", - BigMath, :frexp, BigDecimal(123.456) - end - - def test_gamma - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - BigMath, :gamma, BigDecimal('0.5'), 32 - end - - def test_hypot - assert_send_type "(::BigDecimal, ::BigDecimal, ::Numeric) -> ::BigDecimal", - BigMath, :hypot, BigDecimal('1'), BigDecimal('2'), 32 - end - - def test_ldexp - assert_send_type "(::BigDecimal, ::Integer) -> ::BigDecimal", - BigMath, :ldexp, BigDecimal("0.123456e0"), 3 - end - - def test_lgamma - assert_send_type "(::BigDecimal, ::Numeric) -> [::BigDecimal, ::Integer]", - BigMath, :lgamma, BigDecimal('0.5'), 32 - end - - def test_log - assert_send_type "(::BigDecimal, ::Numeric prec) -> ::BigDecimal", - BigMath, :log, BigDecimal('1.23'), 10 - end - - def test_log2 - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - BigMath, :log2, BigDecimal('3'), 32 - end - - def test_sin - assert_send_type "(::BigDecimal x, ::Numeric prec) -> ::BigDecimal", - BigMath, :sin, BigDecimal('1.23'), 10 - end - - def test_sinh - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - BigMath, :sinh, BigDecimal('1'), 32 - end - - def test_sqrt - assert_send_type "(::BigDecimal x, ::Numeric prec) -> ::BigDecimal", - BigMath, :sqrt, BigDecimal('1.23'), 10 - end - - def test_tanh - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - BigMath, :tanh, BigDecimal('1'), 32 - end -end - -class BigMathTest < Test::Unit::TestCase - include TestHelper - library "bigdecimal", "bigdecimal-math" - testing "::BigMath" - - class TestClass - include BigMath - end - - def test_E - assert_send_type "(::Numeric prec) -> ::BigDecimal", - TestClass.new, :E, 10 - end - - def test_PI - assert_send_type "(::Numeric prec) -> ::BigDecimal", - TestClass.new, :PI, 10 - end - - def test_acos - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - TestClass.new, :acos, BigDecimal('0.5'), 32 - end - - def test_acosh - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - TestClass.new, :acosh, BigDecimal('2'), 32 - end - - def test_asin - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - TestClass.new, :asin, BigDecimal('0.5'), 32 - end - - def test_asinh - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - TestClass.new, :asinh, BigDecimal('1'), 32 - end - - def test_atan - assert_send_type "(::BigDecimal x, ::Numeric prec) -> ::BigDecimal", - TestClass.new, :atan, BigDecimal('1.23'), 10 - end - - def test_atan2 - assert_send_type "(::BigDecimal, ::BigDecimal, ::Numeric) -> ::BigDecimal", - TestClass.new, :atan2, BigDecimal('-1'), BigDecimal('1'), 32 - end - - def test_atanh - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - TestClass.new, :atanh, BigDecimal('0.5'), 32 - end - - def test_cbrt - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - TestClass.new, :cbrt, BigDecimal('2'), 32 - end - - def test_cos - assert_send_type "(::BigDecimal x, ::Numeric prec) -> ::BigDecimal", - TestClass.new, :cos, BigDecimal('1.23'), 10 - end - - def test_cosh - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - TestClass.new, :cosh, BigDecimal('1'), 32 - end - - def test_erf - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - TestClass.new, :erf, BigDecimal('1'), 32 - end - - def test_erfc - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - TestClass.new, :erfc, BigDecimal('10'), 32 - end - - def test_exp - assert_send_type "(::BigDecimal, ::Numeric prec) -> ::BigDecimal", - TestClass.new, :exp, BigDecimal('1.23'), 10 - end - - def test_frexp - assert_send_type "(::BigDecimal) -> [::BigDecimal, ::Integer]", - TestClass.new, :frexp, BigDecimal(123.456) - end - - def test_gamma - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - TestClass.new, :gamma, BigDecimal('0.5'), 32 - end - - def test_hypot - assert_send_type "(::BigDecimal, ::BigDecimal, ::Numeric) -> ::BigDecimal", - TestClass.new, :hypot, BigDecimal('1'), BigDecimal('2'), 32 - end - - def test_ldexp - assert_send_type "(::BigDecimal, ::Integer) -> ::BigDecimal", - TestClass.new, :ldexp, BigDecimal("0.123456e0"), 3 - end - - def test_lgamma - assert_send_type "(::BigDecimal, ::Numeric) -> [::BigDecimal, ::Integer]", - TestClass.new, :lgamma, BigDecimal('0.5'), 32 - end - - def test_log - assert_send_type "(::BigDecimal, ::Numeric prec) -> ::BigDecimal", - TestClass.new, :log, BigDecimal('1.23'), 10 - end - - def test_log2 - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - TestClass.new, :log2, BigDecimal('3'), 32 - end - def test_sin - assert_send_type "(::BigDecimal x, ::Numeric prec) -> ::BigDecimal", - TestClass.new, :sin, BigDecimal('1.23'), 10 - end - - def test_sinh - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - TestClass.new, :sinh, BigDecimal('1'), 32 - end - - def test_sqrt - assert_send_type "(::BigDecimal x, ::Numeric prec) -> ::BigDecimal", - TestClass.new, :sqrt, BigDecimal('1.23'), 10 - end - - def test_tanh - assert_send_type "(::BigDecimal, ::Numeric) -> ::BigDecimal", - TestClass.new, :tanh, BigDecimal('1'), 32 - end -end diff --git a/test/stdlib/CSV_Row_test.rb b/test/stdlib/CSV_Row_test.rb deleted file mode 100644 index c32c9ec61..000000000 --- a/test/stdlib/CSV_Row_test.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -require_relative "test_helper" -require "csv" - -class CSV::RowSingletonTest < Test::Unit::TestCase - include TestHelper - - library 'csv' - testing "singleton(::CSV::Row)" - - def test_initialize - assert_send_type "(Array[String] headers, Array[String] fields, ?header_row: bool) -> void", - CSV::Row, :new, ["header1", "header2"], ["row1_1", "row1_2"], header_row: true - assert_send_type "(Array[String] headers, Array[String] fields) -> void", - CSV::Row, :new, ["header1", "header2"], ["row1_1", "row1_2"] - assert_send_type "(Array[Symbol] headers, Array[Symbol] fields) -> void", - CSV::Row, :new, [:header1, :header2], [:row_1, :row_2] - assert_send_type "(Array[Integer] headers, Array[Integer] fields) -> void", - CSV::Row, :new, [1, 2], [1, 2] - end -end diff --git a/test/stdlib/CSV_Table_test.rb b/test/stdlib/CSV_Table_test.rb deleted file mode 100644 index c36d412bf..000000000 --- a/test/stdlib/CSV_Table_test.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -require_relative "test_helper" -require "csv" - -class CSV::TableInstanceTest < Test::Unit::TestCase - include TestHelper - - library 'csv' - testing "CSV::Table[CSV::Row]" - - def test_each - table = CSV::Table.new([ - CSV::Row.new([], []), - CSV::Row.new([], []), - CSV::Row.new([], []) - ]) - - assert_send_type "() -> Enumerator[CSV::Row, void]", - table, :each - assert_send_type "() { (CSV::Row) -> void } -> CSV::Table", - table, :each do end - end -end diff --git a/test/stdlib/CSV_test.rb b/test/stdlib/CSV_test.rb deleted file mode 100644 index dc0c3fb01..000000000 --- a/test/stdlib/CSV_test.rb +++ /dev/null @@ -1,126 +0,0 @@ -# frozen_string_literal: true - -require_relative "test_helper" -require "csv" - -class CSVSingletonTest < Test::Unit::TestCase - include TestHelper - - library 'csv' - testing "singleton(::CSV)" - - def test_foreach - tmpdir = Dir.mktmpdir - path = File.join(tmpdir, "example.csv") - File.write(path, "a,b,c\n1,2,3\n") - - string_array_block = ->(row) { row.size } - assert_send_type "(String path) { (Array[String?]) -> void } -> void", - CSV, :foreach, path, &string_array_block - assert_send_type "(IO path) { (Array[String?]) -> void } -> void", - CSV, :foreach, File.open(path), &string_array_block - - csv_row_array_block = ->(row) { row.fields } - assert_send_type "(String path, headers: true) { (CSV::Row) -> void } -> void", - CSV, :foreach, path, headers: true, &csv_row_array_block - assert_send_type "(String path, headers: false) { (Array[String?]) -> void } -> void", - CSV, :foreach, path, headers: false, &string_array_block - assert_send_type "(IO path, headers: bool) { (CSV::Row) -> void } -> void", - CSV, :foreach, File.open(path), headers: true, &csv_row_array_block - assert_send_type "(String path, headers: :first_row) { (CSV::Row) -> void } -> void", - CSV, :foreach, path, headers: :first_row, &csv_row_array_block - assert_send_type "(String path, headers: Array[untyped]) { (CSV::Row) -> void } -> void", - CSV, :foreach, path, headers: ["name"], &csv_row_array_block - assert_send_type "(String path, headers: String) { (CSV::Row) -> void } -> void", - CSV, :foreach, path, headers: "name", &csv_row_array_block - - assert_send_type "(String path, **untyped) -> Enumerator[Array[String?], void]", - CSV, :foreach, path, encoding: 'UTF-8' - assert_send_type "(String path, headers: bool) -> Enumerator[CSV::Row, void]", - CSV, :foreach, path, headers: true - assert_send_type "(String path, headers: :first_row) -> Enumerator[CSV::Row, void]", - CSV, :foreach, path, headers: :first_row - assert_send_type "(String path, headers: Array[untyped]) -> Enumerator[CSV::Row, void]", - CSV, :foreach, path, headers: ["name"] - assert_send_type "(String path, headers: String) -> Enumerator[CSV::Row, void]", - CSV, :foreach, path, headers: "name" - assert_send_type "(String path, headers: bool, **untyped) -> Enumerator[CSV::Row, void]", - CSV, :foreach, path, headers: true, encoding: 'UTF-8' - end - - def test_read - tmpdir = Dir.mktmpdir - path = File.join(tmpdir, "example.csv") - File.write(path, "a,b,c\n1,2,3\n") - - assert_send_type "(String path, headers: true) -> CSV::Table[CSV::Row]", - CSV, :read, path, headers: true - assert_send_type "(IO path, headers: true) -> CSV::Table[CSV::Row]", - CSV, :read, File.open(path), headers: true - assert_send_type "(String path, headers: :first_row) -> CSV::Table[CSV::Row]", - CSV, :read, path, headers: :first_row - assert_send_type "(IO path, headers: :first_row) -> CSV::Table[CSV::Row]", - CSV, :read, File.open(path), headers: :first_row - assert_send_type "(String path, headers: Array[String]) -> CSV::Table[CSV::Row]", - CSV, :read, path, headers: %w[foo bar baz] - assert_send_type "(IO path, headers: Array[String]) -> CSV::Table[CSV::Row]", - CSV, :read, File.open(path), headers: %w[foo bar baz] - assert_send_type "(String path, headers: String) -> CSV::Table[CSV::Row]", - CSV, :read, path, headers: "foo,bar,baz" - assert_send_type "(IO path, headers: String) -> CSV::Table[CSV::Row]", - CSV, :read, File.open(path), headers: "foo,bar,baz" - - assert_send_type "(String path) -> Array[Array[String?]]", - CSV, :read, path - assert_send_type "(IO path) -> Array[Array[String?]]", - CSV, :read, File.open(path) - end -end - -class CSVTest < Test::Unit::TestCase - include TestHelper - - library "csv" - testing "CSV" - - def test_headers - csv = CSV.new("header1,header2\nrow1_1,row1_2") - assert_send_type "() -> nil", - csv, :headers - - csv = CSV.new("header1,header2\nrow1_1,row1_2", headers: true) - assert_send_type "() -> true", - csv, :headers - csv.read - assert_send_type "() -> Array[String]", - csv, :headers - end -end - -class CSVArrayTest < Test::Unit::TestCase - include TestHelper - - library "csv" - testing "Array[untyped]" - - def test_to_csv_with_array - assert_send_type "() -> String", - [1, 2, 3], :to_csv - assert_send_type "(**untyped) -> String", - [1, 2, 3], :to_csv, col_sep: '\t' - end -end - -class CSVStringTest < Test::Unit::TestCase - include TestHelper - - library "csv" - testing "String" - - def test_parse_csv_with_string - assert_send_type "() -> Array[String?]", - "1,2,3", :parse_csv - assert_send_type "(**untyped) -> Array[String?]", - "1,2,3", :parse_csv, col_sep: '\t' - end -end diff --git a/test/stdlib/Minitest_test.rb b/test/stdlib/Minitest_test.rb deleted file mode 100644 index f8c1cb511..000000000 --- a/test/stdlib/Minitest_test.rb +++ /dev/null @@ -1,63 +0,0 @@ -if ENV.key?("NO_MINITEST") - warn "Skip testing for library 'minitest' since enable NO_MINITEST" - return -end - -require_relative "test_helper" -require 'minitest' - -class MinitestSingletonTest < Test::Unit::TestCase - include TestHelper - - library "minitest" - testing "singleton(::Minitest)" - - def test_clock_time - assert_send_type "() -> untyped", - Minitest, :clock_time - end - - def test_filter_backtrace - assert_send_type "(untyped bt) -> untyped", - Minitest, :filter_backtrace, caller - end - - def test_process_args - assert_send_type "(?untyped args) -> untyped", - Minitest, :process_args - end - - def test_load_plugins - assert_send_type "() -> (nil | untyped)", - Minitest, :load_plugins - end - - def test_init_plugins - assert_send_type "(untyped options) -> untyped", - Minitest, :init_plugins, {} - end - - def test_after_run - assert_send_type "() { () -> untyped } -> untyped", - Minitest, :after_run do end - end -end - -class MinitestTestLifecycleHooksTest < Test::Unit::TestCase - include TestHelper - - library "minitest" - testing "Minitest::Test::LifecycleHooks" - - class LifecycleSetup < Minitest::Test - def setup - super - @foo = 123 - end - end - - def test_setup_return_type_void - test = LifecycleSetup.new("setup") - assert_send_type "() -> void", test, :setup - end -end diff --git a/test/stdlib/Mutex_m_test.rb b/test/stdlib/Mutex_m_test.rb deleted file mode 100644 index a7ce77586..000000000 --- a/test/stdlib/Mutex_m_test.rb +++ /dev/null @@ -1,55 +0,0 @@ -require_relative "test_helper" -require 'mutex_m' - -class Mutex_mInstanceTest < Test::Unit::TestCase - include TestHelper - - library 'mutex_m' - testing "::Mutex_m" - - def mu - Object.new.tap do |o| - o.extend Mutex_m - end - end - - def test_mu_lock - assert_send_type "() -> Thread::Mutex", - mu, :mu_lock - end - - def test_mu_locked? - mu = mu() - assert_send_type "() -> false", - mu, :mu_locked? - mu.lock - assert_send_type "() -> true", - mu, :mu_locked? - end - - def test_mu_synchronize - assert_send_type "() { () -> String } -> String", - mu, :mu_synchronize do 'foo' end - end - - def test_mu_try_lock - assert_send_type "() -> bool", - mu, :mu_try_lock - end - - def test_mu_unlock - mu = mu() - mu.lock - assert_send_type "() -> Thread::Mutex", - mu, :mu_unlock - end - - def test_sleep - mu = mu() - mu.lock - assert_send_type "(Integer) -> Integer?", - mu, :sleep, 0 - assert_send_type "(Float) -> Integer?", - mu, :sleep, 0.1 - end -end diff --git a/test/stdlib/NKF_test.rb b/test/stdlib/NKF_test.rb deleted file mode 100644 index e90139740..000000000 --- a/test/stdlib/NKF_test.rb +++ /dev/null @@ -1,20 +0,0 @@ -require_relative "test_helper" -require "nkf" - -class NKFSingletonTest < Test::Unit::TestCase - include TestHelper - - library "nkf" - testing "singleton(::NKF)" - - - def test_guess - assert_send_type "(::String str) -> ::Encoding", - NKF, :guess, "str" - end - - def test_nkf - assert_send_type "(::String opt, ::String str) -> ::String", - NKF, :nkf, "-w", "str" - end -end