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)
51
51
return gen_random ( n )
52
52
end
53
53
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
+
54
64
private
55
65
56
66
# :stopdoc:
Original file line number Diff line number Diff line change @@ -9,6 +9,12 @@ def setup
9
9
@it = SecureRandom
10
10
end
11
11
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
+
12
18
# This test took 2 minutes on my machine.
13
19
# And 65536 times loop could not be enough for forcing PID recycle.
14
20
# TODO: We should run this test only on GitHub Actions.
You can’t perform that action at this time.
0 commit comments