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

Umple doesn't parse a guard with a string variable and equal operation #789

Closed
vahdat-ab opened this issue Mar 21, 2016 · 6 comments
Closed
Assignees
Labels
bug Crashes or wrong results constraints Related to umple constraints shown in square brackets in classes Correctness A type of bug related to Umple generated code executing correctly Diffic-Med A non-trivial problem that may take over a week or may not be obvious how to fix or require analysis Priority-High This problem or enhancement is likely to be highly visible and or impactful of users stateMachines Related to state machine syntax, semantics, diagrams or code generation ucosp Suitable for 4th year capstone projects

Comments

@vahdat-ab
Copy link
Member

consider the following example"

class CommandControl{
    String cmdString = "";

    CommandControl{
        IDLE{
            execute -> CHECK_AVAILABILITY;
        }
        CHECK_AVAILABILITY{
        //The issue is with =="" and !="". When I remove !="" or =="" it works
        execute [cmdString!=""]-> COMMAND_VALIDITY;
        //  execute [cmdString==""] -> IDLE;

        //  execute [cmdString]-> COMMAND_VALIDITY;
        //  execute [cmdString] -> IDLE;
        }
        COMMAND_VALIDITY{
            [isCommandValid(cmdString)] -> EXECUTION;
        }
        EXECUTION{
        }
    }
}

It doesn't compile because of cmdString!="". When the !="" is removed it is comp[iled.

@vahdat-ab vahdat-ab added bug Crashes or wrong results Priority-High This problem or enhancement is likely to be highly visible and or impactful of users Correctness A type of bug related to Umple generated code executing correctly Diffic-Med A non-trivial problem that may take over a week or may not be obvious how to fix or require analysis stateMachines Related to state machine syntax, semantics, diagrams or code generation constraints Related to umple constraints shown in square brackets in classes labels Mar 21, 2016
@vahdat-ab
Copy link
Member Author

@opeyemiAdesina

@TimLethbridge
Copy link
Member

Yes it should use equals() when the comparison is string or some other non-primitive data.

@vahdat-ab
Copy link
Member Author

I think it must be parsed because if we give correct rules, there is no problem. Using equals() is just a programming level concept and normally people won't use it at the modeling level.
if we parse it correctly, the analysis phase can take care of correctness of the variable 9e.g. if it's been defined or it's an Integer or String). I think we should avoid bringing programming concepts to the modeling because they are hard to interpret.

@TimLethbridge
Copy link
Member

Yes of course parse =. What I meant was convert it to generate .equals() internally in generated code. The user would never see that.

@TimLethbridge TimLethbridge added the ucosp Suitable for 4th year capstone projects label Sep 20, 2016
@tlaport4 tlaport4 self-assigned this Oct 11, 2016
@tlaport4
Copy link
Contributor

tlaport4 commented Nov 8, 2016

This issue seems to have already been fixed. The generated code uses .equals to compare Strings.

In this example, the conditions in the generated code look like this:

 if (!"".equals(getCmdString()))

and

 if ("".equals(getCmdString()))

Should I just add some tests for this specific situation?

@vahdat-ab
Copy link
Member Author

Yes. Just add test cases and then we will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Crashes or wrong results constraints Related to umple constraints shown in square brackets in classes Correctness A type of bug related to Umple generated code executing correctly Diffic-Med A non-trivial problem that may take over a week or may not be obvious how to fix or require analysis Priority-High This problem or enhancement is likely to be highly visible and or impactful of users stateMachines Related to state machine syntax, semantics, diagrams or code generation ucosp Suitable for 4th year capstone projects
Projects
None yet
Development

No branches or pull requests

3 participants