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.119 tracks/ocaml/tools/test-generator/src/model.ml
trackler-2.2.1.118 tracks/ocaml/tools/test-generator/src/model.ml
trackler-2.2.1.117 tracks/ocaml/tools/test-generator/src/model.ml
trackler-2.2.1.116 tracks/ocaml/tools/test-generator/src/model.ml
trackler-2.2.1.115 tracks/ocaml/tools/test-generator/src/model.ml
trackler-2.2.1.114 tracks/ocaml/tools/test-generator/src/model.ml
trackler-2.2.1.113 tracks/ocaml/tools/test-generator/src/model.ml
trackler-2.2.1.111 tracks/ocaml/tools/test-generator/src/model.ml
trackler-2.2.1.110 tracks/ocaml/tools/test-generator/src/model.ml
trackler-2.2.1.109 tracks/ocaml/tools/test-generator/src/model.ml