open Alcotest open Fixgen let parse (s : string) = let lexbuf = Lexing.from_string s in let ast = Parser.prog Lexer.read lexbuf in ast let test_parse s () = let ast = parse s in check bool "Parses" (Option.is_some ast) true let table_suite = [ "Can use underscore for table names", `Quick, test_parse "user_all: name uuidv4" ] let rows_suite = [ "Can parse uuidv4", `Quick, test_parse "user: id uuidv4" ; ( "Can parse multiple tables" , `Quick , test_parse "user: id uuidv4\npurchases: id uuidv4" ) ; "Resolves conflicting names", `Quick, test_parse "purchases: name uuidv4" ] let relations_suite = [ ( "Can reference other tables" , `Quick , test_parse "user: id uuidv4\npurchases: id uuidv4, user_id user.id" ) ; "Can use ; as a separator", `Quick, test_parse "user: id uuidv4; purchases: id uuidv4" ] let () = Alcotest.run "Parsing" [ "Tables", table_suite; "Rows", rows_suite; "Relations", relations_suite ]