/**
 * Tests some evaluation order / side effects with && and ||.
 *
 * @author Elvis Stansvik <elvstone@gmail.com>
 */

//EXT:BDJ
//EXT:IWE

class SideEffects {
    public static void main(String[] args) {
        IncredibleMachine m;
        m = new IncredibleMachine();
        System.out.println(m.run()); // Should print 329.
    }
}

class IncredibleMachine {
    int result;
    public int run() {
        result = 2;
        if (this.a(3, false) && this.a(5, true)                             /* r = 2 + 3 */
            || (this.m(7, false) || this.s(11, true) && this.m(13, false))  /* r = ((2 + 3) * 7 - 11) * 13 */
            || this.a(17, true) || this.m(19, true))                        /* r = ((2 + 3) * 7 - 11) * 13 + 17 = 329 */
            result = result;
        return result;
    }
    public boolean m(int value, boolean ret) {
        result = result * value;
        return ret;
    }
    public boolean a(int value, boolean ret) {
        result = result + value;
        return ret;
    }
    public boolean s(int value, boolean ret) {
        result = result - value;
        return ret;
    }
}

/**
 * Tests some evaluation order / side effects with && and ||.
 *
 * @author Elvis Stansvik <elvstone@gmail.com>
 */

//EXT:BDJ

class SideEffects {
    public static void main(String[] args) {
        IncredibleMachine m;
        m = new IncredibleMachine();
        System.out.println(m.run()); // Should print 329.
    }
}

class IncredibleMachine {
    int result;
    public int run() {
        result = 2;
        if (a(3, false) && a(5, true)                        /* r = 2 + 3 */
            || (m(7, false) || s(11, true) && m(13, false))  /* r = ((2 + 3) * 7 - 11) * 13 */
            || a(17, true) || m(19, true))                   /* r = ((2 + 3) * 7 - 11) * 13 + 17 = 329 */
            result = result;
        else
            result = 42;
        return result;
    }
    public boolean m(int value, boolean ret) {
        result = result * value;
        return ret;
    }
    public boolean a(int value, boolean ret) {
        result = result + value;
        return ret;
    }
    public boolean s(int value, boolean ret) {
        result = result - value;
        return ret;
    }
}

--- 
+++ 
@@ -5,6 +5,7 @@
  */
 
 //EXT:BDJ
+//EXT:IWE
 
 class SideEffects {
     public static void main(String[] args) {
@@ -18,12 +19,10 @@
     int result;
     public int run() {
         result = 2;
-        if (a(3, false) && a(5, true)                        /* r = 2 + 3 */
-            || (m(7, false) || s(11, true) && m(13, false))  /* r = ((2 + 3) * 7 - 11) * 13 */
-            || a(17, true) || m(19, true))                   /* r = ((2 + 3) * 7 - 11) * 13 + 17 = 329 */
+        if (this.a(3, false) && this.a(5, true)                             /* r = 2 + 3 */
+            || (this.m(7, false) || this.s(11, true) && this.m(13, false))  /* r = ((2 + 3) * 7 - 11) * 13 */
+            || this.a(17, true) || this.m(19, true))                        /* r = ((2 + 3) * 7 - 11) * 13 + 17 = 329 */
             result = result;
-        else
-            result = 42;
         return result;
     }
     public boolean m(int value, boolean ret) {
Make test case valid MiniJava.
