mirror of
https://github.com/LucasVbr/croissant.git
synced 2026-07-09 15:07:48 +00:00
refactor: Move tests of ast in separate folder
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
(library
|
||||||
|
(name ast)
|
||||||
|
(modules syntax print))
|
||||||
@@ -10,10 +10,6 @@
|
|||||||
(modules parser)
|
(modules parser)
|
||||||
(libraries ast))
|
(libraries ast))
|
||||||
|
|
||||||
(library
|
|
||||||
(name ast)
|
|
||||||
(modules ast))
|
|
||||||
|
|
||||||
(menhir
|
(menhir
|
||||||
(modules parser))
|
(modules parser))
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
(* test/ast.ml *)
|
(* test/print.ml *)
|
||||||
|
|
||||||
open Alcotest
|
open Alcotest
|
||||||
open Ast
|
open Ast.Syntax
|
||||||
|
open Ast.Print
|
||||||
|
|
||||||
let test_string_of_binary_operator () =
|
let test_string_of_binary_operator () =
|
||||||
check string "+" "Add" (string_of_binary_operator Add);
|
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 "*" "Multiply" (string_of_binary_operator Multiply);
|
||||||
check string "/" "Divide" (string_of_binary_operator Divide)
|
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 test_string_of_expression () =
|
||||||
let expr = BinaryExpression (Add, IntegerLiteral 1, IntegerLiteral 2) in
|
let expr = BinaryExpression (Add, IntegerLiteral 1, IntegerLiteral 2) in
|
||||||
check string "1 + 2"
|
check string "1 + 2"
|
||||||
@@ -39,6 +43,11 @@ let () =
|
|||||||
let open Alcotest in
|
let open Alcotest in
|
||||||
run "AST tests"
|
run "AST tests"
|
||||||
[
|
[
|
||||||
|
( "string_of_unary_operator",
|
||||||
|
[
|
||||||
|
test_case "string_of_unary_operator" `Quick
|
||||||
|
test_string_of_unary_operator;
|
||||||
|
] );
|
||||||
( "string_of_binary_operator",
|
( "string_of_binary_operator",
|
||||||
[
|
[
|
||||||
test_case "string_of_binary_operator" `Quick
|
test_case "string_of_binary_operator" `Quick
|
||||||
Reference in New Issue
Block a user