From 5aa271c81f2b10f5e3239bcb8bd31626f63525a9 Mon Sep 17 00:00:00 2001 From: Isaac Good Date: Sat, 4 Jul 2026 19:08:55 -0700 Subject: [PATCH 1/3] [space-age] Add a Jinja test template --- .../practice/space-age/.meta/template.j2 | 14 ++++++++ .../practice/space-age/space_age_test.f90 | 35 ++++++++++--------- 2 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 exercises/practice/space-age/.meta/template.j2 diff --git a/exercises/practice/space-age/.meta/template.j2 b/exercises/practice/space-age/.meta/template.j2 new file mode 100644 index 00000000..a89d4d19 --- /dev/null +++ b/exercises/practice/space-age/.meta/template.j2 @@ -0,0 +1,14 @@ +{{ header }} + +program {{ name }}_test_main + use TesterMain + use {{ name }} + + implicit none +{% for case in cases %} + ! Test {{ loop.index }}: {{ case["description"] }} + call assert_equal({{ case["expected"] }}, age_in_years("{{ case["input"]["planet"] }}", {{ case["input"]["seconds"] }}.d0), "{{ case["description"] }}") +{% endfor %} + call test_report() + +end program diff --git a/exercises/practice/space-age/space_age_test.f90 b/exercises/practice/space-age/space_age_test.f90 index 1713b0b8..be6cf100 100644 --- a/exercises/practice/space-age/space_age_test.f90 +++ b/exercises/practice/space-age/space_age_test.f90 @@ -1,34 +1,35 @@ +! The tests were created from https://github.com/exercism/problem-specifications/blob/main/exercises/space-age/canonical-data.json + program space_age_test_main use TesterMain use space_age implicit none - ! Test 0: age on Neptune - call assert_equal(0.35016863257806585d0, age_in_years("Neptune", 1821023456.d0), "age on Neptune") - - ! Test 1: age on Uranus - call assert_equal(0.45641439979244397d0, age_in_years("Uranus", 1210123456.d0), "age on Uranus") + ! Test 1: age on Earth + call assert_equal(31.69, age_in_years("Earth", 1000000000.d0), "age on Earth") - ! Test 2: age on Saturn - call assert_equal(2.1521752248037473d0, age_in_years("Saturn", 2000000000.d0), "age on Saturn") + ! Test 2: age on Mercury + call assert_equal(280.88, age_in_years("Mercury", 2134835688.d0), "age on Mercury") - ! Test 3: age on Jupiter - call assert_equal(2.4091431771337701d0, age_in_years("Jupiter", 901876382.d0), "age on Jupiter") + ! Test 3: age on Venus + call assert_equal(9.78, age_in_years("Venus", 189839836.d0), "age on Venus") ! Test 4: age on Mars - call assert_equal(35.884187517994398d0, age_in_years("Mars", 2129871239.d0), "age on Mars") + call assert_equal(35.88, age_in_years("Mars", 2129871239.d0), "age on Mars") - ! Test 5: age on Venus - call assert_equal(9.778426831369266d0, age_in_years("Venus", 189839836.d0), "age on Venus") + ! Test 5: age on Jupiter + call assert_equal(2.41, age_in_years("Jupiter", 901876382.d0), "age on Jupiter") - ! Test 6: age on Mercury - call assert_equal(280.87933423985845d0, age_in_years("Mercury", 2134835688.d0), "age on Mercury") + ! Test 6: age on Saturn + call assert_equal(2.15, age_in_years("Saturn", 2000000000.d0), "age on Saturn") - ! Test 7: age on Earth - call assert_equal(31.688087814028950d0, age_in_years("Earth", 1000000000.d0), "age on Earth") + ! Test 7: age on Uranus + call assert_equal(0.46, age_in_years("Uranus", 1210123456.d0), "age on Uranus") + + ! Test 8: age on Neptune + call assert_equal(0.35, age_in_years("Neptune", 1821023456.d0), "age on Neptune") call test_report() end program - From 55035c6e66518c7d32241814171456e343ac7b30 Mon Sep 17 00:00:00 2001 From: Colin Leach Date: Sun, 5 Jul 2026 10:52:06 -0700 Subject: [PATCH 2/3] Update assert_equal calls to use double precision --- exercises/practice/space-age/.meta/template.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/practice/space-age/.meta/template.j2 b/exercises/practice/space-age/.meta/template.j2 index a89d4d19..64c060e8 100644 --- a/exercises/practice/space-age/.meta/template.j2 +++ b/exercises/practice/space-age/.meta/template.j2 @@ -7,7 +7,7 @@ program {{ name }}_test_main implicit none {% for case in cases %} ! Test {{ loop.index }}: {{ case["description"] }} - call assert_equal({{ case["expected"] }}, age_in_years("{{ case["input"]["planet"] }}", {{ case["input"]["seconds"] }}.d0), "{{ case["description"] }}") + call assert_equal({{ case["expected"] }}d0, age_in_years("{{ case["input"]["planet"] }}", {{ case["input"]["seconds"] }}.d0), "{{ case["description"] }}") {% endfor %} call test_report() From 270fcfff81526f96739f01252da817ae4fc8e5ba Mon Sep 17 00:00:00 2001 From: Colin Leach Date: Sun, 5 Jul 2026 10:52:34 -0700 Subject: [PATCH 3/3] Update test cases to use double precision literals --- exercises/practice/space-age/space_age_test.f90 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/exercises/practice/space-age/space_age_test.f90 b/exercises/practice/space-age/space_age_test.f90 index be6cf100..6d849d88 100644 --- a/exercises/practice/space-age/space_age_test.f90 +++ b/exercises/practice/space-age/space_age_test.f90 @@ -7,28 +7,28 @@ program space_age_test_main implicit none ! Test 1: age on Earth - call assert_equal(31.69, age_in_years("Earth", 1000000000.d0), "age on Earth") + call assert_equal(31.69d0, age_in_years("Earth", 1000000000.d0), "age on Earth") ! Test 2: age on Mercury - call assert_equal(280.88, age_in_years("Mercury", 2134835688.d0), "age on Mercury") + call assert_equal(280.88d0, age_in_years("Mercury", 2134835688.d0), "age on Mercury") ! Test 3: age on Venus - call assert_equal(9.78, age_in_years("Venus", 189839836.d0), "age on Venus") + call assert_equal(9.78d0, age_in_years("Venus", 189839836.d0), "age on Venus") ! Test 4: age on Mars - call assert_equal(35.88, age_in_years("Mars", 2129871239.d0), "age on Mars") + call assert_equal(35.88d0, age_in_years("Mars", 2129871239.d0), "age on Mars") ! Test 5: age on Jupiter - call assert_equal(2.41, age_in_years("Jupiter", 901876382.d0), "age on Jupiter") + call assert_equal(2.41d0, age_in_years("Jupiter", 901876382.d0), "age on Jupiter") ! Test 6: age on Saturn - call assert_equal(2.15, age_in_years("Saturn", 2000000000.d0), "age on Saturn") + call assert_equal(2.15d0, age_in_years("Saturn", 2000000000.d0), "age on Saturn") ! Test 7: age on Uranus - call assert_equal(0.46, age_in_years("Uranus", 1210123456.d0), "age on Uranus") + call assert_equal(0.46d0, age_in_years("Uranus", 1210123456.d0), "age on Uranus") ! Test 8: age on Neptune - call assert_equal(0.35, age_in_years("Neptune", 1821023456.d0), "age on Neptune") + call assert_equal(0.35d0, age_in_years("Neptune", 1821023456.d0), "age on Neptune") call test_report()