summaryrefslogtreecommitdiff
path: root/test/ruby/test_pattern_matching.rb
AgeCommit message (Collapse)Author
2024-05-14Fix TestPatternMatching#test_deconstruct_keys testAndrew Konchin
Before the change `C.keys` returned keys captured in some previous test case that by chance captured `nil` value what made this test passed successfully. Now it returns keys captured in this test case.
2024-03-04Support NODE_ONCE for pattern matchingS-H-GAMELINKS
2023-10-31Keep unused literal nodesyui-knk
For static analysis, it’s better to keep unused literal nodes. If simply change `block_append` to fall through, both "unused literal ignored" and "possibly useless use of a literal in void context" warnings are shown for the same line. But it’s verbose then remove "unused literal ignored" warning. This kind of optimization is already implemented on compile.c. `compile_block` calls `iseq_compile_each0` with `popped = 1` when NODE_BLOCK has next.
2023-09-05Pattern matching has not been experimentalyui-knk
Notes: Merged: https://github.com/ruby/ruby/pull/8360
2023-04-16skip if `DidYouMean.formatter=` is not definedKoichi Sasada
ruby/test_default_gems.rb can define empty `DidYouMean` module because of the following line (second require) in the `lib/did_you_mean/did_you_mean.gemspec`: ```ruby begin require_relative "lib/did_you_mean/version" rescue LoadError # Fallback to load version file in ruby core repository require_relative "version" end ``` It defines only `::DidYouMean::VERSION`. However, in the `test/ruby/test_patten_matching.rb` assumes that if `defined?(DidYouMean)` is true, then there is a method `DidYouMean.formatter=` and this assumption fails all tests in `test/ruby/test_patten_matching.rb` if there is only a `::DidYouMean::VERSION`. To reproduce the failures, we need to repeat the following command: `make test-all TESTS='-v ruby/test_default_gems.rb ruby/pattern_matching'` (because the ruby/test_default_gems.rb should be run before the ruby/pattern_matching`) This patch introduces more strict gurds. Notes: Merged: https://github.com/ruby/ruby/pull/7722
2023-03-26[Bug #19175] p_rest should be `assignable'Kazuki Tsujimoto
It should also check for duplicate names.
2022-12-13[Bug #19195] Allow optional newlines before closing parenthesisNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6916
2022-09-09Fix unexpected "duplicated key name" error in paren-less one line pattern ↵Kazuki Tsujimoto
matching [Bug #18990]
2022-07-08[Bug #18890] Suppress warnings and fix the messageNobuyoshi Nakada
``` test/ruby/test_parse.rb:1384: warning: assigned but unused variable - obj test/ruby/test_pattern_matching.rb:1162: warning: unused literal ignored test/ruby/test_pattern_matching.rb:1165: warning: unused literal ignored test/ruby/test_pattern_matching.rb:1161: warning: assigned but unused variable - a test/ruby/test_pattern_matching.rb:1164: warning: assigned but unused variable - b ``` And a newline should be significant here.
2022-07-06[Bug #18890] newline should be insignificant after pattern labelNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6087
2022-02-19Find pattern is no longer experimental [Feature #18585]Kazuki Tsujimoto
2021-10-22Disable did_you_mean in TestPatternMatchingYuki Nishijima
2021-08-19Allow omission of parentheses in one line pattern matching [Feature #16182]Kazuki Tsujimoto
2021-08-15Show verbose error messages when single pattern match failsKazuki Tsujimoto
[0] => [0, *, a] #=> [0] length mismatch (given 1, expected 2+) (NoMatchingPatternError) Ignore test failures of typeprof caused by this change for now.
2021-07-17One-line pattern matching is no longer experimentalKazuki Tsujimoto
https://github.com/ruby/dev-meeting-log/blob/master/DevelopersMeeting20210715Japan.md#feature-17724-make-the-pin-operator-support-instanceclassglobal-variables-jeremyevans0
2021-07-15Add pattern matching pin support for instance/class/global variablesJeremy Evans
Pin matching for local variables and constants is already supported, and it is fairly simple to add support for these variable types. Note that pin matching for method calls is still not supported without wrapping in parentheses (pin expressions). I think that's for the best as method calls are far more complex (arguments/blocks). Implements [Feature #17724] Notes: Merged: https://github.com/ruby/ruby/pull/4502
2021-03-21Pattern matching pin operator against expression [Feature #17411]Kazuki Tsujimoto
This commit is based on the patch by @nobu.
2021-01-19test/ruby/test_pattern_matching.rb: Avoid a warningYusuke Endoh
http://rubyci.s3.amazonaws.com/ubuntu2004/ruby-master/log/20210119T033003Z.log.html.gz ``` /home/chkbuild/chkbuild/tmp/build/20210119T033003Z/ruby/test/ruby/test_pattern_matching.rb:798: warning: assigned but unused variable - x ```
2021-01-19Mark pattern labels as unremoveableVladimir Dementyev
Peephole optimization doesn't play well with find pattern at least. The only case when a pattern matching could have unreachable patterns is when we have lasgn/dasgn node, which shouldn't happen in real-life. Fixes https://bugs.ruby-lang.org/issues/17534
2020-12-23Make NoMatchingPatternError a subclass of StandardErrorKazuki Tsujimoto
2020-12-13Reintroduce `expr in pat` [Feature #17371]Kazuki Tsujimoto
2020-11-01Pattern matching is no longer experimentalKazuki Tsujimoto
2020-10-26Assoc pattern matching (#3703)Nobuyoshi Nakada
[Feature #17260] One-line pattern matching using tASSOC R-assignment is rejected instead. Notes: Merged-By: nobu <[email protected]>
2020-06-27Suppress "assigned but unused variable" warningsKazuki Tsujimoto
2020-06-27Add #deconstruct cache to find patternVladimir Dementyev
Notes: Merged: https://github.com/ruby/ruby/pull/3104
2020-06-27Optimize array pattern matching by caching #deconstruct valueVladimir Dementyev
Notes: Merged: https://github.com/ruby/ruby/pull/3104
2020-06-14Introduce find pattern [Feature #16828]Kazuki Tsujimoto
2020-03-03Suppress an "assigned but unused variable" warningYusuke Endoh
2020-03-03Preserve `kwarg` flag and fix up f5c904c2a9Nobuyoshi Nakada
2020-03-02Suppress "assigned but unused variable" warningsYusuke Endoh
2020-03-02Allow newlines inside braced patternNobuyoshi Nakada
2020-03-01Allow trailing comma in hash patternKazuki Tsujimoto
2019-12-21test/ruby/test_pattern_matching.rb: suppress "unused variable" warningYusuke Endoh
2019-12-20Added `experimental` warning categoryNobuyoshi Nakada
[Feature #16420]
2019-11-30Make single line pattern matching void expressionNobuyoshi Nakada
Instead of returning `nil`, raise a syntax error if its value is used. [Feature #16355]
2019-11-28Raise `NoMatchingPatternError` when expr `in` pat doesn't matchNobuyoshi Nakada
* `expr in pattern` should raise `NoMatchingError` when unmatched * `expr in pattern` should return `nil`. (this is unspecified, but this feature is experimental, at all) [Feature #16355]
2019-11-19Avoid needless object allocationKazuki Tsujimoto
2019-11-10Disallow omission of parentheses/brackets in single line pattern matching ↵Kazuki Tsujimoto
[Feature #16182]
2019-11-08Define Struct#deconstruct_keysKazuki Tsujimoto
2019-11-07Disallow duplicated pattern variableKazuki Tsujimoto
2019-10-29Restore `in_kwarg` flag properlyNobuyoshi Nakada
2019-09-26[EXPERIMENTAL] Expression with modifier `in`Nobuyoshi Nakada
[Feature #15865] Notes: Merged: https://github.com/ruby/ruby/pull/2485
2019-09-01Make pattern matching support **nil syntaxKazuki Tsujimoto
2019-06-30Fixed an assertionNobuyoshi Nakada
2019-05-21Simplified the guard against old versionsNobuyoshi Nakada
2019-04-21test/ruby/test_pattern_matching.rb: add missing tests for NODE_DASGN, NODE_LASGNktsj
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-21Add missing test for p_var_refktsj
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-21Add missing tests for p_argsktsj
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-17Suppress warning in assertion tookazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-17Suppress warnings in `make test-all`kazu
suppress "warning: Pattern matching is experimental, and the behavior may change in future versions of Ruby!" git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e