diff options
-rw-r--r-- | lib/random/formatter.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_random_formatter.rb | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/random/formatter.rb b/lib/random/formatter.rb index 2b5cf718ad..4ecd6ad027 100644 --- a/lib/random/formatter.rb +++ b/lib/random/formatter.rb @@ -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. # diff --git a/test/ruby/test_random_formatter.rb b/test/ruby/test_random_formatter.rb index f927522d96..784fbfc2b8 100644 --- a/test/ruby/test_random_formatter.rb +++ b/test/ruby/test_random_formatter.rb @@ -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 |