Skip to content

Commit 4eb5319

Browse files
committed
Add matcher for an arbitrary lvar
1 parent b5eb26a commit 4eb5319

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/analyzers/acronym/representation.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def uses_method_chain?
2020
},
2121
{
2222
method_name: :tr,
23-
receiver: s(:lvar, :words),
23+
receiver: ArbitraryLvar.new,
2424
chained?: true,
2525
arguments: [{ to_ast: s(:str, "-") }, { to_ast: s(:str, " ") }]
2626
}
@@ -53,7 +53,7 @@ def uses_method_chain_with_block?
5353
},
5454
{
5555
method_name: :tr,
56-
receiver: s(:lvar, :words),
56+
receiver: ArbitraryLvar.new,
5757
chained?: true,
5858
arguments: [{ to_ast: s(:str, "-") }, { to_ast: s(:str, " ") }]
5959
},
@@ -77,7 +77,7 @@ def uses_scan?
7777
},
7878
{
7979
method_name: :scan,
80-
receiver: s(:lvar, :words),
80+
receiver: ArbitraryLvar.new,
8181
chained?: true,
8282
arguments: [{ type: :regexp }]
8383
},
@@ -102,7 +102,7 @@ def uses_split?
102102
},
103103
{
104104
method_name: :split,
105-
receiver: s(:lvar, :words),
105+
receiver: ArbitraryLvar.new,
106106
arguments: [{ type: :regexp }]
107107
}
108108
]
@@ -140,9 +140,15 @@ def node_matches?(node, matcher)
140140
node_matches?(n, expected_value[i])
141141
end
142142
else
143-
criteria_value == expected_value
143+
expected_value == criteria_value
144144
end
145145
end
146146
end
147147
end
148148
end
149+
150+
class ArbitraryLvar
151+
def ==(other)
152+
other.type == :lvar
153+
end
154+
end

0 commit comments

Comments
 (0)