summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2024-01-17[Prism] Implement defined? for PM_INTERPOLATED_SYMBOL_NODEeileencodes
Ruby code: ```ruby defined?(:"1 #{1 + 2} 1") ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,25)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,25)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_DEFINED_NODEeileencodes
Ruby code: ```ruby defined?(defined?(a)) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,21)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,21)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_BREAK_NODEeileencodes
Ruby code: ```ruby defined?(break) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,15)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,15)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined for PM_NEXT_NODEeileencodes
Ruby code: ```ruby defined?(next) ``` Instructions ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,15)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,15)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[PRISM] Fix test_compile_prism_with_filePeter Zhu
The test should be testing RubyVM::InstructionSequence.compile_prism with a file but it is instead passing the file path (which is a string) which raises a SyntaxError because it is not Ruby syntax.
2024-01-17[PRISM] Fix stack inconsistency in MultiWriteNodeMatt Valentine-House
2024-01-17Fix off-by-one error of argcNobuyoshi Nakada
Fix ruby/ruby#9562
2024-01-17Omit low-memory test on old platformsNobuyoshi Nakada
2024-01-16[PRISM] Fix crash with empty ensure blocksPeter Zhu
Fixes ruby/prism#2179.
2024-01-16[PRISM] Fix splat assignmentPeter Zhu
Fixes ruby/prism#2177
2024-01-16Fix coderange of invalid_encoding_string.<<(ord)tompng
Appending valid encoding character can change coderange from invalid to valid. Example: "\x95".force_encoding('sjis')<<0x5C will be a valid string "\x{955C}"
2024-01-16[PRISM] Fix defined? for chained callsPeter Zhu
Fixes ruby/prism#2148.
2024-01-16[Bug #20184] Test for low memoryNobuyoshi Nakada
2024-01-15[PRISM] Fix keyword splat inside of arrayPeter Zhu
Fixes ruby/prism#2155.
2024-01-15[PRISM] Fix case without predicatePeter Zhu
Fixes ruby/prism#2149.
2024-01-15Improve behavioural consistency of unallocated (zero length) `IO::Buffer`. ↵Samuel Williams
(#9532) This makes the behaviour of IO::Buffer.new(0) and IO::Buffer.new.slice(0, 0) consistent. Fixes https://bugs.ruby-lang.org/issues/19542 and https://bugs.ruby-lang.org/issues/18805.
2024-01-14Support keyword splatting nilJeremy Evans
nil is treated similarly to the empty hash in this case, passing no keywords and not calling any conversion methods. Fixes [Bug #20064] Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2024-01-14Add test for `Errno` constantsNobuyoshi Nakada
2024-01-12Fix splat assigns with no leftiesAaron Patterson
We still need to emit an expand array even if there's no "left side" variables Fixes: https://github.com/ruby/prism/issues/2153
2024-01-12Update test/ruby/test_compile_prism.rbAaron Patterson
Co-authored-by: Ufuk Kayserilioglu <ufuk@paralaus.com>
2024-01-12[PRISM] Pre-concatenate Strings in InterpolatedStringNodeJemma Issroff
This commit concatenates String VALUEs within InterpolatedStringNodes to allow us to preserve frozenness of concatenated strings such as `"a""b"` Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2024-01-12[PRISM] Fix splat in whenPeter Zhu
Fixes ruby/prism#2147.
2024-01-11[PRISM] Raise syntax errors when foundKevin Newton
2024-01-11[PRISM] Fix splat inside of asetPeter Zhu
Fixes ruby/prism#2146.
2024-01-11[PRISM] Support repeated required parameter names.Aaron Patterson
Fixes: https://github.com/ruby/prism/issues/2062 This patch only fixes positional parameters, we still need to fix the other cases spelled out in test/prism/fixtures/repeat_parameters.txt
2024-01-11Reject encodings determined at runtime as source code encodingsNobuyoshi Nakada
The encodings determined at runtime are affected by the runtime environment, such as the OS and locale, while the file contents are not.
2024-01-11Prevent syntax warnings in test/ruby/test_regexp.rbYusuke Endoh
2024-01-11Prevent a warning: ambiguous first argumentYusuke Endoh
2024-01-11Add a test for what happens with concurent calls to waitpidKJ Tsanaktsidis
Ruby 3.1 and 3.2 have a bug in their _implementation_, for which I'm backporting a fix. However, the current development branch doesn't have the issue (because the MJIT -> RJIT change refactored how waitpid worked substantially). I do however want to commit the test which verifies that waitpid works properly on master. [Fixes #19387]
2024-01-10Make defined? for op asgn expressions to constants use "assignment"Jeremy Evans
Previously, it used "expression", as that was the default. However, op asgn expressions to constants use the NODE_OP_CDECL, so recognize that node type as assignement. Fixes [Bug #20111]
2024-01-10[PRISM] Don't increment argc for PM_ASSOC_SPLAT_NODEPeter Zhu
Fixes ruby/prism#2087.
2024-01-10Fix memory leak when duplicating too complex objectPeter Zhu
[Bug #20162] Creating a ST table then calling st_replace leaks memory because the st_replace overwrites the ST table without freeing any of the existing memory. This commit changes it to use st_copy instead. For example: RubyVM::Shape.exhaust_shapes o = Object.new o.instance_variable_set(:@a, 0) 10.times do 100_000.times { o.dup } puts `ps -o rss= -p #{$$}` end Before: 23264 33600 42672 52160 61600 71728 81056 90528 100560 109840 After: 14752 14816 15584 15584 15664 15664 15664 15664 15664 15664
2024-01-10Fix CRLF -> LF conversion on read for rb_io_fdopen & rb_file_openKJ Tsanaktsidis
When opening a file with `File.open`, and then setting the encoding with `IO#set_encoding`, it still correctly performs CRLF -> LF conversion on Windows when reading files with a CRLF line ending in them (in text mode). However, the file is opened instead with either the `rb_io_fdopen` or `rb_file_open` APIs from C, the CRLF conversion is _NOT_ set up correctly; it works if the encoding is not specified, but if `IO#set_encoding` is called, the conversion stops happening. This seems to be because the encflags never get ECONV_DEFAULT_NEWLINE_DECORATOR set in these codepaths. Concretely, this means that the conversion doesn't happen in the following circumstances: * When loading ruby files with require (that calls rb_io_fdopen) * When parsing ruuby files with RubyVM::AbstractSyntaxTree (that calls rb_file_open). This then causes the ErrorHighlight tests to fail on windows if git has checked them out with CRLF line endings - the error messages it's testing wind up with literal \r\n sequences in them because the iseq text from the parser contains un-newline-converted strings. This commit fixes the problem by copy-pasting the relevant snippet which sets this up in `rb_io_extract_modeenc` (for the File.open path) into the relevant codepaths for `rb_io_fdopen` and `rb_file_open`. [Bug #20101]
2024-01-10Fix test case for `test_match_cache_with_peek_optimization` (#9466)Hiroya Fujinami
2024-01-10Fix to work match cache with peek next optimization (#9459)Hiroya Fujinami
2024-01-09[PRISM] Frozen string literals should be fstringsPeter Zhu
Frozen string literals should not just be frozen, but deduplicated as an fstring so that two string literals with the same contents are the exact same object. Fixes ruby/prism#2095.
2024-01-09Introduce NODE_SYM to manage symbol literalyui-knk
`:sym` was managed by `NODE_LIT` with `Symbol` object. This commit introduces `NODE_SYM` so that 1. Symbol literal is detectable from AST Node 2. Reduce dependency on ruby object
2024-01-08Fix memory leak in grapheme clustersPeter Zhu
[Bug #20150] String#grapheme_cluters and String#each_grapheme_cluster leaks memory because if the string is not UTF-8, then the created regex will not be freed. For example: str = "hello world".encode(Encoding::UTF_32LE) 10.times do 1_000.times do str.grapheme_clusters end puts `ps -o rss= -p #{$$}` end Before: 26000 42256 59008 75792 92528 109232 125936 142672 159392 176160 After: 9264 9504 9808 10000 10128 10224 10352 10544 10704 10896
2024-01-07Label memory leak testPeter Zhu
2024-01-07Check hash key duplication for `__LINE__` and `__FILE__`yui-knk
2024-01-07Introduce Numeric Node'sS-H-GAMELINKS
2024-01-06Add test case for GC.measure_total_timeRian McGuire
2024-01-05YJIT: Let RubyVM::YJIT.enable respect --yjit-stats (#9415)Takashi Kokubun
2024-01-05Add test cases for duplicated `when\' clause warningsyui-knk
Add test cases for `__LINE__` and `__FILE__` because they were managed by NODE_LIT and NODE_STR but changed to be managed by dedicated NODE now.
2024-01-04Memory leak when duplicating identhashPeter Zhu
[Bug #20145] Before this commit, both copy_compare_by_id and hash_copy will create a copy of the ST table, so the ST table created in copy_compare_by_id will be leaked. h = { 1 => 2 }.compare_by_identity 10.times do 1_000_000.times do h.select { false } end puts `ps -o rss= -p #{$$}` end Before: 110736 204352 300272 395520 460704 476736 542000 604704 682624 770528 After: 15504 16048 16144 16256 16320 16320 16752 16752 16752 16752
2024-01-02Fix Exception#detailed_message for GC compactionPeter Zhu
Before this commit, the test fails with RGENGC_CHECK_MODE enabled: TestException#test_detailed_message_under_gc_compact_stress [test/ruby/test_exception.rb:1466]: <"\e[1mfoo (\e[1;4mRuntimeError\e[m\e[1m)\e[m\n" + "\e[1mbar\e[m\n" + "\e[1mbaz\e[m"> expected but was <"\e[1mfoo (\e[1;4mRuntimeError\e[m\e[1m)\e[m\n" + "\e[1m\x00\x00\x00\x00\x00\x00\x00\e[m">.
2024-01-02Introduce NODE_FILEyui-knk
`__FILE__` was managed by `NODE_STR` with `String` object. This commit introduces `NODE_FILE` and `struct rb_parser_string` so that 1. `__FILE__` is detectable from AST Node 2. Reduce dependency ruby object
2024-01-02Add a test case for `__LINE__` assignment in condition warningyui-knk
2024-01-02Warn "literal in condition" for `__LINE__`yui-knk
Print warning for a code like ```ruby if __LINE__ end # => warning: literal in condition ```
2024-01-01Don't create T_MATCH object if /regexp/.match(string) doesn't matchLuke Gruber
Fixes [Bug #20104]