diff options
| author | Jemma Issroff <jemmaissroff@gmail.com> | 2023-10-23 14:49:39 -0300 |
|---|---|---|
| committer | Aaron Patterson <aaron.patterson@gmail.com> | 2023-10-23 13:22:55 -0700 |
| commit | 39207b496eb1f45750bc664c8796f5aa3f5d641e (patch) | |
| tree | 8722d2e711e503425bf1d5fee3c0fe239ba45212 /test/ruby | |
| parent | 5abff9dbff4f2e50b4b65fa00438a5e67bfd7c49 (diff) | |
[PRISM] Implement compilation for PreExecutionNodes
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_compile_prism.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index 74efd36ce2..acda2f5d49 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -535,6 +535,18 @@ module Prism test_prism_eval("(1)") end + def test_PreExecutionNode + # BEGIN {} must be defined at the top level, so we need to manually + # call the evals here instead of calling `test_prism_eval` + ruby_eval = RubyVM::InstructionSequence.compile("BEGIN { a = 1 }; 2").eval + prism_eval = RubyVM::InstructionSequence.compile_prism("BEGIN { a = 1 }; 2").eval + assert_equal ruby_eval, prism_eval + + ruby_eval = RubyVM::InstructionSequence.compile("b = 2; BEGIN { a = 1 }; a + b").eval + prism_eval = RubyVM::InstructionSequence.compile_prism("b = 2; BEGIN { a = 1 }; a + b").eval + assert_equal ruby_eval, prism_eval + end + def test_ProgramNode test_prism_eval("") test_prism_eval("1") |
