summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2024-01-25Use echo command in mswin platformHiroshi SHIBATA
2024-01-24[PRISM] Fix method calls in keyword argumentsPeter Zhu
Fixes ruby/prism#2248.
2024-01-24Fix repeated block paramAaron Patterson
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24Fix local table size / index for repeated kwrestAaron Patterson
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24Fix local table size and variable offset for repeated keywordsAaron Patterson
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24Fix local table size and index for required post underscoreAaron Patterson
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24Fix local table space for `*_`Aaron Patterson
We need to make sure there is enough room in the local table for repeated `*_` parameters Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24Fix repeated optional _ parametersAaron Patterson
Ensure there is enough space in the local table for repeated optional parameters. Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24Fix required positional repeated _ parametersAaron Patterson
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24[PRISM] Fix forwarding from within blockPeter Zhu
Fixes ruby/prism#2253.
2024-01-24[PRISM] Fix crash in anonymous block with forwarding argumentsPeter Zhu
Fixes ruby/prism#2262.
2024-01-24[PRISM] Don't skip test_ForwardingArgumentsNodePeter Zhu
It seems to work with RUBY_ISEQ_DUMP_DEBUG=to_binary so we can try this test again on CI.
2024-01-24Insert all locals in the locals index tableAaron Patterson
Prism provides an index (local_body_index) which is supposed to point at the start of locals declared in the method body. Prism assumed that method body locals would only occur _after_ parameter names. Unfortunately this assumption is not correct, which meant that we would in some cases not insert all locals in the local table. This commit iterates over locals a second time, inserting any that didn't get inserted on the first pass. Fixes: https://github.com/ruby/prism/issues/2245 Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24[PRISM] Fix anonymous keyword argumentsPeter Zhu
Fixes ruby/prism#2256.
2024-01-24[PRISM] Nested MultiWriteNode with method callsPeter Zhu
Fixes ruby/prism#2247.
2024-01-23[PRISM] Fix anonymous splat nodesPeter Zhu
Fixes ruby/prism#2257.
2024-01-23[PRISM] Fix block fowardingPeter Zhu
2024-01-23[PRISM] Support block parameters with no namePeter Zhu
Fixes ruby/prism#2249.
2024-01-23Rewrite Array#each in Ruby using Primitive (#9533)Takashi Kokubun
2024-01-23Memory leak with TracePoint on bmethodPeter Zhu
[Bug #20194] When disabling the TracePoint on bmethod, the hooks list is not freed. For example: obj = Object.new obj.define_singleton_method(:foo) {} bmethod = obj.method(:foo) tp = TracePoint.new(:return) {} 10.times do 100_000.times do tp.enable(target: bmethod) {} end puts `ps -o rss= -p #{$$}` end Before: 18208 22832 26528 29728 34000 37776 40864 44400 47680 51504 After: 16688 17168 17168 17248 17696 17760 17824 17824 17856 17920
2024-01-22Handle trailing commas on blocksAaron Patterson
We need to set a special flag on block iseqs when there is a trailing comma. Fixes: https://github.com/ruby/prism/issues/2244
2024-01-22Check keyword parameters correctlyAaron Patterson
We weren't checking the right offsets when compiling methods with keyword parameters that had complex code. Fixes: https://github.com/ruby/prism/issues/2228
2024-01-22[PRISM] Fix keyword arguments in IndexOrWriteNodePeter Zhu
Fixes ruby/prism#2236.
2024-01-22[PRISM] Fix splat and block in asetPeter Zhu
2024-01-22[PRISM] Fix block in asetPeter Zhu
Fixes ruby/prism#2223.
2024-01-22Fix compiling rescue + ensureAaron Patterson
When we're compiling begin / rescue / ensure nodes, we need to "wrap" the code in the begin statements correctly. The wrapping is like this: (ensure code (rescue code (begin code))) This patch pulls the each leg in to its own function, then calls the appropriate wrapping function depending on whether there are ensure / rescue legs. Fixes: https://github.com/ruby/prism/issues/2221
2024-01-22[PRISM] Fix keyword splat in IndexAndWriteNode and IndexOrWriteNodePeter Zhu
Fixes ruby/prism#2232 and ruby/prism#2234.
2024-01-22[PRISM] Fix keywords arguments in IndexAndWriteNodePeter Zhu
Fixes ruby/prism#2233.
2024-01-22[PRISM] Fix incorrect ordering of MultiTargetNodePeter Zhu
Fixes ruby/prism#2218.
2024-01-20More testsBurdetteLamar
2024-01-19[PRISM] Fix ensure code running twiceeileencodes
Fixes: ruby/prism#2212
2024-01-19Fix kwarg orderingAaron Patterson
Required keyword arguments need to come first. Fixes: https://github.com/ruby/prism/issues/2158 Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-01-19Fix ensure code when running break in a while loopAaron Patterson
We need to run ensure code when breaking from a while loop Co-authored-by: John Hawthorn <jhawthorn@github.com> Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-01-18[PRISM] Fix case splat with no predicateMatt Valentine-House
2024-01-17[Prism] Implement defined? for PM_UNLESS_NODEeileencodes
Ruby code: ```ruby defined?(unless true; 1; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,16)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,16)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_UNTIL_NODEeileencodes
Ruby code: ```ruby defined?(until a == 1; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,16)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,16)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_WHILE_NODEeileencodes
Ruby code: ```ruby defined?(while a != 1; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,16)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,16)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_SINGLETON_CLASS_NODEeileencodes
Ruby code: ```ruby defined?(class << self; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,16)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,16)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_RATIONAL_NODEeileencodes
Ruby code: ```ruby defined?(1.2r) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,16)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,16)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_MODULE_NODEeileencodes
Ruby code: ```ruby defined?(module M; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,16)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,16)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_MATCH_REQUIRED_NODEeileencodes
Ruby code: ```ruby defined?(1 => 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,16)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,16)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_MATCH_WRITE_NODEeileencodes
Ruby code: ```ruby defined?(/(?<foo>bar)/ =~ 'barbar') ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,35)> local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 1] foo@0 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,35)> local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 1] foo@0 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_IF_NODEeileencodes
Ruby code: ```ruby defined?(if true; 1; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,43)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,43)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_FOR_NODEeileencodes
Ruby code: ```ruby defined?(for i in [1,2] do; i; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,43)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,43)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_DEF_NODEeileencodes
Ruby code: ```ruby defined?(def prism_test_def_node; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,43)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,43)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CLASS_NODEeileencodes
Ruby code: ```ruby defined?(class PrismClassA; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,43)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,43)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CASE_MATCH_NODEeileencodes
Ruby code: ```ruby defined?(case [1, 2, 3]; in [1, 2, 3]; 4; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,43)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,43)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CASE_NODEeileencodes
Ruby code: ```ruby defined?(case :a; when :a; 1; else; 2; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,43)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,43)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[PRISM] Fix test spelling `RescueModifer` -> `RescueModifier`eileencodes
`RescueModifier` was spelled wrong. Not a big deal, but it meant I didn't immediately find the test when I was searching for it while working on implementing `defined?` nodes.
2024-01-17[Prism] Implement defined? for PM_INDEX_OR_WRITE_NODEeileencodes
Ruby code: ```ruby defined?([0][0] ||= 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188