49 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 698f5f707c Removed to_ary conversion method. 2018-11-19 12:08: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
Yukihiro "Matz" Matsumoto 68470bef86 Check method existence in `to_enum'; ref #3773 2017-08-11 09:21:09 +09:00
Christopher Aue 3359b86ec7 Improved speed of enumeration methods 2017-07-30 13:19:31 +02:00
Yukihiro "Matz" Matsumoto 464d3fc0a3 Use alias enum_for to_enum instead of alias :enum_for :to_enum. 2017-06-21 11:13:43 +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
ksss 0f774ff4df Support nil argument as no argument 2016-12-01 15:33:27 +09:00
ksss 31f0ffeac8 Support Enumerable methods 2016-12-01 10:42:57 +09:00
Yukihiro "Matz" Matsumoto 727f2485c9 Merge pull request #2999 from sagmor/better-docs
More Docs
2015-10-22 07:10:16 +09:00
Seba Gamboa 25c8e95365 Revert "Mark core gems with mrbgem tag"
This reverts commit 5cdcce8dbd.
2015-10-21 14:31:13 -03:00
Yukihiro "Matz" Matsumoto 7278fd1f1b loop may return StopIteration#result; [ruby-bugs#11498] 2015-10-21 21:47:25 +09:00
Seba Gamboa 13b552538a Remove obvious warnings from docs 2015-10-20 12:48:31 -03:00
Seba Gamboa 45e70e4dd6 Fix enumerator doc errors 2015-10-20 12:16:47 -03:00
Seba Gamboa 5cdcce8dbd Mark core gems with mrbgem tag 2015-10-20 12:16:47 -03:00
Yukihiro "Matz" Matsumoto 569c7dec5f move StopIteration to core; close #2518 2014-08-08 16:08:53 +09:00
take_cheeze 4a6c651f82 Run mrbgem and core tests on minimum dependencies.
Solves #2355.

In test drivers:
* Uses `mrb_t_pass_result` to check and pass test result to main `mrb_state`.
* Adds `mrb_init_test_driver` to init test `mrb_state`.
2014-07-12 20:36:45 +09:00
Yukihiro "Matz" Matsumoto 5867167ffd add dependency information based on #2239; fix #2236, close #2239 2014-05-13 13:08:18 +09:00
Yukihiro "Matz" Matsumoto f454f827ee should not use String#<< which is defined in mruby-string-ext; use Array#join instead; ref #2239 2014-05-13 12:59:21 +09:00
Nobuyoshi Nakada ab67c57f65 remove trailing spaces 2014-04-30 09:50:14 +09:00
Yukihiro "Matz" Matsumoto 8808c9a31a wrap args by parens 2014-04-06 20:29:54 +09:00
Jun Hiroe 1368ae647b Add args in Enumerator#inspect 2014-04-06 02:45:04 +09:00
Yukihiro "Matz" Matsumoto 2277c374db revert #1974; ref #1979 2014-03-30 08:29:09 +09:00
ksss 5a2014b8f8 Enumerator#initialize support duck-type 2014-03-29 09:24:00 +09:00
Jun Hiroe 110486debe Fix a typo 2014-03-29 00:16:12 +09:00
Yukihiro "Matz" Matsumoto b5cb8284ba Enumerable#zip to use enumerator if mruby-enumerator gem is available 2014-03-27 14:35:07 +09:00
Yukihiro "Matz" Matsumoto 8250016136 use __svalue instead of ary2sv 2014-03-27 14:28:49 +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
take_cheeze c73f8d4def move summary of mrbgems in default gembox to its spec 2014-03-17 00:34:24 +09:00
ksss 447764763c add test for Array#each_index if non block given 2014-03-15 08:21:39 +09:00
ksss 4f8e11ae57 optimize from each to enumerator_block_call 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 29964cfdac make private method enumerator_block_call 2014-03-14 23:42:04 +09:00
Yukihiro "Matz" Matsumoto 8094a503f0 move dependency check from runtime to mrbgem.rake 2014-03-14 02:59:50 +09:00
Yukihiro "Matz" Matsumoto 58362fc30c remove ambiguity warnings 2014-03-14 02:44:14 +09:00
Yukihiro "Matz" Matsumoto 113ab60784 mruby-enumerator: move definitions in core_mod.rb to mrblib core 2014-03-14 02:41:22 +09:00
ksss 463c5f83c3 add mruby-enumerator 2014-03-13 23:47:12 +09:00