File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,16 @@ def bytes(n)
5151 return gen_random ( n )
5252 end
5353
54+ # Compatibility methods for Ruby 3.2, we can remove this after dropping to support Ruby 3.2
55+ def alphanumeric ( n = nil , chars : ALPHANUMERIC )
56+ if RUBY_VERSION < '3.3'
57+ n = 16 if n . nil?
58+ choose ( chars , n )
59+ else
60+ super n , chars : chars
61+ end
62+ end
63+
5464 private
5565
5666 # :stopdoc:
Original file line number Diff line number Diff line change @@ -9,6 +9,12 @@ def setup
99 @it = SecureRandom
1010 end
1111
12+ def test_alphanumeric_with_chars
13+ assert_nothing_raised ( ArgumentError ) do
14+ @it . alphanumeric ( 1 , chars : ( "0" .."9" ) . to_a )
15+ end
16+ end
17+
1218 # This test took 2 minutes on my machine.
1319 # And 65536 times loop could not be enough for forcing PID recycle.
1420 # TODO: We should run this test only on GitHub Actions.
You can’t perform that action at this time.
0 commit comments