Skip to content

Commit

Permalink
Fixed Short Truth Table case rule bug (Bram-Hub#707)
Browse files Browse the repository at this point in the history
* Revert "Bugfix 549 (Bram-Hub#682)"

This reverts commit 5048ee6.

* Case rule test fix (Bram-Hub#705)

Co-authored-by: Chase Grajeda <[email protected]>

* Rapid fix for STT case rules

Case rules broke at some point from legacy code or merge conflict. Provided is a quick fix in CaseRule and CaseRule_Generic

* Revert "Revert "Bugfix 549 (Bram-Hub#682)"" (Bram-Hub#706)

This reverts commit e9fe310.

---------

Co-authored-by: Chase-Grajeda <[email protected]>
Co-authored-by: Chase Grajeda <[email protected]>
  • Loading branch information
3 people authored Jan 26, 2024
1 parent dca8358 commit 653c816
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 40 deletions.
28 changes: 14 additions & 14 deletions bin/main/edu/rpi/legup/log4j2.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Logging level
# Root logger option
log4j.rootLogger=DEBUG, stdout, file
# Redirect log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=Legup.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
# Logging level
# Root logger option
log4j.rootLogger=DEBUG, stdout, file
# Redirect log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=Legup.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
10 changes: 0 additions & 10 deletions src/main/java/edu/rpi/legup/model/rules/CaseRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,10 @@ public String checkRule(TreeTransition transition) {
return "Must not have multiple parent nodes";
}

/*if (transition.getBoard().getModifiedData().size() != 0){
return "Should not modify before case rule";
}*/


for (TreeTransition childTrans : parentNodes.get(0).getChildren()) {
if (childTrans.getRule() == null || !childTrans.getRule().getClass().equals(this.getClass())) {
return "All children nodes must be justified with the same case rule.";
}
else {
if (childTrans.getBoard().getModifiedData().isEmpty()) {
return "You must modify the board in each case node";
}
}
}

String check = checkRuleRaw(transition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ public CaseRule_Generic(String ruleID, String ruleName, String title, String des
public String checkRuleRaw(TreeTransition transition) {
// Validate that two children are generated
List<TreeTransition> childTransitions = transition.getParents().get(0).getChildren();
if (childTransitions.size() >= 1) {
if (childTransitions.size() == 0) {
return "ERROR: This case rule must spawn at least 1 child.";
}

// Validate that the modified cells are of type UNKNOWN, TRUE, or FALSE
List<TreeTransition> cases = Arrays.asList(childTransitions.get(0), childTransitions.get(1));
for (TreeTransition c : cases) {
ShortTruthTableCell mod1 = (ShortTruthTableCell)c.getBoard().getModifiedData().iterator().next();
ShortTruthTableCell mod2 = (ShortTruthTableCell)c.getBoard().getModifiedData().iterator().next();
if (!(mod1.getType() == ShortTruthTableCellType.TRUE || mod1.getType() == ShortTruthTableCellType.FALSE || mod1.getType() == ShortTruthTableCellType.UNKNOWN) &&
(mod2.getType() == ShortTruthTableCellType.TRUE || mod2.getType() == ShortTruthTableCellType.FALSE || mod2.getType() == ShortTruthTableCellType.UNKNOWN)) {
return "ERROR: This case rule must be an unknown, true, or false cell.";
}
}
// // Validate that the modified cells are of type UNKNOWN, TRUE, or FALSE
// List<TreeTransition> cases = Arrays.asList(childTransitions.get(0), childTransitions.get(1));
// for (TreeTransition c : cases) {
// ShortTruthTableCell mod1 = (ShortTruthTableCell)c.getBoard().getModifiedData().iterator().next();
// ShortTruthTableCell mod2 = (ShortTruthTableCell)c.getBoard().getModifiedData().iterator().next();
// if (!(mod1.getType() == ShortTruthTableCellType.TRUE || mod1.getType() == ShortTruthTableCellType.FALSE || mod1.getType() == ShortTruthTableCellType.UNKNOWN) &&
// (mod2.getType() == ShortTruthTableCellType.TRUE || mod2.getType() == ShortTruthTableCellType.FALSE || mod2.getType() == ShortTruthTableCellType.UNKNOWN)) {
// return "ERROR: This case rule must be an unknown, true, or false cell.";
// }
// }
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private void falseAndTest(String fileName,
ArrayList<Board> cases = RULE.getCases(board, cell);

// Make sure that the rule checks out
Assert.assertNotNull(RULE.checkRule(transition));
Assert.assertNull(RULE.checkRule(transition));

// Make sure there are two branches
Assert.assertEquals(2, cases.size());
Expand Down Expand Up @@ -120,7 +120,7 @@ private void trueAndTest(String fileName,
ArrayList<Board> cases = RULE.getCases(board, cell);

// Make sure that the rule checks out
Assert.assertNotNull(RULE.checkRule(transition));
Assert.assertNull(RULE.checkRule(transition));

// There should only be 1 branch
Assert.assertEquals(1, cases.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private void trueOrTest(String fileName,
ArrayList<Board> cases = RULE.getCases(board, cell);

// Make sure that the rule checks out
Assert.assertNotNull(RULE.checkRule(transition));
Assert.assertNull(RULE.checkRule(transition));

// Make sure there are two branches
Assert.assertEquals(2, cases.size());
Expand Down Expand Up @@ -121,7 +121,7 @@ private void falseOrTest(String fileName,
ArrayList<Board> cases = RULE.getCases(board, cell);

// Make sure that the rule checks out
Assert.assertNotNull(RULE.checkRule(transition));
Assert.assertNull(RULE.checkRule(transition));

// There should only be 1 branch
Assert.assertEquals(1, cases.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void TwoBranchesTest() throws InvalidFileFormatException {
ArrayList<Board> cases = RULE.getCases(board, cell);

// Make sure that the rule checks out
Assert.assertNotNull(RULE.checkRule(transition));
Assert.assertNull(RULE.checkRule(transition));

// Make sure there are two branches
Assert.assertEquals(2, cases.size());
Expand Down

0 comments on commit 653c816

Please sign in to comment.