/**
 * 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;
    }
}

@@ -123,16 +123,26 @@
 /EXT:BDJ
+%0A//EXT:IWE
 %0A%0Aclass 
@@ -430,16 +430,21 @@
     if (
+this.
 a(3, fal
@@ -450,16 +450,21 @@
 lse) && 
+this.
 a(5, tru
@@ -485,24 +485,29 @@
             
+ 
+    
 /* r = 2 + 3
@@ -526,16 +526,21 @@
     %7C%7C (
+this.
 m(7, fal
@@ -546,16 +546,21 @@
 lse) %7C%7C 
+this.
 s(11, tr
@@ -566,16 +566,21 @@
 rue) && 
+this.
 m(13, fa
@@ -635,16 +635,21 @@
      %7C%7C 
+this.
 a(17, tr
@@ -655,16 +655,21 @@
 rue) %7C%7C 
+this.
 m(19, tr
@@ -687,24 +687,29 @@
             
+  
+   
 /* r = ((2 +
@@ -774,46 +774,8 @@
 lt;%0A
-        else%0A            result = 42;%0A
     

Make test case valid MiniJava.