From 9a617456bca7e0e7de3b3fd3f932dd2a3553967a Mon Sep 17 00:00:00 2001
From: Charles Tian <46334090+charlestian23@users.noreply.github.com>
Date: Tue, 28 Nov 2023 16:17:44 -0500
Subject: [PATCH] Or Elimination, Or Introduction, Not Introduction, and And
Introduction Test Cases (#689)
* Initial setup
* Working initial test
* Added another test
* Added more tests
* Added another test
* Added comments, removed useless imports, added 1 more test
* Reformatting
* Removed useless import
* Added initial and elimination test
* Comments and spacing
* Another test
* Updated comments and wrote new test
* Created two new test files
* Renamed test to be more descriptive
* Added another test
* Rewrote test to be more comprehensive
* More tests :))))
* Fixed test name and file
* Fixed test
* Fixed broken tests
* Shouldn't have touched these files
* CHECKSTYLE
* Trying to make CheckStyle happy
* Initial commit for more tests
* Finished a test
* Another test done
* More tests
* Added cannot set both at once test
* Conditional files
* Some tests done
* More tests
* Even more tests
* Fixed comments to use biconditional symbol
* Added tests for false conditional
Now tests only setting the A value and only setting the B value
* Fixed some broken biconditional files and added new ones
* Added more tests for B and fixed some descriptions
* Checkstyle fix
* Added tests for Not Elimination
One of the tests failed, but I tested that and that seems to be the case. It should be failing.
* Temporarily commenting out broken test
* Added or elimination puzzle files
* Renamed directory
These should be for Or Introduction, not Or Elimination
* Added Or Elimination files
* Added FTU and UTF tests
* More tests
* Add Or Intro tests
* Checkstyle fix
* Spacing fix
* Added not introduction test
* Added And Introduction tests and modified Or Introduction tests
---------
Co-authored-by: Ivan Ho <41582274+Corppet@users.noreply.github.com>
---
.../rules/AndIntroductionDirectRuleTest.java | 105 ++++++++++++
.../rules/NotIntroductionTest.java | 122 ++++++++++++++
.../rules/OrEliminationTest.java | 150 ++++++++++++++++++
.../rules/OrIntroductionTest.java | 105 ++++++++++++
.../rules/AndIntroductionDirectRule/FUF | 14 ++
.../rules/AndIntroductionDirectRule/FUT | 14 ++
.../rules/AndIntroductionDirectRule/FUU | 13 ++
.../rules/AndIntroductionDirectRule/TUF | 14 ++
.../rules/AndIntroductionDirectRule/TUT | 14 ++
.../rules/AndIntroductionDirectRule/TUU | 13 ++
.../rules/AndIntroductionDirectRule/UUF | 13 ++
.../rules/AndIntroductionDirectRule/UUT | 13 ++
.../rules/AndIntroductionDirectRule/UUU | 12 ++
.../rules/NotIntroductionDirectRule/BlankA | 12 ++
.../rules/NotIntroductionDirectRule/FalseA | 13 ++
.../rules/NotIntroductionDirectRule/TrueA | 13 ++
.../rules/OrEliminationDirectRule/FTU | 14 ++
.../rules/OrEliminationDirectRule/UFU | 13 ++
.../rules/OrEliminationDirectRule/UTF | 14 ++
.../rules/OrEliminationDirectRule/UTU | 13 ++
.../rules/OrIntroductionDirectRule/FUF | 14 ++
.../rules/OrIntroductionDirectRule/FUT | 14 ++
.../rules/OrIntroductionDirectRule/FUU | 13 ++
.../rules/OrIntroductionDirectRule/TUF | 14 ++
.../rules/OrIntroductionDirectRule/TUT | 14 ++
.../rules/OrIntroductionDirectRule/TUU | 13 ++
.../rules/OrIntroductionDirectRule/UUF | 13 ++
.../rules/OrIntroductionDirectRule/UUT | 13 ++
.../rules/OrIntroductionDirectRule/UUU | 12 ++
29 files changed, 814 insertions(+)
create mode 100644 src/test/java/puzzles/shorttruthtable/rules/AndIntroductionDirectRuleTest.java
create mode 100644 src/test/java/puzzles/shorttruthtable/rules/NotIntroductionTest.java
create mode 100644 src/test/java/puzzles/shorttruthtable/rules/OrEliminationTest.java
create mode 100644 src/test/java/puzzles/shorttruthtable/rules/OrIntroductionTest.java
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/FUF
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/FUT
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/FUU
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/TUF
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/TUT
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/TUU
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/UUF
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/UUT
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/UUU
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/NotIntroductionDirectRule/BlankA
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/NotIntroductionDirectRule/FalseA
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/NotIntroductionDirectRule/TrueA
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/OrEliminationDirectRule/FTU
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/OrEliminationDirectRule/UFU
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/OrEliminationDirectRule/UTF
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/OrEliminationDirectRule/UTU
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/FUF
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/FUT
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/FUU
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/TUF
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/TUT
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/TUU
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/UUF
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/UUT
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/UUU
diff --git a/src/test/java/puzzles/shorttruthtable/rules/AndIntroductionDirectRuleTest.java b/src/test/java/puzzles/shorttruthtable/rules/AndIntroductionDirectRuleTest.java
new file mode 100644
index 000000000..4d4e009b2
--- /dev/null
+++ b/src/test/java/puzzles/shorttruthtable/rules/AndIntroductionDirectRuleTest.java
@@ -0,0 +1,105 @@
+package puzzles.shorttruthtable.rules;
+
+import edu.rpi.legup.model.tree.TreeNode;
+import edu.rpi.legup.model.tree.TreeTransition;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTable;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableBoard;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCell;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCellType;
+import edu.rpi.legup.puzzle.shorttruthtable.rules.basic.introduction.DirectRuleAndIntroduction;
+import edu.rpi.legup.save.InvalidFileFormatException;
+import legup.MockGameBoardFacade;
+import legup.TestUtilities;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class AndIntroductionDirectRuleTest {
+ private static final DirectRuleAndIntroduction RULE = new DirectRuleAndIntroduction();
+ private static ShortTruthTable stt;
+
+ @BeforeClass
+ public static void setup() {
+ MockGameBoardFacade.getInstance();
+ stt = new ShortTruthTable();
+ }
+
+ /**
+ * Given a statement: A ^ B
+ *
+ * Asserts that if at least 1 of A or B is false, then this is a valid application
+ * of the rule if and only if ^ is false.
+ *
+ * @param filePath The file path for test board setup.
+ * @throws InvalidFileFormatException
+ */
+ @Test
+ public void FalseAndTest() throws InvalidFileFormatException {
+ String path = "puzzles/shorttruthtable/rules/AndIntroductionDirectRule/";
+ falseAndTestHelper(path + "FUF");
+ falseAndTestHelper(path + "FUU");
+ falseAndTestHelper(path + "UUF");
+ falseAndTestHelper(path + "FUT");
+ falseAndTestHelper(path + "TUF");
+ }
+
+ private void falseAndTestHelper(String filePath) throws InvalidFileFormatException {
+ TestUtilities.importTestBoard(filePath, stt);
+ TreeNode rootNode = stt.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
+ ShortTruthTableCell and = board.getCell(1, 0);
+
+ and.setData(ShortTruthTableCellType.TRUE);
+ board.addModifiedData(and);
+ Assert.assertNotNull(RULE.checkRule(transition));
+
+ and.setData(ShortTruthTableCellType.FALSE);
+ board.addModifiedData(and);
+ Assert.assertNull(RULE.checkRule(transition));
+ }
+
+ /**
+ * Given a statement: A ^ B
+ *
+ * Asserts that setting ^ to true is a valid application of the rule if
+ * and only if both A and B are true.
+ *
+ * @param filePath The file path for test board setup.
+ * @throws InvalidFileFormatException
+ */
+ @Test
+ public void FalseOrTest() throws InvalidFileFormatException {
+ String path = "puzzles/shorttruthtable/rules/AndIntroductionDirectRule/";
+ String[] letters = {"T", "F", "U"};
+ for (String first : letters) {
+ for (String second : letters) {
+ trueAndTestHelper(path + first + "U" + second);
+ }
+ }
+ }
+
+ private void trueAndTestHelper(String filePath) throws InvalidFileFormatException {
+ TestUtilities.importTestBoard(filePath, stt);
+ TreeNode rootNode = stt.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
+ ShortTruthTableCell a = board.getCell(0, 0);
+ ShortTruthTableCell b = board.getCell(2, 0);
+ ShortTruthTableCell and = board.getCell(1, 0);
+
+ and.setData(ShortTruthTableCellType.TRUE);
+ board.addModifiedData(and);
+
+ if (a.getType() == ShortTruthTableCellType.TRUE && b.getType() == ShortTruthTableCellType.TRUE) {
+ Assert.assertNull(RULE.checkRule(transition));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRule(transition));
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/puzzles/shorttruthtable/rules/NotIntroductionTest.java b/src/test/java/puzzles/shorttruthtable/rules/NotIntroductionTest.java
new file mode 100644
index 000000000..a0a062ab3
--- /dev/null
+++ b/src/test/java/puzzles/shorttruthtable/rules/NotIntroductionTest.java
@@ -0,0 +1,122 @@
+package puzzles.shorttruthtable.rules;
+
+import edu.rpi.legup.model.tree.TreeNode;
+import edu.rpi.legup.model.tree.TreeTransition;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTable;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableBoard;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCell;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCellType;
+import edu.rpi.legup.puzzle.shorttruthtable.rules.basic.introduction.DirectRuleNotIntroduction;
+import edu.rpi.legup.save.InvalidFileFormatException;
+import legup.MockGameBoardFacade;
+import legup.TestUtilities;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class NotIntroductionTest {
+ private static final DirectRuleNotIntroduction RULE = new DirectRuleNotIntroduction();
+ private static ShortTruthTable stt;
+
+ @BeforeClass
+ public static void setup() {
+ MockGameBoardFacade.getInstance();
+ stt = new ShortTruthTable();
+ }
+
+ /**
+ * Given one statement: ¬A where A is false
+ *
+ * Asserts that this is a valid application of this rule if and only if ¬ is true
+ *
+ * @throws InvalidFileFormatException
+ */
+ @Test
+ public void FalseNot() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/NotIntroductionDirectRule/FalseA", stt);
+ TreeNode rootNode = stt.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ ShortTruthTableCellType[] cellTypes = {ShortTruthTableCellType.TRUE, ShortTruthTableCellType.FALSE, ShortTruthTableCellType.UNKNOWN};
+
+ for (ShortTruthTableCellType cellType : cellTypes) {
+ ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
+ ShortTruthTableCell not = board.getCell(0, 0);
+ not.setData(cellType);
+ board.addModifiedData(not);
+
+ if (cellType == ShortTruthTableCellType.TRUE) {
+ Assert.assertNull(RULE.checkRule(transition));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRule(transition));
+ }
+ }
+ }
+
+ /**
+ * Given one statement: ¬A where A is true
+ *
+ * Asserts that this is a valid application of this rule if and only if ¬ is false
+ *
+ * @throws InvalidFileFormatException
+ */
+ @Test
+ public void TrueNot() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/NotIntroductionDirectRule/TrueA", stt);
+ TreeNode rootNode = stt.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ ShortTruthTableCellType[] cellTypes = {ShortTruthTableCellType.TRUE, ShortTruthTableCellType.FALSE, ShortTruthTableCellType.UNKNOWN};
+
+ for (ShortTruthTableCellType cellType : cellTypes) {
+ ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
+ ShortTruthTableCell not = board.getCell(0, 0);
+ not.setData(cellType);
+ board.addModifiedData(not);
+
+ if (cellType == ShortTruthTableCellType.FALSE) {
+ Assert.assertNull(RULE.checkRule(transition));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRule(transition));
+ }
+ }
+ }
+
+ /**
+ * Given one statement: ¬A
+ *
+ * Asserts that setting both ¬ and A to any values would not be a valid
+ * application of this rule
+ *
+ * @throws InvalidFileFormatException
+ */
+ @Test
+ public void CannotSetBothAtOnceTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/NotIntroductionDirectRule/BlankA", stt);
+ TreeNode rootNode = stt.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ ShortTruthTableCellType[] cellTypes = {ShortTruthTableCellType.TRUE, ShortTruthTableCellType.FALSE, ShortTruthTableCellType.UNKNOWN};
+
+ for (ShortTruthTableCellType cellType1 : cellTypes) {
+ for (ShortTruthTableCellType cellType2 : cellTypes) {
+ ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
+ ShortTruthTableCell not = board.getCell(0, 0);
+ ShortTruthTableCell a = board.getCell(1, 0);
+
+ not.setData(cellType1);
+ a.setData(cellType2);
+
+ board.addModifiedData(not);
+ board.addModifiedData(a);
+
+ Assert.assertNotNull(RULE.checkRule(transition));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/puzzles/shorttruthtable/rules/OrEliminationTest.java b/src/test/java/puzzles/shorttruthtable/rules/OrEliminationTest.java
new file mode 100644
index 000000000..6cdd0d639
--- /dev/null
+++ b/src/test/java/puzzles/shorttruthtable/rules/OrEliminationTest.java
@@ -0,0 +1,150 @@
+package puzzles.shorttruthtable.rules;
+
+import edu.rpi.legup.model.tree.TreeNode;
+import edu.rpi.legup.model.tree.TreeTransition;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTable;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableBoard;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCell;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCellType;
+import edu.rpi.legup.puzzle.shorttruthtable.rules.basic.elimination.DirectRuleOrElimination;
+import edu.rpi.legup.save.InvalidFileFormatException;
+import legup.MockGameBoardFacade;
+import legup.TestUtilities;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class OrEliminationTest {
+ private static final DirectRuleOrElimination RULE = new DirectRuleOrElimination();
+ private static ShortTruthTable stt;
+
+ @BeforeClass
+ public static void setup() {
+ MockGameBoardFacade.getInstance();
+ stt = new ShortTruthTable();
+ }
+
+ /**
+ * Given a statement: A V B, where A is false and V is true
+ *
+ * Asserts that this is a valid application of the rule if and only if B is true.
+ *
+ * @throws InvalidFileFormatException
+ */
+ @Test
+ public void FTUTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/OrEliminationDirectRule/FTU", stt);
+ TreeNode rootNode = stt.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
+ ShortTruthTableCell cell = board.getCell(2, 0);
+
+ cell.setData(ShortTruthTableCellType.TRUE);
+ board.addModifiedData(cell);
+ Assert.assertNull(RULE.checkRule(transition));
+
+ cell.setData(ShortTruthTableCellType.FALSE);
+ board.addModifiedData(cell);
+ Assert.assertNotNull(RULE.checkRule(transition));
+ }
+
+ /**
+ * Given a statement: A V B, where B is false and V is true
+ *
+ * Asserts that this is a valid application of the rule if and only if B is true.
+ *
+ * @throws InvalidFileFormatException
+ */
+ @Test
+ public void UTFTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/OrEliminationDirectRule/UTF", stt);
+ TreeNode rootNode = stt.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
+ ShortTruthTableCell cell = board.getCell(0, 0);
+
+ cell.setData(ShortTruthTableCellType.TRUE);
+ board.addModifiedData(cell);
+ Assert.assertNull(RULE.checkRule(transition));
+
+ cell.setData(ShortTruthTableCellType.FALSE);
+ board.addModifiedData(cell);
+ Assert.assertNotNull(RULE.checkRule(transition));
+ }
+
+ /**
+ * Given a statement: A V B, where V is false
+ *
+ * Asserts that this is a valid application of the rule if and only if both A
+ * and B are false.
+ *
+ * @throws InvalidFileFormatException
+ */
+ @Test
+ public void UFUTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/OrEliminationDirectRule/UFU", stt);
+ TreeNode rootNode = stt.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ ShortTruthTableCellType[] cellTypes = {ShortTruthTableCellType.TRUE, ShortTruthTableCellType.FALSE, ShortTruthTableCellType.UNKNOWN};
+
+ for (ShortTruthTableCellType cellType1 : cellTypes) {
+ for (ShortTruthTableCellType cellType2 : cellTypes) {
+ ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
+ ShortTruthTableCell a = board.getCell(0, 0);
+ ShortTruthTableCell b = board.getCell(2, 0);
+
+ a.setData(cellType1);
+ b.setData(cellType2);
+
+ board.addModifiedData(a);
+ board.addModifiedData(b);
+
+ if (cellType1 == ShortTruthTableCellType.FALSE && cellType2 == ShortTruthTableCellType.FALSE) {
+ Assert.assertNull(RULE.checkRule(transition));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRule(transition));
+ }
+ }
+ }
+ }
+
+ /**
+ * Given a statement: A V B, where V is true
+ *
+ * Asserts that setting both A and B is not a valid application of this rule.
+ *
+ * @throws InvalidFileFormatException
+ */
+ @Test
+ public void UTUTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/OrEliminationDirectRule/UTU", stt);
+ TreeNode rootNode = stt.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ ShortTruthTableCellType[] cellTypes = {ShortTruthTableCellType.TRUE, ShortTruthTableCellType.FALSE, ShortTruthTableCellType.UNKNOWN};
+
+ for (ShortTruthTableCellType cellType1 : cellTypes) {
+ for (ShortTruthTableCellType cellType2 : cellTypes) {
+ ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
+ ShortTruthTableCell a = board.getCell(0, 0);
+ ShortTruthTableCell b = board.getCell(2, 0);
+
+ a.setData(cellType1);
+ b.setData(cellType2);
+
+ board.addModifiedData(a);
+ board.addModifiedData(b);
+
+ Assert.assertNotNull(RULE.checkRule(transition));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/puzzles/shorttruthtable/rules/OrIntroductionTest.java b/src/test/java/puzzles/shorttruthtable/rules/OrIntroductionTest.java
new file mode 100644
index 000000000..13cb10d55
--- /dev/null
+++ b/src/test/java/puzzles/shorttruthtable/rules/OrIntroductionTest.java
@@ -0,0 +1,105 @@
+package puzzles.shorttruthtable.rules;
+
+import edu.rpi.legup.model.tree.TreeNode;
+import edu.rpi.legup.model.tree.TreeTransition;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTable;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableBoard;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCell;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCellType;
+import edu.rpi.legup.puzzle.shorttruthtable.rules.basic.introduction.DirectRuleOrIntroduction;
+import edu.rpi.legup.save.InvalidFileFormatException;
+import legup.MockGameBoardFacade;
+import legup.TestUtilities;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class OrIntroductionTest {
+ private static final DirectRuleOrIntroduction RULE = new DirectRuleOrIntroduction();
+ private static ShortTruthTable stt;
+
+ @BeforeClass
+ public static void setup() {
+ MockGameBoardFacade.getInstance();
+ stt = new ShortTruthTable();
+ }
+
+ /**
+ * Given a statement: A V B
+ *
+ * Asserts that if at least 1 of A or B is true, then this is a valid application
+ * of the rule if and only if V is true.
+ *
+ * @param filePath The file path for test board setup.
+ * @throws InvalidFileFormatException
+ */
+ @Test
+ public void TrueOrTest() throws InvalidFileFormatException {
+ String path = "puzzles/shorttruthtable/rules/OrIntroductionDirectRule/";
+ trueOrTestHelper(path + "TUT");
+ trueOrTestHelper(path + "TUU");
+ trueOrTestHelper(path + "UUT");
+ trueOrTestHelper(path + "TUF");
+ trueOrTestHelper(path + "FUT");
+ }
+
+ private void trueOrTestHelper(String filePath) throws InvalidFileFormatException {
+ TestUtilities.importTestBoard(filePath, stt);
+ TreeNode rootNode = stt.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
+ ShortTruthTableCell or = board.getCell(1, 0);
+
+ or.setData(ShortTruthTableCellType.TRUE);
+ board.addModifiedData(or);
+ Assert.assertNull(RULE.checkRule(transition));
+
+ or.setData(ShortTruthTableCellType.FALSE);
+ board.addModifiedData(or);
+ Assert.assertNotNull(RULE.checkRule(transition));
+ }
+
+ /**
+ * Given a statement: A V B
+ *
+ * Asserts that setting V to false is a valid application of the rule if
+ * and only if both A and B are false.
+ *
+ * @param filePath The file path for test board setup.
+ * @throws InvalidFileFormatException
+ */
+ @Test
+ public void FalseOrTest() throws InvalidFileFormatException {
+ String path = "puzzles/shorttruthtable/rules/OrIntroductionDirectRule/";
+ String[] letters = {"T", "F", "U"};
+ for (String first : letters) {
+ for (String second : letters) {
+ falseOrTestHelper(path + first + "U" + second);
+ }
+ }
+ }
+
+ private void falseOrTestHelper(String filePath) throws InvalidFileFormatException {
+ TestUtilities.importTestBoard(filePath, stt);
+ TreeNode rootNode = stt.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
+ ShortTruthTableCell a = board.getCell(0, 0);
+ ShortTruthTableCell b = board.getCell(2, 0);
+ ShortTruthTableCell or = board.getCell(1, 0);
+
+ or.setData(ShortTruthTableCellType.FALSE);
+ board.addModifiedData(or);
+
+ if (a.getType() == ShortTruthTableCellType.FALSE && b.getType() == ShortTruthTableCellType.FALSE) {
+ Assert.assertNull(RULE.checkRule(transition));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRule(transition));
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/FUF b/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/FUF
new file mode 100644
index 000000000..003792ec0
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/FUF
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+ |
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/FUT b/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/FUT
new file mode 100644
index 000000000..05803b88d
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/FUT
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+ |
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/FUU b/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/FUU
new file mode 100644
index 000000000..b97eafdfe
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/FUU
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/TUF b/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/TUF
new file mode 100644
index 000000000..fc10f77bb
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/TUF
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+ |
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/TUT b/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/TUT
new file mode 100644
index 000000000..dc99e3cdc
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/TUT
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+ |
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/TUU b/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/TUU
new file mode 100644
index 000000000..2c592ef86
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/TUU
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/UUF b/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/UUF
new file mode 100644
index 000000000..39b5fb079
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/UUF
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/UUT b/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/UUT
new file mode 100644
index 000000000..261c035cd
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/UUT
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/UUU b/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/UUU
new file mode 100644
index 000000000..d9f415439
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/AndIntroductionDirectRule/UUU
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/NotIntroductionDirectRule/BlankA b/src/test/resources/puzzles/shorttruthtable/rules/NotIntroductionDirectRule/BlankA
new file mode 100644
index 000000000..e7bf96e4a
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/NotIntroductionDirectRule/BlankA
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/NotIntroductionDirectRule/FalseA b/src/test/resources/puzzles/shorttruthtable/rules/NotIntroductionDirectRule/FalseA
new file mode 100644
index 000000000..d4c178464
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/NotIntroductionDirectRule/FalseA
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/NotIntroductionDirectRule/TrueA b/src/test/resources/puzzles/shorttruthtable/rules/NotIntroductionDirectRule/TrueA
new file mode 100644
index 000000000..7c4f71984
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/NotIntroductionDirectRule/TrueA
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/OrEliminationDirectRule/FTU b/src/test/resources/puzzles/shorttruthtable/rules/OrEliminationDirectRule/FTU
new file mode 100644
index 000000000..bda22c0e6
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/OrEliminationDirectRule/FTU
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+ |
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/OrEliminationDirectRule/UFU b/src/test/resources/puzzles/shorttruthtable/rules/OrEliminationDirectRule/UFU
new file mode 100644
index 000000000..b7c23215e
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/OrEliminationDirectRule/UFU
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/OrEliminationDirectRule/UTF b/src/test/resources/puzzles/shorttruthtable/rules/OrEliminationDirectRule/UTF
new file mode 100644
index 000000000..60eaca2b8
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/OrEliminationDirectRule/UTF
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+ |
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/OrEliminationDirectRule/UTU b/src/test/resources/puzzles/shorttruthtable/rules/OrEliminationDirectRule/UTU
new file mode 100644
index 000000000..c28ba1fde
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/OrEliminationDirectRule/UTU
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/FUF b/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/FUF
new file mode 100644
index 000000000..2326f8df4
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/FUF
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+ |
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/FUT b/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/FUT
new file mode 100644
index 000000000..447c91981
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/FUT
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+ |
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/FUU b/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/FUU
new file mode 100644
index 000000000..083c30039
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/FUU
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/TUF b/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/TUF
new file mode 100644
index 000000000..ef36a432d
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/TUF
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+ |
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/TUT b/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/TUT
new file mode 100644
index 000000000..05f65ad45
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/TUT
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+ |
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/TUU b/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/TUU
new file mode 100644
index 000000000..d6e54b326
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/TUU
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/UUF b/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/UUF
new file mode 100644
index 000000000..5f69fb73f
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/UUF
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/UUT b/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/UUT
new file mode 100644
index 000000000..d7ef8cd88
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/UUT
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/UUU b/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/UUU
new file mode 100644
index 000000000..005a4f462
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/OrIntroductionDirectRule/UUU
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+