summaryrefslogtreecommitdiff
path: root/test/psych
diff options
context:
space:
mode:
authorjory-graham <jory.graham@shopify.com>2021-08-05 13:58:39 -0400
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-08-31 19:34:54 +0900
commitdb154b20cceb2fc71390cce21fdff23f6f36f7b6 (patch)
tree21302069f4192b0d8703610b2251f963760c0b45 /test/psych
parent9ed2cb26dee8ed801a75cf4b276f1ec354ade032 (diff)
[ruby/psych] Replace A-Za-z with [:alpha:]
https://github.com/ruby/psych/commit/8ec36494fb
Diffstat (limited to 'test/psych')
-rw-r--r--test/psych/test_scalar_scanner.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/psych/test_scalar_scanner.rb b/test/psych/test_scalar_scanner.rb
index cac8b8feb19..abd55155015 100644
--- a/test/psych/test_scalar_scanner.rb
+++ b/test/psych/test_scalar_scanner.rb
@@ -156,5 +156,27 @@ module Psych
def test_scan_plus_dot
assert_equal '+.', ss.tokenize('+.')
end
+
+ class MatchCallCounter < String
+ attr_reader :match_call_count
+
+ def match?(pat)
+ @match_call_count ||= 0
+ @match_call_count += 1
+ super
+ end
+ end
+
+ def test_scan_ascii_matches_quickly
+ ascii = MatchCallCounter.new('abcdefghijklmnopqrstuvwxyz')
+ ss.tokenize(ascii)
+ assert_equal 1, ascii.match_call_count
+ end
+
+ def test_scan_unicode_matches_quickly
+ unicode = MatchCallCounter.new('鳥かご関連用品')
+ ss.tokenize(unicode)
+ assert_equal 1, unicode.match_call_count
+ end
end
end