diff options
Diffstat (limited to 'test/-ext-')
-rw-r--r-- | test/-ext-/integer/test_my_integer.rb | 34 | ||||
-rw-r--r-- | test/-ext-/string/test_capacity.rb | 2 | ||||
-rw-r--r-- | test/-ext-/string/test_chilled.rb | 19 | ||||
-rw-r--r-- | test/-ext-/string/test_set_len.rb | 18 | ||||
-rw-r--r-- | test/-ext-/thread/test_instrumentation_api.rb | 4 |
5 files changed, 32 insertions, 45 deletions
diff --git a/test/-ext-/integer/test_my_integer.rb b/test/-ext-/integer/test_my_integer.rb index 1b6f8489f8..0dfa234921 100644 --- a/test/-ext-/integer/test_my_integer.rb +++ b/test/-ext-/integer/test_my_integer.rb @@ -8,19 +8,13 @@ class Test_MyInteger < Test::Unit::TestCase Bug::Integer::MyInteger.new.to_f end - begin - Bug::Integer::MyInteger.class_eval do - def to_f - end + int = Class.new(Bug::Integer::MyInteger) do + def to_f end + end - assert_nothing_raised do - Bug::Integer::MyInteger.new.to_f - end - ensure - Bug::Integer::MyInteger.class_eval do - remove_method :to_f - end + assert_nothing_raised do + int.new.to_f end end @@ -29,20 +23,14 @@ class Test_MyInteger < Test::Unit::TestCase Bug::Integer::MyInteger.new <=> 0 end - begin - Bug::Integer::MyInteger.class_eval do - def <=>(other) - 0 - end + int = Class.new(Bug::Integer::MyInteger) do + def <=>(other) + 0 end + end - assert_nothing_raised do - Bug::Integer::MyInteger.new <=> 0 - end - ensure - Bug::Integer::MyInteger.class_eval do - remove_method :<=> - end + assert_nothing_raised do + int.new <=> 0 end end end diff --git a/test/-ext-/string/test_capacity.rb b/test/-ext-/string/test_capacity.rb index 2c6c51fdda..bcca64d85a 100644 --- a/test/-ext-/string/test_capacity.rb +++ b/test/-ext-/string/test_capacity.rb @@ -23,7 +23,7 @@ class Test_StringCapacity < Test::Unit::TestCase def test_s_new_capacity assert_equal("", String.new(capacity: 1000)) assert_equal(String, String.new(capacity: 1000).class) - assert_equal(10_000 - 1, capa(String.new(capacity: 10_000))) # Real capa doesn't account for termlen + assert_equal(10_000, capa(String.new(capacity: 10_000))) assert_equal("", String.new(capacity: -1000)) assert_equal(capa(String.new(capacity: -10000)), capa(String.new(capacity: -1000))) diff --git a/test/-ext-/string/test_chilled.rb b/test/-ext-/string/test_chilled.rb deleted file mode 100644 index dccab61ced..0000000000 --- a/test/-ext-/string/test_chilled.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'test/unit' -require '-test-/string' - -class Test_String_ChilledString < Test::Unit::TestCase - def test_rb_str_chilled_p - str = "" - assert_equal true, Bug::String.rb_str_chilled_p(str) - end - - def test_rb_str_chilled_p_frozen - str = "".freeze - assert_equal false, Bug::String.rb_str_chilled_p(str) - end - - def test_rb_str_chilled_p_mutable - str = "".dup - assert_equal false, Bug::String.rb_str_chilled_p(str) - end -end diff --git a/test/-ext-/string/test_set_len.rb b/test/-ext-/string/test_set_len.rb index e3eff75d9b..1531d76167 100644 --- a/test/-ext-/string/test_set_len.rb +++ b/test/-ext-/string/test_set_len.rb @@ -63,4 +63,22 @@ class Test_StrSetLen < Test::Unit::TestCase assert_not_predicate str, :ascii_only? assert_equal u, str end + + def test_valid_encoding_after_resized + s = "\0\0".force_encoding(Encoding::UTF_16BE) + str = Bug::String.new(s) + assert_predicate str, :valid_encoding? + str.resize(1) + assert_not_predicate str, :valid_encoding? + str.resize(2) + assert_predicate str, :valid_encoding? + str.resize(3) + assert_not_predicate str, :valid_encoding? + + s = "\xDB\x00\xDC\x00".force_encoding(Encoding::UTF_16BE) + str = Bug::String.new(s) + assert_predicate str, :valid_encoding? + str.resize(2) + assert_not_predicate str, :valid_encoding? + end end diff --git a/test/-ext-/thread/test_instrumentation_api.rb b/test/-ext-/thread/test_instrumentation_api.rb index 9a3b67fa10..663e41be53 100644 --- a/test/-ext-/thread/test_instrumentation_api.rb +++ b/test/-ext-/thread/test_instrumentation_api.rb @@ -54,7 +54,7 @@ class TestThreadInstrumentation < Test::Unit::TestCase thread&.join end - def test_muti_thread_timeline + def test_multi_thread_timeline threads = nil full_timeline = record do threads = threaded_cpu_bound_work(1.0) @@ -68,7 +68,7 @@ class TestThreadInstrumentation < Test::Unit::TestCase threads.each do |thread| timeline = timeline_for(thread, full_timeline) assert_consistent_timeline(timeline) - assert timeline.count(:suspended) > 1, "Expected threads to yield suspended at least once: #{timeline.inspect}" + assert_operator timeline.count(:suspended), :>=, 1, "Expected threads to yield suspended at least once: #{timeline.inspect}" end timeline = timeline_for(Thread.current, full_timeline) |