open Ast

let parse_config config = 
  let lexbuf = Lexing.from_string config in 
   Parser.main Lexer.read_token lexbuf 

let () =
  assert (parse_config "[id]\ntype=string\nvalues=[test, test]" = Columns([
    Column(
      "id",
      String,
      Values(["test";"test"])
    )
  ])
);

  assert (parse_config "[id]\n type = int \n range = [7, 77]" = Columns([
    Column(
      "id",
      Int,
      Range("7","77")
    )
  ])
);
  assert (parse_config "[id]\ntype=int\nrange=[7,77]\n\n[name]\ntype=string\nvalues=[Alice,Bob]" = 
  Columns([
    Column(
      "id",
      Int,
      Range("7","77")
    );
    Column(
      "name",
      String,
      Values(["Alice";"Bob"])
    )
  ])
);


  let ic = open_in "files/test1.toml" in
  let len = in_channel_length ic in
  let config = really_input_string ic len in
  print_string config;
  
  let cols = parse_config config in
  assert (cols = 
    Columns([
      Column(
        "id",
        Int,
        Range("0", "1000")
      )
    ])
  );
