Skip to content

Commit

Permalink
Preferences store cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
maccasoft committed Apr 17, 2024
1 parent ae69e9f commit bcb2b7c
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,68 +39,33 @@ void testDefaultPreferences() throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
mapper.setSerializationInclusion(Include.NON_EMPTY);
mapper.setSerializationInclusion(Include.NON_DEFAULT);
mapper.writeValue(os, subject.preferences);

Assertions.assertEquals(""
+ "{\n"
+ " \"showLineNumbers\" : true,\n"
+ " \"showIndentLines\" : true,\n"
+ " \"indentLinesSize\" : 0,\n"
+ " \"showEditorOutline\" : true,\n"
+ " \"spin1CaseSensitiveSymbols\" : false,\n"
+ " \"spin2CaseSensitiveSymbols\" : false,\n"
+ " \"spin2ClockSetter\" : false,\n"
+ " \"reloadOpenTabs\" : true,\n"
+ " \"terminal\" : {\n"
+ " \"lineInput\" : false,\n"
+ " \"localEcho\" : false,\n"
+ " \"type\" : 0,\n"
+ " \"baudRate\" : 115200\n"
+ " },\n"
+ " \"console\" : {\n"
+ " \"maxLines\" : 500,\n"
+ " \"writeLogFile\" : true\n"
+ " }\n"
+ "}", os.toString().replaceAll("\\r\\n", "\n"));
+ "{ }", os.toString().replaceAll("\\r\\n", "\n"));
}

@Test
void testSetSpin1LibraryPath() throws Exception {
File path = new File("spin1/path");

Preferences subject = new Preferences();
subject.setSpin1LibraryPath(new File[] {
new File("spin1/path")
path
});

ByteArrayOutputStream os = new ByteArrayOutputStream();

ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
mapper.setSerializationInclusion(Include.NON_EMPTY);
mapper.setSerializationInclusion(Include.NON_DEFAULT);
mapper.writeValue(os, subject.preferences);

Assertions.assertEquals(""
+ "{\n"
+ " \"showLineNumbers\" : true,\n"
+ " \"showIndentLines\" : true,\n"
+ " \"indentLinesSize\" : 0,\n"
+ " \"showEditorOutline\" : true,\n"
+ " \"spin1LibraryPath\" : [ \"" + new File("spin1/path").getAbsolutePath() + "\" ],\n"
+ " \"spin1CaseSensitiveSymbols\" : false,\n"
+ " \"spin2CaseSensitiveSymbols\" : false,\n"
+ " \"spin2ClockSetter\" : false,\n"
+ " \"reloadOpenTabs\" : true,\n"
+ " \"terminal\" : {\n"
+ " \"lineInput\" : false,\n"
+ " \"localEcho\" : false,\n"
+ " \"type\" : 0,\n"
+ " \"baudRate\" : 115200\n"
+ " },\n"
+ " \"console\" : {\n"
+ " \"maxLines\" : 500,\n"
+ " \"writeLogFile\" : true\n"
+ " }\n"
+ " \"spin1LibraryPath\" : [ \"" + path.getAbsolutePath() + "\" ]\n"
+ "}", os.toString().replaceAll("\\r\\n", "\n"));
}

Expand Down Expand Up @@ -151,37 +116,20 @@ void testSetSpin1DefaultLibraryPath() throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
mapper.setSerializationInclusion(Include.NON_EMPTY);
mapper.setSerializationInclusion(Include.NON_DEFAULT);
mapper.writeValue(os, subject.preferences);

Assertions.assertEquals(""
+ "{\n"
+ " \"showLineNumbers\" : true,\n"
+ " \"showIndentLines\" : true,\n"
+ " \"indentLinesSize\" : 0,\n"
+ " \"showEditorOutline\" : true,\n"
+ " \"spin1CaseSensitiveSymbols\" : false,\n"
+ " \"spin2CaseSensitiveSymbols\" : false,\n"
+ " \"spin2ClockSetter\" : false,\n"
+ " \"reloadOpenTabs\" : true,\n"
+ " \"terminal\" : {\n"
+ " \"lineInput\" : false,\n"
+ " \"localEcho\" : false,\n"
+ " \"type\" : 0,\n"
+ " \"baudRate\" : 115200\n"
+ " },\n"
+ " \"console\" : {\n"
+ " \"maxLines\" : 500,\n"
+ " \"writeLogFile\" : true\n"
+ " }\n"
+ "}", os.toString().replaceAll("\\r\\n", "\n"));
+ "{ }", os.toString().replaceAll("\\r\\n", "\n"));
}

@Test
void testSetSpin1LibraryWithDefaultPath() throws Exception {
File path = new File("spin1/path");

Preferences subject = new Preferences();
subject.setSpin1LibraryPath(new File[] {
new File("spin1/path"),
path,
Preferences.defaultSpin1LibraryPath
});

Expand All @@ -190,69 +138,35 @@ void testSetSpin1LibraryWithDefaultPath() throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
mapper.setSerializationInclusion(Include.NON_EMPTY);
mapper.setSerializationInclusion(Include.NON_DEFAULT);
mapper.writeValue(os, subject.preferences);

Assertions.assertEquals(""
+ "{\n"
+ " \"showLineNumbers\" : true,\n"
+ " \"showIndentLines\" : true,\n"
+ " \"indentLinesSize\" : 0,\n"
+ " \"showEditorOutline\" : true,\n"
+ " \"spin1LibraryPath\" : [ \"" + new File("spin1/path").getAbsolutePath() + "\", null ],\n"
+ " \"spin1CaseSensitiveSymbols\" : false,\n"
+ " \"spin2CaseSensitiveSymbols\" : false,\n"
+ " \"spin2ClockSetter\" : false,\n"
+ " \"reloadOpenTabs\" : true,\n"
+ " \"terminal\" : {\n"
+ " \"lineInput\" : false,\n"
+ " \"localEcho\" : false,\n"
+ " \"type\" : 0,\n"
+ " \"baudRate\" : 115200\n"
+ " },\n"
+ " \"console\" : {\n"
+ " \"maxLines\" : 500,\n"
+ " \"writeLogFile\" : true\n"
+ " }\n"
+ " \"spin1LibraryPath\" : [ \"" + path.getAbsolutePath() + "\", null ]\n"
+ "}", os.toString().replaceAll("\\r\\n", "\n"));
}

@Test
void testSetSpin2LibraryPath() throws Exception {
File path = new File("spin2/path");

Preferences subject = new Preferences();
subject.setSpin2LibraryPath(new File[] {
new File("spin2/path")
path
});

ByteArrayOutputStream os = new ByteArrayOutputStream();

ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
mapper.setSerializationInclusion(Include.NON_EMPTY);
mapper.setSerializationInclusion(Include.NON_DEFAULT);
mapper.writeValue(os, subject.preferences);

Assertions.assertEquals(""
+ "{\n"
+ " \"showLineNumbers\" : true,\n"
+ " \"showIndentLines\" : true,\n"
+ " \"indentLinesSize\" : 0,\n"
+ " \"showEditorOutline\" : true,\n"
+ " \"spin1CaseSensitiveSymbols\" : false,\n"
+ " \"spin2LibraryPath\" : [ \"" + new File("spin2/path").getAbsolutePath() + "\" ],\n"
+ " \"spin2CaseSensitiveSymbols\" : false,\n"
+ " \"spin2ClockSetter\" : false,\n"
+ " \"reloadOpenTabs\" : true,\n"
+ " \"terminal\" : {\n"
+ " \"lineInput\" : false,\n"
+ " \"localEcho\" : false,\n"
+ " \"type\" : 0,\n"
+ " \"baudRate\" : 115200\n"
+ " },\n"
+ " \"console\" : {\n"
+ " \"maxLines\" : 500,\n"
+ " \"writeLogFile\" : true\n"
+ " }\n"
+ " \"spin2LibraryPath\" : [ \"" + path.getAbsolutePath() + "\" ]\n"
+ "}", os.toString().replaceAll("\\r\\n", "\n"));
}

Expand All @@ -266,37 +180,20 @@ void testSetSpin2DefaultLibraryPath() throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
mapper.setSerializationInclusion(Include.NON_EMPTY);
mapper.setSerializationInclusion(Include.NON_DEFAULT);
mapper.writeValue(os, subject.preferences);

Assertions.assertEquals(""
+ "{\n"
+ " \"showLineNumbers\" : true,\n"
+ " \"showIndentLines\" : true,\n"
+ " \"indentLinesSize\" : 0,\n"
+ " \"showEditorOutline\" : true,\n"
+ " \"spin1CaseSensitiveSymbols\" : false,\n"
+ " \"spin2CaseSensitiveSymbols\" : false,\n"
+ " \"spin2ClockSetter\" : false,\n"
+ " \"reloadOpenTabs\" : true,\n"
+ " \"terminal\" : {\n"
+ " \"lineInput\" : false,\n"
+ " \"localEcho\" : false,\n"
+ " \"type\" : 0,\n"
+ " \"baudRate\" : 115200\n"
+ " },\n"
+ " \"console\" : {\n"
+ " \"maxLines\" : 500,\n"
+ " \"writeLogFile\" : true\n"
+ " }\n"
+ "}", os.toString().replaceAll("\\r\\n", "\n"));
+ "{ }", os.toString().replaceAll("\\r\\n", "\n"));
}

@Test
void testSetSpin2LibraryWithDefaultPath() throws Exception {
File path = new File("spin2/path");

Preferences subject = new Preferences();
subject.setSpin2LibraryPath(new File[] {
new File("spin2/path"),
path,
Preferences.defaultSpin2LibraryPath
});

Expand All @@ -305,30 +202,12 @@ void testSetSpin2LibraryWithDefaultPath() throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
mapper.setSerializationInclusion(Include.NON_EMPTY);
mapper.setSerializationInclusion(Include.NON_DEFAULT);
mapper.writeValue(os, subject.preferences);

Assertions.assertEquals(""
+ "{\n"
+ " \"showLineNumbers\" : true,\n"
+ " \"showIndentLines\" : true,\n"
+ " \"indentLinesSize\" : 0,\n"
+ " \"showEditorOutline\" : true,\n"
+ " \"spin1CaseSensitiveSymbols\" : false,\n"
+ " \"spin2LibraryPath\" : [ \"" + new File("spin2/path").getAbsolutePath() + "\", null ],\n"
+ " \"spin2CaseSensitiveSymbols\" : false,\n"
+ " \"spin2ClockSetter\" : false,\n"
+ " \"reloadOpenTabs\" : true,\n"
+ " \"terminal\" : {\n"
+ " \"lineInput\" : false,\n"
+ " \"localEcho\" : false,\n"
+ " \"type\" : 0,\n"
+ " \"baudRate\" : 115200\n"
+ " },\n"
+ " \"console\" : {\n"
+ " \"maxLines\" : 500,\n"
+ " \"writeLogFile\" : true\n"
+ " }\n"
+ " \"spin2LibraryPath\" : [ \"" + path.getAbsolutePath() + "\", null ]\n"
+ "}", os.toString().replaceAll("\\r\\n", "\n"));
}

Expand Down Expand Up @@ -387,31 +266,13 @@ void testSetTabStops() throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
mapper.setSerializationInclusion(Include.NON_EMPTY);
mapper.setSerializationInclusion(Include.NON_DEFAULT);
mapper.writeValue(os, subject.preferences);

Assertions.assertEquals(""
+ "{\n"
+ " \"showLineNumbers\" : true,\n"
+ " \"showIndentLines\" : true,\n"
+ " \"indentLinesSize\" : 0,\n"
+ " \"showEditorOutline\" : true,\n"
+ " \"spin1CaseSensitiveSymbols\" : false,\n"
+ " \"spin2CaseSensitiveSymbols\" : false,\n"
+ " \"spin2ClockSetter\" : false,\n"
+ " \"reloadOpenTabs\" : true,\n"
+ " \"sectionTabStops\" : {\n"
+ " \"pub\" : [ 8, 16 ]\n"
+ " },\n"
+ " \"terminal\" : {\n"
+ " \"lineInput\" : false,\n"
+ " \"localEcho\" : false,\n"
+ " \"type\" : 0,\n"
+ " \"baudRate\" : 115200\n"
+ " },\n"
+ " \"console\" : {\n"
+ " \"maxLines\" : 500,\n"
+ " \"writeLogFile\" : true\n"
+ " }\n"
+ "}", os.toString().replaceAll("\\r\\n", "\n"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ else if ("P2".equals(node.getToken(index).getText())) {
if (compiler != null) {
compiler.setRemoveUnusedMethods(true);
compiler.setDebugEnabled(debug || sourcePool.isDebugEnabled());

try {
object = compiler.compile(localFile, root);
objectTree = compiler.getObjectTree();
Expand Down
Loading

0 comments on commit bcb2b7c

Please sign in to comment.