aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_pattern_matching.rb
Commit message (Collapse)AuthorAgeFilesLines
* Keep unused literal nodesyui-knk2023-10-311-1/+1
| | | | | | | | | | | | 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.
* Pattern matching has not been experimentalyui-knk2023-09-051-4/+0
|
* skip if `DidYouMean.formatter=` is not definedKoichi Sasada2023-04-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* [Bug #19175] p_rest should be `assignable'Kazuki Tsujimoto2023-03-261-0/+8
| | | | It should also check for duplicate names.
* [Bug #19195] Allow optional newlines before closing parenthesisNobuyoshi Nakada2022-12-131-0/+2
|
* Fix unexpected "duplicated key name" error in paren-less one line pattern ↵Kazuki Tsujimoto2022-09-091-0/+12
| | | | | | matching [Bug #18990]
* [Bug #18890] Suppress warnings and fix the messageNobuyoshi Nakada2022-07-081-6/+13
| | | | | | | | | | | | ``` 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.
* [Bug #18890] newline should be insignificant after pattern labelNobuyoshi Nakada2022-07-061-0/+15
|
* Find pattern is no longer experimental [Feature #18585]Kazuki Tsujimoto2022-02-191-20/+0
|
* Disable did_you_mean in TestPatternMatchingYuki Nishijima2021-10-221-0/+19
|
* Allow omission of parentheses in one line pattern matching [Feature #16182]Kazuki Tsujimoto2021-08-191-7/+7
|
* Show verbose error messages when single pattern match failsKazuki Tsujimoto2021-08-151-0/+127
| | | | | | | [0] => [0, *, a] #=> [0] length mismatch (given 1, expected 2+) (NoMatchingPatternError) Ignore test failures of typeprof caused by this change for now.
* One-line pattern matching is no longer experimentalKazuki Tsujimoto2021-07-171-2/+0
| | | | https://github.com/ruby/dev-meeting-log/blob/master/DevelopersMeeting20210715Japan.md#feature-17724-make-the-pin-operator-support-instanceclassglobal-variables-jeremyevans0
* Add pattern matching pin support for instance/class/global variablesJeremy Evans2021-07-151-0/+24
| | | | | | | | | | | 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]
* Pattern matching pin operator against expression [Feature #17411]Kazuki Tsujimoto2021-03-211-0/+23
| | | | This commit is based on the patch by @nobu.
* test/ruby/test_pattern_matching.rb: Avoid a warningYusuke Endoh2021-01-191-0/+1
| | | | | | | | 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 ```
* Mark pattern labels as unremoveableVladimir Dementyev2021-01-191-0/+10
| | | | | | | | | 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
* Make NoMatchingPatternError a subclass of StandardErrorKazuki Tsujimoto2020-12-231-0/+4
|
* Reintroduce `expr in pat` [Feature #17371]Kazuki Tsujimoto2020-12-131-1/+5
|
* Pattern matching is no longer experimentalKazuki Tsujimoto2020-11-011-2/+2
|
* Assoc pattern matching (#3703)Nobuyoshi Nakada2020-10-261-11/+11
| | | | | [Feature #17260] One-line pattern matching using tASSOC R-assignment is rejected instead.
* Suppress "assigned but unused variable" warningsKazuki Tsujimoto2020-06-271-4/+4
|
* Add #deconstruct cache to find patternVladimir Dementyev2020-06-271-0/+9
|
* Optimize array pattern matching by caching #deconstruct valueVladimir Dementyev2020-06-271-0/+79
|
* Introduce find pattern [Feature #16828]Kazuki Tsujimoto2020-06-141-0/+57
|
* Suppress an "assigned but unused variable" warningYusuke Endoh2020-03-031-0/+1
|
* Preserve `kwarg` flag and fix up f5c904c2a9Nobuyoshi Nakada2020-03-031-0/+2
|
* Suppress "assigned but unused variable" warningsYusuke Endoh2020-03-021-0/+2
|
* Allow newlines inside braced patternNobuyoshi Nakada2020-03-021-0/+14
|
* Allow trailing comma in hash patternKazuki Tsujimoto2020-03-011-0/+9
|
* test/ruby/test_pattern_matching.rb: suppress "unused variable" warningYusuke Endoh2019-12-211-0/+17
|
* Added `experimental` warning categoryNobuyoshi Nakada2019-12-201-4/+22
| | | | [Feature #16420]
* Make single line pattern matching void expressionNobuyoshi Nakada2019-11-301-2/+2
| | | | | Instead of returning `nil`, raise a syntax error if its value is used. [Feature #16355]
* Raise `NoMatchingPatternError` when expr `in` pat doesn't matchNobuyoshi Nakada2019-11-281-1/+4
| | | | | | | | * `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]
* Avoid needless object allocationKazuki Tsujimoto2019-11-191-0/+2
|
* Disallow omission of parentheses/brackets in single line pattern matching ↵Kazuki Tsujimoto2019-11-101-1/+7
| | | | [Feature #16182]
* Define Struct#deconstruct_keysKazuki Tsujimoto2019-11-081-0/+24
|
* Disallow duplicated pattern variableKazuki Tsujimoto2019-11-071-8/+59
|
* Restore `in_kwarg` flag properlyNobuyoshi Nakada2019-10-291-0/+1
|
* [EXPERIMENTAL] Expression with modifier `in`Nobuyoshi Nakada2019-09-261-0/+7
| | | | [Feature #15865]
* Make pattern matching support **nil syntaxKazuki Tsujimoto2019-09-011-0/+38
|
* Fixed an assertionNobuyoshi Nakada2019-06-301-1/+1
|
* Simplified the guard against old versionsNobuyoshi Nakada2019-05-211-5/+2
|
* test/ruby/test_pattern_matching.rb: add missing tests for NODE_DASGN, NODE_LASGNktsj2019-04-211-0/+18
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add missing test for p_var_refktsj2019-04-211-0/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add missing tests for p_argsktsj2019-04-211-0/+29
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Suppress warning in assertion tookazu2019-04-171-0/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Suppress warnings in `make test-all`kazu2019-04-171-0/+7
| | | | | | 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
* Define Struct#deconstructktsj2019-04-171-0/+12
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Introduce pattern matching [EXPERIMENTAL]ktsj2019-04-171-0/+1075
[ruby-core:87945] [Feature #14912] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e