@@ -794,28 +794,28 @@ public static BigInteger getRandomBI(int bits, int top, boolean bottom, Random r
794794
795795 @ JRubyMethod (name = "rand_range" , meta = true )
796796 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 ());
798798 }
799799
800800 @ JRubyMethod (name = "pseudo_rand_range" , meta = true )
801801 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 ());
803803 }
804804
805- private static BN getRandomBNInRange (Ruby runtime , BigInteger limit , Random random ) {
805+ private static BN randomValueInRange (Ruby runtime , BigInteger limit , Random random ) {
806806 BigInteger value ;
807807 try {
808- value = getRandomBIInRange (limit , random );
808+ value = randomIntegerInRange (limit , random );
809809 }
810810 catch (IllegalArgumentException e ) {
811- throw newBNError (runtime , "illegal range" );
811+ throw newBNError (runtime , e . getMessage () );
812812 }
813- return newBN (runtime , value );
813+ return newInstance (runtime , value );
814814 }
815815
816- public static BigInteger getRandomBIInRange (BigInteger limit , Random random ) {
816+ public static BigInteger randomIntegerInRange (BigInteger limit , Random random ) {
817817 if (limit .signum () < 0 ) {
818- throw new IllegalArgumentException ("illegal range" );
818+ throw new IllegalArgumentException ("illegal range: " + limit );
819819 }
820820 int bits = limit .bitLength ();
821821 BigInteger value ;
0 commit comments