summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorjory-graham <jory.graham@shopify.com>2021-08-05 13:58:39 -0400
committerjory-graham <jory.graham@shopify.com>2021-08-05 13:58:39 -0400
commit8ec36494fb28d92d8bb5c4b3fc213a1a2b6d0bb6 (patch)
tree6ea7699474325d10840f3a8f33117347d2898b8d /test
parent02f759dd74cbd3787263c5a32b7505fc8ddf76cc (diff)
downloadpsych-8ec36494fb28d92d8bb5c4b3fc213a1a2b6d0bb6.tar.gz
Replace A-Za-z with [:alpha:]
Diffstat (limited to 'test')
-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 cac8b8f..abd5515 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