Sha256: 7889e0cae8b3a04ab8afb76aa3e2466b356f1faad935c24806990b990d4539fd

Contents?: true

Size: 1.18 KB

Versions: 156

Compression:

Stored size: 1.18 KB

Contents

open Core
open OUnit2
open Beer_song

let zip s1 s2 = 
  let rec go s1 s2 acc = match (s1,s2) with
  | ([], _) -> acc
  | (_, []) -> acc
  | (x::xs, y::ys) -> go xs ys ((x,y)::acc) in List.rev @@ go s1 s2 []

 let find_diffs s1 s2 =
   let s1 = String.to_list s1 in
   let s2 = String.to_list s2 in
   let both = zip s1 s2 in
   List.find_mapi both ~f:(fun i (c1, c2) -> if c1 = c2 then None else Some (sprintf "Diff at index %d: %c <> %c" i c1 c2))
 
 let diff_message s1 s2 = match find_diffs s1 s2 with
 | None -> if String.length s1 = String.length s2 then "" else "Lengths of expected and actual differ but have a common prefix."
 | Some m -> m
 
 let ae exp got _test_ctxt = 
   if exp = got 
    then ()
    else failwith @@ "Expected differs from actual: " ^ (diff_message exp got)

let (* SUITE verse *)verse_tests = [
(* TEST
   "$description" >::
     ae $expected 
     (verse $number);
   END TEST *)
]
(* END SUITE *)

let (* SUITE lyrics *)lyrics_tests = [
(* TEST
   "$description" >::
     ae $expected 
     (lyrics ~from:$beginning ~until:$end);
   END TEST *)
]
(* END SUITE *)

let () =
  run_test_tt_main (
    "beer song tests" >:::
      List.concat [verse_tests; lyrics_tests]
  )

Version data entries

156 entries across 156 versions & 1 rubygems

Version Path
trackler-2.2.1.35 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.34 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.33 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.32 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.31 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.30 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.29 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.28 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.27 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.26 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.25 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.24 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.23 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.22 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.21 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.20 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.19 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.18 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.17 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml
trackler-2.2.1.16 tracks/ocaml/tools/test-generator/templates/ocaml/beer-song/test.ml