From b81e3c7b8199c4f50f848e64990f87397d902167 Mon Sep 17 00:00:00 2001 From: Thomas Walker Lynch Date: Fri, 8 Nov 2024 13:00:47 +0000 Subject: [PATCH] check point before modifying package name prefixes are added --- developer/javac/File.java | 2 +- developer/javac/Graph.java | 3 - tester/javac/#Test_Node_0.java# | 63 +++++ tester/javac/In.java | 76 ++++++ tester/javac/Test2.javax | 242 ------------------ tester/javac/TestMosaicUtil.java | 15 ++ tester/javac/Test_File_0.java | 215 ++++++++-------- tester/javac/Test_Graph_0.java | 72 ++++++ tester/javac/Test_LabelList_0.java | 6 - tester/javac/Test_Label_0.java | 2 - tester/javac/Test_NodeList_0.java | 3 - tester/javac/Test_TokenSet_0.java | 3 - tester/javac/Test_Token_0.java | 2 - tester/javac/Test_Util_0.java | 6 - tester/javac/import_aliases.java | 4 - tester/jvm/Test_Ariadne.jar | Bin 15018 -> 17220 bytes tester/scratchpad/In$MIO.class | Bin 0 -> 320 bytes tester/scratchpad/In$MU.class | Bin 0 -> 320 bytes tester/scratchpad/In$TB.class | Bin 0 -> 324 bytes tester/scratchpad/In$TestBench.class | Bin 0 -> 345 bytes tester/scratchpad/In.class | Bin 0 -> 3182 bytes .../scratchpad/Test_Graph_0$TestSuite.class | Bin 0 -> 3150 bytes tester/scratchpad/Test_Graph_0.class | Bin 0 -> 745 bytes tester/shell/Test_Graph_0 | 2 + tester/tool/shell_wrapper_list | 1 + 25 files changed, 340 insertions(+), 377 deletions(-) create mode 100644 tester/javac/#Test_Node_0.java# create mode 100644 tester/javac/In.java delete mode 100644 tester/javac/Test2.javax create mode 100644 tester/javac/TestMosaicUtil.java create mode 100644 tester/javac/Test_Graph_0.java delete mode 100644 tester/javac/import_aliases.java create mode 100644 tester/scratchpad/In$MIO.class create mode 100644 tester/scratchpad/In$MU.class create mode 100644 tester/scratchpad/In$TB.class create mode 100644 tester/scratchpad/In$TestBench.class create mode 100644 tester/scratchpad/In.class create mode 100644 tester/scratchpad/Test_Graph_0$TestSuite.class create mode 100644 tester/scratchpad/Test_Graph_0.class create mode 100755 tester/shell/Test_Graph_0 diff --git a/developer/javac/File.java b/developer/javac/File.java index 109d7b6..4058dc7 100644 --- a/developer/javac/File.java +++ b/developer/javac/File.java @@ -5,7 +5,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; -import com.ReasoningTechnology.Mosaic.IO; +import com.ReasoningTechnology.Mosaic.Mosaic_IO; public class File { static boolean debug = false; diff --git a/developer/javac/Graph.java b/developer/javac/Graph.java index 3b7f970..d50c429 100644 --- a/developer/javac/Graph.java +++ b/developer/javac/Graph.java @@ -60,7 +60,4 @@ public class Graph{ return lookup(node_label ,true); } - - - } diff --git a/tester/javac/#Test_Node_0.java# b/tester/javac/#Test_Node_0.java# new file mode 100644 index 0000000..98cf614 --- /dev/null +++ b/tester/javac/#Test_Node_0.java# @@ -0,0 +1,63 @@ + +public class Test_Node_0 { + + public class TestSuite { + + public Boolean node_creation_0(IO io) { + Boolean[] conditions = new Boolean[2]; + int i = 0; + + // Test that neighbor list is initialized + Node node = new Node(); + conditions[i++] = node.neighbor_LabelList() != null && node.neighbor_LabelList().isEmpty(); // Expect true + + // Test that the mark property is not initialized until used + conditions[i++] = node.get("mark") == null; // Expect true + + // Return true if all conditions are met + return MU.all(conditions); + } + + public Boolean node_marking_0(IO io) { + Boolean[] conditions = new Boolean[3]; + int i = 0; + + Node node = new Node(); + Token token1 = new Token("token1"); + Token token2 = new Token("token2"); + + // Test marking the node with token1 + node.mark(token1); + conditions[i++] = node.has_mark(token1); // Expect true + conditions[i++] = !node.has_mark(token2); // Expect false for unmarked token + + // Test that mark property is now initialized and contains token1 + TokenSet markSet = (TokenSet) node.get("mark"); + conditions[i++] = markSet != null && markSet.contains(token1); // Expect true + + // Return true if all conditions are met + return MU.all(conditions); + } + + public Boolean node_neighbor_0(IO io) { + Boolean[] conditions = new Boolean[1]; + int i = 0; + + // Test adding and retrieving neighbors + Node node = new Node(); + LabelList neighbors = node.neighbor_LabelList(); + neighbors.add(new Label("neighbor1")); + neighbors.add(new Label("neighbor2")); + conditions[i++] = neighbors.size() == 2 && neighbors.get(0).get().equals("neighbor1") && neighbors.get(1).get().equals("neighbor2"); // Expect true + + // Return true if all conditions are met + return MU.all(conditions); + } + } + + public static void main(String[] args) { + TestSuite suite = new Test_Node_0().new TestSuite(); + int result = TestBench.run(suite); + System.exit(result); + } +} diff --git a/tester/javac/In.java b/tester/javac/In.java new file mode 100644 index 0000000..09d3af6 --- /dev/null +++ b/tester/javac/In.java @@ -0,0 +1,76 @@ +/* + Import to the package, rather than to individual files. +*/ +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.attribute.FileTime; +import java.util.List; +import java.util.Map; + +import com.ReasoningTechnology.Ariadne.File; +import com.ReasoningTechnology.Ariadne.Util; +import com.ReasoningTechnology.Mosaic.IO; +import com.ReasoningTechnology.Mosaic.TestBench; + + +public class In { + // Mosaic imports + public static final Class MIO = com.ReasoningTechnology.Mosaic.IO.class; + public static final Class MU = com.ReasoningTechnology.Mosaic.Util.class; + public static final Class TB = com.ReasoningTechnology.Mosaic.TestBench.class; + + // Ariadne imports + public static final Class File = com.ReasoningTechnology.Ariadne.File.class; + public static final Class AU = com.ReasoningTechnology.Ariadne.Util.class; + public static final Class Graph = com.ReasoningTechnology.Ariadne.Graph.class; + public static final Class Label = com.ReasoningTechnology.Ariadne.Label.class; + public static final Class LabelList = com.ReasoningTechnology.Ariadne.LabelList.class; + public static final Class Node = com.ReasoningTechnology.Ariadne.Node.class; + public static final Class NodeList = com.ReasoningTechnology.Ariadne.NodeList.class; + public static final Class ProductionList = com.ReasoningTechnology.Ariadne.ProductionList.class; + public static final Class Token = com.ReasoningTechnology.Ariadne.Token.class; + public static final Class TokenSet = com.ReasoningTechnology.Ariadne.TokenSet.class; + + // Java standard library imports + public static final Class Arrays = java.util.Arrays.class; + public static final Class Files = java.nio.file.Files.class; + public static final Class Path = java.nio.file.Path.class; + public static final Class Paths = java.nio.file.Paths.class; + public static final Class FileTime = java.nio.file.attribute.FileTime.class; + public static final Class HashMap = java.util.HashMap.class; + public static final Class List = java.util.List.class; + public static final Class Map = java.util.Map.class; +} +/* + +public class In { + // Class references for direct access to imported class definitions + public static final Class MIO = com.ReasoningTechnology.Mosaic.IO.class; + public static final Class MU = com.ReasoningTechnology.Mosaic.Util.class; + public static final Class TestBench = com.ReasoningTechnology.Mosaic.TestBench.class; + + public static final Class File = com.ReasoningTechnology.Ariadne.File.class; + public static final Class Graph = com.ReasoningTechnology.Ariadne.Graph.class; + public static final Class Label = com.ReasoningTechnology.Ariadne.Label.class; + public static final Class LabelList = com.ReasoningTechnology.Ariadne.LabelList.class; + public static final Class Node = com.ReasoningTechnology.Ariadne.Node.class; + public static final Class NodeList = com.ReasoningTechnology.Ariadne.NodeList.class; + public static final Class ProductionList = com.ReasoningTechnology.Ariadne.ProductionList.class; + public static final Class Token = com.ReasoningTechnology.Ariadne.Token.class; + public static final Class TokenSet = com.ReasoningTechnology.Ariadne.TokenSet.class; + public static final Class AU = com.ReasoningTechnology.Ariadne.Util.class; + + // For standard Java classes + public static final Class Arrays = java.util.Arrays.class; + public static final Class Files = java.nio.file.Files.class; + public static final Class Path = java.nio.file.Path.class; + public static final Class Paths = java.nio.file.Paths.class; + public static final Class FileTime = java.nio.file.attribute.FileTime.class; + public static final Class HashMap = java.util.HashMap.class; + public static final Class List = java.util.List.class; + public static final Class Map = java.util.Map.class; + + // Optional: Utility methods to create instances or perform actions on these classes could be added here +} +*/ diff --git a/tester/javac/Test2.javax b/tester/javac/Test2.javax deleted file mode 100644 index 028c466..0000000 --- a/tester/javac/Test2.javax +++ /dev/null @@ -1,242 +0,0 @@ -package com.ReasoningTechnology.Ariadne.TestBench; - -/* -Component smoke test. At least call each method of each class. - -*/ - - -import com.ReasoningTechnology.Ariadne.*; -import com.ReasoningTechnology.TestBench.*; -import java.util.List; -import java.util.Map; -import java.util.ArrayList; -import java.util.HashMap; -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; - - -public class Test2 extends TestBench{ - - public static boolean test_File_unpack_file_path_0(){ - boolean[] conditions = new boolean[5]; - int i = 0; - - // Test input - String test_fp = "/home/user/test.txt"; - - // Expected output - String expected_dp = "/home/user/"; - String expected_fn = "test.txt"; - String expected_fn_base = "test"; - String expected_fn_ext = "txt"; - - // Actual output - Map result = File.unpack_file_path( test_fp ); - - conditions[i++] = result.get("dp").equals( expected_dp ); - conditions[i++] = result.get("fn").equals( expected_fn ); - conditions[i++] = result.get("fn_base").equals( expected_fn_base ); - conditions[i++] = result.get("fn_ext").equals( expected_fn_ext ); - conditions[i++] = result.size() == 4; - - // Return true if all conditions are met - return all( conditions ); - } - - public static boolean test_Label_0(){ - boolean[] conditions = new boolean[2]; - int i = 0; - - // Test input - Label test_label = new Label("test"); - - // Expected output - String expected_value = "test"; - - // Actual output - conditions[i++] = test_label.get().equals(expected_value); - conditions[i++] = test_label.toString().equals(expected_value); - - return all(conditions); - } - - public static boolean test_Token_0(){ - boolean[] conditions = new boolean[4]; - int i = 0; - - // Test input - Token token = new Token("test_value"); - - // Check if the value is correctly stored and retrieved - conditions[i++] = token.get().equals("test_value"); - - // Check if the string representation is correct - conditions[i++] = token.toString().equals("test_value"); - - // Check equality with another Token object with the same value - Token another_token = new Token("test_value"); - conditions[i++] = token.equals( another_token ); - - // Check the hashCode consistency - conditions[i++] = token.hashCode() == another_token.hashCode(); - - return all(conditions); - } - - public static boolean test_LabelList_0(){ - LabelList label_list = new LabelList(); // Use the constructor - - // Add a label and check the size - label_list.add(new Label("test")); - return label_list.size() == 1; - } - - public static boolean test_Node_0(){ - Node node = new Node(); // Use the constructor - node.put("key", new Object()); - return node.containsKey("key"); - } - - public static boolean test_NodeList_0(){ - NodeList node_list = new NodeList(); // Use the constructor - - // Add a node and check the size - node_list.add(new Node()); // Use Node constructor - return node_list.size() == 1; - } - - public static boolean test_Production_0(){ - Production production = label -> new Node(); // Use the Node constructor - - // Apply the production function - Node node = production.apply(new Label("test")); - return node != null; - } - - public static boolean test_ProductionList_0(){ - ProductionList production_list = new ProductionList(); // Use the constructor - - // Add a production and check the size - production_list.add(label -> new Node()); // Use the Node constructor - return production_list.size() == 1; - } - - public static boolean test_TokenSet_0(){ - TokenSet token_set = new TokenSet(); // Use the constructor - - // Add a token and check if it's contained in the set - token_set.add(new Token("test")); - return token_set.contains(new Token("test")); - } - - public static boolean test_Graph_0() { - boolean[] conditions = new boolean[3]; - int i = 0; - - // Create an empty node map and a production list - Map node_map = new HashMap<>(); - ProductionList production_list = new ProductionList(); - - // Initialize the Graph - Graph graph = new Graph(node_map, production_list); - - // Test that lookup returns null for a non-existent node - Label non_existent_label = new Label("non_existent"); - conditions[i++] = graph.lookup(non_existent_label, false) == null; - - // Add a node to the map and test lookup - Node test_node = new Node(); - Label test_label = new Label("test"); - node_map.put(test_label, test_node); - conditions[i++] = graph.lookup(test_label, false) == test_node; - - // Test lookup with verbosity - conditions[i++] = graph.lookup(test_label).equals(test_node); - - // Return true if all conditions are met - return all(conditions); - } - - public static boolean test_Util_print_list_0(){ - boolean[] conditions = new boolean[1]; - int i = 0; - - String prefix = "Test List:"; - List items = new ArrayList<>(); - items.add("item1"); - items.add("item2"); - items.add("item3"); - - String expectedOutput = "Test List: 'item1', 'item2', 'item3'.\n"; - - ByteArrayOutputStream outContent = new ByteArrayOutputStream(); - PrintStream originalOut = System.out; - System.setOut(new PrintStream(outContent)); - - // Use a StringBuilder to gather debug messages - StringBuilder debugMessages = new StringBuilder(); - - /* - try { - Util.print_list(prefix, items); - String result = outContent.toString(); - - // Gather debug messages - debugMessages.append("Captured output: ").append(result).append("\n"); - debugMessages.append("Expected output: ").append(expectedOutput).append("\n"); - - conditions[i++] = result.equals(expectedOutput); - } catch (Exception e) { - conditions[i++] = false; - } finally { - System.setOut(originalOut); // Restore System.out - - // Now print the gathered debug messages - System.out.print(debugMessages.toString()); - } - */ - - try { - Util.print_list(prefix, items); - String result = outContent.toString(); - conditions[i++] = result.equals(expectedOutput); - } catch (Exception e) { - conditions[i++] = false; - } finally { - System.setOut(originalOut); - } - - return all(conditions); - } - - - // Method to run all tests - public static void test_Ariadne(){ - Map test_map = new HashMap<>(); - - // Adding tests to the map - test_map.put( "test_File_unpack_file_path_0", test_File_unpack_file_path_0() ); - test_map.put( "test_Label_0", test_Label_0() ); - test_map.put( "test_Token_0", test_Label_0() ); - test_map.put( "test_LabelList_0", test_LabelList_0() ); - test_map.put( "test_Node_0", test_Node_0() ); - test_map.put( "test_NodeList_0", test_NodeList_0() ); - test_map.put( "test_Production_0", test_Production_0() ); - test_map.put( "test_ProductionList_0", test_ProductionList_0() ); - test_map.put( "test_TokenSet_0", test_TokenSet_0() ); - test_map.put("test_Graph_0", test_Graph_0()); - test_map.put("test_Util_print_list_0", test_Util_print_list_0()); - - // Run the tests using TestBench - TestBench.run( test_map ); - } - - // Main function to provide a shell interface for running tests - public static void main(String[] args){ - System.out.println("Running Ariadne tests..."); - test_Ariadne(); // Calls the method to run all tests - } - -} - diff --git a/tester/javac/TestMosaicUtil.java b/tester/javac/TestMosaicUtil.java new file mode 100644 index 0000000..17be83f --- /dev/null +++ b/tester/javac/TestMosaicUtil.java @@ -0,0 +1,15 @@ +import com.ReasoningTechnology.Mosaic; // Importing the entire Mosaic package + +public class TestMosaicUtil { + + public static void main(String[] args) { + // Sample array of conditions to check with Util.all + Boolean[] conditions = {true, true, true}; + + // Using Mosaic.Util.all() to check if all conditions are true + boolean result = Mosaic.Util.all(conditions); + + // Print the result + System.out.println("All conditions are true: " + result); + } +} diff --git a/tester/javac/Test_File_0.java b/tester/javac/Test_File_0.java index 383544d..44342ba 100644 --- a/tester/javac/Test_File_0.java +++ b/tester/javac/Test_File_0.java @@ -1,109 +1,114 @@ - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.attribute.FileTime; -import java.util.List; -import java.util.Map; - -import com.ReasoningTechnology.Ariadne.File; -import com.ReasoningTechnology.Mosaic.*; - -public class Test_File_0{ - - public class TestSuite{ - - public Boolean unpack_file_path_0(IO io){ - Boolean[] conditions = new Boolean[5]; - int i = 0; - - // Test input - String test_fp = "/home/user/test.txt"; - - // Expected output - String expected_dp = "/home/user/"; - String expected_fn = "test.txt"; - String expected_fn_base = "test"; - String expected_fn_ext = "txt"; - - // Actual output - Map result = File.unpack_file_path( test_fp ); - - conditions[i++] = result.get("dp").equals( expected_dp ); - conditions[i++] = result.get("fn").equals( expected_fn ); - conditions[i++] = result.get("fn_base").equals( expected_fn_base ); - conditions[i++] = result.get("fn_ext").equals( expected_fn_ext ); - conditions[i++] = result.size() == 4; - - // Return true if all conditions are met - return MU.all( conditions ); +import java.lang.reflect.Method; + +public class Test_File_0 { + + public class TestSuite { + + public Boolean unpack_file_path_0(In.MIO io) { + Boolean[] conditions = new Boolean[5]; + int i = 0; + + String test_fp = "/home/user/test.txt"; + String expected_dp = "/home/user/"; + String expected_fn = "test.txt"; + String expected_fn_base = "test"; + String expected_fn_ext = "txt"; + + try { + // Use reflection to call In.File.unpack_file_path + Method unpackFilePath = In.File.getMethod("unpack_file_path", String.class); + java.util.Map result = (java.util.Map) unpackFilePath.invoke(null, test_fp); + + conditions[i++] = result.get("dp").equals(expected_dp); + conditions[i++] = result.get("fn").equals(expected_fn); + conditions[i++] = result.get("fn_base").equals(expected_fn_base); + conditions[i++] = result.get("fn_ext").equals(expected_fn_ext); + conditions[i++] = result.size() == 4; + + Method allMethod = In.MU.getMethod("all", Boolean[].class); + return (Boolean) allMethod.invoke(null, (Object) conditions); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + public Boolean file_exists_q_0(In.MIO io) { + Boolean[] conditions = new Boolean[2]; + int i = 0; + + String repoHome = System.getenv("REPO_HOME"); + String existingFilePath = repoHome + "/tester/data_Test_File_0/I_exist"; + String nonExistentFilePath = repoHome + "/tester/data_Test_File_0/I_do_not_exist"; + + try { + // Use reflection to call In.File.file_exists_q + Method fileExistsMethod = In.File.getMethod("file_exists_q", String.class); + conditions[i++] = (Boolean) fileExistsMethod.invoke(null, existingFilePath); + conditions[i++] = !(Boolean) fileExistsMethod.invoke(null, nonExistentFilePath); + + Method allMethod = In.MU.getMethod("all", Boolean[].class); + return (Boolean) allMethod.invoke(null, (Object) conditions); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + public Boolean newer_than_all_0(In.MIO io) throws java.io.IOException { + Boolean[] conditions = new Boolean[5]; + int i = 0; + + String repoHome = System.getenv("REPO_HOME"); + String file_0 = repoHome + "/tester/data_Test_File_0/file_0"; + String file_1 = repoHome + "/tester/data_Test_File_0/file_1"; + String file_2 = repoHome + "/tester/data_Test_File_0/file_2"; + String file_3 = repoHome + "/tester/data_Test_File_0/file_3"; + String missing_file_0 = repoHome + "/tester/data_Test_File_0/missing_file_0"; + + try { + Method setLastModifiedTime = In.Files.getMethod("setLastModifiedTime", java.nio.file.Path.class, java.nio.file.attribute.FileTime.class); + Method getPath = In.Paths.getMethod("get", String.class); + Method fromMillis = In.FileTime.getMethod("fromMillis", long.class); + + // Setting modification times + setLastModifiedTime.invoke(null, getPath.invoke(null, file_3), fromMillis.invoke(null, System.currentTimeMillis() - 20000)); + setLastModifiedTime.invoke(null, getPath.invoke(null, file_2), fromMillis.invoke(null, System.currentTimeMillis() - 15000)); + setLastModifiedTime.invoke(null, getPath.invoke(null, file_1), fromMillis.invoke(null, System.currentTimeMillis() - 10000)); + setLastModifiedTime.invoke(null, getPath.invoke(null, file_0), fromMillis.invoke(null, System.currentTimeMillis() - 5000)); + + Method newerThanAll = In.File.getMethod("newer_than_all", String.class, java.util.List.class); + conditions[i++] = (Boolean) newerThanAll.invoke(null, file_0, java.util.List.of(file_1, file_2, file_3)); + + // Updating times and repeating checks + setLastModifiedTime.invoke(null, getPath.invoke(null, file_2), fromMillis.invoke(null, System.currentTimeMillis() + 10000)); + conditions[i++] = !(Boolean) newerThanAll.invoke(null, file_0, java.util.List.of(file_1, file_2, file_3)); + + setLastModifiedTime.invoke(null, getPath.invoke(null, file_1), fromMillis.invoke(null, System.currentTimeMillis() + 15000)); + conditions[i++] = !(Boolean) newerThanAll.invoke(null, file_0, java.util.List.of(file_1, file_2, file_3)); + + conditions[i++] = !(Boolean) newerThanAll.invoke(null, missing_file_0, java.util.List.of(file_1, file_2, file_3)); + + conditions[i++] = !(Boolean) newerThanAll.invoke(null, file_0, java.util.List.of(file_1, missing_file_0)); + + Method allMethod = In.MU.getMethod("all", Boolean[].class); + return (Boolean) allMethod.invoke(null, (Object) conditions); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } } - public Boolean file_exists_q_0(IO io) { - Boolean[] conditions = new Boolean[2]; - int i = 0; - - // Test file paths, assuming $REPO_HOME is set in the environment - String repoHome = System.getenv("REPO_HOME"); - String existingFilePath = repoHome + "/tester/data_Test_File_0/I_exist"; - String nonExistentFilePath = repoHome + "/tester/data_Test_File_0/I_do_not_exist"; - - // Test cases - conditions[i++] = File.file_exists_q(existingFilePath); // Expect true for existing file - conditions[i++] = !File.file_exists_q(nonExistentFilePath); // Expect false for non-existent file - - // Return true if both conditions are met - return MU.all(conditions); - } - - public Boolean newer_than_all_0(IO io) throws IOException { - Boolean[] conditions = new Boolean[5]; - int i = 0; - - String repoHome = System.getenv("REPO_HOME"); - - // Define paths for existing and missing files - String file_0 = repoHome + "/tester/data_Test_File_0/file_0"; - String file_1 = repoHome + "/tester/data_Test_File_0/file_1"; - String file_2 = repoHome + "/tester/data_Test_File_0/file_2"; - String file_3 = repoHome + "/tester/data_Test_File_0/file_3"; - String missing_file_0 = repoHome + "/tester/data_Test_File_0/missing_file_0"; - - // Set modification times: file_0 is the youngest, file_3 is the oldest - Files.setLastModifiedTime(Paths.get(file_3), FileTime.fromMillis(System.currentTimeMillis() - 20000)); - Files.setLastModifiedTime(Paths.get(file_2), FileTime.fromMillis(System.currentTimeMillis() - 15000)); - Files.setLastModifiedTime(Paths.get(file_1), FileTime.fromMillis(System.currentTimeMillis() - 10000)); - Files.setLastModifiedTime(Paths.get(file_0), FileTime.fromMillis(System.currentTimeMillis() - 5000)); - - // Test case 1: file_0 is newer than all other files - conditions[i++] = File.newer_than_all(file_0, List.of(file_1, file_2, file_3)); // Expect true - - // Test case 2: file_0 is newer than some, but not all (make file_2 newer) - Files.setLastModifiedTime(Paths.get(file_2), FileTime.fromMillis(System.currentTimeMillis() + 10000)); // file_2 is now newer - conditions[i++] = !File.newer_than_all(file_0, List.of(file_1, file_2, file_3)); // Expect false - - // Test case 3: file_0 is not newer than any (make both file_1 and file_2 newer) - Files.setLastModifiedTime(Paths.get(file_1), FileTime.fromMillis(System.currentTimeMillis() + 15000)); - conditions[i++] = !File.newer_than_all(file_0, List.of(file_1, file_2, file_3)); // Expect false - - // Test case 4: file_0 does not exist - conditions[i++] = !File.newer_than_all(missing_file_0, List.of(file_1, file_2, file_3)); // Expect false - - // Test case 5: Some files in the list are missing - conditions[i++] = !File.newer_than_all(file_0, List.of(file_1, missing_file_0)); // Expect false - - // Return true if all conditions pass - return MU.all(conditions); + public static void main(String[] args) { + try { + Method runMethod = In.TB.getMethod("run", Object.class); + TestSuite suite = new Test_File_0().new TestSuite(); + int result = (int) runMethod.invoke(null, suite); + System.exit(result); + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } } - - } - - public static void main(String[] args) { - TestSuite suite = new Test_File_0().new TestSuite(); - int result = TestBench.run(suite); - System.exit(result); - } - } - diff --git a/tester/javac/Test_Graph_0.java b/tester/javac/Test_Graph_0.java new file mode 100644 index 0000000..4c8dc6a --- /dev/null +++ b/tester/javac/Test_Graph_0.java @@ -0,0 +1,72 @@ + + +public class Test_Graph_0 { + + public class TestSuite { + + // Test constructor with null parameters (expecting error message) + public Boolean graph_constructor_null_params(IO io) { + Boolean[] conditions = new Boolean[1]; + int i = 0; + + // Attempt to initialize Graph with both parameters null + new Graph(null, null); + + // Capture stderr to check for error message + String stderrContent = io.get_err_content(); + conditions[i++] = stderrContent.contains("AriadneGraph: At least one of 'node_map' (Map) or 'recognizer_f_list' (List) must be provided."); + io.clear_buffers(); // Clear after validation + return MU.all(conditions); + } + + // Test lookup with populated node_map + public Boolean graph_lookup_populated_map(IO io) { + Boolean[] conditions = new Boolean[2]; + int i = 0; + + // Setup node_map with labeled nodes + Map nodeMap = new HashMap<>(); + Label label1 = new Label("node1"); + Label label2 = new Label("node2"); + Node node1 = new Node(); + Node node2 = new Node(); + nodeMap.put(label1, node1); + nodeMap.put(label2, node2); + + Graph graph = new Graph(nodeMap, new ProductionList()); + + // Test lookup for existing and non-existing labels + conditions[i++] = graph.lookup(label1, true) == node1; + conditions[i++] = graph.lookup(new Label("nonexistent"), true) == null; + + io.clear_buffers(); // Clear after each case + return MU.all(conditions); + } + + // Test lookup without verbosity + public Boolean graph_lookup_non_verbose(IO io) { + Boolean[] conditions = new Boolean[1]; + int i = 0; + + // Initialize node_map with one node + Map nodeMap = new HashMap<>(); + Label label = new Label("singleNode"); + Node node = new Node(); + nodeMap.put(label, node); + + Graph graph = new Graph(nodeMap, new ProductionList()); + + // Perform lookup without verbosity + Node result = graph.lookup(label, false); + conditions[i++] = result == node; // Expected to find node without verbose output + + return MU.all(conditions); + } + } + + public static void main(String[] args) { + TestSuite suite = new Test_Graph_0().new TestSuite(); + int result = TestBench.run(suite); + System.exit(result); + } +} diff --git a/tester/javac/Test_LabelList_0.java b/tester/javac/Test_LabelList_0.java index ce17cd6..3a6ea44 100644 --- a/tester/javac/Test_LabelList_0.java +++ b/tester/javac/Test_LabelList_0.java @@ -1,9 +1,3 @@ -import java.util.List; -import java.util.Arrays; - -import com.ReasoningTechnology.Ariadne.Label; -import com.ReasoningTechnology.Ariadne.LabelList; -import com.ReasoningTechnology.Mosaic.*; public class Test_LabelList_0 { diff --git a/tester/javac/Test_Label_0.java b/tester/javac/Test_Label_0.java index 6392b18..572e4fc 100644 --- a/tester/javac/Test_Label_0.java +++ b/tester/javac/Test_Label_0.java @@ -1,5 +1,3 @@ -import com.ReasoningTechnology.Ariadne.Label; -import com.ReasoningTechnology.Mosaic.*; public class Test_Label_0 { diff --git a/tester/javac/Test_NodeList_0.java b/tester/javac/Test_NodeList_0.java index 6c9af14..b220bc6 100644 --- a/tester/javac/Test_NodeList_0.java +++ b/tester/javac/Test_NodeList_0.java @@ -1,6 +1,3 @@ -import com.ReasoningTechnology.Ariadne.Node; -import com.ReasoningTechnology.Ariadne.NodeList; -import com.ReasoningTechnology.Mosaic.*; public class Test_NodeList_0 { diff --git a/tester/javac/Test_TokenSet_0.java b/tester/javac/Test_TokenSet_0.java index 74d7a40..624a1f5 100644 --- a/tester/javac/Test_TokenSet_0.java +++ b/tester/javac/Test_TokenSet_0.java @@ -1,6 +1,3 @@ -import com.ReasoningTechnology.Ariadne.Token; -import com.ReasoningTechnology.Ariadne.TokenSet; -import com.ReasoningTechnology.Mosaic.*; public class Test_TokenSet_0 { diff --git a/tester/javac/Test_Token_0.java b/tester/javac/Test_Token_0.java index 216078d..715129c 100644 --- a/tester/javac/Test_Token_0.java +++ b/tester/javac/Test_Token_0.java @@ -1,5 +1,3 @@ -import com.ReasoningTechnology.Ariadne.Token; -import com.ReasoningTechnology.Mosaic.*; public class Test_Token_0 { diff --git a/tester/javac/Test_Util_0.java b/tester/javac/Test_Util_0.java index 8887067..9f76216 100644 --- a/tester/javac/Test_Util_0.java +++ b/tester/javac/Test_Util_0.java @@ -1,9 +1,3 @@ -import com.ReasoningTechnology.Ariadne.Util; -import com.ReasoningTechnology.Ariadne.Label; -import com.ReasoningTechnology.Mosaic.IO; -import com.ReasoningTechnology.Mosaic.*; -import java.util.List; -import java.util.Arrays; public class Test_Util_0 { diff --git a/tester/javac/import_aliases.java b/tester/javac/import_aliases.java deleted file mode 100644 index ef437d2..0000000 --- a/tester/javac/import_aliases.java +++ /dev/null @@ -1,4 +0,0 @@ - -import com.ReasoningTechnology.Mosaic.Util; -class MU extends com.ReasoningTechnology.Mosaic.Util{}; - diff --git a/tester/jvm/Test_Ariadne.jar b/tester/jvm/Test_Ariadne.jar index bebaba1f41cd709ccdf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*a=*>?#*qA_!$rDV)HnVWs zGJ`pVYGRwC_`WfMl>`es1B-695fK2Z-Rv)>!3vhDlIDWwuGbLTJXcm2qHeQ-Ai~VM zN)sWXg=*Xo-SrxWAR;b0Q1im|Sin|IJTJDnM4yKRY<9CT6B92ZlL!Oc3zHYwT7aE* z*VZ0P%iFnu=?ps?FumN)9ZY|;vjx+J_TFH+-rf;RAGU|6=W&3j_jd3Ci_dUy0MoY} zAo^7uA^KAtA@Z9XA@W}xjlt@)o!mHpVHSDdefsvvf(~Mn`<=u^SlJkWKo|%GSs56b HO+h>WZjNjh diff --git a/tester/scratchpad/In$MIO.class b/tester/scratchpad/In$MIO.class new file mode 100644 index 0000000000000000000000000000000000000000..0e0675bc1b9d61beb78bec727b4fc4180a527759 GIT binary patch literal 320 zcmXX>%}T>S7@SS>)5d6P)CVYdP!HzlLGe;34Wt#c^uCQtyOQogHWhpALcfWr=zX06eEJhE<5z+`J0^yxDy15tVU0kjN{E2;50>eTZwb<|0s$R-< zMJFw6DXW#Nb*ukPzu9WX(RuzLkmSawdQwT}6wQ8-n{yuA3dB!#UzcjC+n^{n*Dvx_ zvSXoKGqbLVaGJnJz}NiE2#ia+%N~_<)@ZX?s&Z>=WjAlx+&Zbtti9074aV^Jn|29q wW)MTFtkXbn^#Sot!$U+2X#*+x#H6bO3|N67heQuY7!AiqG5Pg#-*)~R7Tm1l`2lZf%9xQ?s#6a4EHob4trCmvPA)6NbEKh<5KfsSF zPJ*-W-n_@`8|L@;{R7}0mk~NR7Z?hR2;oEB4`=ANJirNa#4{cS%)LLz@H>S7 literal 0 HcmV?d00001 diff --git a/tester/scratchpad/In$TB.class b/tester/scratchpad/In$TB.class new file mode 100644 index 0000000000000000000000000000000000000000..a29ca9bda9420381df5f5c8f07162774a55065c9 GIT binary patch literal 324 zcmXX>!AiqG5Pg#-*)~R7YyAMhL-k;e9uyBLh=JIHhTga9(ypYtkWB?Y%ah>25AdVJ zNpKe4oA;P`%l!O)eFM10X@UWc1*QT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#HjJ>R6APOCy|dhP(qukQom#15UF2i69%{x0?1+#QxbssKLF54dw^u=Ylj$&8ea_=r*RWA(s&kg zWWwI>2gd5${2|g$PRMH#^Ew4FAtA=)UM2tYWCo~s7w-{+Tl79it4=}P#`^)M1*GVW zf;vKGhq9tZc}<3RW${4})B-*Xcx@0U2c;chXlHKz09i&zh4OkcL`%a*_?W(vKK*3< zgk0aH_ioPl+o!b4)BgY#iRNdx*H2Spn!{0=^RYDVt$NsK=yAhejqpi literal 0 HcmV?d00001 diff --git a/tester/scratchpad/Test_Graph_0$TestSuite.class b/tester/scratchpad/Test_Graph_0$TestSuite.class new file mode 100644 index 0000000000000000000000000000000000000000..04e46404a1e26733fce9114f387fa032bae4383c GIT binary patch literal 3150 zcmb7G+jA3D9R5zS$)-zs1qz{pK}wrmYzkf|2^89Lt4%M`QY;{GlWg0C?QYm?3OM78 z55D>CgENlug0K1@MHzi{#y?8@&Tf*XVku5C$=P#$x9|6T=a>BT_iujyID>~RID(Hf z^k7CsPQ|PS1#=oMU_OQg4IksWhAZXNUa+{+m2--^wXD0Qe6DROGKoNo%&=HBJ=(>mZQF3C zEWJ`OcyxG2ir$7H>o~gRmsE7@isx2~p5x~2s%7QNx~p%{bu5)DIveThhF)=O(_ULL zitDyxIcty8vra`fi|Oh4>_G0GzNx1z-Cj#iI*w)NHbaL@N8rR8xC>~^Uot(DRR|oo z{h#54DIlf=S}R`3aNQ}#_6*yTJ=spa=(((sxsL>}EXTQDE$7QlxoYX2QOa-VWdYS@ zduQdUJ@Bo1rj_P~WQ(5NJB9GLTo=RLoruouSxSInPcy&bab|8^^z`C=Hp^F^ih_z^6-A0{N6T%; z&TkrS!KqM=5x=R_wQLZ3>>8D-Me4Lgr|K4sE2h+TXY&mik(>&|=BVjwPQ_DEisLOD zjpG=k?Kb5#y$PJ$O{aCf{NBj`t8uJhUEpr*#6QR+C%hz;Tk(>PZ6ux5WWTIdDyBb~ zBHn?d<0kuEqv)*J=I4f+U(H))#p7X)UjxaFDqRakvg|sWX2~dxs4(NWhx>6@*oec1 zp~8uyj0bf9zV5E+m34-H0{}i%5`ZhvyBAtXSR56w%_Do+F1SvKcc0f!LW!e_O@V!+ z(0IgW|CVVLUM$OyQK`OWs7$!+MD^5a@h9HYy6!F- z52}V;G_nJ?IA1n(t7^=zvQep9&C$1KV{4I8bMuAj>Z;)~U}*LRaq5;OkV-Yrzo3n~ zOxT0XWzZL1p1Mx#rl@9BRm^ben)sVJpKa8iV$0f+#Gs_Xhs=6`c+sYlrHrdV$adC$X#vt zIrjZTpCIEgs9bk3%6_i8(TM~O5kWsO3^Aju7Q81*rqs@ECnCNhnYo<{0*##gq`no(Y$ZKbPy3mut=zwDID=nHi5cz;H%FJcKL z5lN`O;y@TTxsE1c!CC@NFv>yNcN2G}C4k(Lh$zo+D4{-us{9BgEYa7F{6vSDNLu{a zbl%(@#pfeKF2GfUeNb@{9ps{iz3C&eG%=5{50}`31)?ty^%ppW@9-X;uxGM!s{!gp z=bkn?_oUIe?`xgwz&AKeUxgXIrvC@b+J`UkAy-jmd&s|cW2|C~gZ3;xW6XF78D!Cd zbIcVdBSDPwj4{rgAE3O%BWNm)sJNiwqEIoRqRoGIso+~dNbbL+_3O>T(u{V;_OSb3 z;aKrxT_a+Rcw1!88d`4FNTQ~ZKp0V957AvTpeEErBusKMv4HYeBDzBdwHpv{Jm_~p%!r1Y#aIfKwkF!8HQN)E~7HjS^b2{_~>y}~w!aFu}M_cVnq M#|!^da@`B@4=VNBM*si- literal 0 HcmV?d00001 diff --git a/tester/scratchpad/Test_Graph_0.class b/tester/scratchpad/Test_Graph_0.class new file mode 100644 index 0000000000000000000000000000000000000000..25e524820e09b9ea52254b85d825806e95f77fea GIT binary patch literal 745 zcmZuvO>fgc6r7Enn7XEE(hpK-p+Etr1dRD{^WUVMk2E>fT897ZeJa0<&R#UgGL||P*!DlQ&gEAbL^2)*-8|Lturcc* z(;@F|{HH8X%;rLC*H{n!Ss;HYRoNuU1w>Q8?Ix2nRPVHrSy@){+%y+h?ND7?88exO zRd`gk3|mlhI?DwEe(d0h2Oo6@haQgbRA7DK>11%OLh7ja*Tl|D`e8B-J}Q|dF@5(` zIEs@f8D0eKB$GM}OsBUh4o94QI^nps{H1BlnHzN)TV=}Q;6@g@*3CDEa{=ly@3*dbyOHvP{jr_=5h#|w7||43a3}F zPN%S^D7KC+QF^_531>lAB@}3ru!BvUpoR}K^8Gmhb6c#J;bI%NNWaO3HSAEWh1;wY Ta0k1LHfsf