Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
object SideEffect
def firstI(): Int(32) = {
Std.printInt(1);
1
}
def secondI(): Int(32) = {
Std.printInt(2);
2
}
def stringLeft(): String = {
Std.printString("SLeft");
"a"
}
def stringRight(): String = {
Std.printString("SRight");
"a"
}
def caseLeft(): L.List = {
Std.printString("CLeft");
L.Nil()
}
def caseRight(): L.List = {
Std.printString("CRight");
L.Nil()
}
// Make sure that operands to binary operations are interpreted only once
// and in the right order
firstI() + secondI();
firstI() - secondI();
firstI() * secondI();
firstI() / secondI();
firstI() % secondI();
firstI() < secondI();
firstI() <= secondI();
// Make sure that the rhs of comparisons to Unit (which always succeed)
// are interpreted.
Std.printString("Left") == Std.printString("Right");
// Make sure that string comparisons evaluate their arguments once
// and in the correct order
stringLeft() == stringRight();
// Make sure that case class comparisons evaluate their arguments once
// and in the correct order
caseLeft() == caseRight();
()
end SideEffect