From: Thomas Walker Lynch Date: Fri, 20 Dec 2024 01:16:24 +0000 (+0000) Subject: testing X-Git-Url: https://git.reasoningtechnology.com/style/rt_dark_doc.css?a=commitdiff_plain;h=5e790dbeafa51c7b6c215f9905b8d027292093e3;p=Mosaic testing --- diff --git a/.idea/runConfigurations/Dispatch_0.xml b/.idea/runConfigurations/Dispatch_0.xml deleted file mode 100644 index 0f3fa0d..0000000 --- a/.idea/runConfigurations/Dispatch_0.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/Dispatcher_0.xml b/.idea/runConfigurations/Dispatcher_0.xml new file mode 100644 index 0000000..816d76a --- /dev/null +++ b/.idea/runConfigurations/Dispatcher_0.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git "a/developer/javac\360\237\226\211/Mosaic_Dispatcher.java" "b/developer/javac\360\237\226\211/Mosaic_Dispatcher.java" index c3822b4..5c83a19 100644 --- "a/developer/javac\360\237\226\211/Mosaic_Dispatcher.java" +++ "b/developer/javac\360\237\226\211/Mosaic_Dispatcher.java" @@ -4,6 +4,7 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; import java.lang.reflect.Constructor; +import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.Arrays; @@ -390,9 +391,47 @@ public class Mosaic_Dispatcher{ // methods unique to the class // + public T read(Object instance ,String field_name){ + try{ + test_print("Call to Mosaic_Dispatcher::read"); + + // Private field lookup + MethodHandles.Lookup lookup = MethodHandles.privateLookupIn(target ,MethodHandles.lookup()); + Field field = target.getDeclaredField(field_name); + + // Access the field using the lookup handle + MethodHandle handle; + if((field.getModifiers() & Modifier.STATIC) != 0){ + // Static field + handle = lookup.unreflectGetter(field); + return (T) handle.invoke(); + }else{ + // Instance-bound field + if(instance == null || !target.isInstance(instance)){ + throw new IllegalArgumentException + ( + "Provided instance is not of target type: " + + target.getName() + + ", but received: " + + (instance == null ? "null" : instance.getClass().getName()) + ); + } + handle = lookup.unreflectGetter(field); + return (T) handle.bindTo(instance).invoke(); + } + }catch(NoSuchFieldException | IllegalAccessException e){ + System.out.println("Mosaic_Dispatcher::read_field exception:"); + e.printStackTrace(); + return null; + }catch(Throwable t){ + System.out.println("Mosaic_Dispatcher::read_field exception:"); + t.printStackTrace(); + return null; + } + } @SuppressWarnings("unchecked") - public T make(Object... arg_list) { + public T make(Object... arg_list){ test_print("Call to Mosaic_Dispatcher::make"); // Use dispatch_1 to invoke the constructor diff --git "a/tester/javac\360\237\226\211/#Dispatch_0.java#" "b/tester/javac\360\237\226\211/#Dispatch_0.java#" new file mode 100644 index 0000000..e69de29 diff --git "a/tester/javac\360\237\226\211/AllMethodsPublicProxy_0.java" "b/tester/javac\360\237\226\211/AllMethodsPublicProxy_0.java" deleted file mode 100644 index 327e04c..0000000 --- "a/tester/javac\360\237\226\211/AllMethodsPublicProxy_0.java" +++ /dev/null @@ -1,98 +0,0 @@ -import com.ReasoningTechnology.Mosaic.Mosaic_AllMethodsPublicProxy; -import com.ReasoningTechnology.Mosaic.Mosaic_IO; -import com.ReasoningTechnology.Mosaic.Mosaic_Testbench; -import com.ReasoningTechnology.Mosaic.TestClasses; - -public class AllMethodsPublicProxy_0 { - - public static class TestSuite { - - private static Mosaic_AllMethodsPublicProxy publicProxy; - private static Mosaic_AllMethodsPublicProxy defaultProxy; - private static Mosaic_AllMethodsPublicProxy privateProxy; - - static { - try { - // Initialize proxies for public, default, and private classes - publicProxy = new Mosaic_AllMethodsPublicProxy(PublicClass.class); - defaultProxy = new Mosaic_AllMethodsPublicProxy(DefaultClass.class); - privateProxy = new Mosaic_AllMethodsPublicProxy(PrivateClass.class); - } catch (Exception e) { - System.err.println("Failed to initialize proxies: " + e.getMessage()); - e.printStackTrace(); - } - } - - public Boolean test_publicClass_publicMethod(Mosaic_IO io) { - try { - Object instance = publicProxy.construct(""); - return (Boolean) publicProxy.invoke(instance, "publicMethod"); - } catch (Exception e) { - System.err.println("Test failed: " + e.getMessage()); - e.printStackTrace(); - return false; - } - } - - public Boolean test_publicClass_privateMethod(Mosaic_IO io) { - try { - Object instance = publicProxy.construct(""); - return (Boolean) publicProxy.invoke(instance, "privateMethod"); - } catch (Exception e) { - System.err.println("Test failed: " + e.getMessage()); - e.printStackTrace(); - return false; - } - } - - public Boolean test_defaultClass_publicMethod(Mosaic_IO io) { - try { - Object instance = defaultProxy.construct(""); - return (Boolean) defaultProxy.invoke(instance, "publicMethod"); - } catch (Exception e) { - System.err.println("Test failed: " + e.getMessage()); - e.printStackTrace(); - return false; - } - } - - public Boolean test_defaultClass_privateMethod(Mosaic_IO io) { - try { - Object instance = defaultProxy.construct(""); - return (Boolean) defaultProxy.invoke(instance, "privateMethod"); - } catch (Exception e) { - System.err.println("Test failed: " + e.getMessage()); - e.printStackTrace(); - return false; - } - } - - public Boolean test_privateClass_publicMethod(Mosaic_IO io) { - try { - Object instance = privateProxy.construct(""); - return (Boolean) privateProxy.invoke(instance, "publicMethod"); - } catch (Exception e) { - System.err.println("Test failed: " + e.getMessage()); - e.printStackTrace(); - return false; - } - } - - public Boolean test_privateClass_privateMethod(Mosaic_IO io) { - try { - Object instance = privateProxy.construct(""); - return (Boolean) privateProxy.invoke(instance, "privateMethod"); - } catch (Exception e) { - System.err.println("Test failed: " + e.getMessage()); - e.printStackTrace(); - return false; - } - } - } - - public static void main(String[] args) { - TestSuite suite = new TestSuite(); - int result = Mosaic_Testbench.run(suite); - System.exit(result); - } -} diff --git "a/tester/javac\360\237\226\211/Dispatch_0.java" "b/tester/javac\360\237\226\211/Dispatch_0.java" deleted file mode 100644 index 51d9a5c..0000000 --- "a/tester/javac\360\237\226\211/Dispatch_0.java" +++ /dev/null @@ -1,135 +0,0 @@ -import com.ReasoningTechnology.Mosaic.Mosaic_Dispatcher; -import com.ReasoningTechnology.Mosaic.Mosaic_IsPrimitive; -import com.ReasoningTechnology.Mosaic.Mosaic_Util; - -import tester.TestClasses_0; -import tester.TestClasses_1; - -public class Dispatch_0{ - - private static Mosaic_Dispatcher dispatcher; - - static{ - // Initialize the dispatcher for TestClasses_0 - Mosaic_Dispatcher.test_switch(true); - } - - public Dispatch_0(){ - Mosaic_Dispatcher.test_print("making map for TestClasses_0"); - dispatcher = new Mosaic_Dispatcher(TestClasses_0.class); - } - - // Test method to access the public method of the public class - public static boolean test_publicClass_publicMethod(){ - Object instance = new TestClasses_0(); - boolean result = dispatcher.dispatch - ( - instance // target instance - ,boolean.class // return type - ,"a_public_method_1" // method name - ); - - return result; - } - - public static boolean test_make_0(){ - Boolean[] condition_list = new Boolean[4]; - Mosaic_Util.all_set_false(condition_list); - int i = 0; - - Mosaic_Dispatcher d1 = new Mosaic_Dispatcher(TestClasses_1.class); - - TestClasses_1 tc0 = new TestClasses_1(); - condition_list[i++] = tc0.get_i() == 0; - - TestClasses_1 tc1 = (TestClasses_1) d1.make(); - condition_list[i++] = tc1.get_i() == 0; - - TestClasses_1 tc2 = (TestClasses_1) d1.make(new Mosaic_IsPrimitive(7)); - condition_list[i++] = tc2.get_i() == 7; - - TestClasses_1 tc3 = (TestClasses_1) d1.make(new Mosaic_IsPrimitive(21) ,new Mosaic_IsPrimitive(17) ); - condition_list[i++] = tc3.get_i() == 38; - - return Mosaic_Util.all(condition_list); - } - - // Test public static method - public static boolean test_publicStaticMethod_7(){ - boolean result = dispatcher.dispatch( - boolean.class, // return type - "a_public_static_method_7" // method name - ); - return result; - } - - // Test private static method - public static boolean test_privateStaticMethod_9(){ - boolean result = dispatcher.dispatch( - boolean.class, // return type - "a_private_static_method_9" // method name - ); - return result; - } - - // Extend the run method to include static method tests - public static boolean run(){ - try{ - boolean result = true; - - System.out.println(""); - System.out.println("running test: publicClass_publicMethod"); - if (Boolean.TRUE.equals(test_publicClass_publicMethod())){ - System.out.println("passed"); - }else{ - System.out.println("FAILED"); - result = false; - } - - System.out.println(""); - System.out.println("running test: make_0"); - if (Boolean.TRUE.equals(test_make_0())){ - System.out.println("passed"); - }else{ - System.out.println("FAILED"); - result = false; - } - - System.out.println(""); - System.out.println("running test: publicStaticMethod_7"); - if (Boolean.TRUE.equals(test_publicStaticMethod_7())){ - System.out.println("passed"); - }else{ - System.out.println("FAILED"); - result = false; - } - - System.out.println(""); - System.out.println("running test: privateStaticMethod_9"); - if (Boolean.TRUE.equals(test_privateStaticMethod_9())){ - System.out.println("passed"); - }else{ - System.out.println("FAILED"); - result = false; - } - - System.out.println(""); - return result; - - }catch (Exception e){ - System.out.println("Exception in Dispatch_0 test:"); - e.printStackTrace(); - return false; - } - } - - public static void main(String[] args){ - // Execute the run method and return its result as the exit code - new Dispatch_0(); - if( run() ) - System.exit(0); - else - System.exit(1); - } - -} diff --git "a/tester/javac\360\237\226\211/Dispatch_1.java" "b/tester/javac\360\237\226\211/Dispatch_1.java" deleted file mode 100644 index 48d5f3b..0000000 --- "a/tester/javac\360\237\226\211/Dispatch_1.java" +++ /dev/null @@ -1,211 +0,0 @@ -import com.ReasoningTechnology.Mosaic.Mosaic_Dispatcher; -import com.ReasoningTechnology.Mosaic.Mosaic_Util; - -import tester.TestClasses_0; - -public class Dispatch_1{ - - private static Mosaic_Dispatcher dispatcher; - - static{ - // Initialize the dispatcher for TestClasses_0 - dispatcher = new Mosaic_Dispatcher(TestClasses_0.class); - // Test messages are disabled for now - } - - // Test public method in the public class - public static boolean test_publicMethod_1(){ - Object instance = new TestClasses_0(); - boolean result = dispatcher.dispatch( - instance, // target instance - boolean.class, // return type - "a_public_method_1" // method name - ); - return result; - } - - // Test private method in the public class - public static boolean test_privateMethod_2(){ - Object instance = new TestClasses_0(); - boolean result = dispatcher.dispatch( - instance, // target instance - boolean.class, // return type - "a_private_method_2" // method name - ); - return result; - } - - public static boolean test_nestedPublicMethod_3(){ - try{ - - // Create a dispatcher for the nested public class - Mosaic_Dispatcher nested_dispatcher = new Mosaic_Dispatcher(TestClasses_0.APublicClass_01.class); - - // Create an instance of the outer class - TestClasses_0 outer_instance = new TestClasses_0(); - - // Create an instance of the nested public class - TestClasses_0.APublicClass_01 nested_instance = outer_instance.new APublicClass_01(); - - // Dispatch the public method call on the nested class - boolean result = nested_dispatcher.dispatch( - nested_instance, // Target instance - boolean.class, // Return type - "a_public_method_3" // Method name - ); - - return result; - - } catch (Exception e){ - System.out.println("Exception in test_nestedPublicMethod_3"); - e.printStackTrace(); - return false; - } - } - - // Test private method in the nested public class - public static boolean test_nestedPrivateMethod_4(){ - - // Create a dispatcher for the nested public class - Mosaic_Dispatcher nested_dispatcher = new Mosaic_Dispatcher(TestClasses_0.APublicClass_01.class); - - // Create an instance of the outer class - TestClasses_0 outer_instance = new TestClasses_0(); - - // Create an instance of the nested public class - TestClasses_0.APublicClass_01 nested_instance = outer_instance.new APublicClass_01(); - - boolean result = nested_dispatcher.dispatch( - nested_instance, // target instance - boolean.class, // return type - "a_private_method_4" // method name - ); - return result; - } - - // Test public method in the nested private class - public static boolean test_private_class_public_method_5(){ - - // Use Mosaic_Dispatch to access the private class - Class private_class_metadata = Mosaic_Dispatch.resolve_class( - TestClasses_0.class ,"tester.TestClasses_0$APrivateClass_02" - ); - - // Create a dispatcher for the private class - Mosaic_Dispatcher nested_dispatcher = new Mosaic_Dispatcher(private_class_metadata); - - // Instance of the private class is created via the dispatcher - Object nested_instance = nested_dispatcher.make(); - - boolean result = nested_dispatcher.dispatch( - nested_instance - ,boolean.class - ,"a_public_method_5" - ); - - return result; - } - - - // Test public method in the nested private class - public static boolean test_privateClassPublicMethod_5(){ - - // Create a dispatcher for the nested public class - Mosaic_Dispatcher nested_dispatcher = new Mosaic_Dispatcher(TestClasses_0.APrivateClass_02.class); - - // Instance of the private class is created via the dispatcher - Object nested_instance = nested_dispatcher.make(); - boolean result = nested_dispatcher.dispatch( - nested_instance, // target instance - boolean.class, // return type - "a_public_method_5" // method name - ); - return result; - } - - // Test private method in the nested private class - public static boolean test_privateClassPrivateMethod_6(){ - Object nested_instance = dispatcher.make( - TestClasses_0.class, - "APrivateClass_02", - null - ); - boolean result = dispatcher.dispatch( - nested_instance, - boolean.class, - "a_private_method_6" - ); - return result; - } - - // Run method to execute all tests - public static boolean run(){ - try{ - boolean result = true; - - /* - System.out.println("\nRunning test: publicMethod_1"); - if (Boolean.TRUE.equals(test_publicMethod_1())){ - System.out.println("PASSED"); - } else{ - System.out.println("FAILED"); - result = false; - } - - System.out.println("\nRunning test: privateMethod_2"); - if (Boolean.TRUE.equals(test_privateMethod_2())){ - System.out.println("PASSED"); - } else{ - System.out.println("FAILED"); - result = false; - } - - System.out.println("\nRunning test: nestedPublicMethod_3"); - if (Boolean.TRUE.equals(test_nestedPublicMethod_3())){ - System.out.println("PASSED"); - } else{ - System.out.println("FAILED"); - result = false; - } - - System.out.println("\nRunning test: nestedPrivateMethod_4"); - if (Boolean.TRUE.equals(test_nestedPrivateMethod_4())){ - System.out.println("PASSED"); - } else{ - System.out.println("FAILED"); - result = false; - } - */ - - System.out.println("\nRunning test: privateClassPublicMethod_5"); - if (Boolean.TRUE.equals(test_privateClassPublicMethod_5())){ - System.out.println("PASSED"); - } else{ - System.out.println("FAILED"); - result = false; - } - - System.out.println("\nRunning test: privateClassPrivateMethod_6"); - if (Boolean.TRUE.equals(test_privateClassPrivateMethod_6())){ - System.out.println("PASSED"); - } else{ - System.out.println("FAILED"); - result = false; - } - - return result; - } catch (Exception e){ - System.out.println("Exception in Dispatch_1 test:"); - e.printStackTrace(); - return false; - } - } - - public static void main(String[] args){ - if (run()){ - System.exit(0); - } else{ - System.exit(1); - } - } -} diff --git "a/tester/javac\360\237\226\211/Dispatcher_0.java" "b/tester/javac\360\237\226\211/Dispatcher_0.java" new file mode 100644 index 0000000..491b8f4 --- /dev/null +++ "b/tester/javac\360\237\226\211/Dispatcher_0.java" @@ -0,0 +1,135 @@ +import com.ReasoningTechnology.Mosaic.Mosaic_Dispatcher; +import com.ReasoningTechnology.Mosaic.Mosaic_IsPrimitive; +import com.ReasoningTechnology.Mosaic.Mosaic_Util; + +import tester.TestClasses_0; +import tester.TestClasses_1; + +public class Dispatcher_0{ + + private static Mosaic_Dispatcher dispatcher; + + static{ + // Initialize the dispatcher for TestClasses_0 + Mosaic_Dispatcher.test_switch(true); + } + + public Dispatcher_0(){ + Mosaic_Dispatcher.test_print("making map for TestClasses_0"); + dispatcher = new Mosaic_Dispatcher(TestClasses_0.class); + } + + // Test method to access the public method of the public class + public static boolean test_publicClass_publicMethod(){ + Object instance = new TestClasses_0(); + boolean result = dispatcher.dispatch + ( + instance // target instance + ,boolean.class // return type + ,"a_public_method_1" // method name + ); + + return result; + } + + public static boolean test_make_0(){ + Boolean[] condition_list = new Boolean[4]; + Mosaic_Util.all_set_false(condition_list); + int i = 0; + + Mosaic_Dispatcher d1 = new Mosaic_Dispatcher(TestClasses_1.class); + + TestClasses_1 tc0 = new TestClasses_1(); + condition_list[i++] = tc0.get_i() == 0; + + TestClasses_1 tc1 = (TestClasses_1) d1.make(); + condition_list[i++] = tc1.get_i() == 0; + + TestClasses_1 tc2 = (TestClasses_1) d1.make(new Mosaic_IsPrimitive(7)); + condition_list[i++] = tc2.get_i() == 7; + + TestClasses_1 tc3 = (TestClasses_1) d1.make(new Mosaic_IsPrimitive(21) ,new Mosaic_IsPrimitive(17) ); + condition_list[i++] = tc3.get_i() == 38; + + return Mosaic_Util.all(condition_list); + } + + // Test public static method + public static boolean test_publicStaticMethod_7(){ + boolean result = dispatcher.dispatch( + boolean.class, // return type + "a_public_static_method_7" // method name + ); + return result; + } + + // Test private static method + public static boolean test_privateStaticMethod_9(){ + boolean result = dispatcher.dispatch( + boolean.class, // return type + "a_private_static_method_9" // method name + ); + return result; + } + + // Extend the run method to include static method tests + public static boolean run(){ + try{ + boolean result = true; + + System.out.println(""); + System.out.println("running test: publicClass_publicMethod"); + if (Boolean.TRUE.equals(test_publicClass_publicMethod())){ + System.out.println("passed"); + }else{ + System.out.println("FAILED"); + result = false; + } + + System.out.println(""); + System.out.println("running test: make_0"); + if (Boolean.TRUE.equals(test_make_0())){ + System.out.println("passed"); + }else{ + System.out.println("FAILED"); + result = false; + } + + System.out.println(""); + System.out.println("running test: publicStaticMethod_7"); + if (Boolean.TRUE.equals(test_publicStaticMethod_7())){ + System.out.println("passed"); + }else{ + System.out.println("FAILED"); + result = false; + } + + System.out.println(""); + System.out.println("running test: privateStaticMethod_9"); + if (Boolean.TRUE.equals(test_privateStaticMethod_9())){ + System.out.println("passed"); + }else{ + System.out.println("FAILED"); + result = false; + } + + System.out.println(""); + return result; + + }catch (Exception e){ + System.out.println("Exception in Dispatcher_0 test:"); + e.printStackTrace(); + return false; + } + } + + public static void main(String[] args){ + // Execute the run method and return its result as the exit code + new Dispatcher_0(); + if( run() ) + System.exit(0); + else + System.exit(1); + } + +} diff --git "a/tester/javac\360\237\226\211/Dispatcher_1.java" "b/tester/javac\360\237\226\211/Dispatcher_1.java" new file mode 100644 index 0000000..89da82f --- /dev/null +++ "b/tester/javac\360\237\226\211/Dispatcher_1.java" @@ -0,0 +1,111 @@ +import com.ReasoningTechnology.Mosaic.Mosaic_Dispatcher; +import com.ReasoningTechnology.Mosaic.Mosaic_Util; + +import tester.TestClasses_0; + +public class Dispatcher_1{ + + private static Mosaic_Dispatcher dispatcher; + + static{ + dispatcher = new Mosaic_Dispatcher(TestClasses_0.class); + } + + public static boolean test_publicMethod_1(){ + TestClasses_0 instance = new TestClasses_0(); + return dispatcher.dispatch(instance, boolean.class, "a_public_method_1"); + } + + public static boolean test_privateMethod_2(){ + TestClasses_0 instance = new TestClasses_0(); + return dispatcher.dispatch(instance, boolean.class, "a_private_method_2"); + } + + public static boolean test_nestedPublicMethod_3(){ + try{ + TestClasses_0 outer = new TestClasses_0(); + TestClasses_0.APublicClass_01 nested = outer.new APublicClass_01(); + Mosaic_Dispatcher nested_dispatcher = new Mosaic_Dispatcher(TestClasses_0.APublicClass_01.class); + return nested_dispatcher.dispatch(nested, boolean.class, "a_public_method_3"); + } catch(Exception e){ + e.printStackTrace(); + return false; + } + } + + public static boolean test_nestedPrivateMethod_4(){ + try{ + TestClasses_0 outer = new TestClasses_0(); + TestClasses_0.APublicClass_01 nested = outer.new APublicClass_01(); + Mosaic_Dispatcher nested_dispatcher = new Mosaic_Dispatcher(TestClasses_0.APublicClass_01.class); + return nested_dispatcher.dispatch(nested, boolean.class, "a_private_method_4"); + } catch(Exception e){ + e.printStackTrace(); + return false; + } + } + + public static boolean run(){ + try{ + boolean result = true; + + System.out.println(""); + System.out.println("running test: publicMethod_1"); + if(Boolean.TRUE.equals(test_publicMethod_1())){ + System.out.println("PASSED"); + }else{ + System.out.println("FAILED"); + result = false; + } + + System.out.println(""); + System.out.println("running test: privateMethod_2"); + if(Boolean.TRUE.equals(test_privateMethod_2())){ + System.out.println("PASSED"); + }else{ + System.out.println("FAILED"); + result = false; + } + + System.out.println(""); + System.out.println("running test: nestedPublicMethod_3"); + if(Boolean.TRUE.equals(test_nestedPublicMethod_3())){ + System.out.println("PASSED"); + }else{ + System.out.println("FAILED"); + result = false; + } + + System.out.println(""); + System.out.println("running test: nestedPrivateMethod_4"); + if(Boolean.TRUE.equals(test_nestedPrivateMethod_4())){ + System.out.println("PASSED"); + }else{ + System.out.println("FAILED"); + result = false; + } + + System.out.println(""); + return result; + + }catch(Exception e){ + System.out.println("Exception in Dispatcher_1 test:"); + e.printStackTrace(); + return false; + } + } + + private static boolean logPass(){ + System.out.println("PASSED"); + return true; + } + + private static boolean logFail(){ + System.out.println("FAILED"); + return false; + } + + public static void main(String[] args){ + System.exit(run() ? 0 : 1); + } +} diff --git "a/tester/javac\360\237\226\211/Dispatcher_2.java" "b/tester/javac\360\237\226\211/Dispatcher_2.java" new file mode 100644 index 0000000..f5aefe3 --- /dev/null +++ "b/tester/javac\360\237\226\211/Dispatcher_2.java" @@ -0,0 +1,122 @@ +import com.ReasoningTechnology.Mosaic.Mosaic_Dispatcher; + +import tester.TestClasses_2; + +public class Dispatcher_2{ + + private static Mosaic_Dispatcher dispatcher; + + static{ + dispatcher = new Mosaic_Dispatcher(TestClasses_2.class); + } + + public static boolean test_publicStaticField(){ + try{ + Integer value = dispatcher.read(Integer.class, "i_200"); + return value != null && value == 200; // Replace 200 with initialized value + }catch(Throwable t){ + t.printStackTrace(); + return false; + } + } + + public static boolean test_privateStaticField(){ + try{ + String value = dispatcher.read(String.class, "s_201"); + return value != null && value.equals("Test"); // Replace "Test" with initialized value + }catch(Throwable t){ + t.printStackTrace(); + return false; + } + } + + public static boolean test_publicInstanceField(){ + try{ + TestClasses_2 instance = dispatcher.make(); + Integer value = dispatcher.read(instance, "i_202"); + return value != null && value == 202; // Replace 202 with initialized value + }catch(Throwable t){ + t.printStackTrace(); + return false; + } + } + + public static boolean test_privateInstanceField(){ + try{ + TestClasses_2 instance = dispatcher.make(); + Integer value = dispatcher.read(instance, "i_203"); + return value != null && value == 203; // Replace 203 with initialized value + }catch(Throwable t){ + t.printStackTrace(); + return false; + } + } + + public static boolean run(){ + try{ + boolean result = true; + + System.out.println(""); + System.out.println("running test: publicStaticField"); + if(Boolean.TRUE.equals(test_publicStaticField())){ + System.out.println("PASSED"); + }else{ + System.out.println("FAILED"); + result = false; + } + + System.out.println(""); + System.out.println("running test: privateStaticField"); + if(Boolean.TRUE.equals(test_privateStaticField())){ + System.out.println("PASSED"); + }else{ + System.out.println("FAILED"); + result = false; + } + + System.out.println(""); + System.out.println("running test: publicInstanceField"); + if(Boolean.TRUE.equals(test_publicInstanceField())){ + System.out.println("PASSED"); + }else{ + System.out.println("FAILED"); + result = false; + } + + System.out.println(""); + System.out.println("running test: privateInstanceField"); + if(Boolean.TRUE.equals(test_privateInstanceField())){ + System.out.println("PASSED"); + }else{ + System.out.println("FAILED"); + result = false; + } + + System.out.println(""); + return result; + + }catch(Exception e){ + System.out.println("Exception in Dispatcher_2 test:"); + e.printStackTrace(); + return false; + } + } + + public static boolean logPass(){ + System.out.println("PASSED"); + return true; + } + + public static boolean logFail(){ + System.out.println("FAILED"); + return false; + } + + public static void main(String[] args){ + if(run()){ + System.exit(0); + }else{ + System.exit(1); + } + } +} diff --git "a/tester/javac\360\237\226\211/Dispatcher_3.java" "b/tester/javac\360\237\226\211/Dispatcher_3.java" new file mode 100644 index 0000000..99433b4 --- /dev/null +++ "b/tester/javac\360\237\226\211/Dispatcher_3.java" @@ -0,0 +1,104 @@ +import com.ReasoningTechnology.Mosaic.Mosaic_Dispatcher; +import com.ReasoningTechnology.Mosaic.Mosaic_Util; + +import tester.TestClasses_0; + +public class Dispatcher_3{ + + private static Mosaic_Dispatcher dispatcher; + + static{ + dispatcher = new Mosaic_Dispatcher(TestClasses_0.class); + } + + public static boolean test_privateClassPublicMethod_5(){ + try{ + Mosaic_Dispatcher nested_dispatcher = new Mosaic_Dispatcher(TestClasses_0.APrivateClass_02.class); + Object nested_instance = nested_dispatcher.make(); + return nested_dispatcher.dispatch(nested_instance, boolean.class, "a_public_method_5"); + } catch(Exception e){ + e.printStackTrace(); + return false; + } + } + + public static boolean test_privateClassPrivateMethod_6(){ + try{ + Mosaic_Dispatcher nested_dispatcher = new Mosaic_Dispatcher(TestClasses_0.APrivateClass_02.class); + Object nested_instance = nested_dispatcher.make(); + return nested_dispatcher.dispatch(nested_instance, boolean.class, "a_private_method_6"); + } catch(Exception e){ + e.printStackTrace(); + return false; + } + } + + public static boolean test_publicDefaultClassField() { + try { + Class defaultClass = dispatcher.getDefaultClass(); // Assuming `getDefaultClass` exists + Integer value = dispatcher.read(Integer.class, "d_300"); + return value != null && value == 300; // Replace 300 with initialized value + } catch (Throwable t) { + t.printStackTrace(); + return false; + } + } + + + + public static boolean run(){ + try{ + boolean result = true; + + System.out.println(""); + System.out.println("running test: privateClassPublicMethod_5"); + if(Boolean.TRUE.equals(test_privateClassPublicMethod_5())){ + System.out.println("PASSED"); + }else{ + System.out.println("FAILED"); + result = false; + } + + System.out.println(""); + System.out.println("running test: privateClassPrivateMethod_6"); + if(Boolean.TRUE.equals(test_privateClassPrivateMethod_6())){ + System.out.println("PASSED"); + }else{ + System.out.println("FAILED"); + result = false; + } + + System.out.println(""); + System.out.println("running test: publicDefaultClassField"); + if(Boolean.TRUE.equals(test_publicDefaultClassField())){ + System.out.println("PASSED"); + }else{ + System.out.println("FAILED"); + result = false; + } + + + System.out.println(""); + return result; + + }catch(Exception e){ + System.out.println("Exception in Dispatcher_1 test:"); + e.printStackTrace(); + return false; + } + } + + private static boolean logPass(){ + System.out.println("PASSED"); + return true; + } + + private static boolean logFail(){ + System.out.println("FAILED"); + return false; + } + + public static void main(String[] args){ + System.exit(run() ? 0 : 1); + } +} diff --git "a/tester/javac\360\237\226\211/TestClasses_0.java" "b/tester/javac\360\237\226\211/TestClasses_0.java" index b147eac..f1dde59 100644 --- "a/tester/javac\360\237\226\211/TestClasses_0.java" +++ "b/tester/javac\360\237\226\211/TestClasses_0.java" @@ -48,7 +48,7 @@ public class TestClasses_0{ } // Default (package-private) class with public and private methods -class DefaultTestClass{ +class DefaultTestClass_01{ public boolean a_public_method_7(){ return true; } diff --git "a/tester/javac\360\237\226\211/TestClasses_2.java" "b/tester/javac\360\237\226\211/TestClasses_2.java" new file mode 100644 index 0000000..b576f0f --- /dev/null +++ "b/tester/javac\360\237\226\211/TestClasses_2.java" @@ -0,0 +1,80 @@ +package tester; + +public class TestClasses_2 { + // Static fields + public static int i_200; + private static String s_201; + + // Instance fields + public Integer i_202; + private Integer i_203; + + // Nested class + public static class Class_Nested_21 { + public static Integer i_210; + private static String s_211; + + public Integer i_212; + private Integer i_213; + + public static void initialize_static_data() { + i_210 = 210; + s_211 = "Static Nested Private String"; + } + + public void initialize_instance_data() { + i_212 = 212; + i_213 = 213; + } + } + + public static void initialize_static_data() { + i_200 = 200; + s_201 = "Static Private String"; + } + + public void initialize_instance_data() { + i_202 = 202; + i_203 = 203; + } +} + +// Default (package-private) class +class DefaultTestClass { + // Static fields + public static double d_300; + private static boolean b_301; + + // Instance fields + public Float f_302; + private Long l_303; + + // Nested class + public static class Class_Nested_31 { + public static Character c_310; + private static String s_311; + + public Byte b_312; + private Short s_313; + + public static void initialize_static_data() { + c_310 = 'C'; + s_311 = "Default Static Nested Private String"; + } + + public void initialize_instance_data() { + b_312 = (byte) 12; + s_313 = (short) 313; + } + } + + public static void initialize_static_data() { + d_300 = 300.5; + b_301 = true; + } + + public void initialize_instance_data() { + f_302 = 302.5f; + l_303 = 303L; + } +} diff --git "a/tester/tool\360\237\226\211/list" "b/tester/tool\360\237\226\211/list" index 9e538ca..48a6468 100755 --- "a/tester/tool\360\237\226\211/list" +++ "b/tester/tool\360\237\226\211/list" @@ -20,7 +20,9 @@ echo\ Testbench\ MockClass_0\ IsPrimitive\ - Dispatch_0\ + Dispatcher_0\ + Dispatcher_1\ + Dispatcher_2\ "" # Dispatch_1\