Commit d8831558 authored by Sarah Grebing's avatar Sarah Grebing

tests

parent f2a2af9b
Pipeline #13008 failed with stage
in 4 minutes and 52 seconds
......@@ -181,26 +181,14 @@ class MatcherImpl extends MatchPatternDualVisitor<Matchings, Term> {
return NO_MATCH;
}
@Override
protected Matchings visitNumber(MatchPatternParser.NumberContext ctx, Term peek) {
//we are at a natural number
if (peek.op().name().toString().equals("Z")) {
ImmutableArray<Term> subs = peek.subs();
int transformedString = transformToNumber(peek.sub(0));
if (Integer.parseUnsignedInt(ctx.DIGITS().getText()) == transformedString) {
return EMPTY_MATCH;
} else {
return NO_MATCH;
}
} else {
return NO_MATCH;
}
}
private int transformToNumber(Term sub) {
List<Integer> integ = transformHelper(new ArrayList<>(), sub);
/**
* Trasnform a term taht represent a number to int
*
* @param sub
* @return
*/
public static int transformToNumber(Term sub) {
List<Integer> integ = MatcherImpl.transformHelper(new ArrayList<>(), sub);
int dec = 10;
int output = integ.get(0);
......@@ -212,10 +200,9 @@ class MatcherImpl extends MatchPatternDualVisitor<Matchings, Term> {
return output;
}
private List<Integer> transformHelper(List<Integer> l, Term sub) {
private static List<Integer> transformHelper(List<Integer> l, Term sub) {
if (sub.op().name().toString().equals("#")) {
return l;
} else {
......@@ -224,6 +211,24 @@ class MatcherImpl extends MatchPatternDualVisitor<Matchings, Term> {
}
}
@Override
protected Matchings visitNumber(MatchPatternParser.NumberContext ctx, Term peek) {
//we are at a number
if (peek.op().name().toString().equals("Z")) {
ImmutableArray<Term> subs = peek.subs();
int transformedString = transformToNumber(peek.sub(0));
if (Integer.parseUnsignedInt(ctx.DIGITS().getText()) == transformedString) {
return EMPTY_MATCH;
} else {
return NO_MATCH;
}
} else {
return NO_MATCH;
}
}
/**
* Visit a sequent pattern 'f(x) ==> f(x)', 'f(x) ==>' or '==> f(x)'
*
......
......@@ -169,6 +169,8 @@ public class MatcherFacadeTest {
//these two need to be checked I think
shouldMatchSeq("pred(a) ==> pred(a), pred(b)", "_ ==> _", "[{EMPTY_MATCH=null}, {EMPTY_MATCH=null}]");
shouldMatchSeq("pred(a) ==> pred(a), pred(b)", " ==> _", "[{EMPTY_MATCH=null}, {EMPTY_MATCH=null}]");
// shouldMatchSeq("fint2(1,2), fint2(2,3), !p ==> pred(a), p", "fint2(1, ?X), fint2(?X, ?Y) ==> p" , "[{?X=2, ?Y=3}]");
shouldMatchSeq("fint2(1,2), fint2(2,3), !p ==> pred(a), p", "fint2(1, ?X), fint2(?X, ?Y) ==> p");
}
......
......@@ -24,6 +24,7 @@
S h(S, S);
int fint(int);
}
\predicates {
......@@ -32,6 +33,7 @@
pred(S);
qpred(S, S);
intPred(int);
fint2(int, int);
}
\problem {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment