summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2021-08-12 16:09:15 -0700
committerGitHub <noreply@github.com>2021-08-12 16:09:15 -0700
commit773180db854e9caff9c1abd3d6dc7a2e80a29167 (patch)
tree6ea7699474325d10840f3a8f33117347d2898b8d /test
parent02f759dd74cbd3787263c5a32b7505fc8ddf76cc (diff)
parent8ec36494fb28d92d8bb5c4b3fc213a1a2b6d0bb6 (diff)
downloadpsych-773180db854e9caff9c1abd3d6dc7a2e80a29167.tar.gz
Merge pull request #516 from Shopify/tokenize-unicode-regexp-on-main
Update ScalarScanner#tokenize pattern for unicode on master
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