Skip to content

Commit

Permalink
refactoring + extra test case
Browse files Browse the repository at this point in the history
  • Loading branch information
gublan24 committed Jan 31, 2019
1 parent 7bd6d7d commit 7be7f4b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
14 changes: 6 additions & 8 deletions cruise.umple/src/UmpleInternalParser_CodeRequireStatement.ump
Expand Up @@ -274,7 +274,7 @@ private ArrayList<TokenTree> generateFeatureTreeTokenFromRequireStList(List<Toke
currentTree = rootTokenTree.getRightTokenTree(); //currentTree points to the first node of the tree

TokenTree previousLinkingSubTokenTree = null;
// Start(3): build binary tree
//Start(3): building the binary tree of re-st argument
while(currentTree.getRightTokenTree() != null)
{
TokenTree rightLinkingTokenTree = currentTree.getRightTokenTree(); //linking operator on the right of current node
Expand Down Expand Up @@ -332,16 +332,16 @@ private ArrayList<TokenTree> generateFeatureTreeTokenFromRequireStList(List<Toke
currentTree = rightLinkingTokenTree; // move to next node of the tree
}
tokenTreeList.add(rootTokenTree.getRightTokenTree());
//End(3)
//Start(4): replace temp with actual values
//End(3)
//Start(4): replace temp with actual values
if(tempTokenTreeList.size() > 0) //there is a open & close round bracket
{
for(TokenTree aTokenTree : tokenTreeList)
{
replaceTempTerminalWithActualValues(aTokenTree,tempTokenTreeList);
}
}
//End(4)
//End(4)
return tokenTreeList;
}

Expand All @@ -358,10 +358,8 @@ private ArrayList<TokenTree> generateFeatureTreeTokenFromRequireStList(List<Toke
{
int indexPositionInTokenValue = token.getValue().indexOf('_') + 1;
int indexOfTempTokenTreeList = Integer.parseInt(token.getValue().substring(indexPositionInTokenValue));
TokenTree block = tempTokenTreeList.get(indexOfTempTokenTreeList);
tokenTree.replaceWith(block);
// tokenTree.setLeftTokenTree(block.getLeftTokenTree());
//tokenTree.setRightTokenTree(block.getRightTokenTree());
TokenTree actualValueOfBlock = tempTokenTreeList.get(indexOfTempTokenTreeList);
tokenTree.replaceWith(actualValueOfBlock);
return;// then stop
}
}
Expand Down
Expand Up @@ -492,5 +492,15 @@ public void parseReqStArgumetToSatisfyFeatureModel_9()
FeatureModel featureModel= model.getFeatureModel();
Assert.assertEquals(false,featureModel.satisfyFeatureModel());
}
@Test
public void parseReqStArgumetToSatisfyFeatureModel_10()
{
UmpleFile umpleFile = new UmpleFile(umpleParserTest.pathToInput,"reqStArgumentParse_validCombinedOpWithRoundBracketExtra.ump");
UmpleModel model = new UmpleModel(umpleFile);
model.setShouldGenerate(false);
model.run();
FeatureModel featureModel= model.getFeatureModel();
Assert.assertEquals(true,featureModel.satisfyFeatureModel());
}

}
Expand Up @@ -7,9 +7,8 @@ mixset A {} mixset B {} mixset C{}
mixset D {}

/*
use-statements result in a valid configuration of feature model.
Not valid configuration of feature model.
*/

//use A;
use C;
use D;
Expand Down
@@ -0,0 +1,15 @@
require [ ((A xor B) and C ) and (D xor (2..3 of {A,B,C,D} and E) ) ];



mixset A {} mixset B {} mixset C{}
mixset D {} mixset E{}

/*
valid configuration of feature model.
*/

use A;
use C;
use E;

0 comments on commit 7be7f4b

Please sign in to comment.