refactor: Syntax with unit tests

This commit is contained in:
Lucàs
2024-07-08 16:44:42 +02:00
parent 6df363c78d
commit 2e76ccf9fc
39 changed files with 460 additions and 771 deletions
+24
View File
@@ -0,0 +1,24 @@
open Alcotest
open Syntax
let test_pp_source_files () =
let to_check =
[
( "Should return \"SourceFile(...)\"",
"SourceFile(ExpressionStatement(BinaryExpression(Add, \
Literal(Integer(1)), Literal(Integer(2)))))",
SourceFiles.SourceFile
(Statements.ExpressionStatement
(Expressions.BinaryExpression
( BinaryOperators.Add,
Expressions.Literal (Literals.Integer 1),
Expressions.Literal (Literals.Integer 2) ))) );
]
in
List.iter
(fun (name, expected, actual) ->
check string name expected (SourceFiles.pp_source_files actual))
to_check
let tests =
("SourceFiles", [ test_case "pp_source_files" `Quick test_pp_source_files ])