aboutsummaryrefslogtreecommitdiff
path: root/test-suite/ltac2
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2021-01-21 14:26:19 +0100
committerPierre-Marie Pédrot2021-01-22 11:55:21 +0100
commit56e2c0391dda94b80fab8c8993ea17ea5d807797 (patch)
tree8b68b438b33e9924ae748fe8d56653b468295e48 /test-suite/ltac2
parent0c1af31e9d338a13b7df2b4468b81e76ef182d32 (diff)
Add tests for the printf feature.
Diffstat (limited to 'test-suite/ltac2')
-rw-r--r--test-suite/ltac2/printf.v31
1 files changed, 31 insertions, 0 deletions
diff --git a/test-suite/ltac2/printf.v b/test-suite/ltac2/printf.v
new file mode 100644
index 0000000000..f96a01a9c9
--- /dev/null
+++ b/test-suite/ltac2/printf.v
@@ -0,0 +1,31 @@
+Require Import Ltac2.Ltac2.
+Require Import Ltac2.Printf.
+
+(* Check that the arguments have type unit *)
+Ltac2 ignore (x : unit) := ().
+
+Ltac2 dummy (_ : unit) (_ : int) := Message.of_string "dummy".
+
+(** Simple test for all specifications *)
+
+Ltac2 Eval ignore (printf "%i" 42).
+Ltac2 Eval ignore (printf "%s" "abc").
+Ltac2 Eval ignore (printf "%I" @Foo).
+Ltac2 Eval ignore (printf "%t" '(1 + 1 = 0)).
+Ltac2 Eval ignore (printf "%%").
+Ltac2 Eval ignore (printf "%a" dummy 18).
+
+(** More complex tests *)
+
+Ltac2 Eval ignore (printf "%I foo%a bar %s" @ok dummy 18 "yes").
+
+Ltac2 Eval Message.print (fprintf "%I foo%a bar %s" @ok dummy 18 "yes").
+
+(** Failure tests *)
+
+Fail Ltac2 Eval printf "%i" "foo".
+Fail Ltac2 Eval printf "%s" 0.
+Fail Ltac2 Eval printf "%I" "foo".
+Fail Ltac2 Eval printf "%t" "foo".
+Fail Ltac2 Eval printf "%a" (fun _ _ => ()).
+Fail Ltac2 Eval printf "%a" (fun _ i => Message.of_int i) "foo".