Freeze Random::Formatter::ALPHANUMERIC and its elements

This commit is contained in:
Nobuyoshi Nakada 2024-05-18 16:14:44 +09:00 committed by Nobuyoshi Nakada
parent 784bd9c42e
commit 946c823ddb
Notes: git 2024-12-16 11:54:58 +00:00
2 changed files with 6 additions and 1 deletions

View File

@ -340,7 +340,7 @@ module Random::Formatter
end
# The default character list for #alphanumeric.
ALPHANUMERIC = [*'A'..'Z', *'a'..'z', *'0'..'9']
ALPHANUMERIC = [*'A'..'Z', *'a'..'z', *'0'..'9'].map(&:freeze).freeze
# Generate a random alphanumeric string.
#

View File

@ -165,6 +165,11 @@ module Random::Formatter
def setup
@it = Random
end
def test_alphanumeric_frozen
assert_predicate @it::Formatter::ALPHANUMERIC, :frozen?
assert @it::Formatter::ALPHANUMERIC.all?(&:frozen?)
end
end
class TestInstanceMethods < Test::Unit::TestCase