summaryrefslogtreecommitdiffhomepage
path: root/test/t
AgeCommit message (Collapse)Author
2020-10-15Merge branch 'work_for_merge' of https://github.com/zubycz/mruby into ↵Yukihiro "Matz" Matsumoto
zubycz-work_for_merge
2020-10-13Introduce endless range (a part of #5085)taiyoslime
Co-Authored-By: n4o847 <[email protected]> Co-Authored-By: smallkirby <[email protected]>
2020-10-12Reorganize `Integer` system.Yukihiro "Matz" Matsumoto
- Integrate `Fixnum` and `Integer` - Remove `Integral` - `int / int -> int` - Replace `mrb_fixnum()` to `mrb_int()` - Replace `mrb_fixnum_value()` to `mrb_int_value()`. - Use `mrb_integer_p()` instead of `mrb_fixnum_p()`
2020-10-12Fixed ISO section numbers in `test/t/superclass.rb`.Yukihiro "Matz" Matsumoto
2020-10-12Make division by zero cause `ZeroDivisionError`.Yukihiro "Matz" Matsumoto
As described in ISO 15.2.30.
2020-10-12Always add trailing `.0` in `Float#inspect`; ref #4225KOBAYASHI Shuji
Trailing `.0` is removed from `Float#to_s` and `Float#inspect` at 9d08025b. However, I think the more human-readable format is better for `Float#inspect`. For example, in the `Float#to_s` format, the failure message is not well understood when testing values including types by `eql?` (e.g. `Numeric#step` test). ```ruby assert "example" do exp = 1.0 act = 1 assert_operator(exp, :eql?, act) #=> Expected 1 to be eql? 1. end ```
2020-10-12Integrate `Fixnum` class into `Integer` classdearblue
* The `Fixnum` constant is now an alias for the `Integer` class. * Remove `struct mrb_state::fixnum_class` member. If necessary, use `struct mrb_state::integer_class` instead.
2020-10-12Update tests for integer division.Yukihiro "Matz" Matsumoto
2020-10-12Rename float configuration option names.Yukihiro "Matz" Matsumoto
- `MRB_WITHOUT_FLOAT` => `MRB_NO_FLOAT` - `MRB_USE_FLOAT` => `MRB_USE_FLOAT32` The former is to use `USE_XXX` naming convention. The latter is to make sure `float` is 32bit float and not floating point number in general.
2020-10-12Rightward-assign by ASSOC.Yukihiro "Matz" Matsumoto
[ruby-bugs:15921]
2020-07-16Fixed shift width for `MRB_ENV_SET_BIDX()`dearblue
ref c07f24cd1 and close #5035
2020-06-09Update `test/t/kernel.rb`dearblue
- Remove unnecessoury assert - Fix typo
2020-05-24Do not destruct rest arguments for __send__Yusuke Endoh
Formerly, `__send__(*args)` modified `args` with `Array#shift`. This bug affects optcarrot. This changeset avoids the array destruction by using `args = args[1, len-1]`.
2020-04-26Integrate class `EnsureYieldBreak` under testdearblue
2020-04-21`Kernel#clone` and `Kernel#dup` no longer raise `TypeError`; fix #4974Yukihiro "Matz" Matsumoto
In ISO, those methods should raise `TypeError`, but the spec has been changed. The change was discussed in [Feature#12979].
2020-01-27Fixed backtrace message for top-level blocks; fix #4936Yukihiro "Matz" Matsumoto
In top-level, `mid` is `NULL`. We used to ignore 'mid` update for `NULL`.
2019-12-21Numbered parameters should not be available in the lambda bodies.Yukihiro "Matz" Matsumoto
`mruby` does not warn like `CRuby` for cases like #4893. Fix #4890, fix #4891, fix #4893.
2019-12-21`_0` is not numbered parameterKOBAYASHI Shuji
#### Before this patch: ```console $ bin/mruby rb -e '_0=:l; p ->{_0}.()' -e:1:13: _0 is not available -e:1:13: syntax error, unexpected $end, expecting '}' ``` #### After this patch (same as Ruby): ```console $ bin/mruby rb -e '_0=:l; p ->{_0}.()' :l ```
2019-12-19Reimplement `vformat` tests; close #4868Yukihiro "Matz" Matsumoto
Avoid creating `Data` object that refers `mruby` objects. Also close #4622 ref #4613
2019-12-19Revert "`%C` value need not to be saved in `TestVFormat::Native`; close #4868"Yukihiro "Matz" Matsumoto
This reverts commit f507ff4842b92a60c0c600fa1f29efdf2688c877. It makes AppVeyor tests fail.
2019-12-18Merge pull request #4875 from ↵Yukihiro "Matz" Matsumoto
shuujii/remove-location-info-from-Exception-inspect Remove location info from `Exception#inspect`
2019-12-18`%C` value need not to be saved in `TestVFormat::Native`; close #4868Yukihiro "Matz" Matsumoto
2019-12-14Remove location info from `Exception#inspect`KOBAYASHI Shuji
Because location info (file name and line number) is kept in the backtrace, it should not be kept in the result of `inspect` (and the exception object itself), I think. ### Example ```ruby # example.rb begin raise "err" rescue => e p e end ``` #### Before this patch: ``` $ bin/mruby example.rb example.rb:2: err (RuntimeError) ``` #### After this patch: ``` $ bin/mruby example.rb err (RuntimeError) ```
2019-12-11Fix behavior of `Kernel#Integer` to numbers ending with `_` and spacesKOBAYASHI Shuji
#### Before this patch: ```ruby Integer("1_ ") #=> 1 ``` #### After this patch (same as Ruby): ```ruby Integer("1_ ") #=> ArgumentError ```
2019-12-10Fix behavior of `String#to_i`/`Kernel#Integer` to numbers starting with `_`KOBAYASHI Shuji
#### Before this patch: ```ruby Integer("_1") #=> 1 "_1".to_i #=> 1 ``` #### After this patch (same as Ruby): ```ruby Integer("_1") #=> ArgumentError "_1".to_i #=> 0 ```
2019-12-10Merge pull request #4858 from ↵Yukihiro "Matz" Matsumoto
shuujii/fix-that-String-to_f-accepts-consecutive-_-as-a-numeric-expression Fix that `String#to_f` accepts consecutive `_` as a numeric expression
2019-12-09Fix that `String#to_f` accepts consecutive `_` as a numeric expressionKOBAYASHI Shuji
Consecutive `_` is not allowed as a numeric expression: 1_2__3 #=> SyntaxError Float("1_2__3") #=> ArgumentError Integer("1_2__3") #=> ArgumentError "1_2__3".to_i #=> 12 But `String#to_f` accept it, so I fixed the issue. Before this patch: "1_2__3".to_f #=> 123 After this patch: "1_2__3".to_f #=> 12
2019-12-09Support new numbered parameter syntax `_1` instead of `@1`.Yukihiro "Matz" Matsumoto
2019-12-09Implement numbered parametersUkrainskiy Sergey
2019-10-25Squeeze redundant spaces in `test/t/numeric.rb` [ci skip]KOBAYASHI Shuji
2019-10-10Integrate `mrb_str_inspect` and `mrb_str_dump`KOBAYASHI Shuji
2019-10-03Add tests for #4746KOBAYASHI Shuji
2019-09-27Simplify arguments check in `String#rindex`KOBAYASHI Shuji
Also fix document about type of the first argument.
2019-09-23Fix `Fixnum` overflow test in `Integer#<<` testKOBAYASHI Shuji
- Skip when `MRB_WITHOUT_FLOAT` is defined. - Make `Fixnum` overflow even when `MRB_INT64` is defined.
2019-09-19Simplify arguments check in `String#index`KOBAYASHI Shuji
Also fix document about type of the first argument.
2019-09-17Fix `Fixnum#(to_s|inspect)` argument specsKOBAYASHI Shuji
Before this patch: $ bin/mruby -e 'p 3.to_s(2)' trace (most recent call last): [0] -e:1 -e:1: 'to_s': wrong number of arguments (1 for 0) (ArgumentError) After this patch: $ bin/mruby -e 'p 3.to_s(2)' "11"
2019-09-11Move tests related to `getbyte`, `setbyte`, byteslice` to core.Yukihiro "Matz" Matsumoto
2019-09-07Revert part of #4225Yukihiro "Matz" Matsumoto
Since in mruby, Integer and Float interchange frequently (mostly on overflow), so adding explicit `.0` can cause problems sometimes. For example: https://github.com/mattn/mruby-json/pull/40 https://github.com/pepabo/mruby-msd/pull/13 https://github.com/mattn/mruby-json/pull/42
2019-08-17Add `String#rindex` test for invalid UTF-8 stringdearblue
2019-08-17Fix `String#rindex` test for UTF-8 stringdearblue
2019-08-03Change second argument to `%l` of `mrb_vformat()` to `size_t` from `mrb_int`KOBAYASHI Shuji
- `size_t` is more commonly used. - `len` argument of `mrb_str_new()` is `size_t`. NOTE: The test for `%l` is temporarily disabled because adding a new type to `mrbgems/mruby-test/vformat.c` causes an error (memory error?) on Visual Studio 2017 in AppVeyor.
2019-08-03Fix `mrb_vformat("%f")` with `MRB_USE_FLOAT`KOBAYASHI Shuji
It potentially not work when `mrb_float` is `float` because `float` variable in variable length arguments is promoted to `double`. Also I fixed build with `MRB_WITHOUT_FLOAT`.
2019-08-02Change the `mrb_vformat` specifier `%d` for `int`KOBAYASHI Shuji
It potentially breaks, for example, in the case of `mrb_int` is 64-bit and more smaller type is passed by `%d`. In fact, the problem could become apparent when I used `%d` to `backtrace_location::lineno` in `src/backtrace.c:mrb_unpack_backtrace()` on AppVeyor. Therefore, change `%d` for `int` (not `mrb_int`) so that it can be used mostly without casting.
2019-08-01Add new specifiers/modifiers to format string of `mrb_vfromat()`KOBAYASHI Shuji
Format sequence syntax: %[modifier]specifier Modifiers: ----------+------------------------------------------------------------ Modifier | Meaning ----------+------------------------------------------------------------ ! | Convert to string by corresponding `inspect` instead of | corresponding `to_s`. ----------+------------------------------------------------------------ Specifiers: ----------+----------------+-------------------------------------------- Specifier | Argument Type | Note ----------+----------------+-------------------------------------------- c | char | d,i | mrb_int | f | mrb_float | l | char*, mrb_int | Arguments are string and length. n | mrb_sym | s | char* | Argument is NUL terminated string. t | mrb_value | Convert to type (class) of object. v,S | mrb_value | C | struct RClass* | T | mrb_value | Convert to real type (class) of object. Y | mrb_value | Same as `!v` if argument is `true`, `false` | | or `nil`, otherwise same as `T`. % | - | Convert to percent sign itself (no argument | | taken). ----------+----------------+-------------------------------------------- This change will increase the binary size, but replacing all format strings with new specifiers/modifiers will decrease the size because it reduces inline expansion of `mrb_obj_value()`, etc. at the caller.
2019-07-30Refine message to `skip` in nested `assert`KOBAYASHI Shuji
- 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-29Merge pull request #4407 from ↵Yukihiro "Matz" Matsumoto
shuujii/add-assert_raise_with_message-and-assert_raise_with_message_pattern Add `assert_raise_with_message` and `assert_raise_with_message_pattern`
2019-07-20Fix `Module#dup` to frozen moduleKOBAYASHI Shuji
Before this patch: $ bin/mruby -e 'p Module.new.freeze.dup.frozen?' #=> true After this patch (same as Ruby): $ bin/mruby -e 'p Module.new.freeze.dup.frozen?' #=> false
2019-07-18Fix `String#*` test with `MRB_WITHOUT_FLOAT`KOBAYASHI Shuji
2019-07-17Fix `String#[]` testKOBAYASHI Shuji
2019-07-17Merge branch 'master' into i110/inspect-recursionYukihiro "Matz" Matsumoto