# How to test that a function doesn't infinite loop

**URL:** <https://discourse.elm-lang.org/t/how-to-test-that-a-function-doesnt-infinite-loop/8102>\
**Category:** Learn\
**Created:** [January 25, 2022, 1:33am UTC](https://discourse.elm-lang.org/t/how-to-test-that-a-function-doesnt-infinite-loop/8102 "2022-01-25T01:33:04Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![jackyjoy123](https://avatars.discourse-cdn.com/v4/letter/j/d6d6ee/32.png) [@jackyjoy123](https://discourse.elm-lang.org/u/jackyjoy123)\
**Post date:** [January 31, 2022, 12:08pm UTC](https://discourse.elm-lang.org/t/how-to-test-that-a-function-doesnt-infinite-loop/8102/4 "2022-01-31T12:08:55Z")

</div>

> [@aiko](#):
>
> You’re question is actually touching on a very fundamental problem “halting problem”.  
> However in your case it is possible to help ensure the loop exits eventually. Things like timeouts, Max depth counters and checking for loops in the current planned path come to mind.  
> Another thing that comes to mind is to try and break down the complexity of the algorithm, so you can test smaller chunks of it ( possibly without the need of the loop/recursive behavior wrapping it)  
> Just some ideas. [https://talktosonic.onl](https://talktosonic.onl) [https://talktowendys.vip](https://talktowendys.vip)

thanks my issue has been fixed.

---

_[View the full topic](https://discourse.elm-lang.org/t/how-to-test-that-a-function-doesnt-infinite-loop/8102)._
