forked from MarkusEble/Compilerbau25
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterpreterSwitchStmtTest.java
More file actions
81 lines (75 loc) · 2.05 KB
/
InterpreterSwitchStmtTest.java
File metadata and controls
81 lines (75 loc) · 2.05 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.compiler;
import org.junit.Test;
public class InterpreterSwitchStmtTest extends InterpreterTestBase{
@Test
public void testSwitchProgram01() throws Exception {
String program = """
{
DECLARE in;
DECLARE out;
in = 2;
out = 0;
SWITCH(in) {
CASE 1:
out = 2;
CASE 2:
out = 3;
}
PRINT out;
}
""";
testInterpreter(program, "3\n");
}
@Test
public void testSwitchProgram02() throws Exception {
String program = """
{
DECLARE in;
DECLARE out;
in = 3;
out = 0;
SWITCH(in) {
CASE 1:
out = 2;
CASE 2:
out = 3;
CASE 4:
out = 3;
CASE 3:
out = 5;
CASE 5:
out = 2;
}
PRINT out;
}
""";
testInterpreter(program, "5\n");
}
@Test
public void testSwitchProgram03() throws Exception {
String program = """
{
DECLARE in;
DECLARE out;
in = 3;
out = 0;
SWITCH(in + 1) {
CASE 1:
out = 2;
CASE 2:
out = 3;
CASE 4:
out = 3;
in = 4;
CASE 3:
out = 5;
CASE 5:
out = 2;
}
PRINT in;
PRINT out;
}
""";
testInterpreter(program, "4\n3\n");
}
}