From f9d9bd4bbf7dd6a297e1daf5ee7b4263d706d9cd Mon Sep 17 00:00:00 2001 From: bjculkin Date: Thu, 1 Mar 2018 19:13:48 -0500 Subject: Update --- scl/src/main/java/bjc/dicelang/scl/Errors.java | 19 ++-- .../bjc/dicelang/scl/StreamControlConsole.java | 10 +- .../java/bjc/dicelang/scl/StreamControlEngine.java | 87 ++++++++-------- .../main/java/bjc/dicelang/scl/StreamEngine.java | 113 ++++++++++----------- .../bjc/dicelang/scl/tokens/BooleanSCLToken.java | 12 +-- .../bjc/dicelang/scl/tokens/FloatSCLToken.java | 12 +-- .../java/bjc/dicelang/scl/tokens/SCLToken.java | 26 ++--- .../bjc/dicelang/scl/tokens/StringSCLToken.java | 19 ++-- .../bjc/dicelang/scl/tokens/WordListSCLToken.java | 19 ++-- .../java/bjc/dicelang/scl/tokens/WordSCLToken.java | 12 +-- scl/src/test/java/bjc/AppTest.java | 48 ++++----- 11 files changed, 171 insertions(+), 206 deletions(-) (limited to 'scl') diff --git a/scl/src/main/java/bjc/dicelang/scl/Errors.java b/scl/src/main/java/bjc/dicelang/scl/Errors.java index d372850..8d3faff 100644 --- a/scl/src/main/java/bjc/dicelang/scl/Errors.java +++ b/scl/src/main/java/bjc/dicelang/scl/Errors.java @@ -3,12 +3,15 @@ package bjc.dicelang.scl; /** * Repository for error messages. * + * + * @author EVE + */ +/* * @TODO 10/08/17 Ben Culkin :ErrorRefactor * - * This way of handling error messages is not easy to deal with. Something - * else needs to be done, but I'm not sure what at the moment. + * This way of handling error messages is not easy to deal with. Something else + * needs to be done, but I'm not sure what at the moment. * - * @author EVE * */ public class Errors { @@ -78,13 +81,13 @@ public class Errors { * Print an error. * * @param key - * The key of the error. + * The key of the error. * * @param args - * The arguments for the error. + * The arguments for the error. */ public void printError(final ErrorKey key, final String... args) { - switch (mode) { + switch(mode) { case WIZARD: System.out.println("\t? " + key.ordinal()); break; @@ -99,7 +102,7 @@ public class Errors { } private static void devError(final ErrorKey key, final String[] args) { - switch (key) { + switch(key) { case EK_STRM_NONEX: System.out.printf("\tERROR: Attempted to switch to non-existent stream\n"); break; @@ -111,7 +114,7 @@ public class Errors { case EK_STRM_INVCOM: System.out.printf("\tERROR: Unknown stream control command %s\n", args[0]); break; - + case EK_SCL_INVTOKEN: System.out.printf("\tERROR: Unknown SCL token %s\n", args[0]); break; diff --git a/scl/src/main/java/bjc/dicelang/scl/StreamControlConsole.java b/scl/src/main/java/bjc/dicelang/scl/StreamControlConsole.java index 26266ff..78c8c5e 100644 --- a/scl/src/main/java/bjc/dicelang/scl/StreamControlConsole.java +++ b/scl/src/main/java/bjc/dicelang/scl/StreamControlConsole.java @@ -21,7 +21,7 @@ public class StreamControlConsole { * Main method * * @param args - * Unused CLI args. + * Unused CLI args. */ public static void main(String[] args) { /* @@ -36,10 +36,10 @@ public class StreamControlConsole { System.out.print("Enter a SCL command string (blank to exit): "); /* Process it. */ - while (scn.hasNextLine()) { + while(scn.hasNextLine()) { String ln = scn.nextLine().trim(); - if (ln.equals("")) { + if(ln.equals("")) { /* Ignore empty lines. */ break; } @@ -50,7 +50,7 @@ public class StreamControlConsole { /* Run the stream engine on the tokens. */ boolean succ = sengine.doStreams(tokens, res); - if (!succ) { + if(!succ) { System.out.printf("ERROR: Stream engine failed for line '%s'\n", ln); continue; } @@ -58,7 +58,7 @@ public class StreamControlConsole { /* Run the command through SCL. */ tokens = res.toArray(new String[res.getSize()]); succ = sclengine.runProgram(tokens); - if (!succ) { + if(!succ) { System.out.printf("ERROR: SCL engine failed for line '%s'\n", ln); continue; } diff --git a/scl/src/main/java/bjc/dicelang/scl/StreamControlEngine.java b/scl/src/main/java/bjc/dicelang/scl/StreamControlEngine.java index fe4fcda..a590bb3 100644 --- a/scl/src/main/java/bjc/dicelang/scl/StreamControlEngine.java +++ b/scl/src/main/java/bjc/dicelang/scl/StreamControlEngine.java @@ -48,7 +48,7 @@ public class StreamControlEngine { * Create a new stream control engine. * * @param engine - * The engine to control. + * The engine to control. */ public StreamControlEngine(final StreamEngine engine) { eng = engine; @@ -61,35 +61,35 @@ public class StreamControlEngine { * Run a SCL program. * * @param tokens - * The program to run. + * The program to run. * * @return Whether the program executed successfully. */ public boolean runProgram(final String[] tokens) { - for (int i = 0; i < tokens.length; i++) { + for(int i = 0; i < tokens.length; i++) { /* Tokenize each token. */ final String token = tokens[i]; final SCLToken tok = SCLToken.tokenizeString(token); - if (tok == null) { + if(tok == null) { System.out.printf("ERROR: Tokenization failed for '%s'\n", token); return false; } /* Handle token types. */ - switch (tok.type) { + switch(tok.type) { case SQUOTE: /* Handle single-quotes. */ i = handleSingleQuote(i, tokens); - if (i == -1) { + if(i == -1) { return false; } break; - + case OBRACKET: /* Handle delimited brackets. */ i = handleDelim(i, tokens, "]"); - if (i == -1) { + if(i == -1) { return false; } break; @@ -97,7 +97,7 @@ public class StreamControlEngine { case OBRACE: /* Handle delimited braces. */ i = handleDelim(i, tokens, "}"); - if (i == -1) { + if(i == -1) { return false; } final SCLToken brak = curStack.pop(); @@ -106,7 +106,7 @@ public class StreamControlEngine { case WORD: /* Handle words. */ - if (!handleWord((WordSCLToken) tok)) { + if(!handleWord((WordSCLToken) tok)) { System.out.printf("WARNING: Execution of word '%s' failed\n", tok); } break; @@ -126,51 +126,52 @@ public class StreamControlEngine { /* Handle each type of word. */ /* - * @NOTE This should probably use something other than a switch statement. + * @NOTE This should probably use something other than a switch + * statement. */ - switch (tk.wordVal) { + switch(tk.wordVal) { case NEWSTREAM: eng.newStream(); break; case LEFTSTREAM: succ = eng.leftStream(); - if (!succ) { + if(!succ) { return false; } break; case RIGHTSTREAM: succ = eng.rightStream(); - if (!succ) { + if(!succ) { return false; } break; case DELETESTREAM: succ = eng.deleteStream(); - if (!succ) { + if(!succ) { return false; } break; case MERGESTREAM: succ = eng.mergeStream(); - if (!succ) { + if(!succ) { return false; } break; case MAKEARRAY: succ = makeArray(); - if (!succ) { + if(!succ) { return false; } break; case MAKEEXEC: succ = toggleExec(true); - if (!succ) { + if(!succ) { return false; } break; case MAKEUNEXEC: succ = toggleExec(false); - if (!succ) { + if(!succ) { return false; } break; @@ -181,7 +182,7 @@ public class StreamControlEngine { curStack.push(new BooleanSCLToken(curStack.empty())); break; case DROP: - if (curStack.size() == 0) { + if(curStack.size() == 0) { Errors.inst.printError(EK_SCL_SUNDERFLOW, tk.toString()); return false; } @@ -189,12 +190,12 @@ public class StreamControlEngine { break; case NDROP: succ = handleNDrop(); - if (!succ) { + if(!succ) { return false; } break; case NIP: - if (curStack.size() < 2) { + if(curStack.size() < 2) { Errors.inst.printError(EK_SCL_SUNDERFLOW, tk.toString()); return false; } @@ -202,7 +203,7 @@ public class StreamControlEngine { break; case NNIP: succ = handleNNip(); - if (!succ) { + if(!succ) { return false; } break; @@ -218,14 +219,14 @@ public class StreamControlEngine { private boolean handleNNip() { final SCLToken num = curStack.pop(); - if (num.type != ILIT) { + if(num.type != ILIT) { Errors.inst.printError(EK_SCL_INVARG, num.type.toString()); return false; } final int n = (int) ((IntSCLToken) num).intVal; - if (curStack.size() < n) { + if(curStack.size() < n) { Errors.inst.printError(EK_SCL_SUNDERFLOW, NNIP.toString()); return false; } @@ -238,14 +239,14 @@ public class StreamControlEngine { private boolean handleNDrop() { final SCLToken num = curStack.pop(); - if (num.type != ILIT) { + if(num.type != ILIT) { Errors.inst.printError(EK_SCL_INVARG, num.type.toString()); return false; } final int n = (int) ((IntSCLToken) num).intVal; - if (curStack.size() < n) { + if(curStack.size() < n) { Errors.inst.printError(EK_SCL_SUNDERFLOW, NDROP.toString()); return false; } @@ -258,15 +259,15 @@ public class StreamControlEngine { private boolean toggleExec(final boolean exec) { final SCLToken top = curStack.top(); - if (exec) { - if (top.type != ARRAY) { + if(exec) { + if(top.type != ARRAY) { Errors.inst.printError(EK_SCL_INVARG, top.toString()); return false; } top.type = WORDS; } else { - if (top.type != WORDS) { + if(top.type != WORDS) { Errors.inst.printError(EK_SCL_INVARG, top.toString()); return false; } @@ -281,13 +282,13 @@ public class StreamControlEngine { private boolean makeArray() { final SCLToken num = curStack.pop(); - if (num.type != ILIT) { + if(num.type != ILIT) { Errors.inst.printError(EK_SCL_INVARG, num.type.toString()); } final IList arr = new FunctionalList<>(); - for (int i = 0; i < ((IntSCLToken) num).intVal; i++) { + for(int i = 0; i < ((IntSCLToken) num).intVal; i++) { arr.add(curStack.pop()); } @@ -302,34 +303,34 @@ public class StreamControlEngine { int n = i + 1; - if (n >= tokens.length) { + if(n >= tokens.length) { Errors.inst.printError(EK_SCL_MMQUOTE); return -1; } String tok = tokens[n]; - while (!tok.equals(delim)) { + while(!tok.equals(delim)) { final SCLToken ntok = SCLToken.tokenizeString(tok); - switch (ntok.type) { + switch(ntok.type) { case SQUOTE: n = handleSingleQuote(n, tokens); - if (n == -1) { + if(n == -1) { return -1; } toks.add(curStack.pop()); break; case OBRACKET: n = handleDelim(n, tokens, "]"); - if (n == -1) { + if(n == -1) { return -1; } toks.add(curStack.pop()); break; case OBRACE: n = handleDelim(i, tokens, "}"); - if (n == -1) { + if(n == -1) { return -1; } final SCLToken brak = curStack.pop(); @@ -342,7 +343,7 @@ public class StreamControlEngine { /* Move to the next token */ n += 1; - if (n >= tokens.length) { + if(n >= tokens.length) { Errors.inst.printError(EK_SCL_MMQUOTE); return -1; } @@ -367,15 +368,15 @@ public class StreamControlEngine { int n = i + 1; - if (n >= tokens.length) { + if(n >= tokens.length) { Errors.inst.printError(EK_SCL_MMQUOTE); return -1; } String tok = tokens[n]; - while (!tok.equals("'")) { - if (tok.matches("\\\\+'")) { + while(!tok.equals("'")) { + if(tok.matches("\\\\+'")) { /* Handle escaped quotes. */ sb.append(tok.substring(1)); } else { @@ -385,7 +386,7 @@ public class StreamControlEngine { /* Move to the next token */ n += 1; - if (n >= tokens.length) { + if(n >= tokens.length) { Errors.inst.printError(EK_SCL_MMQUOTE); return -1; } diff --git a/scl/src/main/java/bjc/dicelang/scl/StreamEngine.java b/scl/src/main/java/bjc/dicelang/scl/StreamEngine.java index e22cae1..7d7c39e 100644 --- a/scl/src/main/java/bjc/dicelang/scl/StreamEngine.java +++ b/scl/src/main/java/bjc/dicelang/scl/StreamEngine.java @@ -4,10 +4,14 @@ import bjc.utils.esodata.SingleTape; import bjc.utils.esodata.Tape; import bjc.utils.esodata.TapeLibrary; import bjc.utils.funcdata.FunctionalList; +import bjc.utils.funcdata.FunctionalMap; import bjc.utils.funcdata.IList; +import bjc.utils.funcdata.IMap; import bjc.utils.funcutils.ListUtils; import java.util.Arrays; +import java.util.function.BooleanSupplier; +import java.util.function.Predicate; import static bjc.dicelang.scl.Errors.ErrorKey.*; @@ -21,7 +25,9 @@ import static bjc.dicelang.scl.Errors.ErrorKey.*; * @author Ben Culkin */ public class StreamEngine { - /* Whether or not we're doing debugging. */ + /** + * Whether or not we're doing debugging. + */ public final boolean debug = true; /* Our streams. */ @@ -34,6 +40,29 @@ public class StreamEngine { /* Handler for SCL programs */ private final StreamControlEngine scleng; + private static IMap> commands; + + static { + commands = new FunctionalMap<>(); + + commands.put('+', (eng) -> { + eng.newStream(); + return true; + }); + + commands.put('>', (eng) -> eng.rightStream()); + commands.put('<', (eng) -> eng.leftStream()); + commands.put('-', (eng) -> eng.deleteStream()); + commands.put('M', (eng) -> eng.mergeStream()); + commands.put('L', (eng) -> { + String[] arr = eng.currStream.toArray(new String[0]); + + boolean succ = eng.scleng.runProgram(arr); + + return succ; + }); + } + /** * Create a new stream engine. * @@ -57,10 +86,10 @@ public class StreamEngine { * Process a possibly interleaved set of streams. * * @param toks - * The raw token to read streams from. + * The raw token to read streams from. * * @param dest - * The list to write the final stream to. + * The list to write the final stream to. * * @return Whether or not the streams were successfully processed. */ @@ -72,10 +101,10 @@ public class StreamEngine { * Process a possibly interleaved set of streams. * * @param toks - * The raw token to read streams from. + * The raw token to read streams from. * * @param dest - * The list to write the final stream to. + * The list to write the final stream to. * * @return Whether or not the streams were successfully processed. */ @@ -87,20 +116,20 @@ public class StreamEngine { boolean quoteMode = false; /* Process each token. */ - for (final String tk : toks) { + for(final String tk : toks) { /* Process stream commands. */ - if (tk.startsWith("{@S") && !quoteMode) { - if (tk.equals("{@SQ}")) { + if(tk.startsWith("{@S") && !quoteMode) { + if(tk.equals("{@SQ}")) { /* Start quoting. */ quoteMode = true; - } else if (!processCommand(tk)) { + } else if(!processCommand(tk)) { return false; } } else { - if (tk.equals("{@SU}")) { + if(tk.equals("{@SU}")) { /* Stop quoting. */ quoteMode = false; - } else if (tk.startsWith("\\") && tk.endsWith("{@SU}")) { + } else if(tk.startsWith("\\") && tk.endsWith("{@SU}")) { /* Unquote quoted end. */ currStream.add(tk.substring(1)); } else { @@ -109,7 +138,7 @@ public class StreamEngine { } } - for (final String tk : currStream) { + for(final String tk : currStream) { /* Collect tokens from the current stream. */ dest.add(tk); } @@ -128,7 +157,7 @@ public class StreamEngine { * @return Whether or not the move was successful. */ public boolean rightStream() { - if (!streams.right()) { + if(!streams.right()) { Errors.inst.printError(EK_STRM_NONEX); return false; } @@ -143,7 +172,7 @@ public class StreamEngine { * @return Whether or not the move was successful. */ public boolean leftStream() { - if (!streams.left()) { + if(!streams.left()) { Errors.inst.printError(EK_STRM_NONEX); return false; } @@ -158,7 +187,7 @@ public class StreamEngine { * @return Whether or not the delete succeeded. */ public boolean deleteStream() { - if (streams.size() == 1) { + if(streams.size() == 1) { Errors.inst.printError(EK_STRM_LAST); return false; } @@ -175,7 +204,7 @@ public class StreamEngine { * @return Whether or not the merge succeded. */ public boolean mergeStream() { - if (streams.size() == 1) { + if(streams.size() == 1) { Errors.inst.printError(EK_STRM_LAST); return false; } @@ -190,7 +219,7 @@ public class StreamEngine { private boolean processCommand(final String tk) { char[] comms = null; - if (tk.length() > 5) { + if(tk.length() > 5) { /* Pull off {@S and closing } */ comms = tk.substring(3, tk.length() - 1).toCharArray(); } else { @@ -199,54 +228,16 @@ public class StreamEngine { comms[0] = tk.charAt(3); } - boolean succ; - /* Process each command. */ - /* - * @TODO 10/09/17 Ben Culkin :StreamCommands This should probably be refactored - * in some way, so as to make it easier to add new commands. - */ - for (final char comm : comms) { - switch (comm) { - case '+': - newStream(); - break; - case '>': - succ = rightStream(); - if (!succ) { - return false; - } - break; - case '<': - succ = leftStream(); - if (!succ) { - return false; - } - break; - case '-': - succ = deleteStream(); - if (!succ) { - return false; - } - break; - case 'M': - succ = mergeStream(); - if (!succ) { - return false; - } - break; - case 'L': - succ = scleng.runProgram(currStream.toArray(new String[0])); - if (!succ) { - return false; - } - break; - default: + for(final char comm : comms) { + boolean succ = commands.getOrDefault(comm, (eng) -> { Errors.inst.printError(EK_STRM_INVCOM, tk); return false; - } + }).test(this); + + if(!succ) return false; } return true; } -} +} \ No newline at end of file diff --git a/scl/src/main/java/bjc/dicelang/scl/tokens/BooleanSCLToken.java b/scl/src/main/java/bjc/dicelang/scl/tokens/BooleanSCLToken.java index bb6d1a2..c62e4a6 100644 --- a/scl/src/main/java/bjc/dicelang/scl/tokens/BooleanSCLToken.java +++ b/scl/src/main/java/bjc/dicelang/scl/tokens/BooleanSCLToken.java @@ -20,15 +20,11 @@ public class BooleanSCLToken extends SCLToken { @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; + if(this == obj) return true; + if(!super.equals(obj)) return false; + if(getClass() != obj.getClass()) return false; BooleanSCLToken other = (BooleanSCLToken) obj; - if (boolVal != other.boolVal) - return false; + if(boolVal != other.boolVal) return false; return true; } diff --git a/scl/src/main/java/bjc/dicelang/scl/tokens/FloatSCLToken.java b/scl/src/main/java/bjc/dicelang/scl/tokens/FloatSCLToken.java index 835e881..6c07c4d 100644 --- a/scl/src/main/java/bjc/dicelang/scl/tokens/FloatSCLToken.java +++ b/scl/src/main/java/bjc/dicelang/scl/tokens/FloatSCLToken.java @@ -22,15 +22,11 @@ public class FloatSCLToken extends SCLToken { @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; + if(this == obj) return true; + if(!super.equals(obj)) return false; + if(getClass() != obj.getClass()) return false; FloatSCLToken other = (FloatSCLToken) obj; - if (Double.doubleToLongBits(floatVal) != Double.doubleToLongBits(other.floatVal)) - return false; + if(Double.doubleToLongBits(floatVal) != Double.doubleToLongBits(other.floatVal)) return false; return true; } diff --git a/scl/src/main/java/bjc/dicelang/scl/tokens/SCLToken.java b/scl/src/main/java/bjc/dicelang/scl/tokens/SCLToken.java index c0158d0..d729705 100644 --- a/scl/src/main/java/bjc/dicelang/scl/tokens/SCLToken.java +++ b/scl/src/main/java/bjc/dicelang/scl/tokens/SCLToken.java @@ -22,19 +22,19 @@ public class SCLToken { public SCLToken.Type type; public static SCLToken tokenizeString(final String token) { - if (litTokens.containsKey(token)) { + if(litTokens.containsKey(token)) { return new IntSCLToken(litTokens.get(token)); - } else if (token.startsWith("\\")) { + } else if(token.startsWith("\\")) { return new SymbolSCLToken(token.substring(1)); - } else if (WordSCLToken.isBuiltinWord(token)) { + } else if(WordSCLToken.isBuiltinWord(token)) { return new WordSCLToken(token); - } else if (token.equals("true")) { + } else if(token.equals("true")) { return new BooleanSCLToken(true); - } else if (token.equals("false")) { + } else if(token.equals("false")) { return new BooleanSCLToken(false); - } else if (TokenUtils.isInt(token)) { + } else if(TokenUtils.isInt(token)) { return new IntSCLToken(Long.parseLong(token)); - } else if (TokenUtils.isDouble(token)) { + } else if(TokenUtils.isDouble(token)) { return new FloatSCLToken(Double.parseDouble(token)); } else { Errors.inst.printError(EK_SCL_INVTOKEN, token); @@ -72,15 +72,11 @@ public class SCLToken { @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; + if(this == obj) return true; + if(obj == null) return false; + if(getClass() != obj.getClass()) return false; SCLToken other = (SCLToken) obj; - if (type != other.type) - return false; + if(type != other.type) return false; return true; } diff --git a/scl/src/main/java/bjc/dicelang/scl/tokens/StringSCLToken.java b/scl/src/main/java/bjc/dicelang/scl/tokens/StringSCLToken.java index fcd339c..d4ed8ec 100644 --- a/scl/src/main/java/bjc/dicelang/scl/tokens/StringSCLToken.java +++ b/scl/src/main/java/bjc/dicelang/scl/tokens/StringSCLToken.java @@ -5,7 +5,7 @@ public class StringSCLToken extends SCLToken { public String stringVal; protected StringSCLToken(boolean isSymbol, String val) { - if (isSymbol) { + if(isSymbol) { type = Type.SYMBOL; } else { type = Type.SLIT; @@ -24,18 +24,13 @@ public class StringSCLToken extends SCLToken { @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; + if(this == obj) return true; + if(!super.equals(obj)) return false; + if(getClass() != obj.getClass()) return false; StringSCLToken other = (StringSCLToken) obj; - if (stringVal == null) { - if (other.stringVal != null) - return false; - } else if (!stringVal.equals(other.stringVal)) - return false; + if(stringVal == null) { + if(other.stringVal != null) return false; + } else if(!stringVal.equals(other.stringVal)) return false; return true; } diff --git a/scl/src/main/java/bjc/dicelang/scl/tokens/WordListSCLToken.java b/scl/src/main/java/bjc/dicelang/scl/tokens/WordListSCLToken.java index f6ae63b..8463b66 100644 --- a/scl/src/main/java/bjc/dicelang/scl/tokens/WordListSCLToken.java +++ b/scl/src/main/java/bjc/dicelang/scl/tokens/WordListSCLToken.java @@ -7,7 +7,7 @@ public class WordListSCLToken extends SCLToken { public IList tokenVals; protected WordListSCLToken(boolean isArray, IList tokens) { - if (isArray) { + if(isArray) { type = Type.ARRAY; } else { type = Type.WORDS; @@ -26,18 +26,13 @@ public class WordListSCLToken extends SCLToken { @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; + if(this == obj) return true; + if(!super.equals(obj)) return false; + if(getClass() != obj.getClass()) return false; WordListSCLToken other = (WordListSCLToken) obj; - if (tokenVals == null) { - if (other.tokenVals != null) - return false; - } else if (!tokenVals.equals(other.tokenVals)) - return false; + if(tokenVals == null) { + if(other.tokenVals != null) return false; + } else if(!tokenVals.equals(other.tokenVals)) return false; return true; } diff --git a/scl/src/main/java/bjc/dicelang/scl/tokens/WordSCLToken.java b/scl/src/main/java/bjc/dicelang/scl/tokens/WordSCLToken.java index dcbef72..5c3c8cb 100644 --- a/scl/src/main/java/bjc/dicelang/scl/tokens/WordSCLToken.java +++ b/scl/src/main/java/bjc/dicelang/scl/tokens/WordSCLToken.java @@ -42,15 +42,11 @@ public class WordSCLToken extends SCLToken { @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; + if(this == obj) return true; + if(!super.equals(obj)) return false; + if(getClass() != obj.getClass()) return false; WordSCLToken other = (WordSCLToken) obj; - if (wordVal != other.wordVal) - return false; + if(wordVal != other.wordVal) return false; return true; } diff --git a/scl/src/test/java/bjc/AppTest.java b/scl/src/test/java/bjc/AppTest.java index 8d8ca91..21becec 100644 --- a/scl/src/test/java/bjc/AppTest.java +++ b/scl/src/test/java/bjc/AppTest.java @@ -7,32 +7,28 @@ import junit.framework.TestSuite; /** * Unit test for simple App. */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } +public class AppTest extends TestCase { + /** + * Create the test case + * + * @param testName + * name of the test case + */ + public AppTest(String testName) { + super(testName); + } - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } + /** + * @return the suite of tests being tested + */ + public static Test suite() { + return new TestSuite(AppTest.class); + } - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } + /** + * Rigourous Test :-) + */ + public void testApp() { + assertTrue(true); + } } -- cgit v1.2.3