24 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 49ae2a69f2 Add mrb_get_arg1() that retrieves single (and only) argument.
`mrb_get_arg1()` raises `ArgumentError` if the method does not receive one
argument.

And replaces all `mrb_get_args(mrb, "o", &arg)` by the new function.
2020-06-20 12:49:46 +09:00
Yukihiro "Matz" Matsumoto 2ffb77586a Symbolify saved alias name to improve performance. 2020-06-20 12:07:49 +09:00
KOBAYASHI Shuji 4bdb1eb5aa Drop dependencies from mruby-complex to some gems 2019-12-15 22:51:07 +09:00
Ray Chason 1cd0ff0d42 Avoid overflow and underflow in Complex#/ 2019-08-09 00:08:36 -04:00
Ray Chason c181d1e7fa Implement Complex#abs in terms of Math.hypot
Math.hypot avoids premature overflow and underflow
2019-08-08 23:59:25 -04:00
KOBAYASHI Shuji 334afb167c Use new specifiers/modifiers of mrb_vfromat()
The binary sizes (gems are only `mruby-bin-mruby`) are reduced slightly in
my environment than before the introduction of new specifiers/modifiers
(5116789a) with this change.

  ------------+-------------------+-------------------+--------
   BINARY     | BEFORE (5116789a) |   AFTER (This PR) |  RATIO
  ------------+-------------------+-------------------+--------
   mruby      |      593416 bytes |      593208 bytes | -0.04%
   libmruby.a |      769048 bytes |      767264 bytes | -0.23%
  ------------+-------------------+-------------------+--------

BTW, I accidentally changed `tasks/toolchains/visualcpp.rake` at #4613,
so I put it back.
2019-08-05 13:18:50 +09:00
KOBAYASHI Shuji 44381f0a0c Refine message to skip in nested assert
- I think "Info" is used only to `skip`, so change to "Skip".
- Changed the default value of `assert` and specify the argument explicitly
  at the caller of `assert` because it is unnatural "Assertion failed" is
  output even though the assertion doesn't fail.

== Example:

  def assert_foo(exp, act)
    assert do
      assert_equal exp[0], act[0]
      assert_equal exp[1], act[1]
    end
  end

  def assert_bar(exp, act)
    assert do
      skip
    end
  end

  def assert_baz(exp, act)
    assert do
      assert_equal exp, act
      assert_bar exp, act
    end
  end

  assert 'test#skip_in_nested_assert' do
    assert_baz 1, 1
  end

  === Before this patch:

    ?..
    Info: test#skip_in_nested_assert (core)
     - Assertion[1]
        Info: Assertion failed (core)
         - Assertion[1-2]
            Skip: Assertion failed (core)
      Total: 3
         OK: 2
         KO: 0
      Crash: 0
    Warning: 0
       Skip: 1

  === After this patch:

    ???
    Skip: test#skip_in_nested_assert (core)
     - Assertion[1]
        Skip: assert (core)
         - Assertion[1-2]
            Skip: assert (core)
      Total: 3
         OK: 0
         KO: 0
      Crash: 0
    Warning: 0
       Skip: 3
2019-07-30 13:05:01 +09:00
Yukihiro "Matz" Matsumoto a57a9bce79 Call MRB_SET_INSTANCE_TT for Complex and Rational. 2019-07-24 10:48:00 +09:00
Yukihiro "Matz" Matsumoto 949f6f5324 Check conflicts with Complex and MRB_WITHOUT_FLOAT; ref #4576
The Complex class needs `mrb_float` so that it does not work with
`MRB_WITHOUT_FLOAT` anyway.
2019-07-22 20:19:01 +09:00
Yukihiro "Matz" Matsumoto 2a410c0e1b Avoid making top-level env in initialization code; ref #4581 2019-07-18 00:34:08 +09:00
Yukihiro "Matz" Matsumoto a9fd2e6464 Resolve ambiguous argument warning. 2019-07-13 13:16:30 +09:00
dearblue a215292b6a Use nested assert 2019-06-29 11:54:17 +09:00
dearblue 82831c6acd Fix not frozen in Complex method by RData
Object allocation was separated, and initialization was made common.
2019-06-05 23:19:16 +09:00
dearblue 97e999c409 Fix memory leak in Complex method by RData
If `Data_Wrap_Struct()` raises a `NoMemoryError` exception,
it will leak memory if it does `mrb_malloc()` first.
2019-06-05 23:19:16 +09:00
KOBAYASHI Shuji 0bdb185a6f Add Complex.rect 2019-05-26 20:17:03 +09:00
Yukihiro "Matz" Matsumoto 4261ba9443 Remove some overhead from methods defined in Ruby in Complex. 2019-05-26 09:19:29 +09:00
KOBAYASHI Shuji 48903850e9 Freeze Rational and Complex objects 2019-05-23 13:40:49 +09:00
Yukihiro "Matz" Matsumoto c02e63eb77 Use MRB_TT_ISTRUCT for Complex numbers if possible. 2019-05-21 21:08:26 +09:00
Yukihiro "Matz" Matsumoto fccec8964a Implements part of Complex class in C. 2019-05-21 21:08:26 +09:00
Yukihiro "Matz" Matsumoto f6e4145ad9 Remove Complex(string) complex generation.
It should raise an error.
2019-05-21 21:08:26 +09:00
KOBAYASHI Shuji 6c9c189e4b Move Object#(Rational|Complex) to Kernel 2019-05-18 18:31:55 +09:00
Ukrainskiy Sergey fa45cc4272 Fix dependencies 2019-05-15 16:57:21 +09:00
Ukrainskiy Sergey d67d2ae8e8 Basic implementation of Complex and Rational classes 2019-05-15 16:57:21 +09:00
Ukrainskiy Sergey 8808219e6d Initial suffix support 2019-05-15 16:57:21 +09:00