aboutsummaryrefslogtreecommitdiff
path: root/test/get_type.ml
diff options
context:
space:
mode:
authorChimrod <>2025-07-19 11:18:24 +0200
committerChimrod <>2025-08-01 14:12:14 +0200
commit3046fb0d0c1ceac2c6a6ca9456e9e05671e0cef9 (patch)
tree8ba2700e541a6753499ceac54ced4f1d02a3b625 /test/get_type.ml
parent406b7b79cd375b071f92ddee9cee14a98dc91281 (diff)
Added dependencies system between the modules in the checksHEADmaster
Diffstat (limited to 'test/get_type.ml')
-rw-r--r--test/get_type.ml68
1 files changed, 37 insertions, 31 deletions
diff --git a/test/get_type.ml b/test/get_type.ml
index 55f087e..56b4689 100644
--- a/test/get_type.ml
+++ b/test/get_type.ml
@@ -3,79 +3,84 @@ module T = Qsp_syntax.T
let _position = (Lexing.dummy_pos, Lexing.dummy_pos)
-let type_of : Get_type.t Alcotest.testable =
- Alcotest.testable Get_type.pp Get_type.equal
+let type_of : Get_type.Expression.t Alcotest.testable =
+ Alcotest.testable Get_type.Expression.pp Get_type.Expression.equal
+
+let ctx = Qsp_syntax.S.{ f = (fun _ -> None) }
let add_number () =
let actual =
- Get_type.boperator _position T.Plus
- (Get_type.integer _position "0")
- (Get_type.integer _position "1")
+ Get_type.Expression.boperator ~ctx _position T.Plus
+ (Get_type.Expression.integer ~ctx _position "0")
+ (Get_type.Expression.integer ~ctx _position "1")
in
- let expected = Get_type.(Raw Integer) in
+ let expected = Get_type.Expression.(Raw Integer) in
let msg = "Adding integer" in
Alcotest.(check' type_of ~msg ~expected ~actual)
let add_literal_number () =
let actual =
- Get_type.boperator _position T.Plus
- (Get_type.literal _position [ T.Text "2" ])
- (Get_type.integer _position "1")
+ Get_type.Expression.boperator ~ctx _position T.Plus
+ (Get_type.Expression.literal ~ctx _position [ T.Text "2" ])
+ (Get_type.Expression.integer ~ctx _position "1")
in
- let expected = Get_type.(Raw Integer) in
+ let expected = Get_type.Expression.(Raw Integer) in
let msg = "A string containing integer is considered as integer" in
Alcotest.(check' type_of ~msg ~expected ~actual)
let concat_text () =
let actual =
- Get_type.boperator _position T.Plus
- (Get_type.literal _position [ T.Text "a" ])
- (Get_type.integer _position "1")
+ Get_type.Expression.boperator ~ctx _position T.Plus
+ (Get_type.Expression.literal ~ctx _position [ T.Text "a" ])
+ (Get_type.Expression.integer ~ctx _position "1")
in
- let expected = Get_type.(Raw String) in
+ let expected = Get_type.Expression.(Raw String) in
let msg = "Concatenate" in
Alcotest.(check' type_of ~msg ~expected ~actual)
let literal_1 () =
let actual =
- Get_type.literal _position [ T.Expression (Get_type.Raw Integer) ]
- and expected = Get_type.(Raw NumericString) in
+ Get_type.Expression.literal ~ctx _position
+ [ T.Expression (Get_type.Expression.Raw Integer) ]
+ and expected = Get_type.Expression.(Raw NumericString) in
let msg = "" in
Alcotest.(check' type_of ~msg ~expected ~actual)
let literal_2 () =
let actual =
- Get_type.literal _position
- Get_type.[ T.Text "1"; T.Expression (Raw Integer) ]
- and expected = Get_type.(Raw NumericString) in
+ Get_type.Expression.literal ~ctx _position
+ Get_type.Expression.[ T.Text "1"; T.Expression (Raw Integer) ]
+ and expected = Get_type.Expression.(Raw NumericString) in
let msg = "" in
Alcotest.(check' type_of ~msg ~expected ~actual)
let literal_3 () =
let actual =
- Get_type.literal _position
- Get_type.[ T.Text "b"; T.Expression (Raw Integer) ]
- and expected = Get_type.(Raw String) in
+ Get_type.Expression.literal ~ctx _position
+ Get_type.Expression.[ T.Text "b"; T.Expression (Raw Integer) ]
+ and expected = Get_type.Expression.(Raw String) in
let msg = "" in
Alcotest.(check' type_of ~msg ~expected ~actual)
let literal_4 () =
let actual =
- Get_type.literal _position [ T.Expression (Get_type.Variable Integer) ]
- and expected = Get_type.(Variable NumericString) in
+ Get_type.Expression.literal ~ctx _position
+ Get_type.Expression.[ T.Expression (Variable Integer) ]
+ and expected = Get_type.Expression.(Variable NumericString) in
let msg = "" in
Alcotest.(check' type_of ~msg ~expected ~actual)
let min () =
- let actual = Get_type.function_ _position T.Min [] in
- let expected = Get_type.(Raw Bool) in
+ let actual = Get_type.Expression.function_ ~ctx _position T.Min [] in
+ let expected = Get_type.Expression.(Raw Bool) in
let msg = "The function min without argument return a default value" in
Alcotest.(check' type_of ~msg ~expected ~actual);
let actual =
- Get_type.function_ _position T.Min [ Get_type.literal _position [] ]
+ Get_type.Expression.function_ ~ctx _position T.Min
+ [ Get_type.Expression.literal ~ctx _position [] ]
in
- let expected = Get_type.(Variable NumericString) in
+ let expected = Get_type.Expression.(Variable NumericString) in
let msg =
"The function min with a literal will take the literal as the name of an \
array"
@@ -83,10 +88,11 @@ let min () =
Alcotest.(check' type_of ~msg ~expected ~actual);
let actual =
- Get_type.function_ _position T.Min
- [ Get_type.integer _position ""; Get_type.integer _position "" ]
+ Get_type.Expression.function_ ~ctx _position T.Min
+ Get_type.Expression.
+ [ integer ~ctx _position ""; integer ~ctx _position "" ]
in
- let expected = Get_type.(Raw Integer) in
+ let expected = Get_type.Expression.(Raw Integer) in
let msg = "With two or more arguments, return the type of the first one" in
Alcotest.(check' type_of ~msg ~expected ~actual)