@@ -794,28 +794,28 @@ public static BigInteger getRandomBI(int bits, int top, boolean bottom, Random r
794
794
795
795
@ JRubyMethod (name = "rand_range" , meta = true )
796
796
public static IRubyObject rand_range (IRubyObject recv , IRubyObject arg ) {
797
- return getRandomBNInRange (recv .getRuntime (), getBigInteger (arg ), getSecureRandom ());
797
+ return randomValueInRange (recv .getRuntime (), getBigInteger (arg ), getSecureRandom ());
798
798
}
799
799
800
800
@ JRubyMethod (name = "pseudo_rand_range" , meta = true )
801
801
public static IRubyObject pseudo_rand_range (IRubyObject recv , IRubyObject arg ) {
802
- return getRandomBNInRange (recv .getRuntime (), getBigInteger (arg ), getRandom ());
802
+ return randomValueInRange (recv .getRuntime (), getBigInteger (arg ), getRandom ());
803
803
}
804
804
805
- private static BN getRandomBNInRange (Ruby runtime , BigInteger limit , Random random ) {
805
+ private static BN randomValueInRange (Ruby runtime , BigInteger limit , Random random ) {
806
806
BigInteger value ;
807
807
try {
808
- value = getRandomBIInRange (limit , random );
808
+ value = randomIntegerInRange (limit , random );
809
809
}
810
810
catch (IllegalArgumentException e ) {
811
- throw newBNError (runtime , "illegal range" );
811
+ throw newBNError (runtime , e . getMessage () );
812
812
}
813
- return newBN (runtime , value );
813
+ return newInstance (runtime , value );
814
814
}
815
815
816
- public static BigInteger getRandomBIInRange (BigInteger limit , Random random ) {
816
+ public static BigInteger randomIntegerInRange (BigInteger limit , Random random ) {
817
817
if (limit .signum () < 0 ) {
818
- throw new IllegalArgumentException ("illegal range" );
818
+ throw new IllegalArgumentException ("illegal range: " + limit );
819
819
}
820
820
int bits = limit .bitLength ();
821
821
BigInteger value ;
0 commit comments