Sha256: 7fe09a1f8d825bcfd410055185f7945ded6e55d3e334d2b9b0561f32e4b39cf6

Contents?: true

Size: 1.54 KB

Versions: 123

Compression:

Stored size: 1.54 KB

Contents

open Core.Std
open OUnit2
open Space_age

(* Assert In Delta *)
let aid ~d:delta exp got =
  let msg = sprintf "Expected %f got %f, difference is greater than %f"
                    exp got delta in
  assert_bool msg (cmp_float ~epsilon:delta exp got)

let tests =
  ["age in Earth years">:: (fun _ ->
    let input = 1_000_000_000 in
    aid ~d:0.005 31.69 (age_on Earth input));
   "age in Mercury years">:: (fun _ ->
    let input = 2_134_835_688 in
    aid ~d:0.005 67.65 (age_on Earth input);
    aid ~d:0.005 280.88 (age_on Mercury input));
   "age in Venus years">:: (fun _ -> 
    let input = 189_839_836 in
    aid ~d:0.005 6.02 (age_on Earth input);
    aid ~d:0.005 9.78 (age_on Venus input));
   "age in Mars years">:: (fun _ ->
    let input = 2_329_871_239 in
    aid ~d:0.005 73.83 (age_on Earth input);
    aid ~d:0.005 39.25 (age_on Mars input));
   "age in Jupiter years">:: (fun _ ->
    let input = 901_876_382 in
    aid ~d:0.005 28.58 (age_on Earth input);
    aid ~d:0.005 2.41 (age_on Jupiter input));
   "age in Saturn years">:: (fun _ ->
    let input = 3_000_000_000 in
    aid ~d:0.005 95.06 (age_on Earth input);
    aid ~d:0.005 3.23 (age_on Saturn input));
   "age in Neptune years">:: (fun _ ->
    let input = 8_210_123_456 in
    aid ~d:0.005 260.16 (age_on Earth input);
    aid ~d:0.005 1.58 (age_on Neptune input));
   "age in Uranus years">:: (fun _ ->
    let input = 3_210_123_456 in
    aid ~d:0.005 101.72 (age_on Earth input);
    aid ~d:0.005 1.21 (age_on Uranus input))
  ]

let () =
  run_test_tt_main ("space-age tests" >::: tests)

Version data entries

123 entries across 123 versions & 1 rubygems

Version Path
trackler-2.0.8.22 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.21 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.20 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.19 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.18 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.17 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.16 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.15 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.14 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.13 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.12 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.11 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.10 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.9 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.8 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.7 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.6 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.5 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.4 tracks/ocaml/exercises/space-age/test.ml
trackler-2.0.8.3 tracks/ocaml/exercises/space-age/test.ml