Sha256: 4e5476f13ee74593a08873deb72e3c0df77a80fddd46caf44c704718d37c7749

Contents?: true

Size: 1.47 KB

Versions: 70

Compression:

Stored size: 1.47 KB

Contents

open Core

open Utils
open Yojson.Basic

type case = {
  description: string;
  parameters: (string * json) list
}

type test = {name: string; cases: case list}

type tests =
  | Single of case list
  | Suite of test list

type canonical_data = {
  version: string option;
  tests: tests
}

let rec json_to_string (j: json): string = match j with
  | `Null -> "null"
  | `String s -> "\"" ^ (String.escaped s) ^ "\""
  | `Float f -> Float.to_string f
  | `Int n -> Int.to_string n
  | `Bool b -> Bool.to_string b
  | `List xs -> "[" ^ String.concat ~sep:"; " (List.map ~f:json_to_string xs) ^ "]"
  | `Assoc xs -> "[" ^ String.concat ~sep:"; "
                         (List.map xs ~f:(fun (k,v) -> "(\"" ^ String.escaped k ^ "\", " ^ json_to_string v ^ ")")) ^ "]"

let list_to_string = String.concat ~sep:"; " 

let json_assoc_to_string (xs: (string * json) list): string =
  List.map xs ~f:(fun (k, j) -> k ^ ": " ^ (json_to_string j))
  |> list_to_string

let case_to_string {description; parameters}: string =
  "{description: " ^ description ^ "; parameters: " ^ (json_assoc_to_string parameters) ^ "}"

let cases_to_string cases = list_to_string (List.map ~f:case_to_string cases)

let test_to_string {name; cases}: string =
  "{name: " ^ name ^ "; cases: " ^ (cases_to_string cases) ^ "}"

let tests_to_string tests: string =
  "[" ^ list_to_string (List.map tests ~f:test_to_string) ^ "]"
  
let tests_to_string = function
| Single case -> cases_to_string case
| Suite tests -> tests_to_string tests

Version data entries

70 entries across 70 versions & 1 rubygems

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