gmp 0.7.19 → 0.7.43

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +7 -0
  3. data/README.html +1 -1
  4. data/README.markdown +4 -2
  5. data/ext/gmp.c +6 -0
  6. data/ext/gmpz.c +23 -27
  7. data/ext/takeover.h +28 -0
  8. data/test/gmp_tcong.rb +1 -1
  9. data/test/gmp_tgcd.rb +1 -1
  10. data/test/gmp_tlcm.rb +1 -1
  11. data/test/gmp_tprintf.rb +1 -1
  12. data/test/gmp_troot.rb +1 -1
  13. data/test/mpfr_tcbrt.rb +1 -1
  14. data/test/mpfr_tconst_euler.rb +1 -1
  15. data/test/mpfr_tfac.rb +1 -1
  16. data/test/mpfr_tfrexp.rb +1 -1
  17. data/test/mpfr_thypot.rb +1 -1
  18. data/test/mpfr_tisnan.rb +1 -1
  19. data/test/mpfr_trec_sqrt.rb +1 -1
  20. data/test/mpfr_tsqrt.rb +1 -1
  21. data/test/tc_cmp.rb +2 -7
  22. data/test/tc_constants.rb +5 -5
  23. data/test/tc_division.rb +1 -1
  24. data/test/tc_f_abs_neg.rb +1 -1
  25. data/test/tc_f_arithmetics_coersion.rb +1 -1
  26. data/test/tc_f_precision.rb +1 -1
  27. data/test/tc_f_to_s.rb +1 -1
  28. data/test/tc_hashes.rb +1 -1
  29. data/test/tc_mpfr_cmp.rb +1 -1
  30. data/test/tc_mpfr_constants.rb +3 -3
  31. data/test/tc_mpfr_functions.rb +1 -1
  32. data/test/tc_mpfr_inf_nan_zero.rb +1 -1
  33. data/test/tc_mpfr_integer.rb +1 -1
  34. data/test/tc_mpfr_new_rounding.rb +1 -1
  35. data/test/tc_mpfr_pow.rb +1 -1
  36. data/test/tc_mpfr_random.rb +1 -1
  37. data/test/tc_mpfr_rounding.rb +1 -1
  38. data/test/tc_q.rb +1 -1
  39. data/test/tc_q_basic.rb +1 -1
  40. data/test/tc_q_floor_ceil_truncate.rb +1 -1
  41. data/test/tc_q_num_den.rb +1 -1
  42. data/test/tc_random.rb +1 -1
  43. data/test/tc_sgn_neg_abs.rb +1 -1
  44. data/test/tc_swap.rb +1 -1
  45. data/test/tc_z.rb +11 -1
  46. data/test/tc_z_addmul.rb +22 -34
  47. data/test/tc_z_basic.rb +1 -1
  48. data/test/tc_z_exponentiation.rb +1 -1
  49. data/test/tc_z_export_import.rb +1 -1
  50. data/test/tc_z_fib_fac_nextprime.rb +1 -1
  51. data/test/tc_z_functional_mappings.rb +1 -2
  52. data/test/tc_z_gcd_lcm_invert.rb +1 -1
  53. data/test/tc_z_hamdist.rb +1 -1
  54. data/test/tc_z_io.rb +1 -1
  55. data/test/tc_z_jac_leg_rem.rb +1 -1
  56. data/test/tc_z_logic.rb +1 -1
  57. data/test/tc_z_logical_roots.rb +1 -1
  58. data/test/tc_z_shifts_last_bits.rb +1 -1
  59. data/test/tc_z_submul.rb +22 -34
  60. data/test/tc_z_to_dis.rb +2 -2
  61. data/test/tc_zero_division_exceptions.rb +1 -1
  62. data/test/test_helper.rb +1 -1
  63. data/test/test_unit/assertions.rb +7 -1
  64. metadata +26 -27
  65. data/benchmark/results-5.1.3_0.6.31.ods +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a40972b493a89ea10856fa799609c7dccea84d13
4
- data.tar.gz: 1614d5eb7cf7846add652665a32d1a92035b3843
3
+ metadata.gz: 739852359b6a3c45c737d9022c26711df7b9874e
4
+ data.tar.gz: 8c7d353563c3dd3f307d53d7e14b85e360d029f1
5
5
  SHA512:
6
- metadata.gz: d6500aca0dec138a7a83a6e4f6e483b5cc7b532aca8f02cf397f4f04eda9ffda3f08342d3e69ea62f94ff33a637062d6837736a3259a0103ef00047c198d83e8
7
- data.tar.gz: 03d62dc2d10bd81a380b0413c168c4db1056564c6e2e5a573cf74fea14e3354f552884647222cf298f23f5ba77e646bfa4c0d358c5733f75daa51bec5582f444
6
+ metadata.gz: f3e76263abeea499f05572d76b473010a24a24a2707d7784a52cb73808c782da0c81917d867cddc09150862d1e79f399d182f30d7112df2b6c16cdaab504b943
7
+ data.tar.gz: 708ff9eb5fa093d178e65e475740a5b38a4aa82c89a3813ea14b4d307da23fca103e4a1f6f707865e839c03d59d71dfddc7d82d5ff6c6ac1eaa6d33b950c0431
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ 0.7.43
2
+ * Tests now use MiniTest
3
+ * Ruby 2.4 and the new Integer class (replacement for Fixnum and Bignum) are
4
+ * now supported (thanks @timocp).
5
+ * GMP::Z can now be initialized from a Float or GMP::F, as well as the
6
+ existing Fixnum, Bignum, Integer, GMP::Z, and String.
7
+
1
8
  0.7.19
2
9
  * GMP::Q.new can now accept a GMP::Z or Fixnum more intelligently, and can
3
10
  accept a Float, and is tested better.
@@ -230,7 +230,7 @@ GMP.RandState()
230
230
  asb! in-place absolute value
231
231
  coerce promotion of arguments
232
232
  == equality test
233
- <=>,>=,>,<=,< comparisions
233
+ <=>,>=,>,<=,< comparisons
234
234
  class methods of GMP::Z
235
235
  fac(n) factorial of n
236
236
  2fac(n), double_fac(n) double factorial of n
@@ -195,9 +195,11 @@ The GMP module is provided with following classes:
195
195
  Numbers are created by using `new()`. Constructors can take following arguments:
196
196
 
197
197
  GMP::Z.new()
198
- GMP::Z.new(GMP::Z)
199
198
  GMP::Z.new(Fixnum)
200
199
  GMP::Z.new(Bignum)
200
+ GMP::Z.new(GMP::Z)
201
+ GMP::Z.new(Float)
202
+ GMP::Z.new(GMP::F)
201
203
  GMP::Z.new(String)
202
204
  GMP::Q.new()
203
205
  GMP::Q.new(Fixnum)
@@ -249,7 +251,7 @@ Methods
249
251
  abs! in-place absolute value
250
252
  coerce promotion of arguments
251
253
  == equality test
252
- <=>, >=, >, <=, < comparisions
254
+ <=>, >=, >, <=, < comparisons
253
255
  class methods of GMP::Z
254
256
  fac(n) factorial of n
255
257
  2fac(n), double_fac(n) double factorial of n
data/ext/gmp.c CHANGED
@@ -161,11 +161,17 @@ mp_rnd_t r_get_rounding_mode(VALUE rnd)
161
161
  /* #include "gmpz.h" */
162
162
  #include "takeover.h"
163
163
 
164
+ #ifdef RUBY_INTEGER_UNIFICATION
165
+ #define REGISTER_TAKEOVER(fname, ruby_fname, old_fname) \
166
+ rb_define_alias(rb_cInteger, old_fname, ruby_fname); \
167
+ rb_define_method(rb_cInteger, ruby_fname, takeover_integer_##fname, -1);
168
+ #else
164
169
  #define REGISTER_TAKEOVER(fname, ruby_fname, old_fname) \
165
170
  rb_define_alias(rb_cFixnum, old_fname, ruby_fname); \
166
171
  rb_define_method(rb_cFixnum, ruby_fname, takeover_fixnum_##fname, -1); \
167
172
  rb_define_alias(rb_cBignum, old_fname, ruby_fname); \
168
173
  rb_define_method(rb_cBignum, ruby_fname, takeover_bignum_##fname, -1);
174
+ #endif /* RUBY_INTEGER_UNIFICATION */
169
175
 
170
176
  void Init_gmp() {
171
177
  bin_base_id = rb_intern("bin");
data/ext/gmpz.c CHANGED
@@ -745,21 +745,27 @@ static VALUE r_gmpz_initialize_copy(VALUE copy_val, VALUE orig_val) {
745
745
  * * String
746
746
  * * Bignum
747
747
  */
748
- void mpz_set_value(MP_INT *target, VALUE source, int base)
748
+ void mpz_set_value(MP_INT *target, VALUE source_val, int base)
749
749
  {
750
- MP_INT *source_val;
751
-
752
- if (GMPZ_P (source)) {
753
- mpz_get_struct (source, source_val);
754
- mpz_set (target, source_val);
755
- } else if (TYPE (source) == T_FIXNUM) {
756
- mpz_set_si (target, FIX2NUM (source));
757
- } else if (STRING_P (source)) {
758
- mpz_set_str (target, StringValuePtr (source), base);
759
- } else if (BIGNUM_P (source)) {
760
- mpz_set_bignum (target, source);
750
+ MP_INT *source_z;
751
+ MP_FLOAT *source_f;
752
+
753
+ if (GMPZ_P (source_val)) {
754
+ mpz_get_struct (source_val, source_z);
755
+ mpz_set (target, source_z);
756
+ } else if (TYPE (source_val) == T_FIXNUM) {
757
+ mpz_set_si (target, FIX2NUM (source_val));
758
+ } else if (STRING_P (source_val)) {
759
+ mpz_set_str (target, StringValuePtr (source_val), base);
760
+ } else if (BIGNUM_P (source_val)) {
761
+ mpz_set_bignum (target, source_val);
762
+ } else if (FLOAT_P (source_val)) {
763
+ mpz_set_d (target, NUM2DBL (source_val));
764
+ } else if (GMPF_P (source_val)) {
765
+ mpf_get_struct (source_val, source_f);
766
+ mpz_set_f (target, source_f);
761
767
  } else {
762
- rb_raise (rb_eTypeError, "Don't know how to convert %s into GMP::Z", rb_class2name (rb_class_of (source)));
768
+ rb_raise (rb_eTypeError, "Don't know how to convert %s into GMP::Z", rb_class2name (rb_class_of (source_val)));
763
769
  }
764
770
  }
765
771
 
@@ -1171,14 +1177,9 @@ static VALUE r_gmpz_addmul_self(VALUE self, VALUE b, VALUE c)
1171
1177
  if (GMPZ_P (c)) {
1172
1178
  mpz_get_struct (c, c_val);
1173
1179
  mpz_addmul (self_val, b_val, c_val);
1174
- } else if (TYPE (c) == T_FIXNUM) {
1175
- if (FIX2NUM (c) < 0)
1176
- {
1177
- if (free_b_val) { mpz_temp_free (b_val); }
1178
- rb_raise (rb_eRangeError, "multiplicand (Fixnum) must be nonnegative");
1179
- }
1180
+ } else if (FIXNUM_P (c) && FIX2NUM (c) >= 0) {
1180
1181
  mpz_addmul_ui (self_val, b_val, FIX2NUM (c));
1181
- } else if (BIGNUM_P (c)) {
1182
+ } else if (FIXNUM_P (c) || BIGNUM_P (c)) {
1182
1183
  mpz_temp_from_bignum (c_val, c);
1183
1184
  mpz_addmul (self_val, b_val, c_val);
1184
1185
  mpz_temp_free (c_val);
@@ -1226,14 +1227,9 @@ static VALUE r_gmpz_submul_self(VALUE self, VALUE b, VALUE c)
1226
1227
  if (GMPZ_P (c)) {
1227
1228
  mpz_get_struct (c, c_val);
1228
1229
  mpz_submul (self_val, b_val, c_val);
1229
- } else if (TYPE (c) == T_FIXNUM) {
1230
- if (FIX2NUM (c) < 0)
1231
- {
1232
- if (free_b_val) { mpz_temp_free (b_val); }
1233
- rb_raise (rb_eRangeError, "multiplicand (Fixnum) must be nonnegative");
1234
- }
1230
+ } else if (FIXNUM_P (c) && FIX2NUM (c) >= 0) {
1235
1231
  mpz_submul_ui (self_val, b_val, FIX2NUM (c));
1236
- } else if (BIGNUM_P (c)) {
1232
+ } else if (FIXNUM_P (c) || BIGNUM_P (c)) {
1237
1233
  mpz_temp_from_bignum (c_val, c);
1238
1234
  mpz_submul (self_val, b_val, c_val);
1239
1235
  mpz_temp_free (c_val);
@@ -1,3 +1,29 @@
1
+ #ifdef RUBY_INTEGER_UNIFICATION
2
+
3
+ #define DEFUN_TAKEOVER_LOGIC(fname, mpz_fname, old_fname) \
4
+ static VALUE takeover_integer_##fname(int argc, VALUE *argv, VALUE self) \
5
+ { \
6
+ MP_INT *res_val, *arg_val; \
7
+ VALUE res; \
8
+ \
9
+ if (argc != 1 || !GMPZ_P(argv[0])) { \
10
+ return rb_funcall2 (self, rb_intern (old_fname), argc, argv); \
11
+ } else { \
12
+ mpz_get_struct(argv[0], arg_val); \
13
+ if (FIXNUM_P(self)) { \
14
+ mpz_make_struct(res, res_val); \
15
+ mpz_init_set_si (res_val, FIX2INT(self)); \
16
+ } else { \
17
+ mpz_make_struct_init(res, res_val); \
18
+ mpz_set_bignum (res_val, self); \
19
+ } \
20
+ mpz_fname (res_val, res_val, arg_val); \
21
+ return res; \
22
+ } \
23
+ }
24
+
25
+ #else
26
+
1
27
  #define DEFUN_TAKEOVER_LOGIC(fname, mpz_fname, old_fname) \
2
28
  static VALUE takeover_fixnum_##fname(int argc, VALUE *argv, VALUE self) \
3
29
  { \
@@ -31,6 +57,8 @@ static VALUE takeover_bignum_##fname(int argc, VALUE *argv, VALUE self) \
31
57
  } \
32
58
  }
33
59
 
60
+ #endif /* RUBY_INTEGER_UNIFICATION */
61
+
34
62
  DEFUN_TAKEOVER_LOGIC(and, mpz_and, "old_and")
35
63
  DEFUN_TAKEOVER_LOGIC(or, mpz_ior, "old_or")
36
64
  DEFUN_TAKEOVER_LOGIC(xor, mpz_xor, "old_xor")
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class GMP_TCong < Test::Unit::TestCase
3
+ class GMP_TCong < MiniTest::Test
4
4
  Data = [
5
5
  # strict equality mod 0
6
6
  [ "0", "0", "0", true],
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class GMP_TGCD < Test::Unit::TestCase
3
+ class GMP_TGCD < MiniTest::Test
4
4
  def setup
5
5
  @rand_state = GMP::RandState.new
6
6
  @min_operand_bitsize = 1
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class GMP_TLCM < Test::Unit::TestCase
3
+ class GMP_TLCM < MiniTest::Test
4
4
  Primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,
5
5
  101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,
6
6
  191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,
@@ -1,7 +1,7 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
3
  unless RUBY_VERSION =~ /^1.8/
4
- class GMP_TPRINTF < Test::Unit::TestCase
4
+ class GMP_TPRINTF < MiniTest::Test
5
5
  MAX_OUTPUT = 1024
6
6
  def setup
7
7
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class GMP_TRoot < Test::Unit::TestCase
3
+ class GMP_TRoot < MiniTest::Test
4
4
  RS = GMP::RandState.new(11213)
5
5
  Reps = 500
6
6
 
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class MPFR_TCBRT < Test::Unit::TestCase
3
+ class MPFR_TCBRT < MiniTest::Test
4
4
  def setup
5
5
  @one = GMP::F(1)
6
6
  @zero = GMP::F(0)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class MPFR_TCONST_EULER < Test::Unit::TestCase
3
+ class MPFR_TCONST_EULER < MiniTest::Test
4
4
  def test_const_euler
5
5
  prec = 53
6
6
 
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class MPFR_TFAC < Test::Unit::TestCase
3
+ class MPFR_TFAC < MiniTest::Test
4
4
  def setup
5
5
  @one = GMP::F(1)
6
6
  @zero = GMP::F(0)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class MPFR_TFrexp < Test::Unit::TestCase
3
+ class MPFR_TFrexp < MiniTest::Test
4
4
  def setup
5
5
  end
6
6
 
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class MpfrTHypot < Test::Unit::TestCase
3
+ class MpfrTHypot < MiniTest::Test
4
4
  def test_special
5
5
  x = GMP::F.nan
6
6
  y = GMP::F.new
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class MPFR_ISNAN < Test::Unit::TestCase
3
+ class MPFR_ISNAN < MiniTest::Test
4
4
  def setup
5
5
  @rand_state = GMP::RandState.new
6
6
  @one = GMP::F(1)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class MPFR_TREC_SQRT < Test::Unit::TestCase
3
+ class MPFR_TREC_SQRT < MiniTest::Test
4
4
  def setup
5
5
  @rand_state = GMP::RandState.new
6
6
  @one = GMP::F(1)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class MPFR_TSQRT < Test::Unit::TestCase
3
+ class MPFR_TSQRT < MiniTest::Test
4
4
  def setup
5
5
  @rand_state = GMP::RandState.new
6
6
  end
@@ -1,17 +1,12 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcCmp < Test::Unit::TestCase
3
+ class TcCmp < MiniTest::Test
4
4
  def setup
5
- @_64bit = 1_000_000_000_000.is_a? Fixnum
6
5
  @a=GMP::Z.new(180)
7
6
  @c=GMP::Q.new(2000,11) # ~181.82
8
7
  @d=GMP::Q.new(3000,17) # ~176.47
9
8
  @e=700
10
- if @_64bit
11
- @f=2**64
12
- else
13
- @f=2**32
14
- end
9
+ @f=2**64
15
10
  @g=GMP::Q(360,2)
16
11
  end
17
12
 
@@ -1,10 +1,10 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcConstants < Test::Unit::TestCase
3
+ class TcConstants < MiniTest::Test
4
4
  def test_constants
5
- assert_instance_of(String, GMP::GMP_VERSION, "GMP::GMP_VERSION should be a String")
6
- assert_instance_of(String, GMP::GMP_CC, "GMP::GMP_CC should be a String")
7
- assert_instance_of(String, GMP::GMP_CFLAGS, "GMP::GMP_CFLAGS should be a String")
8
- assert_instance_of(Fixnum, GMP::GMP_BITS_PER_LIMB, "GMP::GMP_BITS_PER_LIMB should be a Fixnum")
5
+ assert_instance_of(String, GMP::GMP_VERSION, "GMP::GMP_VERSION should be a String")
6
+ assert_instance_of(String, GMP::GMP_CC, "GMP::GMP_CC should be a String")
7
+ assert_instance_of(String, GMP::GMP_CFLAGS, "GMP::GMP_CFLAGS should be a String")
8
+ assert_instance_of(0.class, GMP::GMP_BITS_PER_LIMB, "GMP::GMP_BITS_PER_LIMB should be a Fixnum")
9
9
  end
10
10
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcDivision < Test::Unit::TestCase
3
+ class TcDivision < MiniTest::Test
4
4
  def setup
5
5
  @a = GMP::Z.new(5)
6
6
  @b = GMP::Z.new(7)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcFloatAbsNeg < Test::Unit::TestCase
3
+ class TcFloatAbsNeg < MiniTest::Test
4
4
  def setup
5
5
  @a=GMP::F.new(3.14)
6
6
  @b=GMP::F.new()
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcFloatArithmeticsCoersion < Test::Unit::TestCase
3
+ class TcFloatArithmeticsCoersion < MiniTest::Test
4
4
  def setup
5
5
  @a = GMP::F.new(3.14, 100)
6
6
  @b = GMP::F.new(2.71, 200)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcFloatPrecision < Test::Unit::TestCase
3
+ class TcFloatPrecision < MiniTest::Test
4
4
  def setup
5
5
  # TODO: um... what?
6
6
  begin
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcFloatToS < Test::Unit::TestCase
3
+ class TcFloatToS < MiniTest::Test
4
4
  def setup
5
5
  @initial_default_prec = GMP::F.default_prec
6
6
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcHashes < Test::Unit::TestCase
3
+ class TcHashes < MiniTest::Test
4
4
  def test_z_hashes
5
5
  h = {}
6
6
  h[GMP::Z(131)] = [GMP::Z(41), GMP::Z(43), GMP::Z(47)]
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcMpfrCmp < Test::Unit::TestCase
3
+ class TcMpfrCmp < MiniTest::Test
4
4
  def setup
5
5
  @neg_inf = GMP::F(0).log # -Inf
6
6
  @inf = -@neg_inf # Inf
@@ -1,10 +1,10 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcMpfrConstants < Test::Unit::TestCase
3
+ class TcMpfrConstants < MiniTest::Test
4
4
  def test_mpfr_constants
5
5
  assert_instance_of(String, GMP::MPFR_VERSION, "GMP::MPFR_VERSION should be a String")
6
- assert_instance_of(Fixnum, GMP::MPFR_PREC_MIN, "GMP::MPFR_PREC_MIN should be a Fixnum")
7
- assert_instance_of(Fixnum, GMP::MPFR_PREC_MAX, "GMP::MPFR_PREC_MAX should be a Fixnum")
6
+ assert_instance_of(0.class, GMP::MPFR_PREC_MIN, "GMP::MPFR_PREC_MIN should be a Fixnum")
7
+ assert_instance_of(0.class, GMP::MPFR_PREC_MAX, "GMP::MPFR_PREC_MAX should be a Fixnum")
8
8
  assert_instance_of(GMP::Rnd, GMP::GMP_RNDN, "GMP::GMP_RNDN should be a GMP::Rnd")
9
9
  assert_instance_of(GMP::Rnd, GMP::GMP_RNDZ, "GMP::GMP_RNDZ should be a GMP::Rnd")
10
10
  assert_instance_of(GMP::Rnd, GMP::GMP_RNDU, "GMP::GMP_RNDU should be a GMP::Rnd")
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcMpfrFunctions < Test::Unit::TestCase
3
+ class TcMpfrFunctions < MiniTest::Test
4
4
  def setup
5
5
  @a = GMP::F(1)
6
6
  @b = GMP::F(2)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcMpfrInfNanZero < Test::Unit::TestCase
3
+ class TcMpfrInfNanZero < MiniTest::Test
4
4
  def setup
5
5
  @neg_inf = GMP::F(0).log # -Inf
6
6
  @inf = -@neg_inf # Inf
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcMpfrInteger < Test::Unit::TestCase
3
+ class TcMpfrInteger < MiniTest::Test
4
4
  def test_mpfr_integer_positive
5
5
  assert(GMP::F(1.0).integer?, "MPFR should decide whether a number is an integer correctly.")
6
6
  assert(GMP::F(2.0).integer?, "MPFR should decide whether a number is an integer correctly.")
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcMpfrNewRounding < Test::Unit::TestCase
3
+ class TcMpfrNewRounding < MiniTest::Test
4
4
  def test_new_fixnum
5
5
  ninety_six = GMP::F(96, 4)
6
6
  one_hundred_four = GMP::F(104, 4)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcMpfrPow < Test::Unit::TestCase
3
+ class TcMpfrPow < MiniTest::Test
4
4
  def setup
5
5
  @a = GMP::F(0.25)
6
6
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcMpfrRandom < Test::Unit::TestCase
3
+ class TcMpfrRandom < MiniTest::Test
4
4
  def setup
5
5
  end
6
6
 
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcMpfrRounding < Test::Unit::TestCase
3
+ class TcMpfrRounding < MiniTest::Test
4
4
  def setup
5
5
  if GMP::MPFR_VERSION < "3.0.0"
6
6
  @prefix = "GMP"
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcRational < Test::Unit::TestCase
3
+ class TcRational < MiniTest::Test
4
4
  def setup
5
5
  @z_1 = GMP::Z(1)
6
6
  @z_2 = GMP::Z(2)
@@ -1,7 +1,7 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
3
  # [Q op Q, Q op Z, Z op Q, Q op FixNum, Q op BigNum, FixNum op Q, BigNum op Q]
4
- class TcRationalBasic < Test::Unit::TestCase
4
+ class TcRationalBasic < MiniTest::Test
5
5
  def setup
6
6
  @a=GMP::Q.new(100,11)
7
7
  @b=GMP::Q.new(200,17)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcRationalFloorCeilTruncate < Test::Unit::TestCase
3
+ class TcRationalFloorCeilTruncate < MiniTest::Test
4
4
  def setup
5
5
  @a = GMP::Q.new(200,11)
6
6
  @b = -@a
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcRationalDenNum < Test::Unit::TestCase
3
+ class TcRationalDenNum < MiniTest::Test
4
4
  def setup
5
5
  @p = GMP::Q.new(22, 7)
6
6
  @q = GMP::Q.new(-0.625)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcRandom < Test::Unit::TestCase
3
+ class TcRandom < MiniTest::Test
4
4
  def test_urandomb
5
5
  @a = GMP::RandState.new
6
6
  @a.seed(13579)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcSgnNegAbs < Test::Unit::TestCase
3
+ class TcSgnNegAbs < MiniTest::Test
4
4
  def setup
5
5
  @a=GMP::Z.new(10)
6
6
  @b=GMP::Z.new()
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcSwap < Test::Unit::TestCase
3
+ class TcSwap < MiniTest::Test
4
4
  def setup
5
5
  @a=GMP::Z.new(100)
6
6
  @b=GMP::Z.new(200)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcInteger < Test::Unit::TestCase
3
+ class TcInteger < MiniTest::Test
4
4
  def test_init_null
5
5
  assert_equal(GMP::Z.new(), 0, "GMP::Z.new() should initialize to 0")
6
6
  end
@@ -55,6 +55,16 @@ class TcInteger < Test::Unit::TestCase
55
55
  assert_equal(2**32, GMP::Z.new(2**32), "GMP::Z.new(x : Bignum) should initialize to x")
56
56
  end
57
57
 
58
+ def test_init_float
59
+ assert_equal(3, GMP::Z.new(3.14), "GMP::Z.new(x : Float) should initialize to x")
60
+ assert_equal(3, GMP::Z.new(3.99), "GMP::Z.new(x : Float) should initialize to x")
61
+ end
62
+
63
+ def test_init_gmpf
64
+ assert_equal(3, GMP::Z.new(GMP::F(3.14)), "GMP::Z.new(x : GMP::F) should initialize to x")
65
+ assert_equal(577, GMP::Z.new(GMP::F("0.57721566")*1000), "GMP::Z.new(x : GMP::F) should initialize to x")
66
+ end
67
+
58
68
  def test_cmp_z
59
69
  a = GMP::Z.new(2)
60
70
  b = GMP::Z.new(1)
@@ -4,11 +4,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
4
4
  # Z op (Fixnum,Z), Z op (Fixnum,Fixnum), Z op (Fixnum,Bignum)
5
5
  # Z op (Bignum,Z), Z op (Bignum,Bignum), Z op (Bignum,Fixnum)]
6
6
  # Things are tested both ways because the implementation is asymetrical
7
- class TcIntegerAddmul < Test::Unit::TestCase
8
- def setup
9
- @_64bit = 1_000_000_000_000.is_a? Fixnum
10
- end
11
-
7
+ class TcIntegerAddmul < MiniTest::Test
12
8
  def test_z
13
9
  five = GMP::Z(5)
14
10
  seven = GMP::Z(7)
@@ -55,40 +51,32 @@ class TcIntegerAddmul < Test::Unit::TestCase
55
51
  m20 = GMP::Z(2)**20 - 1 # 1_048_575
56
52
  m20.addmul!(-524_287, 2) # <= 1_048_575 + -1_048_574
57
53
  assert_equal(1, m20, "GMP::Z should addmul Fixnum correctly")
58
- if @_64bit
59
- neg_m40 = -GMP::Z(2)**40 # -1_099_511_627_776
60
- neg_m40.addmul!( 1_000_000_000_000, 1) # <= -1_099_511_627_776 + 1_000_000_000_000
61
- assert_equal(GMP::Z(-99_511_627_776), neg_m40, "GMP::Z should addmul 64-bit Fixnum correctly")
62
- end
54
+ neg_m40 = -GMP::Z(2)**40 # -1_099_511_627_776
55
+ neg_m40.addmul!( 1_000_000_000_000, 1) # <= -1_099_511_627_776 + 1_000_000_000_000
56
+ assert_equal(GMP::Z(-99_511_627_776), neg_m40, "GMP::Z should addmul 64-bit Fixnum correctly")
63
57
  end
64
58
 
65
59
  def test_bignum
66
- if ! @_64bit
67
- neg_m40 = -GMP::Z(2)**40 # -1_099_511_627_776
68
- neg_m40.addmul!( 1_000_000_000_000, 1) # <= -1_099_511_627_776 + 1_000_000_000_000
69
- assert_equal(GMP::Z(-99_511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
70
- neg_m40.addmul!(10, 9_000_000_000) # <= - 99_511_627_776 + 90_000_000_000
71
- assert_equal(GMP::Z(- 9_511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
72
- neg_m40.addmul!( 3_000_000_000, 3) # <= - 9_511_627_776 + 9_000_000_000
73
- assert_equal(GMP::Z(- 511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
74
- else
75
- m70 = GMP::Z(2)**70 - 1 # 1_180_591_620_717_411_303_423
76
- m70.addmul!(-11*10_000_000_000, 10_000_000_000)
77
- assert_equal(GMP::Z(80_591_620_717_411_303_423), m70, "GMP::Z should addmul 64-bit Bignum correctly")
78
- m70.addmul!(-1_000_000_000, 8*10_000_000_000)
79
- assert_equal(GMP::Z( 591_620_717_411_303_423), m70, "GMP::Z should addmul 64-bit Bignum correctly")
80
- end
60
+ neg_m40 = -GMP::Z(2)**40 # -1_099_511_627_776
61
+ neg_m40.addmul!( 1_000_000_000_000, 1) # <= -1_099_511_627_776 + 1_000_000_000_000
62
+ assert_equal(GMP::Z(-99_511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
63
+ neg_m40.addmul!(10, 9_000_000_000) # <= - 99_511_627_776 + 90_000_000_000
64
+ assert_equal(GMP::Z(- 9_511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
65
+ neg_m40.addmul!( 3_000_000_000, 3) # <= - 9_511_627_776 + 9_000_000_000
66
+ assert_equal(GMP::Z(- 511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
67
+ m70 = GMP::Z(2)**70 - 1 # 1_180_591_620_717_411_303_423
68
+ m70.addmul!(-11*10_000_000_000, 10_000_000_000)
69
+ assert_equal(GMP::Z(80_591_620_717_411_303_423), m70, "GMP::Z should addmul 64-bit Bignum correctly")
70
+ m70.addmul!(-1_000_000_000, 8*10_000_000_000)
71
+ assert_equal(GMP::Z( 591_620_717_411_303_423), m70, "GMP::Z should addmul 64-bit Bignum correctly")
81
72
  end
82
73
 
83
74
  def test_raise
84
- if ! @_64bit
85
- assert_raise(RangeError) { GMP::Z(123).addmul!(456, -7) }
86
- assert_nothing_raised(RangeError) { GMP::Z(123).addmul!(456, -7_000_000_000) }
87
- else
88
- assert_raise(RangeError) { GMP::Z(123).addmul!(456, -7_000_000_000) }
89
- assert_nothing_raised(RangeError) { GMP::Z(123).addmul!(456, -7_000_000_000_000_000_000) }
90
- end
91
- assert_nothing_raised(RangeError) { GMP::Z(123).addmul!(456, 7) }
92
- assert_nothing_raised(RangeError) { GMP::Z(123).addmul!(456, GMP::Z(-7)) }
75
+ assert_nothing_raised(RangeError) { GMP::Z(123).addmul!(456, -7) }
76
+ assert_nothing_raised(RangeError) { GMP::Z(123).addmul!(456, -7_000_000_000) }
77
+ assert_nothing_raised(RangeError) { GMP::Z(123).addmul!(456, -7_000_000_000) }
78
+ assert_nothing_raised(RangeError) { GMP::Z(123).addmul!(456, -7_000_000_000_000_000_000) }
79
+ assert_nothing_raised(RangeError) { GMP::Z(123).addmul!(456, 7) }
80
+ assert_nothing_raised(RangeError) { GMP::Z(123).addmul!(456, GMP::Z(-7)) }
93
81
  end
94
82
  end
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
3
  # Tested: [Z op Z, Z op FixNum, Z op BigNum, FixNum op Z, BigNum op Z]
4
4
  # Things are tested both ways because the implementation is asymetrical
5
- class TcIntegerBasic < Test::Unit::TestCase
5
+ class TcIntegerBasic < MiniTest::Test
6
6
  def setup
7
7
  @a=GMP::Z.new(100)
8
8
  @b=GMP::Z.new(200)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcIntegerExponentiation < Test::Unit::TestCase
3
+ class TcIntegerExponentiation < MiniTest::Test
4
4
  def setup
5
5
  @a = GMP::Z.new(100)
6
6
  @b = GMP::Z.new(16)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcIntegerExportImport < Test::Unit::TestCase
3
+ class TcIntegerExportImport < MiniTest::Test
4
4
  def setup
5
5
  @a = GMP::Z.new(3)**40
6
6
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcFibFacNextprime < Test::Unit::TestCase
3
+ class TcFibFacNextprime < MiniTest::Test
4
4
  def setup
5
5
  @z0 = GMP::Z.new( 0)
6
6
  @z1 = GMP::Z.new( 1)
@@ -1,8 +1,7 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcIntegerFunctionalMappings < Test::Unit::TestCase
3
+ class TcIntegerFunctionalMappings < MiniTest::Test
4
4
  def setup
5
- @_64bit = 1_000_000_000_000.is_a? Fixnum
6
5
  @xp1 = 7
7
6
  @xp2 = 2**30 - 1
8
7
  @xn1 = -5
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcIntegerGcdLcmInvert < Test::Unit::TestCase
3
+ class TcIntegerGcdLcmInvert < MiniTest::Test
4
4
  def setup
5
5
  @a = GMP::Z( 24) # 2^3 * 3
6
6
  @b = GMP::Z( 8) # 2^3
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcIntegerHamdist < Test::Unit::TestCase
3
+ class TcIntegerHamdist < MiniTest::Test
4
4
  def setup
5
5
  @z32 = GMP::Z(32) # 100000
6
6
  @z33 = GMP::Z(33) # 100001
@@ -6,7 +6,7 @@ if (RUBY_DESCRIPTION =~ /rubinius/i and RUBY_VERSION =~ /^1.8/) ||
6
6
  # Sorry charlie
7
7
  else
8
8
 
9
- class TcIntegerIo < Test::Unit::TestCase
9
+ class TcIntegerIo < MiniTest::Test
10
10
  def setup
11
11
  @two_pow_100 = GMP::Z.pow(GMP::Z(2), 100)
12
12
  @three_pow_100 = GMP::Z.pow(GMP::Z(3), 100)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcIntegerJacobiLegendreRemove < Test::Unit::TestCase
3
+ class TcIntegerJacobiLegendreRemove < MiniTest::Test
4
4
  def setup
5
5
  @one = GMP::Z(1)
6
6
  @two = GMP::Z(2)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcIntegerLogic < Test::Unit::TestCase
3
+ class TcIntegerLogic < MiniTest::Test
4
4
  def setup
5
5
  @a=GMP::Z.new(0xffff00000000ffff)
6
6
  @b=GMP::Z.new(0xffff0000ffff0000)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcIntegerLogicalRoots < Test::Unit::TestCase
3
+ class TcIntegerLogicalRoots < MiniTest::Test
4
4
  def setup
5
5
  @a = GMP::Z.new(100)
6
6
  @b = GMP::Z.new( 27)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcIntegerShiftsLastBits < Test::Unit::TestCase
3
+ class TcIntegerShiftsLastBits < MiniTest::Test
4
4
  def setup
5
5
  @a = GMP::Z.new(100) # 01100100
6
6
  @b = -@a # 10011100
@@ -4,11 +4,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
4
4
  # Z op (Fixnum,Z), Z op (Fixnum,Fixnum), Z op (Fixnum,Bignum)
5
5
  # Z op (Bignum,Z), Z op (Bignum,Bignum), Z op (Bignum,Fixnum)]
6
6
  # Things are tested both ways because the implementation is asymetrical
7
- class TcIntegerSubmul < Test::Unit::TestCase
8
- def setup
9
- @_64bit = 1_000_000_000_000.is_a? Fixnum
10
- end
11
-
7
+ class TcIntegerSubmul < MiniTest::Test
12
8
  def test_z
13
9
  five = GMP::Z(5)
14
10
  seven = GMP::Z(7)
@@ -55,40 +51,32 @@ class TcIntegerSubmul < Test::Unit::TestCase
55
51
  m20 = GMP::Z(2)**20 - 1 # 1_048_575
56
52
  m20.submul!(-524_287, 2) # <= 1_048_575 - -1_048_574
57
53
  assert_equal(2_097_149, m20, "GMP::Z should submul Fixnum correctly")
58
- if @_64bit
59
- neg_m40 = -GMP::Z(2)**40 # -1_099_511_627_776
60
- neg_m40.submul!( 1_000_000_000_000, 1) # <= -1_099_511_627_776 - 1_000_000_000_000
61
- assert_equal(GMP::Z(-2_099_511_627_776), neg_m40, "GMP::Z should submul 64-bit Fixnum correctly")
62
- end
54
+ neg_m40 = -GMP::Z(2)**40 # -1_099_511_627_776
55
+ neg_m40.submul!( 1_000_000_000_000, 1) # <= -1_099_511_627_776 - 1_000_000_000_000
56
+ assert_equal(GMP::Z(-2_099_511_627_776), neg_m40, "GMP::Z should submul 64-bit Fixnum correctly")
63
57
  end
64
58
 
65
59
  def test_bignum
66
- if ! @_64bit
67
- neg_m40 = -GMP::Z(2)**40 # -1_099_511_627_776
68
- neg_m40.submul!( -1_000_000_000_000, 1) # <= -1_099_511_627_776 - -1_000_000_000_000
69
- assert_equal(GMP::Z(-99_511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
70
- neg_m40.submul!(-10, 9_000_000_000) # <= - 99_511_627_776 - -90_000_000_000
71
- assert_equal(GMP::Z(- 9_511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
72
- neg_m40.submul!( -3_000_000_000, 3) # <= - 9_511_627_776 - -9_000_000_000
73
- assert_equal(GMP::Z(- 511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
74
- else
75
- m70 = GMP::Z(2)**70 - 1 # 1_180_591_620_717_411_303_423
76
- m70.submul!(11*10_000_000_000, 10_000_000_000)
77
- assert_equal(GMP::Z(80_591_620_717_411_303_423), m70, "GMP::Z should addmul 64-bit Bignum correctly")
78
- m70.submul!(1_000_000_000, 8*10_000_000_000)
79
- assert_equal(GMP::Z( 591_620_717_411_303_423), m70, "GMP::Z should addmul 64-bit Bignum correctly")
80
- end
60
+ neg_m40 = -GMP::Z(2)**40 # -1_099_511_627_776
61
+ neg_m40.submul!( -1_000_000_000_000, 1) # <= -1_099_511_627_776 - -1_000_000_000_000
62
+ assert_equal(GMP::Z(-99_511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
63
+ neg_m40.submul!(-10, 9_000_000_000) # <= - 99_511_627_776 - -90_000_000_000
64
+ assert_equal(GMP::Z(- 9_511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
65
+ neg_m40.submul!( -3_000_000_000, 3) # <= - 9_511_627_776 - -9_000_000_000
66
+ assert_equal(GMP::Z(- 511_627_776), neg_m40, "GMP::Z should addmul Bignum correctly")
67
+ m70 = GMP::Z(2)**70 - 1 # 1_180_591_620_717_411_303_423
68
+ m70.submul!(11*10_000_000_000, 10_000_000_000)
69
+ assert_equal(GMP::Z(80_591_620_717_411_303_423), m70, "GMP::Z should addmul 64-bit Bignum correctly")
70
+ m70.submul!(1_000_000_000, 8*10_000_000_000)
71
+ assert_equal(GMP::Z( 591_620_717_411_303_423), m70, "GMP::Z should addmul 64-bit Bignum correctly")
81
72
  end
82
73
 
83
74
  def test_raise
84
- if ! @_64bit
85
- assert_raise(RangeError) { GMP::Z(123).submul!(456, -7) }
86
- assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, -7_000_000_000) }
87
- else
88
- assert_raise(RangeError) { GMP::Z(123).submul!(456, -7_000_000_000) }
89
- assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, -7_000_000_000_000_000_000) }
90
- end
91
- assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, 7) }
92
- assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, GMP::Z(-7)) }
75
+ assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, -7) }
76
+ assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, -7_000_000_000) }
77
+ assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, -7_000_000_000) }
78
+ assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, -7_000_000_000_000_000_000) }
79
+ assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, 7) }
80
+ assert_nothing_raised(RangeError) { GMP::Z(123).submul!(456, GMP::Z(-7)) }
93
81
  end
94
82
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TcIntegerToDis < Test::Unit::TestCase
3
+ class TcIntegerToDis < MiniTest::Test
4
4
  def setup
5
5
  @a = GMP::Z.new(100)
6
6
  @b = GMP::Z.pow(2,32)
@@ -10,7 +10,7 @@ class TcIntegerToDis < Test::Unit::TestCase
10
10
 
11
11
  def test_to_i
12
12
  assert_equal(@a.to_i, 100, "GMP::Z should to_i correctly.")
13
- assert_equal(@a.to_i.class, Fixnum, "GMP::Z.to_i should be a Fixnum.")
13
+ assert_equal(@a.to_i.class, 0.class, "GMP::Z.to_i should be a Fixnum.")
14
14
  assert_equal(@b.to_i, 2**32, "GMP::Z (Bignum) should to_i correctly.")
15
15
  end
16
16
 
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
2
 
3
- class TCZeroDivisionExceptions < Test::Unit::TestCase
3
+ class TCZeroDivisionExceptions < MiniTest::Test
4
4
  def setup
5
5
  @a = GMP::Z.new(10)
6
6
  @b = GMP::Z.new()
@@ -1,4 +1,4 @@
1
- require 'test/unit'
1
+ require 'minitest/autorun'
2
2
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_unit', 'assertions'))
3
3
  #require './test_unit/assertions' # Monkey patch
4
4
  require 'rbconfig'
@@ -1,4 +1,4 @@
1
- module Test::Unit::Assertions
1
+ module Minitest::Assertions
2
2
  def assert_less_than(expected, actual, message=nil)
3
3
  assert_true(actual < expected, message)
4
4
  end
@@ -28,4 +28,10 @@ module Test::Unit::Assertions
28
28
  def assert_false(actual, message=nil)
29
29
  assert(!actual, message)
30
30
  end
31
+
32
+ # backwards compatibility with Test::Unit
33
+ alias assert_raise assert_raises
34
+ def assert_nothing_raised(e=nil)
35
+ yield
36
+ end
31
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.19
4
+ version: 0.7.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Wegrzanowski
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-12 00:00:00.000000000 Z
12
+ date: 2017-02-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: gmp - providing Ruby bindings to the GMP and MPFR libraries.
15
15
  email:
@@ -20,21 +20,36 @@ extensions:
20
20
  - ext/extconf.rb
21
21
  extra_rdoc_files: []
22
22
  files:
23
+ - CHANGELOG
24
+ - COPYING.md
25
+ - FEATURES.html
26
+ - README.html
27
+ - README.markdown
28
+ - benchmark/bench.sh
29
+ - benchmark/csv.sh
30
+ - benchmark/results-5.0.5_1.9.3_0.6.7.ods
31
+ - benchmark/results-5.1.0_0.6.19.ods
32
+ - ext/extconf.rb
23
33
  - ext/gmp.c
24
34
  - ext/gmpbench_timing.c
25
35
  - ext/gmpf.c
36
+ - ext/gmpf.h
26
37
  - ext/gmpq.c
38
+ - ext/gmpq.h
27
39
  - ext/gmprandstate.c
28
40
  - ext/gmpz.c
29
- - ext/mprnd.c
30
- - ext/gmpf.h
31
- - ext/gmpq.h
32
41
  - ext/gmpz.h
42
+ - ext/mprnd.c
33
43
  - ext/mprnd.h
34
44
  - ext/ruby_gmp.h
35
45
  - ext/takeover.h
36
- - ext/extconf.rb
37
46
  - lib/gmp.rb
47
+ - manual.pdf
48
+ - manual.tex
49
+ - performance.2012.html
50
+ - performance.2012.md
51
+ - performance.2012.pdf
52
+ - test/README
38
53
  - test/gmp_tcong.rb
39
54
  - test/gmp_tgcd.rb
40
55
  - test/gmp_tlcm.rb
@@ -94,27 +109,11 @@ files:
94
109
  - test/test-22.rb
95
110
  - test/test-23.rb
96
111
  - test/test_helper.rb
97
- - test/unit_tests.rb
98
- - test/README
99
112
  - test/test_unit/assertions.rb
100
- - benchmark/bench.sh
101
- - benchmark/csv.sh
102
- - benchmark/results-5.0.5_1.9.3_0.6.7.ods
103
- - benchmark/results-5.1.0_0.6.19.ods
104
- - benchmark/results-5.1.3_0.6.31.ods
105
- - CHANGELOG
106
- - COPYING.md
107
- - README.html
108
- - README.markdown
109
- - manual.pdf
110
- - manual.tex
111
- - FEATURES.html
112
- - performance.2012.md
113
- - performance.2012.html
114
- - performance.2012.pdf
113
+ - test/unit_tests.rb
115
114
  homepage: http://github.com/srawlins/gmp
116
115
  licenses:
117
- - Apache License Version 2.0
116
+ - Apache-2.0
118
117
  metadata: {}
119
118
  post_install_message:
120
119
  rdoc_options: []
@@ -122,18 +121,18 @@ require_paths:
122
121
  - lib
123
122
  required_ruby_version: !ruby/object:Gem::Requirement
124
123
  requirements:
125
- - - '>='
124
+ - - ">="
126
125
  - !ruby/object:Gem::Version
127
126
  version: 1.8.6
128
127
  required_rubygems_version: !ruby/object:Gem::Requirement
129
128
  requirements:
130
- - - '>='
129
+ - - ">="
131
130
  - !ruby/object:Gem::Version
132
131
  version: '0'
133
132
  requirements:
134
133
  - GMP compiled and working properly.
135
134
  rubyforge_project:
136
- rubygems_version: 2.0.7
135
+ rubygems_version: 2.5.1
137
136
  signing_key:
138
137
  specification_version: 4
139
138
  summary: Provides Ruby bindings to the GMP and MPFR libraries.