Skip to content

Incorrect parsing of or/and constraints with more than two literals #33

Description

@skrieter

When writing a UVL model with a constraint such as A or B or C, it is correctly written as A | B | C. But when parsing it, it is parsed as (A or B) or C.

Here is a failing test case demonstrating this behavior:

@Test
void multiOr() {
	FeatureModel uvlModel = new FeatureModel();

    Feature root = new Feature("root");
    uvlModel.getFeatureMap().put("root", root);
    
    uvlModel.setRootFeature(root);
    Group uvlRootGroup = new Group(Group.GroupType.OPTIONAL);
    root.addChildren(uvlRootGroup);

    Feature a = new Feature("A");
	Feature b = new Feature("B");
	Feature c = new Feature("C");

    uvlRootGroup.getFeatures().add(a);
    uvlRootGroup.getFeatures().add(b);
    uvlRootGroup.getFeatures().add(c);
    
    uvlModel.getFeatureMap().put("A", a);
    uvlModel.getFeatureMap().put("B", b);
    uvlModel.getFeatureMap().put("C", c);
    
    OrConstraint constraint = new OrConstraint(
			new LiteralConstraint(a),
			new LiteralConstraint(b),
			new LiteralConstraint(c));
    
	uvlModel.getOwnConstraints().add(constraint);
	
	assertEquals(constraint, new UVLModelFactory().parse(uvlModel.toString()).getConstraints().get(0));
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions