From 78ff9b719c236b56956d446053256f8e30edf0c3 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 8 Oct 2021 14:08:03 +0900 Subject: Add tests for the edge caces of `String#end_with?` Also, check if a suffix is empty, to guarantee the assumption of `onigenc_get_left_adjust_char_head` that `*s` is always accessible, even in the case of `SHARABLE_MIDDLE_SUBSTRING`. --- test/ruby/test_string.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/ruby/test_string.rb') diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 12e4b0fe2a..3f7c06e075 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1180,6 +1180,8 @@ CODE assert_send([S("hello"), :end_with?, S("llo")]) assert_not_send([S("hello"), :end_with?, S("ll")]) assert_send([S("hello"), :end_with?, S("el"), S("lo")]) + assert_send([S("hello"), :end_with?, S("")]) + assert_not_send([S("hello"), :end_with?]) bug5536 = '[ruby-core:40623]' assert_raise(TypeError, bug5536) {S("str").end_with? :not_convertible_to_string} -- cgit v1.2.3