Skip to content

Commit 0f2db72

Browse files
lyonel2017strub
authored andcommitted
Split exception examples into unit tests
1 parent e9b0c1c commit 0f2db72

9 files changed

Lines changed: 272 additions & 252 deletions

config/tests.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ exclude = examples/MEE-CBC examples/old examples/old/list-ddh !examples/incomple
1414
okdirs = examples/MEE-CBC
1515

1616
[test-unit]
17-
okdirs = tests
17+
okdirs = !tests

examples/exception.ec

Lines changed: 0 additions & 251 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
require import AllCore.
2+
3+
abstract theory Et.
4+
type t.
5+
6+
op test : t -> bool.
7+
8+
op truc : t -> exn.
9+
10+
exception et of t.
11+
exception et2 of t * t.
12+
13+
print et2.
14+
15+
module Truc = {
16+
proc f (x:t):t = {
17+
if (test x) {raise (et x);}
18+
return x;
19+
}
20+
}.
21+
22+
axiom hf : forall (_x :t), hoare [Truc.f : _x = x ==> res = _x | et x => test x = false].
23+
end Et.
24+
25+
require import List.
26+
27+
exception et1 of int.
28+
29+
clone Et as H with
30+
type t <- int.
31+
32+
print H.
33+
print H.truc.
34+
print H.et.
35+
print H.et2.
36+
37+
fail clone Et as H' with
38+
type t <- int,
39+
op et <- et1.
40+
41+
clone Et as H' rename [exception] "et" as "ett".
42+
43+
print H'.
44+
45+
clone Et as H'' rename [op] "t" as "ett".
46+
47+
print H''.

tests/exception/exception_args.ec

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require import AllCore.
2+
3+
exception arg1 of int.
4+
5+
op toto i = arg1 i.
6+
7+
module M3 = {
8+
proc f () = {
9+
raise (toto 3);
10+
}
11+
}.
12+
13+
lemma test5 :
14+
hoare [M3.f : true ==> false | arg1 x => x = 3].
15+
proof.
16+
proc. wp. skip => //.
17+
qed.
18+
19+
lemma test6 :
20+
hoare [M3.f : true ==> false | arg1 x => x = 3].
21+
proof.
22+
conseq (: _ ==> _ | arg1 x => 3 = x).
23+
+ done.
24+
proc. wp. skip => //.
25+
qed.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
require import AllCore.
2+
3+
(* exception arg ['a] of 'a. *)
4+
5+
exception evar of int.
6+
7+
op v : int.
8+
9+
module Mv ={
10+
var i:int
11+
12+
proc f1 (x:int) : int = {
13+
i <- 0;
14+
raise (evar (v + i)) ;
15+
return x;
16+
}
17+
}.
18+
19+
lemma testv :
20+
hoare [Mv.f1 : true ==> false | evar a => a = v].
21+
proof.
22+
proc. wp. skip => //.
23+
qed.

0 commit comments

Comments
 (0)