Issue #13068
I believe it will be very useful if, especially for the unit test framework if it were possible to get the name of method present in a class as a string. This will be helpful to check if the method is a test method or not.
/* Get the type of the ith method in a class.
Causes a compilation error if `i` is not in 1..numMethods(t).
:arg t: a class type
:arg i: which method to get the name of
:returns: the name of the method, as a string
*/
proc getMethodName(type t, var i:int) string
return __primitive("method num to name", t, i);
Issue #13069
I believe it will be very useful if, especially for the unit test framework if it were possible to get the number of methods present in a class. This will be helpful to get the name or reference of method.
// Return the number of methods in a class.
proc numMethods(type t) param : int
return __primitive("num method", t);
Already an issue chapel-lang/chapel#8326 if present for it.
Note: I don't think we need it.
I believe it will be very useful if, especially for the unit test framework if it were possible to store classes in list/LinkedList. This will be useful when user write tests in multiple classes and want to test all them in a suite. So we need to store the Classes.
use LinkedLists;
var classNames : LinkedList(type);
class a{
// do something
}
class b{
// do something
}
classNames.push_back(a);
classNames.push_back(b);
Issue #13070
I believe it will be very useful especially for the unit test framework if it were possible to get the instance of a class given its name as a string. This will help in calling the test methods of all classes in a suite.
// Return the instance of methods in a class.
proc classInstance(string fname) var
return __primitive("class instance", fname);
For the 4th one, I think we can have another alternative but won't be that friendly for the users. We can store objects of each class and then write a function which can return the class from the object. Currently, we have a function that returns the name of the class from the obj.