From 8d5803116f9b4b684a09f8d0179f6a969a94b9e5 Mon Sep 17 00:00:00 2001 From: Maiste Date: Tue, 24 Oct 2023 14:04:28 +0200 Subject: [PATCH] Support texttest with OCaml --- ocaml/dune-project | 1 - ocaml/gilded_rose.opam | 1 - ocaml/lib/dune | 1 - ocaml/lib/gilded_rose.ml | 15 ++++++++++++--- texttests/config.gr | 3 +++ 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ocaml/dune-project b/ocaml/dune-project index 6eb4f1cd..8d314b1d 100644 --- a/ocaml/dune-project +++ b/ocaml/dune-project @@ -16,6 +16,5 @@ (depends (ocaml (>= 4.08)) dune - ppx_deriving (alcotest (>= 1.7.0)))) diff --git a/ocaml/gilded_rose.opam b/ocaml/gilded_rose.opam index 2400917f..7408f6cb 100644 --- a/ocaml/gilded_rose.opam +++ b/ocaml/gilded_rose.opam @@ -12,7 +12,6 @@ bug-reports: depends: [ "ocaml" {>= "4.08"} "dune" {>= "3.11"} - "ppx_deriving" "alcotest" {>= "1.7.0"} "odoc" {with-doc} ] diff --git a/ocaml/lib/dune b/ocaml/lib/dune index f3ac778b..2ef54c3f 100644 --- a/ocaml/lib/dune +++ b/ocaml/lib/dune @@ -1,3 +1,2 @@ (library - (preprocess (pps ppx_deriving.show)) (name gilded_rose)) diff --git a/ocaml/lib/gilded_rose.ml b/ocaml/lib/gilded_rose.ml index 6a2d0946..0087f654 100644 --- a/ocaml/lib/gilded_rose.ml +++ b/ocaml/lib/gilded_rose.ml @@ -1,14 +1,23 @@ module Item = struct - type t = { name : string; sell_in : int; quality : int } [@@deriving show] + type t = { name : string; sell_in : int; quality : int } + + let show { name; sell_in; quality } = + Printf.printf "%s, %d, %d" name sell_in quality let v name sell_in quality = { name; sell_in; quality } end module Items = struct - type items = Item.t list [@@deriving show] + type items = Item.t list let v ?(items = []) () = items - let show items : string = show_items items + + let show items = + List.iter + (fun item -> + Item.show item; + Printf.printf "\n") + items let update_quality items = let update_quality_items ({ name; sell_in; quality } as item : Item.t) = diff --git a/texttests/config.gr b/texttests/config.gr index 6e5f9ee2..82e47242 100755 --- a/texttests/config.gr +++ b/texttests/config.gr @@ -39,4 +39,7 @@ diff_program:meld #executable:${TEXTTEST_HOME}/php/fixtures/texttest_fixture.php #interpreter:php +# Settings for the OCaml version +# executable:${TEXTTEST_HOME}/ocaml/_build/default/bin/main.exe + filename_convention_scheme:standard