Skip to content

Commit

Permalink
Added several tests for "splice" and "typed var becomes" inside or
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Jun 28, 2024
1 parent cfd638d commit 22e0023
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,9 @@ test bool matchListSpliceVars4() = [1, * int _, 4, 5] := [1, 2, 3, 4, 5];
test bool matchListSpliceVars5() = [1, *L, 4, *L, 5] := [1, 2, 3, 4, 2, 3, 5] && L == [2, 3];
test bool matchListSpliceVars6() = [1, * int L, 4, *L, 5] := [1, 2, 3, 4, 2, 3, 5] && L == [2, 3];

test bool matchListSpliceVarsInOr()
= [1,2,3] == (([*int x] := [1,2,3] || [*int x] := [10,20,30]) ? x : []);

// match list of tuples

test bool matchListTuples1() = [<1, 2, 3>] := [<1, 2, 3>];
Expand Down Expand Up @@ -948,6 +951,9 @@ test bool matchTypedListVarBecomes2() = [1, list[int] L: [int _], 2] := [1,[2],2
test bool matchTypedListVarBecomes3() = [1, list[int] L1: [*int L2, int N], 5] := [1,[2,3,4],5] && L1 == [2,3,4] && L2 == [2,3] && N == 4;
test bool matchTypedListVarBecomes4() = [1, list[int] L1: [*int L2, int N], L1] := [1,[2,3,4],[2,3,4]] && L1 == [2,3,4] && L2 == [2,3] && N == 4;

test bool matchTypedListVarInOr() =
1 == (([int x: 1] := [1] || [int x: 10] := [10]) ? x : -1);

data D = d(int n);

test bool listNamedElem1() = [n:d(1)] := [d(1)] && n == d(1);
Expand All @@ -957,3 +963,5 @@ test bool listNamedElem3() = [_n:d(2)] !:= [d(1)];
test bool listTypeNamedElem1() = [D n:d(1)] := [d(1)] && n == d(1);
test bool listTypeNamedElem2() = [D _:d(1)] := [d(1)];
test bool listTypeNamedElem3() = [D _n:d(2)] !:= [d(1)];


Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,12 @@ test bool matchSetSpliceVars2() = {1, * int S, 4, 5}:= {1, 2, 3, 4, 5} && S == {
test bool matchSetSpliceVars3() = {1, *_, 4, 5} := {1, 2, 3, 4, 5};
test bool matchSetSpliceVars4() = {1, * int _, 4, 5} := {1, 2, 3, 4, 5};

test bool matchSetSpliceVarInOr()
= {1,2,3} == (({*int x} := {1,2,3} || {*int x} := {10,20,30}) ? x : {});

test bool matchTypedSetVarInOr() =
1 == (({int x: 1} := {1} || {int x: 10} := {10}) ? x : -1);

// match set of tuples

test bool matchSetTuples1() = {<1, 2, 3>} := {<1, 2, 3>};
Expand Down

0 comments on commit 22e0023

Please sign in to comment.