-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathCorrectOperatorPrecedence.java
More file actions
66 lines (52 loc) · 1.39 KB
/
CorrectOperatorPrecedence.java
File metadata and controls
66 lines (52 loc) · 1.39 KB
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
58
59
60
61
62
63
64
65
66
package testSuite;
import liquidjava.specification.Refinement;
public class CorrectOperatorPrecedence {
@Refinement("_ == 1 + 2 * 0")
int multiplicationBeforeAddition() {
return 1;
}
@Refinement("_ == (1 + 2) * 0")
int groupedAdditionBeforeMultiplication() {
return 0;
}
@Refinement("_ == 10 - 3 - 1")
int subtractionAssociatesLeft() {
return 6;
}
@Refinement("_ == 10 - (3 - 1)")
int groupedSubtractionAssociatesRight() {
return 8;
}
@Refinement("_ == -2 + 3")
int unaryBeforeAddition() {
return 1;
}
@Refinement("_ == (true || false && false)")
boolean andBeforeOr() {
return true;
}
@Refinement("_ == (!false && false)")
boolean notBeforeAnd() {
return false;
}
@Refinement("_ == (false --> true && false)")
boolean andBeforeImplication() {
return true;
}
@Refinement("_ == (true || true --> false)")
boolean orBeforeImplication() {
return false;
}
@Refinement("_ == (false --> false && false)")
boolean anotherAndBeforeImplication() {
return true;
}
@Refinement("_ == (false --> true --> false)")
boolean implicationAssociatesRight() {
return true;
}
@Refinement("_ == (true ? false : true ? false : true)")
boolean ternaryAssociatesRight() {
return false;
}
}