Sha256: 909fab61b62da8d56281db0005e9107406775162f5f93e31e4ec5cc15c4ca136

Contents?: true

Size: 1.51 KB

Versions: 116

Compression:

Stored size: 1.51 KB

Contents

-module(space_age_tests).

-include_lib("erl_exercism/include/exercism.hrl").
-include_lib("eunit/include/eunit.hrl").

age_in_earth_years_test() ->
  equalFloat(space_age:ageOn(earth, 1000000000), 31.69).

age_in_mercury_years_test() ->
  Seconds = 2134835688,
  equalFloat(space_age:ageOn(earth, Seconds), 67.65),
  equalFloat(space_age:ageOn(mercury, Seconds), 280.88).

age_in_venus_years_test() ->
  Seconds = 189839836,
  equalFloat(space_age:ageOn(earth, Seconds), 6.02),
  equalFloat(space_age:ageOn(venus, Seconds), 9.78).

age_in_mars_years_test() ->
  Seconds = 2329871239,
  equalFloat(space_age:ageOn(earth, Seconds), 73.83),
  equalFloat(space_age:ageOn(mars, Seconds), 39.25).

age_in_jupiter_years_test() ->
  Seconds = 901876382,
  equalFloat(space_age:ageOn(earth, Seconds), 28.58),
  equalFloat(space_age:ageOn(jupiter, Seconds), 2.41).

age_in_saturn_years_test() ->
  Seconds = 3000000000,
  equalFloat(space_age:ageOn(earth, Seconds), 95.06),
  equalFloat(space_age:ageOn(saturn, Seconds), 3.23).

age_in_uranus_years_test() ->
  Seconds = 3210123456,
  equalFloat(space_age:ageOn(earth, Seconds), 101.72),
  equalFloat(space_age:ageOn(uranus, Seconds), 1.21).

age_in_neptune_years_test() ->
  Seconds = 8210123456,
  equalFloat(space_age:ageOn(earth, Seconds), 260.16),
  equalFloat(space_age:ageOn(neptune, Seconds), 1.58).

equalFloat(A, B) ->
  ?assertEqual(B, round(A,2)).

round(Number, Precision) ->
  P = math:pow(10, Precision),
  round(Number * P) / P.

version_test() ->
  ?assertMatch(1, space_age:test_version()).

Version data entries

116 entries across 116 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.118 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.117 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.116 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.115 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.114 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.113 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.111 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.110 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.109 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.108 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.107 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.106 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.105 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.104 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.103 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.102 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.101 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.100 tracks/erlang/exercises/space-age/test/space_age_tests.erl
trackler-2.2.1.99 tracks/erlang/exercises/space-age/test/space_age_tests.erl