Skip to content
Permalink
Browse files

fixes #1492 crash in guards

  • Loading branch information...
TimLethbridge committed Sep 10, 2019
1 parent fe0fadb commit 561de78eba87dd1129e89e4f465c0e75a374e30a
@@ -1582,7 +1582,7 @@ class UmpleInternalParser
private Token getExpressionOperator(Token expression, Integer startIndex)
{
Integer operatorPosition = startIndex + OPERATOR_POSITION;
if (operatorPosition < expression.getSubTokens().size())
if (operatorPosition < expression.getSubTokens().size()-1)
{
Token operator = expression.getSubToken(operatorPosition);
String operatorName = operator.getName();
@@ -0,0 +1,24 @@
class OtherClass {
* -> 1 Another ;
Integer row;
Integer row2;
}

class Another {
Integer junk;
}

class Statemachine {
* -> 1 OtherClass other;
Boolean cond;
sm {
s1 {
event1[other.another.junk == 3] -> s3;
event1[other.another.junk == 3] -> s1;
event1[cond && other.row > 4] -> s2;
event1[cond && other.row == 3] -> s3;
event1[cond && other.row == 3] -> s1;
}
s3 {}
}
}
@@ -113,6 +113,14 @@ public void handleBangInGuard2()
Assert.assertEquals("if (((getFlag()!=getFlag())||(getFlag()||getFlag())))\n{\n {0}\n}", gen.translate("on", t3.getGuard()));
Assert.assertEquals("if ((!(!getFlag()&&getX())&&(getX()||getX())))\n{\n {0}\n}", gen.translate("on", t4.getGuard()));
}

// Issue 1492
@Test
public void verifyDuplicateGuards()
{
assertHasWarning("DuplicateGuards.ump",0,70);
assertHasWarning("DuplicateGuards.ump",1,70);
}

// Issue 796
@Test
@@ -2723,6 +2731,10 @@ private void assertNoWarnings(String filename)
assertHasWarning(filename, -1, -1, null);
}

private void assertHasWarning(String filename, int expectedWarningIndex, int expectedError) {
assertHasWarning(filename, expectedWarningIndex, expectedError, null);
}

private void assertHasWarning(String filename, int expectedWarningIndex, int expectedError, Position expectedPosition)
{
File file = new File(pathToInput, filename);
@@ -2755,7 +2767,9 @@ private void assertHasWarning(String filename, int expectedWarningIndex, int exp
Assert.assertNotNull(parser.getParseResult().getErrorMessage(expectedWarningIndex));
Assert.assertEquals(expectedError, parser.getParseResult().getErrorMessage(expectedWarningIndex).getErrorType().getErrorCode());
System.out.println(">>" + parser.getParseResult().getErrorMessage(expectedWarningIndex).getPosition().getOffset());
Assert.assertEquals(expectedPosition, parser.getParseResult().getErrorMessage(expectedWarningIndex).getPosition());
if (expectedPosition != null) {
Assert.assertEquals(expectedPosition, parser.getParseResult().getErrorMessage(expectedWarningIndex).getPosition());
}
}
}

@@ -11,6 +11,7 @@ The following instructs the system to inject comments on every class point to th
@outputumplesource
*/
strictness allow 30;
strictness allow 31;
strictness allow 1006;
strictness allow 1007;
strictness allow 1008;

0 comments on commit 561de78

Please sign in to comment.
You can’t perform that action at this time.