forked from hflicka/arden2bytecode
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathImplementationTest.java
More file actions
73 lines (61 loc) · 2.08 KB
/
ImplementationTest.java
File metadata and controls
73 lines (61 loc) · 2.08 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
package arden.tests.implementation;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Calendar;
import java.util.GregorianCalendar;
import org.junit.Assert;
import org.junit.internal.ArrayComparisonFailure;
import arden.compiler.CompiledMlm;
import arden.compiler.Compiler;
import arden.runtime.ArdenTime;
import arden.runtime.MedicalLogicModule;
public abstract class ImplementationTest {
private static Calendar calendar = null;
static ArdenTime createDate(int year, int month, int day) {
if (calendar == null) {
calendar = new GregorianCalendar();
}
calendar.clear();
calendar.set(year, month, day);
return new ArdenTime(calendar.getTimeInMillis());
}
static ArdenTime createDateTime(int year, int month, int day, int hour, int minutes, int seconds) {
if (calendar == null) {
calendar = new GregorianCalendar();
}
calendar.clear();
calendar.set(year, month, day, hour, minutes, seconds);
return new ArdenTime(calendar.getTimeInMillis());
}
protected static String inputStreamToString(InputStream in) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in));
StringBuilder stringBuilder = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
stringBuilder.append(line);
stringBuilder.append("\n");
}
bufferedReader.close();
return stringBuilder.toString();
}
protected static MedicalLogicModule compile(String filename) throws Exception {
Compiler c = new Compiler();
c.enableDebugging(filename);
CompiledMlm mlm = c
.compileMlm(new InputStreamReader(ImplementationTest.class.getResourceAsStream(filename)));
return mlm;
}
protected static void assertArrayNotEquals(Object[] expecteds, Object[] actuals) throws AssertionError {
boolean exceptionThrown = false;
try {
Assert.assertArrayEquals(expecteds, actuals);
} catch (ArrayComparisonFailure f) {
exceptionThrown = true;
}
if (!exceptionThrown) {
throw new AssertionError("Array is same.");
}
}
}