diff options
| author | Michael Soegtrop | 2021-03-06 17:25:33 +0100 |
|---|---|---|
| committer | Michael Soegtrop | 2021-03-06 17:25:33 +0100 |
| commit | 2c47f51a9b03b962cf688967f2ad1bdf0df448c9 (patch) | |
| tree | 694d6420b8a84cdc8aec2a34f45e794e3268613f /test-suite | |
| parent | c738d6540ddadaa29ea6b3181f6ee462792fe9ce (diff) | |
| parent | 14875457711853bcbf7021fba9490e554324a043 (diff) | |
Merge PR #13236: Add a type of format strings to Ltac2.
Reviewed-by: JasonGross
Reviewed-by: MSoegtropIMC
Diffstat (limited to 'test-suite')
| -rw-r--r-- | test-suite/ltac2/printf.v | 31 |
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". |
