Skip to content

Commit 06f5e57

Browse files
committed
upate test
1 parent fec4438 commit 06f5e57

File tree

1 file changed

+52
-23
lines changed

1 file changed

+52
-23
lines changed

tests/Compilation/positive/test092.juvix

+52-23
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,60 @@ module test092;
22

33
import Stdlib.Prelude as Prelude open;
44

5-
n1 : Nat := suc zero;
6-
n2 : Nat := suc n1;
7-
n3 : Nat := suc n2;
8-
n4 : Nat := suc n3;
9-
n5 : Nat := suc n4;
10-
n6 : Nat := suc n5;
5+
module Parity;
6+
trait
7+
type Even (n : Nat) := proof;
8+
9+
trait
10+
type Odd (n : Nat) := proof;
11+
12+
instance
13+
Even-zero : Even zero := Even.proof;
14+
15+
instance
16+
Even-suc {n : Nat} {{Even n}} : Even (suc (suc n)) := Even.proof;
17+
18+
instance
19+
Odd-suc {n : Nat} {{Even n}} : Odd (suc n) := Odd.proof;
20+
21+
checkEven (n : Nat) {{Even n}} : Unit := unit;
22+
23+
checkOdd (n : Nat) {{Odd n}} : Unit := unit;
24+
25+
test : _ :=
26+
let
27+
one : Nat := 1;
28+
two : Nat := suc one;
29+
e1 : uint 20 := uint.mk 87;
30+
e2 : uint zero := uint.mk 87;
31+
e3 : uint (suc zero) := uint.mk 87;
32+
p1 : Unit := checkEven zero;
33+
p3 : Unit := checkOdd (suc 0);
34+
p2 : Unit := checkEven 2;
35+
p4 : Unit := checkEven two;
36+
p5 : Unit := checkEven 4;
37+
p6 : Unit := checkOdd 3;
38+
in unit;
39+
end;
1140

1241
type uint (bytes : Nat) := mk Nat
1342
with
1443
instance
15-
Show-uint {bytes : Nat} : Show (uint bytes) :=
44+
Show-uint {bytes : Nat} : Show (uint (suc bytes)) :=
1645
Show.mk@{
17-
show : uint bytes -> String
46+
show : uint (suc bytes) -> String
1847
| (uint.mk val) := Show.show bytes ++str ":" ++str Show.show val;
1948
};
49+
50+
51+
main : _ :=
52+
let
53+
e1 : uint 20 := uint.mk 87;
54+
e2 : uint zero := uint.mk 87;
55+
e3 : uint (suc zero) := uint.mk 87;
56+
in printStringLn (Show.show e1)
57+
>>> printStringLn (Show.show e1)
58+
>>> printStringLn (Show.show e3);
2059
end;
2160

2261
module Le;
@@ -32,21 +71,11 @@ module Le;
3271
le-suc {a b : Nat} {{a '<= b}} : suc a '<= suc b := truth;
3372
end;
3473

35-
test (a b : Nat) {{a '<= b}} : Unit := unit;
74+
le (a b : Nat) {{a '<= b}} : Unit := unit;
75+
76+
example1 : Unit := le 1 5;
3677

37-
example1 : Unit := test n1 n4;
38-
example2 : Unit := test n4 n4;
39-
-- example3 : Unit := test 1 3;
78+
example2 : Unit := le 4 4;
4079
end;
4180

42-
main : _ :=
43-
let
44-
z : uint zero := uint.mk 5;
45-
e : uint n2 := uint.mk 5;
46-
e3 : uint (suc (suc (suc zero))) := uint.mk 5;
47-
e4 : uint 7 := uint.mk 87;
48-
in printStringLn (Show.show z)
49-
>>> printStringLn (Show.show e)
50-
>>> printStringLn (Show.show e3)
51-
>>> printStringLn (Show.show e3)
52-
>>> printStringLn (Show.show {{_}} e4);
81+
open uint using {main} public;

0 commit comments

Comments
 (0)