Skip to content

Commit 104208d

Browse files
committed
Implement Parser#arg1 for C_LABEL, C_GOTO, C_IF
1 parent a037faf commit 104208d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/parser.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def command_type
3737

3838
def arg1
3939
case command_type
40-
when C_PUSH, C_POP
41-
current.split[1]
42-
else
40+
when C_ARITHMETIC
4341
current
42+
else
43+
current.split[1]
4444
end
4545
end
4646

spec/unit/parser_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,23 +211,23 @@
211211
context 'when the current command is a label' do
212212
let(:input) { 'label LOOP_START' }
213213

214-
it 'returns the first argument', :pending do
214+
it 'returns the first argument' do
215215
expect(parser.arg1).to eq 'LOOP_START'
216216
end
217217
end
218218

219219
context 'when the current command is a goto' do
220220
let(:input) { 'goto WHILE' }
221221

222-
it 'returns the first argument', :pending do
222+
it 'returns the first argument' do
223223
expect(parser.arg1).to eq 'WHILE'
224224
end
225225
end
226226

227227
context 'when the current command is an if-goto' do
228228
let(:input) { 'if-goto COMPUTE_ELEMENT' }
229229

230-
it 'returns the first argument', :pending do
230+
it 'returns the first argument' do
231231
expect(parser.arg1).to eq 'COMPUTE_ELEMENT'
232232
end
233233
end

0 commit comments

Comments
 (0)