From: Thomas Walker Lynch Date: Fri, 8 Nov 2024 13:00:47 +0000 (+0000) Subject: check point before modifying package name prefixes are added X-Git-Url: https://git.reasoningtechnology.com/usr/lib/python2.7/encodings/charmap.py?a=commitdiff_plain;h=b81e3c7b8199c4f50f848e64990f87397d902167;p=Ariadne check point before modifying package name prefixes are added --- 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 bebaba1..5febc4e 100644 Binary files a/tester/jvm/Test_Ariadne.jar and b/tester/jvm/Test_Ariadne.jar differ diff --git a/tester/scratchpad/In$MIO.class b/tester/scratchpad/In$MIO.class new file mode 100644 index 0000000..0e0675b Binary files /dev/null and b/tester/scratchpad/In$MIO.class differ diff --git a/tester/scratchpad/In$MU.class b/tester/scratchpad/In$MU.class new file mode 100644 index 0000000..b1c12c6 Binary files /dev/null and b/tester/scratchpad/In$MU.class differ diff --git a/tester/scratchpad/In$TB.class b/tester/scratchpad/In$TB.class new file mode 100644 index 0000000..a29ca9b Binary files /dev/null and b/tester/scratchpad/In$TB.class differ diff --git a/tester/scratchpad/In$TestBench.class b/tester/scratchpad/In$TestBench.class new file mode 100644 index 0000000..a6d27ed Binary files /dev/null and b/tester/scratchpad/In$TestBench.class differ diff --git a/tester/scratchpad/In.class b/tester/scratchpad/In.class new file mode 100644 index 0000000..fab265e Binary files /dev/null and b/tester/scratchpad/In.class differ diff --git a/tester/scratchpad/Test_Graph_0$TestSuite.class b/tester/scratchpad/Test_Graph_0$TestSuite.class new file mode 100644 index 0000000..04e4640 Binary files /dev/null and b/tester/scratchpad/Test_Graph_0$TestSuite.class differ diff --git a/tester/scratchpad/Test_Graph_0.class b/tester/scratchpad/Test_Graph_0.class new file mode 100644 index 0000000..25e5248 Binary files /dev/null and b/tester/scratchpad/Test_Graph_0.class differ diff --git a/tester/shell/Test_Graph_0 b/tester/shell/Test_Graph_0 new file mode 100755 index 0000000..7653d09 --- /dev/null +++ b/tester/shell/Test_Graph_0 @@ -0,0 +1,2 @@ +#!/bin/env bash +java Test_Graph_0 diff --git a/tester/tool/shell_wrapper_list b/tester/tool/shell_wrapper_list index c186b41..c8a3926 100755 --- a/tester/tool/shell_wrapper_list +++ b/tester/tool/shell_wrapper_list @@ -18,6 +18,7 @@ echo \ Test_Token_0 \ Test_TokenSet_0 \ Test_Util_0 \ + Test_Graph_0 \ ""