From: Thomas Walker Lynch Date: Tue, 17 Dec 2024 16:21:30 +0000 (+0000) Subject: ditto X-Git-Url: https://git.reasoningtechnology.com/style/static/gitweb.js?a=commitdiff_plain;h=60acdb5267c14723d30d4e86d6f83486a980dd8c;p=Mosaic ditto --- diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..00bb152 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +Mosaic Tester - developer \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 639900d..51e7401 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,4 @@ - - - + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..5b835c8 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index d843f34..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,4 +1,6 @@ - + + + \ No newline at end of file diff --git a/developer/developer.iml b/developer/developer.iml new file mode 100644 index 0000000..990111a --- /dev/null +++ b/developer/developer.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git "a/developer/javac\360\237\226\211/Mosaic_AllMethodsPublicProxy.java" "b/developer/javac\360\237\226\211/Mosaic_AllMethodsPublicProxy.java" deleted file mode 100644 index 83b4184..0000000 --- "a/developer/javac\360\237\226\211/Mosaic_AllMethodsPublicProxy.java" +++ /dev/null @@ -1,258 +0,0 @@ -package com.ReasoningTechnology.Mosaic; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.HashMap; -import java.util.Map; - -class FunctionSignature { - private final String method_name; - private final Class[] parameter_types; - - public FunctionSignature(String method_name ,Class[] parameter_types){ - this.method_name = method_name; - this.parameter_types = parameter_types; - } - - public FunctionSignature(String method_name ,Object[] args){ - this.method_name = method_name; - this.parameter_types = resolve_parameter_types(args); - } - - public FunctionSignature(Method method){ - this.method_name = method.getName(); - this.parameter_types = method.getParameterTypes(); - } - - private static Class[] resolve_parameter_types(Object[] arg_list){ - Class[] parameter_types = new Class[arg_list.length]; - for( int i = 0; i < arg_list.length; i++ ){ - if( arg_list[i] instanceof Mosaic_IsPrimitive ){ - parameter_types[i] = ((Mosaic_IsPrimitive) arg_list[i]).get_type(); - }else if( arg_list[i] != null ){ - parameter_types[i] = arg_list[i].getClass(); - }else{ - parameter_types[i] = null; - } - } - return parameter_types; - } - - public String get_method_name(){ - return method_name; - } - - public Class[] get_parameter_types(){ - return parameter_types; - } - - @Override - public boolean equals(Object o){ - if( this == o ) return true; - if( o == null || getClass() != o.getClass() ) return false; - FunctionSignature signature = (FunctionSignature) o; - return method_name.equals(signature.method_name) && - java.util.Arrays.equals(parameter_types ,signature.parameter_types); - } - - @Override - public int hashCode(){ - int result = method_name.hashCode(); - result = 31 * result + java.util.Arrays.hashCode(parameter_types); - return result; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(method_name).append("("); - for (int i = 0; i < parameter_types.length; i++) { - sb.append(parameter_types[i].getSimpleName()); - if (i < parameter_types.length - 1) sb.append(", "); - } - sb.append(")"); - return sb.toString(); - } - -} - -class FunctionSignature_To_Handle_Map { - private final Map map; - - public FunctionSignature_To_Handle_Map(Class class_metadata){ - this.map = new HashMap<>(); - add_class(class_metadata); - } - - private void add_class(Class class_metadata){ - try{ - MethodHandles.Lookup lookup = MethodHandles.lookup(); - MethodHandles.Lookup private_lookup = MethodHandles.privateLookupIn(class_metadata ,lookup); - - // Map constructors - for(Constructor constructor : class_metadata.getDeclaredConstructors()){ - try{ - Class[] parameter_types = constructor.getParameterTypes(); - MethodType method_type = MethodType.methodType(class_metadata, parameter_types); - MethodHandle constructor_handle = private_lookup.findConstructor(class_metadata, method_type); - - FunctionSignature signature = new FunctionSignature("", parameter_types); - map.put(signature, constructor_handle); - }catch (NoSuchMethodException e){ - System.err.println("Skipping constructor: " + constructor); - }catch(Throwable t){ - t.printStackTrace(); - } - } - - // Map methods - for(Method method : class_metadata.getDeclaredMethods()){ - Class[] parameter_types = method.getParameterTypes(); - MethodType method_type = MethodType.methodType( - method.getReturnType() ,parameter_types - ); - MethodHandle method_handle; - - if((method.getModifiers() & Modifier.PRIVATE) != 0){ - method_handle = private_lookup.findSpecial(class_metadata ,method.getName() ,method_type ,class_metadata); - } else{ - method_handle = lookup.findVirtual(class_metadata ,method.getName() ,method_type); - } - - FunctionSignature signature = new FunctionSignature(method); - map.put(signature ,method_handle); - } - - }catch(Throwable t){ - System.out.println("FunctionSignature_To_Handle_Map::add_class exception:"); - t.printStackTrace(); - } - } - - public MethodHandle get_handle(FunctionSignature signature){ - return map.get(signature); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("FunctionSignature to MethodHandle Map:\n"); - for(Map.Entry entry : map.entrySet()) { - sb.append(" ").append(entry.getKey()).append(" -> ").append(entry.getValue()).append("\n"); - } - return sb.toString(); - } - -} - -public class Mosaic_AllMethodsPublicProxy { - private final FunctionSignature_To_Handle_Map map; - private final Class target_type; - - public Mosaic_AllMethodsPublicProxy(Class target_type){ - this.target_type = target_type; - this.map = new FunctionSignature_To_Handle_Map(target_type); - } - - // Constructor accepting a fully qualified class name - public Mosaic_AllMethodsPublicProxy(String fully_qualified_class_name) throws ClassNotFoundException { - try { - Class clazz = Class.forName(fully_qualified_class_name); - - // Use MethodHandles to ensure access to private classes - MethodHandles.Lookup lookup = MethodHandles.lookup(); - MethodHandles.Lookup private_lookup = MethodHandles.privateLookupIn(clazz, lookup); - - this.target_type = clazz; - this.map = new FunctionSignature_To_Handle_Map(clazz); - - } catch (ClassNotFoundException e) { - throw new ClassNotFoundException("Class not found: " + fully_qualified_class_name, e); - } catch (IllegalAccessException e) { - throw new RuntimeException("Failed to access private class: " + fully_qualified_class_name, e); - } - } - - - public Object construct(String constructor_name, Object... arg_list) { - try { - // Resolve the constructor signature - FunctionSignature signature = new FunctionSignature(constructor_name, arg_list); - MethodHandle handle = map.get_handle(signature); - - if (handle == null) { - throw new NoSuchMethodException("No constructor found for signature: " + signature.get_method_name()); - } - - // Unwrap Mosaic_IsPrimitive instances - Object[] unwrapped_args = new Object[arg_list.length]; - for (int i = 0; i < arg_list.length; i++) { - if (arg_list[i] instanceof Mosaic_IsPrimitive) { - unwrapped_args[i] = ((Mosaic_IsPrimitive) arg_list[i]).get_value(); - } else { - unwrapped_args[i] = arg_list[i]; - } - } - - // Invoke the constructor handle - return handle.invokeWithArguments(unwrapped_args); - - } catch (Throwable t) { - System.out.println("Mosaic_AllMethodsPublicProxy::construct exception:"); - t.printStackTrace(); - return null; - } - } - - - public Object invoke(Object target_instance, String method_name, Object... arg_list) { - try { - if(target_instance == null || !target_type.isInstance(target_instance)) { - System.out.println("Warning: Instance is not of type " + target_type.getName()); - } - - // Resolve the function signature. - // The IsPrimtiive tags are needed here so as to form a correct signature for - // looking up the handle. - // - FunctionSignature signature = new FunctionSignature(method_name, arg_list); - MethodHandle handle = map.get_handle(signature); - System.out.println( "invoked with signature: " + signature.toString() ); - - if(handle == null) { - throw new NoSuchMethodException("No method found for signature: " + signature.get_method_name()); - } - - // This removes the IsPrimitive tags (unwrap the containted - // values). The `get_value` will be boxed in the Java Wrappers, - // i.e. `int` values wills till be Integer, because it is - // Object type. Later `invokeWithArguments` below will unbox the - // primitive values as it is aware of the types required for the call. - // - Object[] unwrapped_args = new Object[arg_list.length]; - for(int i = 0; i < arg_list.length; i++) { - if(arg_list[i] instanceof Mosaic_IsPrimitive) { - unwrapped_args[i] = ((Mosaic_IsPrimitive) arg_list[i]).get_value(); - } else { - unwrapped_args[i] = arg_list[i]; - } - } - - return handle.bindTo(target_instance).invokeWithArguments(unwrapped_args); - - }catch(Throwable t) { - System.out.println("Mosaic_AllMethodsPublicProxy::invoke exception:"); - t.printStackTrace(); - return null; - } - } - - public FunctionSignature_To_Handle_Map get_map() { - return map; - } - -} diff --git "a/developer/javac\360\237\226\211/Mosaic_Dispatcher.java" "b/developer/javac\360\237\226\211/Mosaic_Dispatcher.java" new file mode 100644 index 0000000..e2b9a86 --- /dev/null +++ "b/developer/javac\360\237\226\211/Mosaic_Dispatcher.java" @@ -0,0 +1,551 @@ +package com.ReasoningTechnology.Mosaic; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + + +/*-------------------------------------------------------------------------------- + Is a signature for a Method + + The envisioned use case is the 'method signature' -> handle map. + + Perhaps the existing method signature in the Reflection library can + replace this ,but most of the work done here is the formatting done + in the constructors. +*/ + +class MethodSignature{ + // header + private Class return_type; + private String class_name; + private String method_name; + + // variable length parameter type list + private Class[] parameter_type_list; + + // field access and strings + // + public String get_class_name(){ + return class_name; + } + + public String get_method_name(){ + return method_name; + } + + public Class get_return_type(){ + return return_type; + } + + public Class[] get_parameter_type_list(){ + return parameter_type_list; + } + + public String to_string_return_type(){ + return get_return_type() != null ? get_return_type().getSimpleName() : "null"; + } + + public String to_string_parameter_type_list(){ + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < get_parameter_type_list().length; i++){ + sb.append(get_parameter_type_list()[i] != null ? get_parameter_type_list()[i].getSimpleName() : "null"); + if (i < get_parameter_type_list().length - 1) sb.append(" ,"); + } + return sb.toString(); + } + + public String to_string_signature_header(){ + return to_string_return_type() + " " + get_class_name() + "." + get_method_name(); + } + + // constructors + // + private void init_header + ( + Class return_type + ,String class_name + ,String method_name + ){ + this.return_type = return_type; + this.class_name = class_name; + this.method_name = method_name; + } + + // Signature when given a Method. + // Used when putting methods into the method signature to handle map. + public MethodSignature(Method method){ + init_header + ( + method.getReturnType() + ,method.getDeclaringClass().getName() + ,method.getName() + ); + this.parameter_type_list = method.getParameterTypes(); + } + + // Signature when given a parameter type list. + // Used putting constructors into the signature to handle map. + public MethodSignature + ( + Class return_type + ,String class_name + ,String method_name + ,Class[] parameter_type_list + ){ + init_header(return_type ,class_name ,method_name); + this.parameter_type_list = parameter_type_list; + } + + // Signature when given an argument value list. + // Used by `invoke`. + public MethodSignature + ( + Class return_type + ,String class_name + ,String method_name + ,Object[] arg_list + ){ + init_header(return_type ,class_name ,method_name); + + // Set the signature parameter type to the argument type. + // No automatic conversions are applied. + this.parameter_type_list = new Class[arg_list.length]; // Initialize the array + for(int i = 0; i < arg_list.length; i++){ + if(arg_list[i] instanceof Mosaic_IsPrimitive){ + parameter_type_list[i] =( (Mosaic_IsPrimitive) arg_list[i] ).get_type(); + } else if(arg_list[i] != null){ + parameter_type_list[i] = arg_list[i].getClass(); + } else{ + parameter_type_list[i] = null; + } + } + } + + // standard interface + // + @Override + public String toString(){ + return to_string_signature_header() + "(" + to_string_parameter_type_list() + ")"; + } + + @Override + public boolean equals(Object o){ + if(this == o) return true; + if(o == null) return false; + if(o.getClass() != MethodSignature.class) return false; + + MethodSignature signature = (MethodSignature) o; + + return + get_class_name().equals(signature.get_class_name()) + && get_method_name().equals(signature.get_method_name()) + && get_return_type().equals(signature.get_return_type()) + && Arrays.equals(get_parameter_type_list() ,signature.get_parameter_type_list()); + } + + @Override + public int hashCode(){ + int result = get_class_name().hashCode(); + result = 31 * result + get_method_name().hashCode(); + result = 31 * result + get_return_type().hashCode(); + result = 31 * result + Arrays.hashCode(get_parameter_type_list()); + return result; + } + +} + +/*-------------------------------------------------------------------------------- +This is a method signature to callable method handle dictionary. + +In the envisioned use case there is one such dictionary per +Dispatcher instance. + + */ +class MethodSignature_To_Handle_Map{ + private Map map; + + // test facilities + // + private boolean test = false; + public void test_switch(boolean test){ + if(this.test && !test){ + test_print("test messages off"); + this.test = test; + } + if( !this.test && test){ + this.test = test; + test_print("test messages on"); + } + } + private void test_print(String message){ + if(test){ + System.out.println("MethodSignature_To_Handle_Map::" + message); + } + } + + // field access and strings + // + + // constructors + // + public MethodSignature_To_Handle_Map(){ + map = new HashMap<>(); + } + + // methods for adding entries + // + private void add_entry(MethodSignature key ,MethodHandle value){ + test_print + ( + "add_entry::" + + "(" + + key + + "," + +value + ); + map.put(key ,value); + } + + public void add_class(Class class_metadata){ + try{ + add_methods_public(class_metadata); + add_methods_private(class_metadata); + add_constructors(class_metadata); + }catch(Throwable t){ + System.out.println("MethodSignature_To_Handle_Map::add_class exception:"); + t.printStackTrace(); + } + } + + public void add_methods_public(Class class_metadata){ + MethodHandles.Lookup lookup = MethodHandles.lookup(); + + for( Method method : class_metadata.getDeclaredMethods() ){ + try{ + if((method.getModifiers() & Modifier.PRIVATE) == 0){ // Skip private methods + Class[] parameter_type_list = method.getParameterTypes(); + MethodType method_type = MethodType.methodType(method.getReturnType() ,parameter_type_list); + MethodHandle method_handle = lookup.findVirtual(class_metadata ,method.getName() ,method_type); + + MethodSignature signature = new MethodSignature + ( + method.getReturnType() + ,class_metadata.getName() + ,method.getName() + ,parameter_type_list + ); + add_entry(signature ,method_handle); + } + }catch(NoSuchMethodException e){ + System.err.println("Skipping public/protected method: " + method); + e.printStackTrace(); + }catch(Throwable t){ + t.printStackTrace(); + } + } + } + + public void add_methods_private(Class class_metadata) throws IllegalAccessException{ + MethodHandles.Lookup lookup = MethodHandles.lookup(); + MethodHandles.Lookup private_lookup = MethodHandles.privateLookupIn(class_metadata ,lookup); + + for(Method method : class_metadata.getDeclaredMethods()){ + try{ + if((method.getModifiers() & Modifier.PRIVATE) != 0){ // Only private methods + Class[] parameter_type_list = method.getParameterTypes(); + MethodType method_type = MethodType.methodType(method.getReturnType() ,parameter_type_list); + MethodHandle method_handle = private_lookup.findSpecial( + class_metadata ,method.getName() ,method_type ,class_metadata + ); + + MethodSignature signature = new MethodSignature + ( + method.getReturnType() + ,class_metadata.getName() + ,method.getName() + ,parameter_type_list + ); + add_entry(signature ,method_handle); + } + }catch(NoSuchMethodException e){ + System.err.println("Skipping private method: " + method); + }catch(Throwable t){ + t.printStackTrace(); + } + } + } + + public void add_constructors(Class class_metadata) throws IllegalAccessException{ + MethodHandles.Lookup lookup = MethodHandles.lookup(); + MethodHandles.Lookup private_lookup = MethodHandles.privateLookupIn(class_metadata ,lookup); + + for( Constructor constructor : class_metadata.getDeclaredConstructors() ){ + try{ + Class[] parameter_type_list = constructor.getParameterTypes(); + MethodType method_type = MethodType.methodType(void.class, parameter_type_list); + MethodHandle constructor_handle = private_lookup.findConstructor(class_metadata ,method_type); + + // Signature for constructors: with parameter types + MethodSignature signature = new MethodSignature + ( + void.class + ,class_metadata.getName() + ,"" + ,parameter_type_list + ); + add_entry(signature ,constructor_handle); + + }catch(NoSuchMethodException e){ + System.err.println("Skipping constructor: " + constructor); + }catch(Throwable t){ + t.printStackTrace(); + } + } + } + + // methods for looking up handles + // + public MethodHandle lookup(MethodSignature s){ + return map.get(s); + } + + // standard interface + // + @Override + public String toString(){ + StringBuilder sb = new StringBuilder(); + sb.append("MethodSignature_To_Handle_Map: {").append(System.lineSeparator()); + + for (Map.Entry entry : map.entrySet()){ + sb.append(" ") + .append(entry.getKey().toString()) // MethodSignature's toString + .append(" -> ") + .append(entry.getValue().toString()) // MethodHandle's toString + .append(System.lineSeparator()); + } + + sb.append("}"); + return sb.toString(); + } + +} + +/*-------------------------------------------------------------------------------- + Given a class, dispatches calls to methods. + +*/ +public class Mosaic_Dispatcher{ + private MethodSignature_To_Handle_Map map; + private Class target; + + // test facilities + // + private boolean test = false; + public void test_switch(boolean test){ + if(this.test && !test){ + test_print("Mosaic_Dispatcher:: test messages off"); + this.test = test; + } + if(!this.test && test){ + this.test = test; + test_print("Mosaic_Dispatcher:: test messages on"); + map.test_switch(true); + } + } + private void test_print(String message){ + if(test){ + System.out.println("Mosaic_Dispatcher::" + message); + } + } + + // field access and strings + // + public Class get_target(){ + return target; + } + + public MethodSignature_To_Handle_Map get_map(){ + return map; + } + + public String to_string_target(){ + return target != null ? target.getName() : "null"; + } + + // constructors + // + + // construct given the class metadata for the target class + public Mosaic_Dispatcher(Class target){ + this.map = new MethodSignature_To_Handle_Map(); + test_switch(true); + this.target = target; + test_print("Mosaic_Dispatcher:: mapping class from metadata:" + to_string_target()); + this.map.add_class(target); + } + + // Constructor accepting a fully qualified class name of the target class + public Mosaic_Dispatcher(String fully_qualified_class_name) throws ClassNotFoundException{ + this.map = new MethodSignature_To_Handle_Map(); + test_switch(true); + try{ + this.target = Class.forName(fully_qualified_class_name); + test_print("Mosaic_Dispatcher:: mapping class from name string:" + to_string_target()); + this.map.add_class(target); + }catch(ClassNotFoundException e){ + throw new ClassNotFoundException("Class not found: " + fully_qualified_class_name ,e); + } + } + + // methods unique to the class + // + + // Factory method to create an instance (dispatch a constructor) + public Object make(Object... arg_list){ + return dispatch_1 + ( + null // there is no instance passed in when calling a constructor + ,void.class // constructor has void return type + ,"" // all contructors in Javaland are called `` + ,arg_list + ); + } + + @SuppressWarnings("unchecked") + public T dispatch + ( + Object instance + ,Class return_type + ,String method_name + ,Object... arg_list + ){ + 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()) + ); + } + + Object result = dispatch_1( + instance + ,return_type + ,method_name + ,arg_list + ); + + // Handle primitive return types explicitly + if(return_type.isPrimitive()){ + if(return_type == boolean.class) return (T) (Boolean) result; + if(return_type == int.class) return (T) (Integer) result; + if(return_type == double.class) return (T) (Double) result; + if(return_type == float.class) return (T) (Float) result; + if(return_type == long.class) return (T) (Long) result; + if(return_type == short.class) return (T) (Short) result; + if(return_type == byte.class) return (T) (Byte) result; + if(return_type == char.class) return (T) (Character) result; + } + + // For non-primitives, cast normally + return return_type.cast(result); + } + + + /* + public T dispatch + ( + Object instance + ,Class return_type + ,String method_name + ,Object... arg_list + ){ + + 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()) + ); + } + + return return_type.cast(dispatch_1( + instance + ,return_type + ,method_name + ,arg_list + )); + } + */ + + private Object dispatch_1( + Object instance + ,Class return_type + ,String method_name + ,Object... arg_list + ){ + try{ + // Resolve method/constructor signature + MethodSignature signature = new MethodSignature( + return_type + ,to_string_target() + ,method_name + ,arg_list + ); + test_print("dispatch_1:: signature is:" + signature.toString()); + + MethodHandle handle = map.lookup(signature); + + if(handle == null){ + throw new NoSuchMethodException("No method or constructor found for signature: " + signature.toString()); + } + + // Unwrap Mosaic_IsPrimitive arguments + Object[] unwrapped_arg_list = new Object[arg_list.length]; + for(int i = 0; i < arg_list.length; i++){ + if (arg_list[i] instanceof Mosaic_IsPrimitive){ + unwrapped_arg_list[i] = ((Mosaic_IsPrimitive) arg_list[i]).get_value(); + } else { + unwrapped_arg_list[i] = arg_list[i]; + } + } + + // Handle constructor vs method + if("".equals(method_name)){ + return handle.invokeWithArguments(unwrapped_arg_list); // Constructor: no binding needed + }else{ + return handle.bindTo(instance).invokeWithArguments(unwrapped_arg_list); // Method: bind instance + } + + }catch(Throwable t){ + System.out.println("Mosaic_Dispatcher::dispatch exception:"); + t.printStackTrace(); + return null; + } + } + + // standard interface + // + @Override + public String toString(){ + return + "Mosaic_Dispatcher {" + + "target=" + + to_string_target() + + " ,map=" + + map.toString() + + "}" + ; + } + +} diff --git "a/developer/javac\360\237\226\211/Mosaic_TestClasses.java" "b/developer/javac\360\237\226\211/Mosaic_TestClasses.java" deleted file mode 100644 index fc56ebb..0000000 --- "a/developer/javac\360\237\226\211/Mosaic_TestClasses.java" +++ /dev/null @@ -1,50 +0,0 @@ -package com.ReasoningTechnology.Mosaic; - -/* - These are used for testing that Mosaic can be used for white box - testing. Mosaic tests for Mosaic itself access each of these as - part of regression. Users are welcome to also check accessing these - when debugging any access problems that might arise. -*/ - -// Public class with public and private methods -public class Mosaic_TestClasses { - public boolean publicMethod() { - return true; - } - - private boolean privateMethod() { - return true; - } - - public class PublicClass { - public boolean publicMethod() { - return true; - } - - private boolean privateMethod() { - return true; - } - } - - private class PrivateClass { - public boolean publicMethod() { - return true; - } - - private boolean privateMethod() { - return true; - } - } -} - -// Default (package-private) class with public and private methods -class DefaultClass { - public boolean publicMethod() { - return true; - } - - private boolean privateMethod() { - return true; - } -} diff --git "a/developer/javac\360\237\226\211/Mosaic_TestClasses_0.java" "b/developer/javac\360\237\226\211/Mosaic_TestClasses_0.java" new file mode 100644 index 0000000..7c09e36 --- /dev/null +++ "b/developer/javac\360\237\226\211/Mosaic_TestClasses_0.java" @@ -0,0 +1,50 @@ +package com.ReasoningTechnology.Mosaic; + +/* + These are used for testing that Mosaic can be used for white box + testing. Mosaic tests for Mosaic itself access each of these as + part of regression. Users are welcome to also check accessing these + when debugging any access problems that might arise. +*/ + +// Public class with public and private methods +public class Mosaic_TestClasses_0 { + public boolean a_public_method_1() { + return true; + } + + private boolean a_private_method_2() { + return true; + } + + public class PublicClass { + public boolean a_public_method_3() { + return true; + } + + private boolean a_private_method_4() { + return true; + } + } + + private class PrivateClass { + public boolean a_public_method_5() { + return true; + } + + private boolean a_private_method_6() { + return true; + } + } +} + +// Default (package-private) class with public and private methods +class DefaultClass { + public boolean a_public_method_7() { + return true; + } + + private boolean a_private_method_8() { + return true; + } +} diff --git "a/developer/javac\360\237\226\211/Mosaic_TestClasses_1.java" "b/developer/javac\360\237\226\211/Mosaic_TestClasses_1.java" new file mode 100644 index 0000000..7c3f2db --- /dev/null +++ "b/developer/javac\360\237\226\211/Mosaic_TestClasses_1.java" @@ -0,0 +1,31 @@ +package com.ReasoningTechnology.Mosaic; + +/* + These are used for testing that Mosaic can be used for white box + testing. Mosaic tests for Mosaic itself access each of these as + part of regression. Users are welcome to also check accessing these + when debugging any access problems that might arise. +*/ + +// Public class with public and private methods +public class Mosaic_TestClasses_1 { + + private int i; + + public Mosaic_TestClasses_1(){ + i = 0; + } + + public Mosaic_TestClasses_1(int a){ + i = a; + } + + public Mosaic_TestClasses_1(int a ,int b){ + i = a + b; + } + + public int get_i() { + return i; + } + +} diff --git "a/document\360\237\226\211/example_proxy.java" "b/document\360\237\226\211/example_proxy.java" new file mode 100644 index 0000000..7c7d0ad --- /dev/null +++ "b/document\360\237\226\211/example_proxy.java" @@ -0,0 +1,26 @@ +// 1. + +Mosaic_AllMethodsPublicProxy proxy = new Mosaic_AllMethodsPublicProxy(SomeClass.class); + +String methodName = "compute"; +Class returnType = int.class; +Object[] args = {42, 15}; + +Object result = proxy.invoke(someInstance, methodName, returnType, args); +System.out.println(result); + + +// 2. + +Method method = SomeClass.class.getDeclaredMethod("compute", int.class, int.class); +FunctionSignature sigFromReflection = new FunctionSignature(method); + +FunctionSignature sigFromInvocation = new FunctionSignature( + "com.example.SomeClass", + "compute", + int.class, + new Object[]{42, 15} +); + +System.out.println(sigFromReflection.equals(sigFromInvocation)); // Should be true + diff --git a/env_run b/env_run deleted file mode 100644 index 262bf14..0000000 --- a/env_run +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash - -# Centralized environment executor. Typically used by IDEs to run developer/tool -# or tester/tool commands in the correct environment. Shell users are encouraged -# to source the appropriate environment file into their shell instead of -# running commands through this executor. - -if [ "$#" -lt 2 ]; then - echo "Usage: $0 [args...]" - echo "Example: $0 developer make" - exit 1 -fi - -# extract the environment and the command -environment=$1 -shift -command=$1 -shift -command_args="$@" - -# Determine the path to the environment script based on the environment -case "$environment" in - developer) - env_script="env_developer" - ;; - tester) - env_script="env_tester" - ;; - *) - echo "Error: Unknown environment '$environment'. Supported environments are: developer, tester." - exit 1 - ;; -esac - -# check if the environment script exists and is readable -if [ ! -f "$env_script" ] || [ ! -r "$env_script" ]; then - echo "Error: Environment script '$env_script' not found or not readable." - exit 1 -fi - -source "$env_script" -exec "$command" "$command_args" diff --git a/release/Mosaic.jar b/release/Mosaic.jar index bd7cf76..d1937e2 100644 Binary files a/release/Mosaic.jar and b/release/Mosaic.jar differ diff --git "a/tester/document\360\237\226\211/notes.txt" "b/tester/document\360\237\226\211/notes.txt" new file mode 100644 index 0000000..330d289 --- /dev/null +++ "b/tester/document\360\237\226\211/notes.txt" @@ -0,0 +1,16 @@ + +(setq gud-jdb-use-separate-io-buffer t) + +(defun jdbx () + "Run jdb with a separate input/output buffer." + (interactive) + (let ((sourcepath (getenv "SOURCEPATH")) + (class-name (read-string "Enter class to debug: " "Test_Util"))) + ;; Create a separate buffer for I/O + (let ((io-buffer (get-buffer-create "*gud-jdb-io*"))) + (with-current-buffer io-buffer + (comint-mode)) + ;; Run jdb + (jdb (concat "jdb " (if sourcepath (concat "-sourcepath " sourcepath " ") "") class-name))) + ;; Switch to the I/O buffer + (pop-to-buffer "*gud-jdb-io*"))) diff --git a/tester/idea/0 b/tester/idea/0 new file mode 100755 index 0000000..51b4923 --- /dev/null +++ b/tester/idea/0 @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 0 diff --git a/tester/idea/Access_0 b/tester/idea/Access_0 new file mode 100755 index 0000000..f25e6f8 --- /dev/null +++ b/tester/idea/Access_0 @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 Access_0 diff --git a/tester/idea/IO b/tester/idea/IO new file mode 100755 index 0000000..235da3f --- /dev/null +++ b/tester/idea/IO @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 IO diff --git a/tester/idea/IsPrimitive b/tester/idea/IsPrimitive new file mode 100755 index 0000000..f835393 --- /dev/null +++ b/tester/idea/IsPrimitive @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 IsPrimitive diff --git a/tester/idea/Logger b/tester/idea/Logger new file mode 100755 index 0000000..f127e85 --- /dev/null +++ b/tester/idea/Logger @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 Logger diff --git a/tester/idea/MockClass_0 b/tester/idea/MockClass_0 new file mode 100755 index 0000000..b047e64 --- /dev/null +++ b/tester/idea/MockClass_0 @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 MockClass_0 diff --git a/tester/idea/Test0 b/tester/idea/Test0 new file mode 100755 index 0000000..b0355f5 --- /dev/null +++ b/tester/idea/Test0 @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 Test0 diff --git a/tester/idea/Test_Access_0 b/tester/idea/Test_Access_0 new file mode 100755 index 0000000..cea74ff --- /dev/null +++ b/tester/idea/Test_Access_0 @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 Test_Access_0 diff --git a/tester/idea/Test_IO b/tester/idea/Test_IO new file mode 100755 index 0000000..c1872c0 --- /dev/null +++ b/tester/idea/Test_IO @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 Test_IO diff --git a/tester/idea/Test_IsPrimitive b/tester/idea/Test_IsPrimitive new file mode 100755 index 0000000..f0342ce --- /dev/null +++ b/tester/idea/Test_IsPrimitive @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 Test_IsPrimitive diff --git a/tester/idea/Test_Logger b/tester/idea/Test_Logger new file mode 100755 index 0000000..89ada20 --- /dev/null +++ b/tester/idea/Test_Logger @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 Test_Logger diff --git a/tester/idea/Test_MockClass_0 b/tester/idea/Test_MockClass_0 new file mode 100755 index 0000000..854787e --- /dev/null +++ b/tester/idea/Test_MockClass_0 @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 Test_MockClass_0 diff --git a/tester/idea/Test_Testbench b/tester/idea/Test_Testbench new file mode 100755 index 0000000..dac80be --- /dev/null +++ b/tester/idea/Test_Testbench @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 Test_Testbench diff --git a/tester/idea/Test_Util b/tester/idea/Test_Util new file mode 100755 index 0000000..345f1af --- /dev/null +++ b/tester/idea/Test_Util @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 Test_Util diff --git a/tester/idea/Testbench b/tester/idea/Testbench new file mode 100755 index 0000000..e1fed4e --- /dev/null +++ b/tester/idea/Testbench @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 Testbench diff --git a/tester/idea/Util b/tester/idea/Util new file mode 100755 index 0000000..bc24d32 --- /dev/null +++ b/tester/idea/Util @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 Util diff --git a/tester/idea/smoke b/tester/idea/smoke new file mode 100755 index 0000000..c7aa8e4 --- /dev/null +++ b/tester/idea/smoke @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 smoke diff --git "a/tester/javac\360\237\226\211/Access_0.java" "b/tester/javac\360\237\226\211/Access_0.java" new file mode 100644 index 0000000..fe3dd69 --- /dev/null +++ "b/tester/javac\360\237\226\211/Access_0.java" @@ -0,0 +1,94 @@ +import com.ReasoningTechnology.Mosaic.Mosaic_Dispatcher; +import com.ReasoningTechnology.Mosaic.Mosaic_IsPrimitive; +import com.ReasoningTechnology.Mosaic.Mosaic_TestClasses_0; +import com.ReasoningTechnology.Mosaic.Mosaic_TestClasses_1; +import com.ReasoningTechnology.Mosaic.Mosaic_Util; + +public class Access_0{ + + private static Mosaic_Dispatcher dispatcher; + + static{ + // Initialize the dispatcher for Mosaic_TestClasses_0 + dispatcher = new Mosaic_Dispatcher(Mosaic_TestClasses_0.class); + dispatcher.test_switch(true); // Enable test messages for debugging + } + + // Test method to access the public method of the public class + public static boolean test_publicClass_publicMethod(){ + System.out.println("\nRunning test: test_publicClass_publicMethod"); + + Object instance = new Mosaic_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(){ + System.out.println("\nRunning test: 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(Mosaic_TestClasses_1.class); + + Mosaic_TestClasses_1 tc0 = new Mosaic_TestClasses_1(); + condition_list[i++] = tc0.get_i() == 0; + + Mosaic_TestClasses_1 tc1 = (Mosaic_TestClasses_1) d1.make(); + condition_list[i++] = tc1.get_i() == 0; + + Mosaic_TestClasses_1 tc2 = (Mosaic_TestClasses_1) d1.make(new Mosaic_IsPrimitive(7)); + condition_list[i++] = tc2.get_i() == 7; + + Mosaic_TestClasses_1 tc3 = (Mosaic_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); + } + + // Run method to execute all tests + public static boolean run(){ + try{ + + // Run the individual test(s) + boolean result = true; + if( !test_publicClass_publicMethod() ){ + System.out.println("test_publicClass_publicMethod failed"); + result = false; + }else{ + System.out.println("test_publicClass_publicMethod passed"); + } + if( !test_make_0() ){ + System.out.println("test_make_0() failed"); + result = false; + }else{ + System.out.println("test_make_0() passed"); + } + + return result; + + }catch(Exception e){ + System.out.println("Exception in test Accept_0"); + e.printStackTrace(); + return false; + } + + } + + public static void main(String[] args){ + // Execute the run method and return its result as the exit code + if( run() ) + System.exit(0); + else + System.exit(1); + } + +} diff --git "a/tester/javac\360\237\226\211/AllMethodsPublicProxy_0.java" "b/tester/javac\360\237\226\211/AllMethodsPublicProxy_0.java" new file mode 100644 index 0000000..2b76f4b --- /dev/null +++ "b/tester/javac\360\237\226\211/AllMethodsPublicProxy_0.java" @@ -0,0 +1,98 @@ +import com.ReasoningTechnology.Mosaic.Mosaic_AllMethodsPublicProxy; +import com.ReasoningTechnology.Mosaic.Mosaic_IO; +import com.ReasoningTechnology.Mosaic.Mosaic_Testbench; +import com.ReasoningTechnology.Mosaic.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/FunctionSignature_0.java" "b/tester/javac\360\237\226\211/FunctionSignature_0.java" new file mode 100644 index 0000000..d45e2cc --- /dev/null +++ "b/tester/javac\360\237\226\211/FunctionSignature_0.java" @@ -0,0 +1,42 @@ +import com.ReasoningTechnology.Mosaic.Mosaic_AllMethodsPublicProxy; +import com.ReasoningTechnology.Mosaic.Mosaic_IO; +import com.ReasoningTechnology.Mosaic.Mosaic_Testbench; + +public class FunctionSignature_0 { + + public static class TestSuite { + + private static Mosaic_AllMethodsPublicProxy proxy; + + static { + try { + proxy = new Mosaic_AllMethodsPublicProxy("com.ReasoningTechnology.Mosaic.FunctionSignature"); + } catch (ClassNotFoundException e) { + System.err.println("Failed to initialize proxy: " + e.getMessage()); + } + } + + public Boolean smoke_test_0(Mosaic_IO io) { + try { + // Create a FunctionSignature instance via the proxy constructor + Object signature = proxy.construct("", "testMethod", new Class[]{}); + + // Call the toString method on the proxy instance + String result = (String) proxy.invoke(signature, "toString"); + + // Check expected output + return "testMethod()".equals(result); + } 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/IO.java" "b/tester/javac\360\237\226\211/IO.java" new file mode 100644 index 0000000..18e8a8f --- /dev/null +++ "b/tester/javac\360\237\226\211/IO.java" @@ -0,0 +1,73 @@ +import com.ReasoningTechnology.Mosaic.Mosaic_IO; +import com.ReasoningTechnology.Mosaic.Mosaic_Util; + +public class IO{ + + public static int fut(){ + try{ + // Echo some characters from stdin to stdout + System.out.print((char) System.in.read()); + System.out.print((char) System.in.read()); + + // Echo some more characters from stdin to stderr + System.err.print((char) System.in.read()); + System.err.print((char) System.in.read()); + + // Count remaining characters until EOF + int count = 0; + while(System.in.read() != -1){ + count++; + } + + return count; + } catch(Exception e){ + e.printStackTrace(); + return -1; // Error case + } + } + + public static int run(){ + Mosaic_IO io = new Mosaic_IO(); + Boolean[] condition = new Boolean[3]; + + // Redirect IO streams + io.redirect(); + + // Provide input for the function under test + io.push_input("abcdefg"); + + // Execute function under test + int result = fut(); + + // Check stdout content + String stdout_string = io.get_out_content(); + condition[0] = stdout_string.equals("ab"); + + // Check stderr content + String stderr_string = io.get_err_content(); + condition[1] = stderr_string.equals("cd"); + + // Check returned character count (3 remaining characters: 'e','f','g') + condition[2] = result == 3; + + // Restore original IO streams + io.restore(); + + if(!Mosaic_Util.all(condition)){ + System.out.println("IO failed"); + return 1; + } + System.out.println("IO passed"); + return 0; + } + + // Main function to provide a shell interface for running tests + public static void main(String[] args){ + int return_code = run(); + System.exit(return_code); + return; + } + +} + + diff --git "a/tester/javac\360\237\226\211/IsPrimitive.java" "b/tester/javac\360\237\226\211/IsPrimitive.java" new file mode 100644 index 0000000..9b6aa2d --- /dev/null +++ "b/tester/javac\360\237\226\211/IsPrimitive.java" @@ -0,0 +1,118 @@ +/* -------------------------------------------------------------------------------- + Integration tests directly simulate the use cases for Mosaic_Testbench. + Each test method validates a specific feature of Mosaic_Testbench ,including pass, + fail ,error handling ,and I/O interactions. +*/ +import java.util.Scanner; + +import com.ReasoningTechnology.Mosaic.Mosaic_IO; +import com.ReasoningTechnology.Mosaic.Mosaic_IsPrimitive; +import com.ReasoningTechnology.Mosaic.Mosaic_Testbench; + +import com.ReasoningTechnology.Mosaic.Mosaic_IO; +import com.ReasoningTechnology.Mosaic.Mosaic_Testbench; +import com.ReasoningTechnology.Mosaic.Mosaic_IsPrimitive; + +public class IsPrimitive{ + + public class TestSuite{ + + + public Boolean test_int_type(Mosaic_IO io){ + Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(42); + return mip.get_type().equals(int.class); + } + + public Boolean test_boolean_type(Mosaic_IO io){ + Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(true); + return mip.get_type().equals(boolean.class); + } + + public Boolean test_double_type(Mosaic_IO io){ + Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(3.14); + return mip.get_type().equals(double.class); + } + + public Boolean test_string_type(Mosaic_IO io){ + Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make("hello"); + return mip.get_type().equals(String.class); + } + + public Boolean test_object_type(Mosaic_IO io){ + Object obj = new Object(); + Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(obj); + return mip.get_type().equals(Object.class); + } + + public Boolean test_char_type(Mosaic_IO io){ + Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make('a'); + return mip.get_type().equals(char.class); + } + + public Boolean test_null_value(Mosaic_IO io){ + try{ + Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(null); + return mip.get_type() == null; // Should handle gracefully or throw + } catch (Exception e){ + return false; + } + } + + public Boolean test_empty_string(Mosaic_IO io){ + Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(""); + return mip.get_type().equals(String.class); + } + + public Boolean test_blank_string(Mosaic_IO io){ + Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(" "); + return mip.get_type().equals(String.class); + } + + // When passing arguments through Object types, there is no way + // for the callee to know if the caller sent a primitive type or a + // boxed value. This is the point of having IsPrimitive. + // IsPrimitive indicates that we really mean to send the primitive + // type, though it appears in the box. + public Boolean test_primitive_wrapper(Mosaic_IO io){ + Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(Integer.valueOf(42)); + return mip.get_type().equals(int.class); + } + + public Boolean test_primitive_array(Mosaic_IO io){ + Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(new int[]{1, 2, 3}); + return mip.get_type().equals(int[].class); + } + + public Boolean test_object_array(Mosaic_IO io){ + Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(new String[]{"a", "b", "c"}); + return mip.get_type().equals(String[].class); + } + + public Boolean test_enum_type(Mosaic_IO io){ + enum TestEnum{ VALUE1, VALUE2 } + Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(TestEnum.VALUE1); + return mip.get_type().equals(TestEnum.class); + } + + public Boolean test_collection_type(Mosaic_IO io){ + java.util.List list = java.util.Arrays.asList(1, 2, 3); + Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(list); + return mip.get_type().getName().equals("java.util.Arrays$ArrayList"); + } + + public Boolean test_extreme_primitive_values(Mosaic_IO io){ + Mosaic_IsPrimitive mipMax = Mosaic_IsPrimitive.make(Integer.MAX_VALUE); + Mosaic_IsPrimitive mipMin = Mosaic_IsPrimitive.make(Integer.MIN_VALUE); + Mosaic_IsPrimitive mipNaN = Mosaic_IsPrimitive.make(Double.NaN); + return mipMax.get_type().equals(int.class) + && mipMin.get_type().equals(int.class) + && mipNaN.get_type().equals(double.class); + } + } + + public static void main(String[] args){ + TestSuite suite = new IsPrimitive().new TestSuite(); + int result = Mosaic_Testbench.run(suite); + System.exit(result); + } +} diff --git "a/tester/javac\360\237\226\211/Logger.java" "b/tester/javac\360\237\226\211/Logger.java" new file mode 100644 index 0000000..c4eb84f --- /dev/null +++ "b/tester/javac\360\237\226\211/Logger.java" @@ -0,0 +1,31 @@ +import com.ReasoningTechnology.Mosaic.Mosaic_IO; +import com.ReasoningTechnology.Mosaic.Mosaic_Logger; + +public class Logger{ + + public class TestSuite{ + public Boolean smoke_test_logging(Mosaic_IO io){ + try{ + Mosaic_Logger logger = new Mosaic_Logger(); + logger.message("smoke_test_logging", "This is a smoke test for logging."); + return true; + }catch (Exception e){ + e.printStackTrace(); + return false; + } + } + } + + public static void main(String[] args){ + TestSuite suite = new Logger().new TestSuite(); + boolean result = suite.smoke_test_logging(null); + + if(result){ + System.out.println("Test passed: 'smoke_test_logging'"); + System.exit(0); + }else{ + System.err.println("Test failed: 'smoke_test_logging'"); + System.exit(1); + } + } +} diff --git "a/tester/javac\360\237\226\211/MockClass_0.java" "b/tester/javac\360\237\226\211/MockClass_0.java" new file mode 100644 index 0000000..923661c --- /dev/null +++ "b/tester/javac\360\237\226\211/MockClass_0.java" @@ -0,0 +1,98 @@ +/* -------------------------------------------------------------------------------- + Integration tests directly simulate the use cases for Mosaic_Testbench. + Each test method validates a specific feature of Mosaic_Testbench ,including pass, + fail ,error handling ,and I/O interactions. +*/ + +import java.util.Scanner; +import com.ReasoningTechnology.Mosaic.Mosaic_IO; +import com.ReasoningTechnology.Mosaic.Mosaic_Testbench; + +public class MockClass_0{ + + public class TestSuite{ + + public TestSuite() { + // no special initialization of data for this test + } + + public Boolean test_failure_0(Mosaic_IO io){ + return false; + } + + // returns a non-Boolean + public Object test_failure_1(Mosaic_IO io){ + return 1; + } + + // has an uncaught error + public Boolean test_failure_2(Mosaic_IO io) throws Exception { + throw new Exception("Intentional exception for testing error handling"); + } + + // extraneous characters on stdout + public Boolean test_failure_3(Mosaic_IO io) throws Exception { + System.out.println("Intentional extraneous chars to stdout for testing"); + return true; + } + + // extraneous characters on stderr + public Boolean test_failure_4(Mosaic_IO io) throws Exception { + System.err.println("Intentional extraneous chars to stderr for testing."); + return true; + } + + public Boolean test_success_0(Mosaic_IO io){ + return true; + } + + // pushing input for testing + + public Boolean test_success_1(Mosaic_IO io){ + io.push_input("input for the fut"); + + Scanner scanner = new Scanner(System.in); + String result = scanner.nextLine(); + scanner.close(); + + Boolean flag = result.equals("input for the fut"); + return flag; + } + + // checking fut stdout + public Boolean test_success_2(Mosaic_IO io){ + System.out.println("fut stdout"); // suppose the fut does this: + String peek_at_futs_output = io.get_out_content(); + Boolean flag0 = io.has_out_content(); + Boolean flag1 = peek_at_futs_output.equals("fut stdout\n"); + io.clear_buffers(); // otherwise extraneous chars will cause an fail + return flag0 && flag1; + } + + // checking fut stderr + public Boolean test_success_3(Mosaic_IO io){ + System.err.print("fut stderr"); // suppose the fut does this: + String peek_at_futs_output = io.get_err_content(); + Boolean flag0 = io.has_err_content(); + Boolean flag1 = peek_at_futs_output.equals("fut stderr"); + io.clear_buffers(); // otherwise extraneous chars will cause an fail + return flag0 && flag1; + } + + } + + public static void main(String[] args) { + MockClass_0 outer = new MockClass_0(); + TestSuite suite = outer.new TestSuite(); // Non-static instantiation + + /* for debug + Mosaic_IO io = new Mosaic_IO(); + io.redirect(); + suite.test_success_2(io); + */ + + int result = Mosaic_Testbench.run(suite); // Pass the suite instance to Mosaic_Testbench + System.exit(result); + } + +} diff --git "a/tester/javac\360\237\226\211/Test_0.java" "b/tester/javac\360\237\226\211/Test_0.java" deleted file mode 100644 index c4abc4a..0000000 --- "a/tester/javac\360\237\226\211/Test_0.java" +++ /dev/null @@ -1,36 +0,0 @@ -import com.ReasoningTechnology.Mosaic.Mosaic_Util; - -/* -Test Zero - -Plug it in, see if there is smoke. There usually is. - -*/ - -public class Test0{ - - public static Boolean test_is_true(){ - return true; - } - - public static int run(){ - Boolean[] condition = new Boolean[1]; - condition[0] = test_is_true(); - - int i = 0; - if( !Mosaic_Util.all(condition) ){ - System.out.println("Test0 failed"); - return 1; - } - System.out.println("Test0 passed"); - return 0; - } - - // Main function to provide a shell interface for running tests - public static void main(String[] args){ - int return_code = run(); - System.exit(return_code); - return; - } - -} diff --git "a/tester/javac\360\237\226\211/Test_Access_0.java" "b/tester/javac\360\237\226\211/Test_Access_0.java" deleted file mode 100644 index 7831f8e..0000000 --- "a/tester/javac\360\237\226\211/Test_Access_0.java" +++ /dev/null @@ -1,67 +0,0 @@ -import com.ReasoningTechnology.Mosaic.Mosaic_AllMethodsPublicProxy; -import com.ReasoningTechnology.Mosaic.Mosaic_IO; -import com.ReasoningTechnology.Mosaic.Mosaic_Testbench; -import com.ReasoningTechnology.Mosaic.Mosaic_TestClasses; - -public class Test_Access_0{ - - public static class TestSuite{ - - private static Mosaic_AllMethodsPublicProxy publicProxy; - // private static Mosaic_AllMethodsPublicProxy nestedPublicProxy; - // private static Mosaic_AllMethodsPublicProxy nestedPrivateProxy; - // private static Mosaic_AllMethodsPublicProxy topPrivateProxy; - - static{ - // Initialize proxies using class metadata and path strings - publicProxy = new Mosaic_AllMethodsPublicProxy(Mosaic_TestClasses.class); - // nestedPublicProxy = new Mosaic_AllMethodsPublicProxy("com.ReasoningTechnology.Mosaic.Mosaic_TestClasses$PublicClass"); - // nestedPrivateProxy = new Mosaic_AllMethodsPublicProxy("com.ReasoningTechnology.Mosaic.Mosaic_TestClasses$PrivateClass"); - // topPrivateProxy = new Mosaic_AllMethodsPublicProxy("com.ReasoningTechnology.Mosaic.PrivateClass"); - } - - public Boolean test_publicClass_publicMethod(Mosaic_IO io){ - Object instance = publicProxy.construct(""); - return true; - // return(Boolean) publicProxy.invoke(instance, "publicMethod"); - } - - /* - - public Boolean test_publicClass_privateMethod(Mosaic_IO io){ - Object instance = publicProxy.construct(""); - return(Boolean) publicProxy.invoke(instance, "privateMethod"); - } - - public Boolean test_nestedPublicClass_publicMethod(Mosaic_IO io){ - Object outerInstance = publicProxy.construct(""); - Object instance = nestedPublicProxy.construct("", outerInstance); - return(Boolean) nestedPublicProxy.invoke(instance, "publicMethod"); - } - - public Boolean test_nestedPublicClass_privateMethod(Mosaic_IO io){ - Object outerInstance = publicProxy.construct(""); - Object instance = nestedPublicProxy.construct("", outerInstance); - return(Boolean) nestedPublicProxy.invoke(instance, "privateMethod"); - } - - public Boolean test_nestedPrivateClass_publicMethod(Mosaic_IO io){ - Object outerInstance = publicProxy.construct(""); - Object instance = nestedPrivateProxy.construct("", outerInstance); - return(Boolean) nestedPrivateProxy.invoke(instance, "publicMethod"); - } - - public Boolean test_nestedPrivateClass_privateMethod(Mosaic_IO io){ - Object outerInstance = publicProxy.construct(""); - Object instance = nestedPrivateProxy.construct("", outerInstance); - return(Boolean) nestedPrivateProxy.invoke(instance, "privateMethod"); - } - */ - } - - 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/Test_AllMethodsPublicProxy_0.java" "b/tester/javac\360\237\226\211/Test_AllMethodsPublicProxy_0.java" deleted file mode 100644 index 05b4759..0000000 --- "a/tester/javac\360\237\226\211/Test_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.Mosaic_TestClasses; - -public class Test_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/Test_FunctionSignature_0.java" "b/tester/javac\360\237\226\211/Test_FunctionSignature_0.java" deleted file mode 100644 index 5f26b70..0000000 --- "a/tester/javac\360\237\226\211/Test_FunctionSignature_0.java" +++ /dev/null @@ -1,42 +0,0 @@ -import com.ReasoningTechnology.Mosaic.Mosaic_AllMethodsPublicProxy; -import com.ReasoningTechnology.Mosaic.Mosaic_IO; -import com.ReasoningTechnology.Mosaic.Mosaic_Testbench; - -public class Test_FunctionSignature_0 { - - public static class TestSuite { - - private static Mosaic_AllMethodsPublicProxy proxy; - - static { - try { - proxy = new Mosaic_AllMethodsPublicProxy("com.ReasoningTechnology.Mosaic.FunctionSignature"); - } catch (ClassNotFoundException e) { - System.err.println("Failed to initialize proxy: " + e.getMessage()); - } - } - - public Boolean smoke_test_0(Mosaic_IO io) { - try { - // Create a FunctionSignature instance via the proxy constructor - Object signature = proxy.construct("", "testMethod", new Class[]{}); - - // Call the toString method on the proxy instance - String result = (String) proxy.invoke(signature, "toString"); - - // Check expected output - return "testMethod()".equals(result); - } 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/Test_IO.java" "b/tester/javac\360\237\226\211/Test_IO.java" deleted file mode 100644 index a7f8248..0000000 --- "a/tester/javac\360\237\226\211/Test_IO.java" +++ /dev/null @@ -1,73 +0,0 @@ -import com.ReasoningTechnology.Mosaic.Mosaic_IO; -import com.ReasoningTechnology.Mosaic.Mosaic_Util; - -public class Test_IO{ - - public static int fut(){ - try{ - // Echo some characters from stdin to stdout - System.out.print((char) System.in.read()); - System.out.print((char) System.in.read()); - - // Echo some more characters from stdin to stderr - System.err.print((char) System.in.read()); - System.err.print((char) System.in.read()); - - // Count remaining characters until EOF - int count = 0; - while(System.in.read() != -1){ - count++; - } - - return count; - } catch(Exception e){ - e.printStackTrace(); - return -1; // Error case - } - } - - public static int run(){ - Mosaic_IO io = new Mosaic_IO(); - Boolean[] condition = new Boolean[3]; - - // Redirect IO streams - io.redirect(); - - // Provide input for the function under test - io.push_input("abcdefg"); - - // Execute function under test - int result = fut(); - - // Check stdout content - String stdout_string = io.get_out_content(); - condition[0] = stdout_string.equals("ab"); - - // Check stderr content - String stderr_string = io.get_err_content(); - condition[1] = stderr_string.equals("cd"); - - // Check returned character count (3 remaining characters: 'e','f','g') - condition[2] = result == 3; - - // Restore original IO streams - io.restore(); - - if(!Mosaic_Util.all(condition)){ - System.out.println("Test_IO failed"); - return 1; - } - System.out.println("Test_IO passed"); - return 0; - } - - // Main function to provide a shell interface for running tests - public static void main(String[] args){ - int return_code = run(); - System.exit(return_code); - return; - } - -} - - diff --git "a/tester/javac\360\237\226\211/Test_IsPrimitive.java" "b/tester/javac\360\237\226\211/Test_IsPrimitive.java" deleted file mode 100644 index 33b9a0e..0000000 --- "a/tester/javac\360\237\226\211/Test_IsPrimitive.java" +++ /dev/null @@ -1,118 +0,0 @@ -/* -------------------------------------------------------------------------------- - Integration tests directly simulate the use cases for Mosaic_Testbench. - Each test method validates a specific feature of Mosaic_Testbench ,including pass, - fail ,error handling ,and I/O interactions. -*/ -import java.util.Scanner; - -import com.ReasoningTechnology.Mosaic.Mosaic_IO; -import com.ReasoningTechnology.Mosaic.Mosaic_IsPrimitive; -import com.ReasoningTechnology.Mosaic.Mosaic_Testbench; - -import com.ReasoningTechnology.Mosaic.Mosaic_IO; -import com.ReasoningTechnology.Mosaic.Mosaic_Testbench; -import com.ReasoningTechnology.Mosaic.Mosaic_IsPrimitive; - -public class Test_IsPrimitive{ - - public class TestSuite{ - - - public Boolean test_int_type(Mosaic_IO io){ - Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(42); - return mip.get_type().equals(int.class); - } - - public Boolean test_boolean_type(Mosaic_IO io){ - Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(true); - return mip.get_type().equals(boolean.class); - } - - public Boolean test_double_type(Mosaic_IO io){ - Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(3.14); - return mip.get_type().equals(double.class); - } - - public Boolean test_string_type(Mosaic_IO io){ - Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make("hello"); - return mip.get_type().equals(String.class); - } - - public Boolean test_object_type(Mosaic_IO io){ - Object obj = new Object(); - Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(obj); - return mip.get_type().equals(Object.class); - } - - public Boolean test_char_type(Mosaic_IO io){ - Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make('a'); - return mip.get_type().equals(char.class); - } - - public Boolean test_null_value(Mosaic_IO io){ - try{ - Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(null); - return mip.get_type() == null; // Should handle gracefully or throw - } catch (Exception e){ - return false; - } - } - - public Boolean test_empty_string(Mosaic_IO io){ - Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(""); - return mip.get_type().equals(String.class); - } - - public Boolean test_blank_string(Mosaic_IO io){ - Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(" "); - return mip.get_type().equals(String.class); - } - - // When passing arguments through Object types, there is no way - // for the callee to know if the caller sent a primitive type or a - // boxed value. This is the point of having IsPrimitive. - // IsPrimitive indicates that we really mean to send the primitive - // type, though it appears in the box. - public Boolean test_primitive_wrapper(Mosaic_IO io){ - Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(Integer.valueOf(42)); - return mip.get_type().equals(int.class); - } - - public Boolean test_primitive_array(Mosaic_IO io){ - Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(new int[]{1, 2, 3}); - return mip.get_type().equals(int[].class); - } - - public Boolean test_object_array(Mosaic_IO io){ - Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(new String[]{"a", "b", "c"}); - return mip.get_type().equals(String[].class); - } - - public Boolean test_enum_type(Mosaic_IO io){ - enum TestEnum{ VALUE1, VALUE2 } - Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(TestEnum.VALUE1); - return mip.get_type().equals(TestEnum.class); - } - - public Boolean test_collection_type(Mosaic_IO io){ - java.util.List list = java.util.Arrays.asList(1, 2, 3); - Mosaic_IsPrimitive mip = Mosaic_IsPrimitive.make(list); - return mip.get_type().getName().equals("java.util.Arrays$ArrayList"); - } - - public Boolean test_extreme_primitive_values(Mosaic_IO io){ - Mosaic_IsPrimitive mipMax = Mosaic_IsPrimitive.make(Integer.MAX_VALUE); - Mosaic_IsPrimitive mipMin = Mosaic_IsPrimitive.make(Integer.MIN_VALUE); - Mosaic_IsPrimitive mipNaN = Mosaic_IsPrimitive.make(Double.NaN); - return mipMax.get_type().equals(int.class) - && mipMin.get_type().equals(int.class) - && mipNaN.get_type().equals(double.class); - } - } - - public static void main(String[] args){ - TestSuite suite = new Test_IsPrimitive().new TestSuite(); - int result = Mosaic_Testbench.run(suite); - System.exit(result); - } -} diff --git "a/tester/javac\360\237\226\211/Test_Logger.java" "b/tester/javac\360\237\226\211/Test_Logger.java" deleted file mode 100644 index 7c8f6e0..0000000 --- "a/tester/javac\360\237\226\211/Test_Logger.java" +++ /dev/null @@ -1,31 +0,0 @@ -import com.ReasoningTechnology.Mosaic.Mosaic_IO; -import com.ReasoningTechnology.Mosaic.Mosaic_Logger; - -public class Test_Logger{ - - public class TestSuite{ - public Boolean smoke_test_logging(Mosaic_IO io){ - try{ - Mosaic_Logger logger = new Mosaic_Logger(); - logger.message("smoke_test_logging", "This is a smoke test for logging."); - return true; - }catch (Exception e){ - e.printStackTrace(); - return false; - } - } - } - - public static void main(String[] args){ - TestSuite suite = new Test_Logger().new TestSuite(); - boolean result = suite.smoke_test_logging(null); - - if(result){ - System.out.println("Test passed: 'smoke_test_logging'"); - System.exit(0); - }else{ - System.err.println("Test failed: 'smoke_test_logging'"); - System.exit(1); - } - } -} diff --git "a/tester/javac\360\237\226\211/Test_MockClass_0.java" "b/tester/javac\360\237\226\211/Test_MockClass_0.java" deleted file mode 100644 index 0f02a64..0000000 --- "a/tester/javac\360\237\226\211/Test_MockClass_0.java" +++ /dev/null @@ -1,98 +0,0 @@ -/* -------------------------------------------------------------------------------- - Integration tests directly simulate the use cases for Mosaic_Testbench. - Each test method validates a specific feature of Mosaic_Testbench ,including pass, - fail ,error handling ,and I/O interactions. -*/ - -import java.util.Scanner; -import com.ReasoningTechnology.Mosaic.Mosaic_IO; -import com.ReasoningTechnology.Mosaic.Mosaic_Testbench; - -public class Test_MockClass_0{ - - public class TestSuite{ - - public TestSuite() { - // no special initialization of data for this test - } - - public Boolean test_failure_0(Mosaic_IO io){ - return false; - } - - // returns a non-Boolean - public Object test_failure_1(Mosaic_IO io){ - return 1; - } - - // has an uncaught error - public Boolean test_failure_2(Mosaic_IO io) throws Exception { - throw new Exception("Intentional exception for testing error handling"); - } - - // extraneous characters on stdout - public Boolean test_failure_3(Mosaic_IO io) throws Exception { - System.out.println("Intentional extraneous chars to stdout for testing"); - return true; - } - - // extraneous characters on stderr - public Boolean test_failure_4(Mosaic_IO io) throws Exception { - System.err.println("Intentional extraneous chars to stderr for testing."); - return true; - } - - public Boolean test_success_0(Mosaic_IO io){ - return true; - } - - // pushing input for testing - - public Boolean test_success_1(Mosaic_IO io){ - io.push_input("input for the fut"); - - Scanner scanner = new Scanner(System.in); - String result = scanner.nextLine(); - scanner.close(); - - Boolean flag = result.equals("input for the fut"); - return flag; - } - - // checking fut stdout - public Boolean test_success_2(Mosaic_IO io){ - System.out.println("fut stdout"); // suppose the fut does this: - String peek_at_futs_output = io.get_out_content(); - Boolean flag0 = io.has_out_content(); - Boolean flag1 = peek_at_futs_output.equals("fut stdout\n"); - io.clear_buffers(); // otherwise extraneous chars will cause an fail - return flag0 && flag1; - } - - // checking fut stderr - public Boolean test_success_3(Mosaic_IO io){ - System.err.print("fut stderr"); // suppose the fut does this: - String peek_at_futs_output = io.get_err_content(); - Boolean flag0 = io.has_err_content(); - Boolean flag1 = peek_at_futs_output.equals("fut stderr"); - io.clear_buffers(); // otherwise extraneous chars will cause an fail - return flag0 && flag1; - } - - } - - public static void main(String[] args) { - Test_MockClass_0 outer = new Test_MockClass_0(); - TestSuite suite = outer.new TestSuite(); // Non-static instantiation - - /* for debug - Mosaic_IO io = new Mosaic_IO(); - io.redirect(); - suite.test_success_2(io); - */ - - int result = Mosaic_Testbench.run(suite); // Pass the suite instance to Mosaic_Testbench - System.exit(result); - } - -} diff --git "a/tester/javac\360\237\226\211/Test_Testbench.java" "b/tester/javac\360\237\226\211/Test_Testbench.java" deleted file mode 100644 index 56f9e21..0000000 --- "a/tester/javac\360\237\226\211/Test_Testbench.java" +++ /dev/null @@ -1,82 +0,0 @@ -import java.lang.reflect.Method; -import com.ReasoningTechnology.Mosaic.Mosaic_IO; -import com.ReasoningTechnology.Mosaic.Mosaic_Testbench; - -public class Test_Testbench { - - /* -------------------------------------------------------------------------------- - Test methods to validate Testbench functionality - Each method tests a specific aspect of the Testbench class, with a focus on - ensuring that well-formed and ill-formed test cases are correctly identified - and handled. - */ - - // Tests if a correctly formed method is recognized as well-formed by Testbench - public static Boolean test_method_is_wellformed_0(Mosaic_IO io) { - try { - Method validMethod = Test_Testbench.class.getMethod("dummy_test_method", Mosaic_IO.class); - return Boolean.TRUE.equals(Mosaic_Testbench.method_is_wellformed(validMethod)); - } catch (NoSuchMethodException e) { - return false; - } - } - - // Tests if a method with an invalid return type is identified as malformed by Testbench - public static Boolean test_method_is_wellformed_1(Mosaic_IO io) { - System.out.println("Expected output: Structural problem message for dummy_invalid_return_method."); - try { - Method invalidReturnMethod = Test_Testbench.class.getMethod("dummy_invalid_return_method", Mosaic_IO.class); - return Boolean.FALSE.equals(Mosaic_Testbench.method_is_wellformed(invalidReturnMethod)); - } catch (NoSuchMethodException e) { - return false; - } - } - - // Tests if a valid test method runs successfully with the Testbench - public static Boolean test_run_test_0(Mosaic_IO io) { - try { - Method validMethod = Test_Testbench.class.getMethod("dummy_test_method", Mosaic_IO.class); - return Boolean.TRUE.equals(Mosaic_Testbench.run_test(new Test_Testbench(), validMethod, io)); - } catch (NoSuchMethodException e) { - return false; - } - } - - /* Dummy methods for testing */ - public Boolean dummy_test_method(Mosaic_IO io) { - return true; // Simulates a passing test case - } - - public void dummy_invalid_return_method(Mosaic_IO io) { - // Simulates a test case with an invalid return type - } - - /* -------------------------------------------------------------------------------- - Manually run all tests and summarize results without using Testbench itself. - Each test's name is printed if it fails, and only pass/fail counts are summarized. - */ - public static int run() { - int passed_tests = 0; - int failed_tests = 0; - Mosaic_IO io = new Mosaic_IO(); - - if (test_method_is_wellformed_0(io)) passed_tests++; else { System.out.println("test_method_is_wellformed_0"); failed_tests++; } - if (test_method_is_wellformed_1(io)) passed_tests++; else { System.out.println("test_method_is_wellformed_1"); failed_tests++; } - if (test_run_test_0(io)) passed_tests++; else { System.out.println("test_run_test_0"); failed_tests++; } - - // Summary for all the tests - System.out.println("Test_Testbench Total tests run: " + (passed_tests + failed_tests)); - System.out.println("Test_Testbench Total tests passed: " + passed_tests); - System.out.println("Test_Testbench Total tests failed: " + failed_tests); - - return (failed_tests > 0) ? 1 : 0; - } - - /* -------------------------------------------------------------------------------- - Main method for shell interface, sets the exit status based on test results - */ - public static void main(String[] args) { - int exitCode = run(); - System.exit(exitCode); - } -} diff --git "a/tester/javac\360\237\226\211/Test_Util.java" "b/tester/javac\360\237\226\211/Test_Util.java" deleted file mode 100644 index b959d5e..0000000 --- "a/tester/javac\360\237\226\211/Test_Util.java" +++ /dev/null @@ -1,82 +0,0 @@ -import com.ReasoningTechnology.Mosaic.Mosaic_Util; - -/* -Test_Util - -*/ - -public class Test_Util{ - - public static Boolean test_all(){ - // Test with zero condition - Boolean[] condition0 = {}; - Boolean result = !Mosaic_Util.all(condition0); // Empty condition list is false. - - // Test with one condition - Boolean[] condition1_true = {true}; - Boolean[] condition1_false = {false}; - result &= Mosaic_Util.all(condition1_true); // should return true - result &= !Mosaic_Util.all(condition1_false); // should return false - - // Test with two condition - Boolean[] condition2_true = {true, true}; - Boolean[] condition2_false1 = {true, false}; - Boolean[] condition2_false2 = {false, true}; - Boolean[] condition2_false3 = {false, false}; - result &= Mosaic_Util.all(condition2_true); // should return true - result &= !Mosaic_Util.all(condition2_false1); // should return false - result &= !Mosaic_Util.all(condition2_false2); // should return false - result &= !Mosaic_Util.all(condition2_false3); // should return false - - // Test with three condition - Boolean[] condition3_false1 = {true, true, false}; - Boolean[] condition3_true = {true, true, true}; - Boolean[] condition3_false2 = {true, false, true}; - Boolean[] condition3_false3 = {false, true, true}; - Boolean[] condition3_false4 = {false, false, false}; - result &= !Mosaic_Util.all(condition3_false1); // should return false - result &= Mosaic_Util.all(condition3_true); // should return true - result &= !Mosaic_Util.all(condition3_false2); // should return false - result &= !Mosaic_Util.all(condition3_false3); // should return false - result &= !Mosaic_Util.all(condition3_false4); // should return false - - return result; - } - - public static Boolean test_all_set_false(){ - Boolean[] condition_list = {true, true, true}; - Mosaic_Util.all_set_false(condition_list); - return !condition_list[0] && !condition_list[1] && !condition_list[2]; - } - - public static Boolean test_all_set_true(){ - Boolean[] condition_list = {false, false, false}; - Mosaic_Util.all_set_true(condition_list); - return condition_list[0] && condition_list[1] && condition_list[2]; - } - - public static int run(){ - Boolean[] condition_list = new Boolean[3]; - condition_list[0] = test_all(); - condition_list[1] = test_all_set_false(); - condition_list[2] = test_all_set_true(); - - if( - !condition_list[0] - || !condition_list[1] - || !condition_list[2] - ){ - System.out.println("Test_Util failed"); - return 1; - } - System.out.println("Test_Util passed"); - return 0; - } - - // Main function to provide a shell interface for running tests - public static void main(String[] args){ - int return_code = run(); - System.exit(return_code); - return; - } -} diff --git "a/tester/javac\360\237\226\211/Testbench.java" "b/tester/javac\360\237\226\211/Testbench.java" new file mode 100644 index 0000000..070365e --- /dev/null +++ "b/tester/javac\360\237\226\211/Testbench.java" @@ -0,0 +1,82 @@ +import java.lang.reflect.Method; +import com.ReasoningTechnology.Mosaic.Mosaic_IO; +import com.ReasoningTechnology.Mosaic.Mosaic_Testbench; + +public class Testbench { + + /* -------------------------------------------------------------------------------- + Test methods to validate Testbench functionality + Each method tests a specific aspect of the Testbench class, with a focus on + ensuring that well-formed and ill-formed test cases are correctly identified + and handled. + */ + + // Tests if a correctly formed method is recognized as well-formed by Testbench + public static Boolean test_method_is_wellformed_0(Mosaic_IO io) { + try { + Method validMethod = Testbench.class.getMethod("dummy_test_method", Mosaic_IO.class); + return Boolean.TRUE.equals(Mosaic_Testbench.method_is_wellformed(validMethod)); + } catch (NoSuchMethodException e) { + return false; + } + } + + // Tests if a method with an invalid return type is identified as malformed by Testbench + public static Boolean test_method_is_wellformed_1(Mosaic_IO io) { + System.out.println("Expected output: Structural problem message for dummy_invalid_return_method."); + try { + Method invalidReturnMethod = Testbench.class.getMethod("dummy_invalid_return_method", Mosaic_IO.class); + return Boolean.FALSE.equals(Mosaic_Testbench.method_is_wellformed(invalidReturnMethod)); + } catch (NoSuchMethodException e) { + return false; + } + } + + // Tests if a valid test method runs successfully with the Testbench + public static Boolean test_run_test_0(Mosaic_IO io) { + try { + Method validMethod = Testbench.class.getMethod("dummy_test_method", Mosaic_IO.class); + return Boolean.TRUE.equals(Mosaic_Testbench.run_test(new Testbench(), validMethod, io)); + } catch (NoSuchMethodException e) { + return false; + } + } + + /* Dummy methods for testing */ + public Boolean dummy_test_method(Mosaic_IO io) { + return true; // Simulates a passing test case + } + + public void dummy_invalid_return_method(Mosaic_IO io) { + // Simulates a test case with an invalid return type + } + + /* -------------------------------------------------------------------------------- + Manually run all tests and summarize results without using Testbench itself. + Each test's name is printed if it fails, and only pass/fail counts are summarized. + */ + public static int run() { + int passed_tests = 0; + int failed_tests = 0; + Mosaic_IO io = new Mosaic_IO(); + + if (test_method_is_wellformed_0(io)) passed_tests++; else { System.out.println("test_method_is_wellformed_0"); failed_tests++; } + if (test_method_is_wellformed_1(io)) passed_tests++; else { System.out.println("test_method_is_wellformed_1"); failed_tests++; } + if (test_run_test_0(io)) passed_tests++; else { System.out.println("test_run_test_0"); failed_tests++; } + + // Summary for all the tests + System.out.println("Testbench Total tests run: " + (passed_tests + failed_tests)); + System.out.println("Testbench Total tests passed: " + passed_tests); + System.out.println("Testbench Total tests failed: " + failed_tests); + + return (failed_tests > 0) ? 1 : 0; + } + + /* -------------------------------------------------------------------------------- + Main method for shell interface, sets the exit status based on test results + */ + public static void main(String[] args) { + int exitCode = run(); + System.exit(exitCode); + } +} diff --git "a/tester/javac\360\237\226\211/Util.java" "b/tester/javac\360\237\226\211/Util.java" new file mode 100644 index 0000000..210fe71 --- /dev/null +++ "b/tester/javac\360\237\226\211/Util.java" @@ -0,0 +1,82 @@ +import com.ReasoningTechnology.Mosaic.Mosaic_Util; + +/* +Util + +*/ + +public class Util{ + + public static Boolean test_all(){ + // Test with zero condition + Boolean[] condition0 = {}; + Boolean result = !Mosaic_Util.all(condition0); // Empty condition list is false. + + // Test with one condition + Boolean[] condition1_true = {true}; + Boolean[] condition1_false = {false}; + result &= Mosaic_Util.all(condition1_true); // should return true + result &= !Mosaic_Util.all(condition1_false); // should return false + + // Test with two condition + Boolean[] condition2_true = {true, true}; + Boolean[] condition2_false1 = {true, false}; + Boolean[] condition2_false2 = {false, true}; + Boolean[] condition2_false3 = {false, false}; + result &= Mosaic_Util.all(condition2_true); // should return true + result &= !Mosaic_Util.all(condition2_false1); // should return false + result &= !Mosaic_Util.all(condition2_false2); // should return false + result &= !Mosaic_Util.all(condition2_false3); // should return false + + // Test with three condition + Boolean[] condition3_false1 = {true, true, false}; + Boolean[] condition3_true = {true, true, true}; + Boolean[] condition3_false2 = {true, false, true}; + Boolean[] condition3_false3 = {false, true, true}; + Boolean[] condition3_false4 = {false, false, false}; + result &= !Mosaic_Util.all(condition3_false1); // should return false + result &= Mosaic_Util.all(condition3_true); // should return true + result &= !Mosaic_Util.all(condition3_false2); // should return false + result &= !Mosaic_Util.all(condition3_false3); // should return false + result &= !Mosaic_Util.all(condition3_false4); // should return false + + return result; + } + + public static Boolean test_all_set_false(){ + Boolean[] condition_list = {true, true, true}; + Mosaic_Util.all_set_false(condition_list); + return !condition_list[0] && !condition_list[1] && !condition_list[2]; + } + + public static Boolean test_all_set_true(){ + Boolean[] condition_list = {false, false, false}; + Mosaic_Util.all_set_true(condition_list); + return condition_list[0] && condition_list[1] && condition_list[2]; + } + + public static int run(){ + Boolean[] condition_list = new Boolean[3]; + condition_list[0] = test_all(); + condition_list[1] = test_all_set_false(); + condition_list[2] = test_all_set_true(); + + if( + !condition_list[0] + || !condition_list[1] + || !condition_list[2] + ){ + System.out.println("Util failed"); + return 1; + } + System.out.println("Util passed"); + return 0; + } + + // Main function to provide a shell interface for running tests + public static void main(String[] args){ + int return_code = run(); + System.exit(return_code); + return; + } +} diff --git "a/tester/javac\360\237\226\211/smoke.java" "b/tester/javac\360\237\226\211/smoke.java" new file mode 100644 index 0000000..ccfc75e --- /dev/null +++ "b/tester/javac\360\237\226\211/smoke.java" @@ -0,0 +1,34 @@ +import com.ReasoningTechnology.Mosaic.Mosaic_Util; + +/* +Plug it in, see if there is smoke. There usually is. + +*/ + +public class smoke{ + + public static Boolean test_is_true(){ + return true; + } + + public static int run(){ + Boolean[] condition = new Boolean[1]; + condition[0] = test_is_true(); + + int i = 0; + if( !Mosaic_Util.all(condition) ){ + System.out.println("Test0 failed"); + return 1; + } + System.out.println("Test0 passed"); + return 0; + } + + // Main function to provide a shell interface for running tests + public static void main(String[] args){ + int return_code = run(); + System.exit(return_code); + return; + } + +} diff --git a/tester/jdwp_server/Access_0 b/tester/jdwp_server/Access_0 new file mode 100755 index 0000000..f25e6f8 --- /dev/null +++ b/tester/jdwp_server/Access_0 @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 Access_0 diff --git a/tester/jdwp_server/IO b/tester/jdwp_server/IO new file mode 100755 index 0000000..235da3f --- /dev/null +++ b/tester/jdwp_server/IO @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 IO diff --git a/tester/jdwp_server/IsPrimitive b/tester/jdwp_server/IsPrimitive new file mode 100755 index 0000000..f835393 --- /dev/null +++ b/tester/jdwp_server/IsPrimitive @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 IsPrimitive diff --git a/tester/jdwp_server/Logger b/tester/jdwp_server/Logger new file mode 100755 index 0000000..f127e85 --- /dev/null +++ b/tester/jdwp_server/Logger @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 Logger diff --git a/tester/jdwp_server/MockClass_0 b/tester/jdwp_server/MockClass_0 new file mode 100755 index 0000000..b047e64 --- /dev/null +++ b/tester/jdwp_server/MockClass_0 @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 MockClass_0 diff --git a/tester/jdwp_server/Testbench b/tester/jdwp_server/Testbench new file mode 100755 index 0000000..e1fed4e --- /dev/null +++ b/tester/jdwp_server/Testbench @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 Testbench diff --git a/tester/jdwp_server/Util b/tester/jdwp_server/Util new file mode 100755 index 0000000..bc24d32 --- /dev/null +++ b/tester/jdwp_server/Util @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 Util diff --git a/tester/jdwp_server/smoke b/tester/jdwp_server/smoke new file mode 100755 index 0000000..c7aa8e4 --- /dev/null +++ b/tester/jdwp_server/smoke @@ -0,0 +1,2 @@ +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 smoke diff --git a/tester/log/console b/tester/log/console new file mode 100644 index 0000000..e69de29 diff --git a/tester/log/log.txt b/tester/log/log.txt deleted file mode 100644 index 1b110b8..0000000 --- a/tester/log/log.txt +++ /dev/null @@ -1,92 +0,0 @@ -2024-12-16T10:34:45.427Z [main] INFO c.R.Mosaic.Mosaic_Logger - -2024-12-16T10:34:45.426403953Z ----------------------------------------------------------- -Test: test_publicClass_publicMethod -Stream: stdout -Output: -Mosaic_AllMethodsPublicProxy::construct exception: - - -2024-12-16T10:34:45.428Z [main] INFO c.R.Mosaic.Mosaic_Logger - -2024-12-16T10:34:45.428781379Z ----------------------------------------------------------- -Test: test_publicClass_publicMethod -Stream: stderr -Output: -java.lang.NoSuchMethodException: No constructor found for signature: - at com.ReasoningTechnology.Mosaic.Mosaic_AllMethodsPublicProxy.construct(Mosaic_AllMethodsPublicProxy.java:188) - at Test_Access_0$TestSuite.test_publicClass_publicMethod(Test_Access_0.java:24) - at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) - at java.base/java.lang.reflect.Method.invoke(Method.java:580) - at com.ReasoningTechnology.Mosaic.Mosaic_Testbench.run_test(Mosaic_Testbench.java:58) - at com.ReasoningTechnology.Mosaic.Mosaic_Testbench.run(Mosaic_Testbench.java:95) - at Test_Access_0.main(Test_Access_0.java:64) - - -2024-12-16T11:02:12.892Z [main] INFO c.R.Mosaic.Mosaic_Logger - -2024-12-16T11:02:12.891300901Z ----------------------------------------------------------- -Test: test_publicClass_publicMethod -Stream: stdout -Output: -Mosaic_AllMethodsPublicProxy::construct exception: - - -2024-12-16T11:02:12.894Z [main] INFO c.R.Mosaic.Mosaic_Logger - -2024-12-16T11:02:12.894076730Z ----------------------------------------------------------- -Test: test_publicClass_publicMethod -Stream: stderr -Output: -java.lang.NoSuchMethodException: No constructor found for signature: - at com.ReasoningTechnology.Mosaic.Mosaic_AllMethodsPublicProxy.construct(Mosaic_AllMethodsPublicProxy.java:188) - at Test_Access_0$TestSuite.test_publicClass_publicMethod(Test_Access_0.java:24) - at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) - at java.base/java.lang.reflect.Method.invoke(Method.java:580) - at com.ReasoningTechnology.Mosaic.Mosaic_Testbench.run_test(Mosaic_Testbench.java:58) - at com.ReasoningTechnology.Mosaic.Mosaic_Testbench.run(Mosaic_Testbench.java:95) - at Test_Access_0.main(Test_Access_0.java:64) - - -2024-12-16T11:03:52.982Z [main] INFO c.R.Mosaic.Mosaic_Logger - -2024-12-16T11:03:52.981361838Z ----------------------------------------------------------- -Test: test_publicClass_publicMethod -Stream: stdout -Output: -Mosaic_AllMethodsPublicProxy::construct exception: - - -2024-12-16T11:03:52.984Z [main] INFO c.R.Mosaic.Mosaic_Logger - -2024-12-16T11:03:52.984090088Z ----------------------------------------------------------- -Test: test_publicClass_publicMethod -Stream: stderr -Output: -java.lang.NoSuchMethodException: No constructor found for signature: - at com.ReasoningTechnology.Mosaic.Mosaic_AllMethodsPublicProxy.construct(Mosaic_AllMethodsPublicProxy.java:188) - at Test_Access_0$TestSuite.test_publicClass_publicMethod(Test_Access_0.java:24) - at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) - at java.base/java.lang.reflect.Method.invoke(Method.java:580) - at com.ReasoningTechnology.Mosaic.Mosaic_Testbench.run_test(Mosaic_Testbench.java:58) - at com.ReasoningTechnology.Mosaic.Mosaic_Testbench.run(Mosaic_Testbench.java:95) - at Test_Access_0.main(Test_Access_0.java:64) - - -2024-12-16T11:05:17.523Z [main] INFO c.R.Mosaic.Mosaic_Logger - -2024-12-16T11:05:17.521819930Z ----------------------------------------------------------- -Test: test_publicClass_publicMethod -Stream: stdout -Output: -Mosaic_AllMethodsPublicProxy::construct exception: - - -2024-12-16T11:05:17.524Z [main] INFO c.R.Mosaic.Mosaic_Logger - -2024-12-16T11:05:17.524857224Z ----------------------------------------------------------- -Test: test_publicClass_publicMethod -Stream: stderr -Output: -java.lang.NoSuchMethodException: No constructor found for signature: - at com.ReasoningTechnology.Mosaic.Mosaic_AllMethodsPublicProxy.construct(Mosaic_AllMethodsPublicProxy.java:188) - at Test_Access_0$TestSuite.test_publicClass_publicMethod(Test_Access_0.java:24) - at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) - at java.base/java.lang.reflect.Method.invoke(Method.java:580) - at com.ReasoningTechnology.Mosaic.Mosaic_Testbench.run_test(Mosaic_Testbench.java:58) - at com.ReasoningTechnology.Mosaic.Mosaic_Testbench.run(Mosaic_Testbench.java:95) - at Test_Access_0.main(Test_Access_0.java:64) - - diff --git a/tester/log/test b/tester/log/test new file mode 100644 index 0000000..e69de29 diff --git a/tester/tester.iml b/tester/tester.iml new file mode 100644 index 0000000..70ddc16 --- /dev/null +++ b/tester/tester.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/tester/tool\360\237\226\211/clean_build_directories" "b/tester/tool\360\237\226\211/clean_build_directories" index 7136c5c..989b007 100755 --- "a/tester/tool\360\237\226\211/clean_build_directories" +++ "b/tester/tool\360\237\226\211/clean_build_directories" @@ -13,7 +13,8 @@ script_afp=$(realpath "${BASH_SOURCE[0]}") cd "$REPO_HOME"/tester rm_na log/log.txt rm_na -r scratchpad/* - rm_na bash/* + rm_na jvm/* + rm_na jdwp_server/* set +x echo "$(script_fn) done." diff --git "a/tester/tool\360\237\226\211/env" "b/tester/tool\360\237\226\211/env" index d35674e..6128cf7 100644 --- "a/tester/tool\360\237\226\211/env" +++ "b/tester/tool\360\237\226\211/env" @@ -34,7 +34,7 @@ export PATH=\ # so we can run individual built tests wrappers export PATH=\ -"$REPO_HOME"/tester/bash\ +"$REPO_HOME"/tester/jvm\ :"$PATH" #-------------------------------------------------------------------------------- diff --git "a/tester/tool\360\237\226\211/list" "b/tester/tool\360\237\226\211/list" index ba12487..b5bef5c 100755 --- "a/tester/tool\360\237\226\211/list" +++ "b/tester/tool\360\237\226\211/list" @@ -1,7 +1,7 @@ #!/bin/env bash script_afp=$(realpath "${BASH_SOURCE[0]}") -# returns the list of tests for 'make' and for 'run_tests'. +# returns list of tests to be used by 'make' and for 'run' # input guards env_must_be="tester/tool🖉/env" @@ -10,14 +10,15 @@ if [ "$ENV" != "$env_must_be" ]; then exit 1 fi -# space separated list of bash interface wrappers +# the list + echo\ - Test_Logger\ - Test0\ - Test_Util\ - Test_IO\ - Test_Testbench\ - Test_MockClass_0\ - Test_IsPrimitive\ - Test_Access_0\ - "" + smoke\ + Logger\ + Util\ + IO\ + Testbench\ + MockClass_0\ + IsPrimitive\ + Access_0\ +"" diff --git "a/tester/tool\360\237\226\211/make" "b/tester/tool\360\237\226\211/make" index 66d4ea9..947d919 100755 --- "a/tester/tool\360\237\226\211/make" +++ "b/tester/tool\360\237\226\211/make" @@ -1,4 +1,5 @@ #!/bin/env bash +set -x script_afp=$(realpath "${BASH_SOURCE[0]}") # input guards @@ -16,24 +17,36 @@ cd $REPO_HOME/tester # Get the list of tests to compile # wrapper is a space-separated list -wrapper_list=$(test_list) +list=$(list) # make class files -for file in $wrapper_list; do +for file in $list; do javac -g -d scratchpad "javac🖉/$file.java" done set +x -echo "Creating bash wrappers..." -mkdir -p bash - -# make shell call wrappers -for file in $wrapper_list; do - cat > bash/$file << EOL +echo "Making jvm scripts ..." +mkdir -p jvm +for file in $list; do + cat > jvm/$file << EOL #!/bin/env bash java $file EOL - chmod +x bash/$file + chmod +x jvm/$file + done + +echo "Making jdwp debug server scripts..." +mkdir -p jdwp_server +for file in $list; do + cat > jdwp_server/$file << EOL +#!/bin/env bash +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 $file +EOL + chmod +x jdwp_server/$file done echo "$(script_fp) done." + + + +set +x diff --git "a/tester/tool\360\237\226\211/run" "b/tester/tool\360\237\226\211/run" new file mode 100755 index 0000000..da69708 --- /dev/null +++ "b/tester/tool\360\237\226\211/run" @@ -0,0 +1,25 @@ +#!/bin/env bash + +# Ensure REPO_HOME is set +if [ -z "$REPO_HOME" ]; then + echo "Error: REPO_HOME is not set." + exit 1 +fi + +# Navigate to the bash directory +cd "$REPO_HOME/tester/jvm" || exit + +# Get the list of test scripts in the specific order from bash_wrapper_list +test_list=$(test_list) +echo test_list: $test_list + +# Execute each test in the specified order +for file in $test_list; do + echo + if [[ -x "$file" && ! -d "$file" ]]; then + echo "... Running $file" + ./"$file" + else + echo "Skipping $file (not executable or is a directory)" + fi +done diff --git "a/tester/tool\360\237\226\211/run_tests" "b/tester/tool\360\237\226\211/run_tests" deleted file mode 100755 index a4d29b8..0000000 --- "a/tester/tool\360\237\226\211/run_tests" +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/env bash - -# Ensure REPO_HOME is set -if [ -z "$REPO_HOME" ]; then - echo "Error: REPO_HOME is not set." - exit 1 -fi - -# Navigate to the bash directory -cd "$REPO_HOME/tester/bash" || exit - -# Get the list of test scripts in the specific order from bash_wrapper_list -test_list=$(bash_wrapper_list) -echo test_list: $test_list - -# Execute each test in the specified order -for file in $test_list; do - echo - if [[ -x "$file" && ! -d "$file" ]]; then - echo "... Running $file" - ./"$file" - else - echo "Skipping $file (not executable or is a directory)" - fi -done