Skip to content

Commit 1557b75

Browse files
authored
Merge pull request #14604 from hernanmd/issues_expression_finder_rb
Search strings without symbols using RB pattern matcher
2 parents bd9acec + 7ad9a64 commit 1557b75

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/AST-Core-Tests/RBPatternParserTest.class.st

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,28 @@ RBPatternParserTest >> testParseFaultyPatternBlock [
4848
self assert: node isFaulty]
4949
]
5050

51+
{ #category : #'tests - parsing' }
52+
RBPatternParserTest >> testPatternNotStringExpression [
53+
| searchPattern tree |
54+
searchPattern := RBPatternParser parseExpression: '`{ :node | node isString }'.
55+
56+
tree := self parseExpression: 'a = a1'.
57+
58+
self deny: (searchPattern match: tree inContext: Dictionary new).
59+
60+
]
61+
62+
{ #category : #'tests - parsing' }
63+
RBPatternParserTest >> testPatternStringExpression [
64+
| searchPattern tree |
65+
searchPattern := RBPatternParser parseExpression: '`{ :node | node isString }'.
66+
67+
tree := self parseExpression: '''justAString'''.
68+
69+
self assert: (searchPattern match: tree inContext: Dictionary new).
70+
71+
]
72+
5173
{ #category : #'tests - parsing' }
5274
RBPatternParserTest >> testPatternVariable [
5375
| searchPattern |

src/AST-Core/RBLiteralValueNode.class.st

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ RBLiteralValueNode >> evaluateForReceiver: aReceicer [
6767
^ value
6868
]
6969

70+
{ #category : #testing }
71+
RBLiteralValueNode >> isString [
72+
73+
^ value isString and: [ value isSymbol not ]
74+
]
75+
7076
{ #category : #accessing }
7177
RBLiteralValueNode >> sourceText [
7278

0 commit comments

Comments
 (0)