Sha256: 411b4cd84ce2d30e02aeadeb39931f42ff05485ec123d25e2fbb820432ac9a1f

Contents?: true

Size: 1.06 KB

Versions: 159

Compression:

Stored size: 1.06 KB

Contents

open Core

open Model
open Yojson.Basic

type edit_parameters_function = (string * json) list -> (string * string) list

type subst = Subst of string [@@deriving eq, show]

let subst_to_string (Subst s) = s

let map_subst (s: subst) ~(f: string -> string): subst =
  Subst (subst_to_string s |> f)

let replace_key (key: string) (value: string) (target: string): string =
  let replace = String.substr_replace_all ~with_:value in
  replace ~pattern:("$" ^ key) target |> replace ~pattern:("$(" ^ key ^ ")")

let rec replace_keys (ed: edit_parameters_function) (s: string) (suite_name: string) (c: case): subst =
  let s = replace_key "description" c.description s in
  let s = replace_key "suite-name" suite_name s in
  let parameter_strings = ed @@ List.map ~f:(fun (k,p) -> (k,p)) c.parameters in
  List.fold parameter_strings ~init:(Subst s) ~f:(fun (Subst s) (k,v) -> Subst (replace_key k v s))

let fill_in_template (ed: edit_parameters_function) (test_template: string) (suite_name: string) (cases: case list) =
  List.map cases ~f:(replace_keys ed test_template suite_name)

Version data entries

159 entries across 159 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.179 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.178 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.177 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.176 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.175 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.174 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.173 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.172 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.171 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.170 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.169 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.167 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.166 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.165 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.164 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.163 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.162 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.161 tracks/ocaml/tools/test-generator/src/codegen.ml
trackler-2.2.1.160 tracks/ocaml/tools/test-generator/src/codegen.ml