diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2019-10-12 14:12:14 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2019-10-12 14:12:14 -0400 |
| commit | 44719c3ac6c5decf15e7a6bab5045c971a5bd689 (patch) | |
| tree | bc478e3d6541e18483a036c9344fcf6c429a47a2 | |
| parent | e6614156f4b86d531720ff3b8ff55ca19ee7b978 (diff) | |
Swap tests to using compilation.
Tests now the compilation feature, so that is being tested thoroughly.
Now to get to going through and switching all the directives that use
strings to use CLStrings instead
3 files changed, 20 insertions, 4 deletions
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/CLFormatter.java b/clformat/src/main/java/bjc/utils/ioutils/format/CLFormatter.java index 86ffd54..3599d9e 100644 --- a/clformat/src/main/java/bjc/utils/ioutils/format/CLFormatter.java +++ b/clformat/src/main/java/bjc/utils/ioutils/format/CLFormatter.java @@ -371,7 +371,15 @@ public class CLFormatter { } } - public void compile(Iterator<Decree> cltok) { + public CLString compile(String inp) { + CLTokenizer tokenzer = new CLTokenizer(inp); + + List<Edict> edts = compile(tokenzer); + + return new CLString(edts); + } + + public List<Edict> compile(Iterator<Decree> cltok) { List<Edict> result = new ArrayList<>(); while (cltok.hasNext()) { @@ -458,5 +466,7 @@ public class CLFormatter { throw new IllegalArgumentException(msg); } } + + return result; } } diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/CLString.java b/clformat/src/main/java/bjc/utils/ioutils/format/CLString.java index 74e4960..7b533d0 100644 --- a/clformat/src/main/java/bjc/utils/ioutils/format/CLString.java +++ b/clformat/src/main/java/bjc/utils/ioutils/format/CLString.java @@ -33,8 +33,12 @@ public class CLString { FormatContext formCTX = new FormatContext(rw, itms); - for (Edict edt : edicts) { - edt.format(formCTX); + try { + for (Edict edt : edicts) { + edt.format(formCTX); + } + } catch (EscapeException eex) { + // General escape exception, so stop formatting. } return rw.toString(); diff --git a/clformat/src/test/java/bjc/utils/test/ioutils/CLFormatterTest.java b/clformat/src/test/java/bjc/utils/test/ioutils/CLFormatterTest.java index 2ceab42..4463488 100644 --- a/clformat/src/test/java/bjc/utils/test/ioutils/CLFormatterTest.java +++ b/clformat/src/test/java/bjc/utils/test/ioutils/CLFormatterTest.java @@ -141,7 +141,9 @@ public class CLFormatterTest { private String format(String str, Object... params) { try { - return fmt.formatString(str, params); + CLString strang = fmt.compile(str); + + return strang.format(params); } catch (Exception ex) { ex.printStackTrace(); |
