|
@@ -4,11 +4,12 @@ import java.util.*;
|
4
|
4
|
|
5
|
5
|
public class ScriptBuilder {
|
6
|
6
|
|
7
|
|
- private final List<String> scripts;
|
|
7
|
+ private final Map<String, String> scriptNameToScript;
|
8
|
8
|
private StringJoiner currentScriptJoiner;
|
|
9
|
+ private String currentScriptName;
|
9
|
10
|
|
10
|
11
|
private ScriptBuilder() {
|
11
|
|
- scripts = new ArrayList<>();
|
|
12
|
+ scriptNameToScript = new HashMap<>();
|
12
|
13
|
startNewScript();
|
13
|
14
|
}
|
14
|
15
|
|
|
@@ -26,20 +27,29 @@ public class ScriptBuilder {
|
26
|
27
|
}
|
27
|
28
|
|
28
|
29
|
public ScriptBuilder startNewScript() {
|
29
|
|
- if(currentScriptJoiner != null) {
|
30
|
|
- scripts.add(currentScriptJoiner.toString());
|
|
30
|
+ return startNewScript(null);
|
|
31
|
+ }
|
|
32
|
+
|
|
33
|
+ public ScriptBuilder startNewScript(String fileName) {
|
|
34
|
+ if(currentScriptJoiner != null && currentScriptJoiner.length() != 0) {
|
|
35
|
+ scriptNameToScript.put(currentScriptName, currentScriptJoiner.toString());
|
31
|
36
|
}
|
32
|
|
-
|
|
37
|
+
|
33
|
38
|
currentScriptJoiner = new StringJoiner(System.lineSeparator());
|
|
39
|
+ if(fileName == null) {
|
|
40
|
+ currentScriptName = "test_script_" + (scriptNameToScript.size() + 1) + ".zs";
|
|
41
|
+ } else {
|
|
42
|
+ currentScriptName = fileName;
|
|
43
|
+ }
|
34
|
44
|
return this;
|
35
|
45
|
}
|
36
|
46
|
|
37
|
47
|
public void appendScriptsToTest(ZenCodeTest test) {
|
38
|
48
|
startNewScript();
|
39
|
49
|
|
40
|
|
- for(String script : scripts) {
|
41
|
|
- test.addScript(script);
|
42
|
|
- }
|
|
50
|
+ scriptNameToScript.forEach((name, content) -> {
|
|
51
|
+ test.addScript(content, name);
|
|
52
|
+ });
|
43
|
53
|
}
|
44
|
54
|
|
45
|
55
|
public void execute(ZenCodeTest test, LogTolerance logTolerance) {
|