diff --git a/lib/ast/dune b/lib/ast/dune new file mode 100644 index 0000000..ffbb18b --- /dev/null +++ b/lib/ast/dune @@ -0,0 +1,3 @@ +(library + (name ast) + (modules syntax print)) diff --git a/lib/dune b/lib/dune index 21805d8..100be86 100644 --- a/lib/dune +++ b/lib/dune @@ -10,10 +10,6 @@ (modules parser) (libraries ast)) -(library - (name ast) - (modules ast)) - (menhir (modules parser)) diff --git a/test/ast.ml b/test/ast/print.ml similarity index 85% rename from test/ast.ml rename to test/ast/print.ml index 8ac9e05..80a4e64 100644 --- a/test/ast.ml +++ b/test/ast/print.ml @@ -1,7 +1,8 @@ -(* test/ast.ml *) +(* test/print.ml *) open Alcotest -open Ast +open Ast.Syntax +open Ast.Print let test_string_of_binary_operator () = check string "+" "Add" (string_of_binary_operator Add); @@ -9,6 +10,9 @@ let test_string_of_binary_operator () = check string "*" "Multiply" (string_of_binary_operator Multiply); check string "/" "Divide" (string_of_binary_operator Divide) +let test_string_of_unary_operator () = + check string "-" "Negate" (string_of_unary_operator Negate) + let test_string_of_expression () = let expr = BinaryExpression (Add, IntegerLiteral 1, IntegerLiteral 2) in check string "1 + 2" @@ -39,6 +43,11 @@ let () = let open Alcotest in run "AST tests" [ + ( "string_of_unary_operator", + [ + test_case "string_of_unary_operator" `Quick + test_string_of_unary_operator; + ] ); ( "string_of_binary_operator", [ test_case "string_of_binary_operator" `Quick diff --git a/test/dune b/test/dune index 6b4976a..d1a8ec0 100644 --- a/test/dune +++ b/test/dune @@ -1,5 +1 @@ -;test/dune - -(test - (name ast) - (libraries ast alcotest)) +;test/dune \ No newline at end of file