summaryrefslogtreecommitdiff
path: root/test/prism/parse_test.rb
AgeCommit message (Collapse)Author
2024-05-30[ruby/prism] Tests overhaulKevin Newton
https://github.com/ruby/prism/commit/6f886be0a4
2024-05-24[ruby/prism] Remove Debug moduleKevin Newton
https://github.com/ruby/prism/commit/4d8929ff6a
2024-04-03[ruby/prism] Allow block exits in defined? and fix modifier while/untilKevin Newton
https://github.com/ruby/prism/commit/2752f0b8df
2024-04-03[ruby/prism] Check for syntax errors using RubyVMKevin Newton
https://github.com/ruby/prism/commit/9e200dd1c1
2024-04-03[ruby/prism] Update fixtures to be all valid RubyKevin Newton
https://github.com/ruby/prism/commit/a0b978d25b
2024-03-26[ruby/prism] Fix typosKoichi ITO
After finding the "if if" typo, some additional typos identified by running `codespell` are also being corrected: https://github.com/codespell-project/codespell https://github.com/ruby/prism/commit/e6a34cfeeb
2024-03-20[ruby/prism] Provide options for reducing sizeKevin Newton
https://github.com/ruby/prism/commit/592128de4d
2024-02-20Workaround for `Prism::ParseTest#test_filepath` for ↵yui-knk
"unparser/corpus/literal/def.txt" See the discussion on https://github.com/ruby/ruby/pull/9923
2024-02-20Skip `test_filepath` of "unparser/corpus/literal/def.txt"yui-knk
The previous commit changes Ripper lex state behavior of `tLABEL`. For example, Ripper lex state for the second `bar` was changed by the previous commit. ``` def foo(bar: bar()) end ``` Before the commit, Ripper didn’t add label `bar` id to `vtable` because `formal_argument` function for Ripper didn’t return id but returned `VALUE lhs`. Therefore Ripper didn’t `SET_LEX_STATE(EXPR_END|EXPR_LABEL)` for following `bar` in `parse_ident` because `lvar_defined` for following `bar` was not true. Currently Ripper does `SET_LEX_STATE(EXPR_END|EXPR_LABEL)` then the result of this test case is changed like below. ``` Prism::ParseTest#test_filepath_unparser/corpus/literal/def.txt [ruby/test/prism/parse_test.rb:280]: <[[80, 13], :on_ident, “bar”, END|LABEL]> expected but was <[[80, 13], :on_ident, “bar”, ARG]>. ``` Parser sets lex state to `END|LABEL` on master branch. Therefore previous commit makes Ripper’s behavior aligned with parser’s behavior. ``` $ ruby -v -y -e "def foo(bar: bar())" -e "end" ruby 3.4.0dev (2024-02-11T23:52:05Z master 697ade7bda) [arm64-darwin21] ... Reading a token parser_dispatch_scan_event:11210 (1: 12|1|7) lex_state: ARG|LABELED -> ARG at line 11113 lex_state: ARG -> END|LABEL at line 11128 parser_dispatch_scan_event:11877 (1: 13|3|4) Next token is token “local variable or method” (1.13-1.16: bar) Shifting token “local variable or method” (1.13-1.16: bar) ```
2024-02-14Initialize the Prism::Source directly with all 3 fields for the C extensionBenoit Daloze
* Faster that way: $ ruby -Ilib -rprism -rbenchmark/ips -e 'Benchmark.ips { |x| x.report("parse") { Prism.parse("1 + 2") } }' 195.722k (± 0.5%) i/s rb_iv_set(): 179.609k (± 0.5%) i/s rb_funcall(): 190.030k (± 0.3%) i/s before this PR: 183.319k (± 0.4%) i/s
2024-02-06[ruby/prism] Implement file parsing error handlingeileencodes
This PR implements proper file parsing error handling. Previously `file_options` would call `pm_string_mapped_init` which would print an error from `perror`. However this wouldn't raise a proper Ruby error so it was just a string output. I've done the following: - Raise an error from `rb_syserr_fail` with the filepath in `file_options`. - No longer return `Qnil` if `file_options` returns false (because now it will raise) - Update `file_options` to return `static void` instead of `static bool`. - Update `file_options` and `profile_file` to check the type so when passing `nil` we see a `TypeError`. - Delete `perror` from `pm_string_mapped_init` - Update `FFI` backend to raise appropriate errors when calling `pm_string_mapped_init`. - Add tests for `dump_file`, `lex_file`, `parse_file`, `parse_file_comments`, `parse_lex_file`, and `parse_file_success?` when a file doesn't exist and for `nil`. - Updates the `bin/parse` script to no longer raise it's own `ArgumentError` now that we raise a proper error. Fixes: ruby/prism#2207 https://github.com/ruby/prism/commit/b2f7494ff5
2024-01-24[ruby/prism] Extract snippet into its own file and skip in TruffleRubyMax Prokopiev
https://github.com/ruby/prism/commit/12649ee74c
2024-01-09[ruby/prism] Fix assertion on spanning heredocsKevin Newton
https://github.com/ruby/prism/commit/e190308845
2023-12-01[ruby/prism] Fix parsing heredoc endsHaldun Bayhantopcu
https://github.com/ruby/prism/commit/aa8c702271
2023-11-29[ruby/prism] Convert start line to signed integersJean Boussier
Ruby allows for 0 or negative line start, this is often used with `eval` calls to get a correct offset when prefixing a snippet. e.g. ```ruby caller = caller_locations(1, 1).first class_eval <<~RUBY, caller.path, caller.line - 2 # frozen_string_literal: true def some_method #{caller_provided_code_snippet} end RUBY ``` https://github.com/ruby/prism/commit/0d14ed1452
2023-11-03[ruby/prism] Wire up options through the Ruby APIKevin Newton
https://github.com/ruby/prism/commit/8582d372a3
2023-10-16[ruby/prism] Additionally handle encoding comments in vim modeKevin Newton
https://github.com/ruby/prism/commit/bf9bdb9d82
2023-10-02`yield` cannot be placed outside methods even in blocksNobuyoshi Nakada
2023-09-28Syntax check of `yield` in the parserNobuyoshi Nakada
2023-09-27Include recently added parse_test code in renameKevin Newton
2023-09-27Sync to prism rename commitsKevin Newton
2023-09-27Rename YARP filepaths to prism filepathsKevin Newton