Having issue runing test for F# 'Accumulate' exercise

I believe it’s a bug, as the exact code runs fine in Visual Studio locally.

But I constantly got an error with no error details:

Here is the code I was testing:

module Accumulate

let rec accumulate (func: 'a -> 'b) (input: 'a list): 'b list = 
    match input with
    | [] -> []
    | h :: t -> (func h) :: (accumulate func t)

How are you running the code? Are you running all the tests locally using the testing framework?

Good point, it was a few days back, but I don’t think so.

What I did is copy the code, and copied the test, and instead of run the unit test framework, I just modified the test code so that it just output the result, not via test framework.

It’s hard to tell if your code actually passes any tests without properly running the test :wink:

Yes, will try to run the full test locally.

On the other hand, I think it’s related to this bug:

Managed to run the test on my local PC.

Looks like the last test caused the issue:

let ``Accumulate large data set without stack overflow`` () =
    accumulate id [1..100000]
    |> should equal [1..100000]

The top of the error message from local test result:

The active test run was aborted. Reason: Test host process crashed : Stack overflow.
Repeat 74735 times:

I mean, it would be nice to have feedback about the error was the last test, and all the tests before were all passed, but it’s not really an online test runner issue if the local test did the same thing: basically stopped without give feedback for for which test passed and whic failed.

The problem your hitting is the implementation not being tail recursive. Our recursion video goes into what tail recursion means: https://www.youtube.com/watch?v=3ppX9InEEAY&t=3120s&ab_channel=Exercism

1 Like

Thanks @ErikSchierboom, it’s kind of obvious as it’s stack overflow.

And your video does help me understand the concept.

1 Like