I just did the “Difference of squares” exercise.
The only given prototype is difference. So, I created two functions squareOfSum and sumOfSquares.
Then, I got a strange error about my function name while compiling… until I realised the functions are called from the tests as square_of_sum and sum_of_squares.
I think it should be made clearer that these functions are needed (and how they should be called) without having to look into the test file.
The exercise text is the same over all tracks and it purposefully avoids dropping any names.
Naming schemes vary widely over the 60+ languages on exercism, so it is more practical to leave that detail to the implementations on the individual tracks.
The track maintainers can add more information for each implemented exercise and it is generally used to point out particularities like special libraries.
Looking into the test files is strongly advised and aligns with Test Driven Development principles. That means the implementation is based on the specification that was used for the tests.
I understand your frustration from looking into several files for the correct path to the solution, but the method is actually quite close to reallife development situations.
Okay, if it’s a track design choice I can live with it.
I wasn’t thinking about modifying the instructions. A simple comment ! Function square_of_sum would do the trick.
I value TDD but I like to think of edge cases and how to divide the code myself. TDD with given tests removes the first step of adding a test, and therefore these reflections.
I guess I will do it before opening the test file (or I just won’t ).
The clearer way would be to define the prototypes for square_of_sum and sum_of_squares, which are needed by the tests, the same way difference is provided.
If the goal is to let the student write the prototype, we could simply add comments with the name of the needed functions:
module difference_of_squares
implicit none
contains
! Function square_of_sum
! Function sum_of_squares
integer function difference(n)
integer :: n
end function difference
end module difference_of_squares
Erik already merged the PR (yay, my first contribution ). But for the sake of completeness, here is a comparison.
Running the tests on the previous stub gave a compilation error:
/tmp/differenceofsquares/difference_of_squares.f:::
 integer function difference(n)

Warning: Unused dummy argument n at () [Wunuseddummyargument]
/tmp/differenceofsquares/difference_of_squares.f:::
 integer function difference(n)

Warning: Return value of function difference at () not set [Wreturntype]
/tmp/differenceofsquares/difference_of_squares_test.f:::
 call assert_equal(, square_of_sum(), square of sum )

Error: Function square_of_sum at () has no IMPLICIT type
/tmp/differenceofsquares/difference_of_squares_test.f:::
 call assert_equal(, square_of_sum(), square of sum )

Error: Function square_of_sum at () has no IMPLICIT type
/tmp/differenceofsquares/difference_of_squares_test.f:::
 call assert_equal(, square_of_sum(), square of sum )

Error: Function square_of_sum at () has no IMPLICIT type
/tmp/differenceofsquares/difference_of_squares_test.f:::
 call assert_equal(, sum_of_squares(), sum of squares )

Error: Function sum_of_squares at () has no IMPLICIT type
/tmp/differenceofsquares/difference_of_squares_test.f:::
 call assert_equal(, sum_of_squares(), sum of squares )

Error: Function sum_of_squares at () has no IMPLICIT type
/tmp/differenceofsquares/difference_of_squares_test.f:::
 call assert_equal(, sum_of_squares(), sum of squares )

Error: Function sum_of_squares at () has no IMPLICIT type
make[]: *** [CMakeFiles/differenceofsquares.dir/build.make:: CMakeFiles/differenceofsquares.dir/difference_of_squares_test.f.o] Error
make[]: *** [CMakeFiles/Makefile:: CMakeFiles/differenceofsquares.dir/all] Error
make: *** [Makefile:: all] Error
Now it compiles and each test can be explored to see what the expected output: