Create unit test for Util module

This commit is contained in:
2021-11-08 11:12:09 +01:00
parent 42b2eb5e41
commit 66dad8ea00
5 changed files with 69 additions and 7 deletions

View File

@@ -97,6 +97,8 @@ instructions = [ Simple { _op = Nop, _noParams = 0, _noPops = 0, _sAction = (\
]
jumpIf :: (Int -> Int -> Bool) -> VM -> Args -> Either String VM
jumpIf _ _ [] = Left $ "Address expected"
jumpIf _ _ (_:_:_) = Left $ "Multiple parameters are not supported by jmp* instructions"
jumpIf predicate vm [addr] = Right $ vm { _pc = pc }
where
(top:_) = toList . _stack $ vm