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

Comments

Projects
None yet
3 participants
@vahdat-ab
Member

vahdat-ab commented Mar 21, 2016

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

This comment has been minimized.

Member

vahdat-ab commented Mar 21, 2016

@TimLethbridge

This comment has been minimized.

Member

TimLethbridge commented Mar 21, 2016

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

@vahdat-ab

This comment has been minimized.

Member

vahdat-ab commented Mar 21, 2016

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

This comment has been minimized.

Member

TimLethbridge commented Mar 21, 2016

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 label Sep 20, 2016

@tlaport4 tlaport4 self-assigned this Oct 11, 2016

@tlaport4

This comment has been minimized.

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

This comment has been minimized.

Member

vahdat-ab commented Nov 8, 2016

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

@vahdat-ab vahdat-ab closed this Dec 17, 2016

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