aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarc Coquand <marc@mccd.space>2023-12-20 20:46:00 -0600
committerMarc Coquand <marc@mccd.space>2023-12-25 18:22:59 -0600
commit262f161f42c4e59beec41c6f440336c38385426a (patch)
tree6491c9b661a0b5a14c9a30ecf25e036f8762239d /test
parentcc783c157f31e7e713c8b83be67449b1859dac27 (diff)
downloadfixgen-262f161f42c4e59beec41c6f440336c38385426a.tar.gz
fixgen-262f161f42c4e59beec41c6f440336c38385426a.tar.bz2
fixgen-262f161f42c4e59beec41c6f440336c38385426a.zip
Initial commit
Diffstat (limited to 'test')
-rw-r--r--test/ann_bloop.ml0
-rw-r--r--test/dune3
-rw-r--r--test/test_parser.ml38
3 files changed, 40 insertions, 1 deletions
diff --git a/test/ann_bloop.ml b/test/ann_bloop.ml
deleted file mode 100644
index e69de29..0000000
--- a/test/ann_bloop.ml
+++ /dev/null
diff --git a/test/dune b/test/dune
index bfa3196..806bce1 100644
--- a/test/dune
+++ b/test/dune
@@ -1,2 +1,3 @@
(test
- (name ann_bloop))
+ (name test_parser)
+ (libraries fixgen alcotest))
diff --git a/test/test_parser.ml b/test/test_parser.ml
new file mode 100644
index 0000000..bfc980c
--- /dev/null
+++ b/test/test_parser.ml
@@ -0,0 +1,38 @@
+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" )
+ ]
+
+
+let () =
+ Alcotest.run
+ "Parsing"
+ [ "Tables", table_suite; "Rows", rows_suite; "Relations", relations_suite ]