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

Unexpected Behavior #1

Open
wbautistajr opened this issue Sep 19, 2012 · 0 comments
Open

Unexpected Behavior #1

wbautistajr opened this issue Sep 19, 2012 · 0 comments

Comments

@wbautistajr
Copy link

I believe there is a bug in the jools.js module.

In the readme, it states that a rule can have multiple conditions and multiple consequences. In the comments for jools.js, it states that the consequences fire when all conditions evaluate to true. However, this is not the behavior. Instead, if you have multiple conditions in a rule, say 2, and the first evaluates to false and the second evaluates to true, the consequence is fired.

I believe the bug resides in the code block that checks each conditions outcome (lines 46-51). It appears to be checking the variable "outcome" to see if it exists (or if a condition has been applied), but only by means of an "if" statement. I'm assuming this is valid in javascript, and that if the variable is null or undefined, it translates to false. However, the problem is that the conditions themselves return boolean values, which are then stored in the "outcome" variable. So, if there are more than one condition, the outcome after the first condition could be false(as in the scenario I described above). On the second time around, "outcome" is already set to false, and instead of "&&" the returned value of the next condition with the current value of "outcome", it just overwrites "outcome" with whatever the second condition returns(in my scenario it returns "true"). Thus, since "outcome" is now set to "true", the consequence function is fired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant