Skip to content

Commit 3254a7d

Browse files
pmderodatraph-amiard
authored andcommitted
Adalog: add tests for the handling of dependency cycles
TN: SB20-024 For libadalang/langkit#618
1 parent 852f847 commit 3254a7d

File tree

6 files changed

+63
-0
lines changed

6 files changed

+63
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- Check that the solver correctly handles an equation that involve a cycle in
2+
-- variable definitions, when that cycle can be resolved anyway.
3+
4+
with Langkit_Support.Adalog.Main_Support;
5+
use Langkit_Support.Adalog.Main_Support;
6+
7+
procedure Main is
8+
use T_Solver, Refs, Solver_Ifc;
9+
10+
X : constant Refs.Logic_Var := Create ("X");
11+
Y : constant Refs.Logic_Var := Create ("Y");
12+
R : constant Relation :=
13+
R_All ((Propagate (X, Y),
14+
Propagate (Y, X),
15+
Assign (X, 1)));
16+
begin
17+
Solve_All (R);
18+
end Main;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Solving relation:
2+
All:
3+
%Y <- %X
4+
%X <- %Y
5+
%X <- 1
6+
7+
... without optimizations:
8+
Solution: [%Y = 1, %X = 1]
9+
10+
... with all optimizations:
11+
Solution: [%Y = 1, %X = 1]
12+
13+
Done.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
driver: adalog
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- Check that the solver correctly handles an equation that involve a cycle in
2+
-- variable definitions, when that cycle cannot be resolved.
3+
4+
with Langkit_Support.Adalog.Main_Support;
5+
use Langkit_Support.Adalog.Main_Support;
6+
7+
procedure Main is
8+
use T_Solver, Refs, Solver_Ifc;
9+
10+
X : constant Refs.Logic_Var := Create ("X");
11+
Y : constant Refs.Logic_Var := Create ("Y");
12+
Z : constant Refs.Logic_Var := Create ("Z");
13+
R : constant Relation :=
14+
R_All ((Propagate (X, Y),
15+
Propagate (Y, Z),
16+
Propagate (Z, X)));
17+
begin
18+
Solve_All (R);
19+
end Main;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Solving relation:
2+
All:
3+
%Y <- %X
4+
%Z <- %Y
5+
%X <- %Z
6+
7+
... without optimizations:
8+
9+
... with all optimizations:
10+
11+
Done.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
driver: adalog

0 commit comments

Comments
 (0)