can_short_circuit.mj 991 Bytes
Newer Older
uwdkn's avatar
uwdkn committed
1
2
class A {
    public boolean side_effect() {
uwdkn's avatar
uwdkn committed
3
4
        System.out.write(70); /* F */
        System.out.write(10); /* newline */
uwdkn's avatar
uwdkn committed
5
6
7
8
9
10
        return false;
    }

    public static void main(String[] args) {
        A a = new A();
        if (true || a.side_effect()) {
uwdkn's avatar
uwdkn committed
11
12
13
            System.out.write(79); /* O */
            System.out.write(75); /* K */
            System.out.write(10); /* newline */
uwdkn's avatar
uwdkn committed
14
15
16
17
        }

        if (false && a.side_effect()) {
        } else {
uwdkn's avatar
uwdkn committed
18
19
20
            System.out.write(79); /* O */
            System.out.write(75); /* K */
            System.out.write(10); /* newline */
uwdkn's avatar
uwdkn committed
21
22
23
        }

        if (!(false && a.side_effect())) {
uwdkn's avatar
uwdkn committed
24
25
26
            System.out.write(79); /* O */
            System.out.write(75); /* K */
            System.out.write(10); /* newline */
uwdkn's avatar
uwdkn committed
27
28
29
        }

        if ((true || a.side_effect()) && true) {
uwdkn's avatar
uwdkn committed
30
31
32
            System.out.write(79); /* O */
            System.out.write(75); /* K */
            System.out.write(10); /* newline */
uwdkn's avatar
uwdkn committed
33
34
35
        }
    }
}