Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions exercises/practice/space-age/.meta/template.j2
Original file line number Diff line number Diff line change
@@ -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"] }}d0, age_in_years("{{ case["input"]["planet"] }}", {{ case["input"]["seconds"] }}.d0), "{{ case["description"] }}")
{% endfor %}
call test_report()

end program
35 changes: 18 additions & 17 deletions exercises/practice/space-age/space_age_test.f90
Original file line number Diff line number Diff line change
@@ -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.69d0, 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.88d0, 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.78d0, 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.88d0, 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.41d0, 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.15d0, 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.46d0, age_in_years("Uranus", 1210123456.d0), "age on Uranus")

! Test 8: age on Neptune
call assert_equal(0.35d0, age_in_years("Neptune", 1821023456.d0), "age on Neptune")

call test_report()

end program

Loading