33 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto f3b570f33a mruby-enumerator: add test for Enumerable#chunk_while 2024-07-22 13:52:12 +09:00
星湖新 ab21813100 Move Enumerable#chunk to mruby-enumerator 2024-01-22 18:31:28 +09:00
Yukihiro "Matz" Matsumoto 4d249c28d9 Skip tests that use Float inside; ref #5421 2021-04-24 12:04:08 +09:00
John Bampton 4fa3359d44 refactor: remove trailing whitespace from C, Header, Ruby and YAML files
Lint
2020-12-15 19:44:02 +10:00
Yukihiro "Matz" Matsumoto 2b188ed8a1 Reorganize Integer system.
- 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-12 18:19:54 +09:00
Yukihiro "Matz" Matsumoto ad4bdda074 Update assert_take for zero size take. 2019-09-13 02:28:56 +09:00
Yukihiro "Matz" Matsumoto f5542b9927 Add Enumerator.produce from Ruby2.7 2019-09-13 02:28:56 +09:00
KOBAYASHI Shuji a70107d725 Drop dependency from mruby-enumerator to mruby-enum-ext 2019-07-28 13:08:11 +09:00
KOBAYASHI Shuji 19740d45a1 Add NoMethodError tests to mruby-enumerator 2019-02-08 17:40:12 +09:00
Yukihiro "Matz" Matsumoto e0bc87297e Update mruby-enumerator test to conform the last update. 2019-02-08 09:35:28 +09:00
KOBAYASHI Shuji 2650999092 Fix Enumerator#(initialize|inspect) for nil/false 2019-02-08 09:35:28 +09:00
Yukihiro "Matz" Matsumoto afca99a40b Remove implicit conversion using to_int method.
The ISO standard does not include implicit type conversion using
`to_int`. This implicit conversion often causes vulnerability.
There will be no more attacks like #4120.

In addition, we have added internal convenience method `__to_int` which
does type check and conversion (from floats).
2018-11-19 11:28:51 +09:00
Yukihiro "Matz" Matsumoto 0a0cc5a217 Check method existence for Enumerators; fix #3920
The issue #3920 was fixed but the fundamental flaw of lack of stack
depth check along with fibers still remains, even though it's not
easy to cause the issue.  Use `MRB_GC_FIXED_ARENA` to avoid the issue
for workaround.

After this patch, `obj.to_enum` raises `ArgumentError` if the object
does not respond to the enumerating method. This is incompatible to
CRuby but I think this behavior is better and CRuby should be updated
to behave like this.
2018-11-19 10:57:07 +09:00
ksss 3a22d113ee Reimplement Enumerable#zip with Enumerator
for fix some specs
- [passes each element of the result array to a block and return nil if a block is given](https://github.com/ruby/spec/blob/a585ec35d185435e5c11f371ba4ed2a29d8817bd/core/enumerable/zip_spec.rb#L11-L17)
- [converts arguments to arrays using #to_ary](https://github.com/ruby/spec/blob/a585ec35d185435e5c11f371ba4ed2a29d8817bd/core/enumerable/zip_spec.rb#L23-L27)
- [converts arguments to enums using #to_enum](https://github.com/ruby/spec/blob/a585ec35d185435e5c11f371ba4ed2a29d8817bd/core/enumerable/zip_spec.rb#L29-L34)
- [gathers whole arrays as elements when each yields multiple](https://github.com/ruby/spec/blob/a585ec35d185435e5c11f371ba4ed2a29d8817bd/core/enumerable/zip_spec.rb#L36-L39)
2018-03-27 10:53:33 +09:00
Yukihiro "Matz" Matsumoto b4f9b031de Some cosmetic changes 2017-11-22 16:09:50 +09:00
Yukihiro "Matz" Matsumoto 6c966a1f86 Change the order of "expected" and "actual" in test 2017-10-28 00:29:30 +09:00
Kenji Okimoto d93a5c1a84 Fix Enumerator#each_with_index with block
In previous version,

```
a = [3, 2, 1]
e = a.each
e.sort_by(&:to_i) # => []
```

In this version,

```
a = [3, 2, 1]
e = a.each
e.sort_by(&:to_i) # => [1, 2, 3]
```
2017-03-30 10:53:55 +09:00
ksss 2718fed124 Support svalue 2016-12-01 16:13:24 +09:00
Yukihiro "Matz" Matsumoto 7278fd1f1b loop may return StopIteration#result; [ruby-bugs#11498] 2015-10-21 21:47:25 +09:00
Nobuyoshi Nakada ab67c57f65 remove trailing spaces 2014-04-30 09:50:14 +09:00
Jun Hiroe 1368ae647b Add args in Enumerator#inspect 2014-04-06 02:45:04 +09:00
ksss d9068f0583 Hash#{reject,reject!} fix yield value 2014-03-23 20:13:49 +09:00
ksss d09e4475bf Hash#{select,select!} fix yield value 2014-03-23 13:31:26 +09:00
ksss 5386cd9b9b Hash#each_{key,value} support return Enumerator
if non block given
2014-03-23 00:22:22 +09:00
Yukihiro "Matz" Matsumoto 2bf718faf8 Merge pull request #1882 from ksss/enum-find_all
Enumerable#find_all return Enumerator if non block given
2014-03-19 10:43:54 +09:00
ksss fd80d4ecdd Enumerable#find_all return Enumerator if non block given 2014-03-17 23:32:31 +09:00
ksss 9abe413530 Enumrable#each_with_index return Enumerator if non block given 2014-03-17 22:31:40 +09:00
ksss 447764763c add test for Array#each_index if non block given 2014-03-15 08:21:39 +09:00
ksss 0bb7f5e950 fix variable name typo 2014-03-15 08:21:39 +09:00
ksss 9447c637a5 test split and to detail 2014-03-15 08:21:34 +09:00
ksss 6b3cc0052d fix self modifying bug 2014-03-15 08:15:16 +09:00
ksss 47fc784b56 fix return value for with_index 2014-03-15 08:15:16 +09:00
ksss 463c5f83c3 add mruby-enumerator 2014-03-13 23:47:12 +09:00