Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In constraint block, if-condition becomes invisible when it doesn't have else statement #19

Open
LeeKaiXuan opened this issue May 8, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@LeeKaiXuan
Copy link
Collaborator

Description

For action (i.e., randWithIfElseCondition) has if-else condition in constraint block, it executed correctly even when expression in if expression failed.
However, when the if expression failed and there was no else statement (as shown in randWithIfCondition action), it incorrectly uses if statement as its constraint. Causing incorrect behaviour from the user's wish.

Scenario Code

component pss_top {
    action root_a {
        activity {
            do randWithIfElseCondition with { condition == "foo"; };
            do randWithIfElseCondition with { condition == "bar"; };
            do randWithIfCondition with { condition == "foo"; };
            do randWithIfCondition with { condition == "bar"; };
        }
    }

    action randWithIfElseCondition {
        rand string condition;
        rand int value;
        constraint {
            if ("foo" == condition) value in [12345];
            else value in [0];
        }

        exec post_solve {
            if (12345 != value) value = 54321;
        }
        exec body ASM = """randWithIfElseCondition: {{condition}} ; {{value}}""";
    }

    action randWithIfCondition {
        rand string condition;
        rand int value;
        constraint {
            if ("foo" == condition) value in [12345];
        }

        exec post_solve {
            if (12345 != value) value = 54321;
        }
        exec body ASM = """randWithIfCondition: {{condition}} ; {{value}}""";
    }
}

Expected Output or Behaviour

randWithIfElseCondition: foo ; 12345
randWithIfElseCondition: bar ; 54321
randWithIfCondition: foo ; 12345
randWithIfCondition: bar ; 54321

Error Message from PSSGen or JAVA

4c4
< randWithIfCondition: bar ; 12345
---
> randWithIfCondition: bar ; 54321
Test Result: FAIL

Additional Context (Optional)

Please feel free to add any other context about the problem here.

@LeeKaiXuan LeeKaiXuan added the bug Something isn't working label May 8, 2024
@LeeKaiXuan LeeKaiXuan self-assigned this May 8, 2024
LeeKaiXuan added a commit that referenced this issue May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant