aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_lambda.rb
Commit message (Collapse)AuthorAgeFilesLines
* test/ruby/test_lambda.rb: prevent lambda(&proc_block) warningsYusuke Endoh2020-12-121-0/+6
|
* Disable deprecation warning by the default [Feature #16345]Nobuyoshi Nakada2020-09-251-6/+0
| | | | And `-w` option turns it on.
* Warn when passing a non-literal block to Kernel#lambdaJeremy Evans2020-06-111-0/+6
| | | | Implements [Feature #15973]
* Kernel#lambda: return forwarded block as non-lambda procAlan Wu2019-12-211-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | Before this commit, Kernel#lambda can't tell the difference between a directly passed literal block and one passed with an ampersand. A block passed with an ampersand is semantically speaking already a non-lambda proc. When Kernel#lambda receives a non-lambda proc, it should simply return it. Implementation wise, when the VM calls a method with a literal block, it places the code for the block on the calling control frame and passes a pointer (block handler) to the callee. Before this commit, the VM forwards block arguments by simply forwarding the block handler, which leaves the slot for block code unused when a control frame forwards its block argument. I use the vacant space to indicate that a frame has forwarded its block argument and inspect that in Kernel#lambda to detect forwarded blocks. This is a very ad-hoc solution and relies *heavily* on the way block passing works in the VM. However, it's the most self-contained solution I have. [Bug #15620]
* add tests for orphan/not-orphan proc/lambda.Tanaka Akira2019-07-151-0/+27
|
* add tests for "break" in lambda.Tanaka Akira2019-07-151-0/+15
|
* vm_args.c: arity check of lambdanobu2017-03-191-0/+6
| | | | | | | | | | | | * vm_eval.c (rb_yield_lambda): new function which yields an array to a proc and splat to a lambda. mainly for Enumerable only. * vm_args.c (setup_parameters_complex): remove special lambda splatting for [Bug #9605]. [ruby-core:77065] [Bug #12705] * vm_insnhelper.c (vm_callee_setup_block_arg): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_lambda.rb: remove duplcate testsnobu2017-03-181-26/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_lambda.rb: refine testnobu2017-03-181-2/+4
| | | | | | | | * test/ruby/test_lambda.rb (test_lambda_as_iterator): refine a test for the intention of the original report. [ruby-core:61340] [Bug #9605] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm.c: fix return in lambdanobu2016-12-311-0/+20
| | | | | | | | | * vm.c (invoke_block_from_c_splattable): pass lambda-ness. * vm_eval.c (yield_under): invoke lambda proc properly. [ruby-core:78917] [Bug #13090] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57240 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_args.c (setup_parameters_complex): don't raise ArgumentErrornaruse2016-07-071-0/+7
| | | | | | | | if an array is given for instance_exec with optional argument. [ruby-core:76300] [Bug #12568] https://github.com/rails/rails/pull/25699 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/ruby: suppress parser warningsnobu2016-02-191-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add frozen_string_literal: false for all filesnaruse2015-12-161-0/+1
| | | | | | When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby/test_lambda.rb: Fix typo yeild -> yieldgogotanaka2015-03-151-1/+1
| | | | | | [fix GH-851][ci skip] Patch by @hanachin git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c: allow to_arynobu2014-10-301-0/+26
| | | | | | | | * vm_insnhelper.c (vm_callee_setup_arg{_complex,}): try conversion by to_ary for a lambda, as well as a proc. [ruby-core:65887] [Bug #9605] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c: relax arity checknobu2014-03-131-1/+12
| | | | | | | | | | | * vm.c (invoke_block_from_c): add splattable argument. * vm.c (vm_invoke_proc): disallow to splat when directly invoked. * vm_insnhelper.c (vm_callee_setup_arg_complex, vm_callee_setup_arg): relax arity check of yielded lambda. [ruby-core:61340] [Bug #9605] * test/ruby/test_yield.rb (TestRubyYieldGen#emu_bind_params): no longer raise ArgumentError when splatting to lambda. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby: get rid of warnings.usa2014-03-051-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_lambda.rb: fix messagesnobu2013-09-191-2/+2
| | | | | | | * test/ruby/test_lambda.rb (test_{do,brace}_lambda_source_location): fix messages, missed to commit at r42980. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: adjust position of lambdanobu2013-09-191-0/+24
| | | | | | * parse.y (lambda): adjust position to the beginning of the block. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_insnhelper.c (vm_invoke_block): returning from lambda procktsj2013-08-091-0/+20
| | | | | | | | now always exits from the Proc. [ruby-core:56193] [Feature #8693] * NEWS, test/ruby/test_lambda.rb: ditto. Patch by nobu. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_insnhelper.c (argument_error): use line number at the beginningnobu2012-03-161-0/+19
| | | | | | | | of lambda, not the first code ob its body. [ruby-core:43314][Bug #6151] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c (iseq_compile_each): call on special object instead ofnobu2012-02-261-0/+7
| | | | | | | | | self. since stabby lambda is a syntax, so it should not be affected by the context. [ruby-core:42349][Bug #5966] * insns.def (send): no special deal for FCALL. self should be put on TOS instead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c (setup_args), vm.c (invoke_block_from_c),nobu2010-12-201-3/+0
| | | | | | | vm_insnhelper.c (caller_setup_args): reverted r30241 and r30243 except for the test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c (setup_args), vm.c (invoke_block_from_c),nobu2010-12-181-0/+1
| | | | | | | vm_insnhelper.c (caller_setup_args): fix of r30241. lambda block shoud check argument number. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test: assert_raises has been deprecated since a long time ago.nobu2008-09-241-12/+12
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * parse.y (new_yield), compile.c (iseq_compile_each): fixko12007-06-051-10/+15
| | | | | | | | | | | | | | | passing parameter. * eval.c, eval_jump.h: simplify rb_yield*. * proc.c (proc_mark): fix to mark proc->block.proc. * proc.c (Init_Proc): add Proc#lambda? * test/ruby/test_lambda.rb: add some tests. * vm.c (invoke_block): fix to check lambda block or not. * vm.c (th_yield_setup_args): fix to check arguments size when lambda block. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * parse.y, node.h, compile.c: change node tree structure. a purposeko12007-02-241-0/+2
| | | | | | | | | | | | | | | | | | | | | of this change is to unify argument structure of method and block. this change prohibits duplicate block parameter name. new argument infromation: NODE_ARGS [m: int, o: NODE_OPT_ARG, ->] NODE_ARGS_AUX [r: ID, b: ID, ->] NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*] optarg information: NODE_OPT_ARGS [idx, expr, ->] * vm_macro.def: ditto. * gc.c: ditto. * iseq.c: ditto. * compile.h: fix debug function name. * test/ripper/test_scanner_events.rb: |_,_,foo| -> |_1,_2,foo| * test/ruby/test_lambda.rb: disalbe test temporarily. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c (iseq_compile_each, set_block_local_tbl) :ko12007-01-051-14/+14
| | | | | | | | | | support NODE_LAMBDA (partly). * sample/test.rb : restore test of NODE_LAMBDA * test/ruby/test_lambda.rb : ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * Merge YARVko12006-12-311-0/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby/test_lambda.rb (TestLambdaParameters::test_lambda_as_iterator):matz2006-07-041-1/+1
| | | | | | | -> style block no longer available. [ruby-dev:28958] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/ostruct.rb (new_ostruct_member): Object#send no longer callnobu2005-09-121-1/+1
| | | | | | | | | | | | | private methods. [ruby-dev:27044] * test/rss/test_dublincore.rb, test/rss/test_trackback.rb, test/ruby/test_eval.rb, test/socket/test_socket.rb: ditto. * test/ruby/test_lambda (test_call_with_block): lambda makes new scope for formal block parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * parse.y (f_block_arg), eval.c (rb_yield_0): deal with dynamicnobu2005-08-081-0/+53
variable lambda arguments. [ruby-core:05540] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e