summaryrefslogtreecommitdiff
path: root/test/prism/ruby/ruby_parser_test.rb
AgeCommit message (Collapse)Author
2025-12-04[ruby/prism] Fix `%Q` with newline delimiter and heredoc interpolationEarlopain
The lexer did not jump to the `heredoc_end`, causing the heredoc end delimiter to be parsed twice. Normally the heredocs get flushed when a newline is encountered. But because the newline is part of the string delimiter, that codepath is not taken. Fixes [Bug #21758] https://github.com/ruby/prism/commit/7440eb4b11
2025-11-08[ruby/prism] Rename Ruby 3.5 to Ruby 4.0Earlopain
See https://github.com/ruby/ruby/commit/6d81969b475262aba251e99b518181bdf7c5a523 It leaves the old variant around. RuboCop for examples accesses `Prism::Translation::Parser35` to test against ruby-head. For now I left these simply as an alias https://github.com/ruby/prism/commit/d0a823f045
2025-10-30[ruby/prism] Unescape unary method callsEarlopain
Followup to https://github.com/ruby/prism/pull/2213 Before: ```sh $ ruby -ve "puts 42.~@" ruby 3.4.6 (2025-09-16 revision https://github.com/ruby/prism/commit/dbd83256b1) +PRISM [x86_64-linux] -e:1:in '<main>': undefined method '~@' for an instance of Integer (NoMethodError) Did you mean? ~ ``` After (matches parse.y): ```sh $ ./miniruby -ve "puts 42.~@" ruby 3.5.0dev (2025-10-16T03:40:45Z master https://github.com/ruby/prism/commit/1d95d75c3f) +PRISM [x86_64-linux] -43 ``` https://github.com/ruby/prism/commit/a755bf228f
2025-10-22[ruby/prism] Make error and snapshot tests multi-version awareEarlopain
This one has been on my mind for a while now. Currently, there are only tests against the latest syntax version. This changes the snapshot structure as follows: * Snapshots at their current location are tested against all syntax versions * Snapshots inside a version folder like "3.3" are tested against all versions starting from that version * Snapshots inside a version folder like "3.3-4.2" are tested against all versions in the given range. This makes sure that as new syntax is added, older versions still work as expected. I also added a few tests for now valid syntax that should be invalid in older versions (and the other way around as well) These tests run really fast. So even though it does 3x the work for these, I am still able to run the whole test suite in just 11 seconds. https://github.com/ruby/prism/commit/5191b1aa68
2025-09-19[ruby/prism] Reject argument command call taking a block with more trailing ↵Earlopain
arguments https://bugs.ruby-lang.org/issues/21168#note-5 The added code samples align with `parse.y`, except for `foo(bar baz do end)` which `parse.y` currently rejects but shouldn't. https://github.com/ruby/prism/commit/3a4e102d80
2025-09-15[ruby/prism] Fix character literal forced encodingKevin Newton
If a character literal was followed by a string concatenation, then the forced encoding of the string concatenation could accidentally overwrite the explicit encoding of the character literal. We now handle this properly. https://github.com/ruby/prism/commit/125c375d74
2025-09-12[ruby/prism] [Bug #17398] Allow `private def hello = puts "Hello"`Earlopain
This was a limitation of parse.y that prism intentionally replicated. https://github.com/ruby/prism/commit/8fd12d594c
2025-09-12[ruby/prism] Support leading logical operatorsKevin Newton
https://github.com/ruby/prism/commit/3f58fa7705
2025-08-01[ruby/prism] Avoid monkey patching Sexp#== in RubyParser testsJustin Collins
https://github.com/ruby/prism/commit/7362b114a3
2025-03-18[ruby/prism] Fix parser translator multiline interpolated symbolsEarlopain
In https://github.com/ruby/prism/commit/26370079291a420c6b2b7be5cdbd5c609da62f21 I added tests but didn't modify them correctly https://github.com/ruby/prism/commit/de021e74de
2025-03-18[ruby/prism] Further refine string handling in the parser translatorEarlopain
Mostly around newlines and line continuation. * percent arrays need special backslash handling in the ast * Fix offset issue for heredocs with many line continuations (used wrong variable as index access) * More refined rules on when to simplify string tokens * Handle line continuations in squiggly heredocs * Correctly dedent squiggly heredocs with interpolation * Consider `':foo:` and `%s[foo]` to not be interpolation https://github.com/ruby/prism/commit/4edfe9d981
2025-03-18[ruby/prism] Fix parser translator when unescaping invalid utf8Earlopain
1. The string starts out as binary 2. `ち` is appended, forcing it back into utf-8 3. Some invalid byte sequences are tried to append > incompatible character encodings: UTF-8 and BINARY (ASCII-8BIT) This makes use of my wish to use `append_as_bytes`. Unfortunatly that method is rather new so it needs a fallback https://github.com/ruby/prism/commit/e31e94a775
2025-01-12[ruby/prism] Fix binary encoding for the parser translatorEarlopain
Skipping detecting the encoding is almost always right, just for binary it should actually happen. A symbol containing escapes that are invalid in utf-8 would fail to parse since symbols must be valid in the script encoding. Additionally, the parser gem would raise an exception somewhere during string handling https://github.com/ruby/prism/commit/fa0154d9e4
2025-01-11[ruby/prism] Import code samples for Ruby 3.3 from the parser gemEarlopain
Slightly tweaking the import script becaues of backtrace format changes in Ruby 3.4 Most tests pass in all parsers, with only a handful of failures overall https://github.com/ruby/prism/commit/9b5b785aa4
2025-01-11[ruby/prism] Fix an incompatibility with the parser translatorEarlopain
The offset cache contains an entry for each byte so it can't be accessed via the string length. Adds tests for all variants except for this: ``` "fo o" "ba ’" ``` For some reason, this still has the wrong offset. https://github.com/ruby/prism/commit/a651126458
2024-05-30[ruby/prism] Tests overhaulKevin Newton
https://github.com/ruby/prism/commit/6f886be0a4