aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2018-04-12 17:18:53 -0300
committerLarry Jr <larry.olj@gmail.com>2018-04-12 17:21:09 -0300
commit94d8c0e8ea6ac0ca8b4103b5b5d628e1ab26279b (patch)
treea302b089d2c15637050144d44f7be0bba844b29d
parentEolian: TestGenerator making initial Mono test version [WIP] (diff)
downloadefl-94d8c0e8ea6ac0ca8b4103b5b5d628e1ab26279b.tar.gz
Eolian: TestGenerator Mono tests [WIP]
-rwxr-xr-xsrc/scripts/pyolian/testgenerator.py61
-rw-r--r--src/scripts/pyolian/testgenerator_suite.cs.template94
2 files changed, 136 insertions, 19 deletions
diff --git a/src/scripts/pyolian/testgenerator.py b/src/scripts/pyolian/testgenerator.py
index 29ff834b0c..b46158d914 100755
--- a/src/scripts/pyolian/testgenerator.py
+++ b/src/scripts/pyolian/testgenerator.py
@@ -6,6 +6,7 @@ import datetime
import eolian
import pyratemp
from copy import copy
+import itertools
# Use .eo files from the source tree (not the installed ones)
script_path = os.path.dirname(os.path.realpath(__file__))
@@ -41,6 +42,39 @@ def load_file(filename):
return f.read()
return None
+dicttypes = {}
+
+def cs_types():
+ dicttypes.update({"byte": "sbyte"
+ , "llong": "long"
+ , "int8": "sbyte"
+ , "int16": "short"
+ , "int32": "int"
+ , "int64": "long"
+ , "ssize": "long"
+ , "ubyte": "byte"
+ , "ullong": "ulong"
+ , "uint8": "byte"
+ , "uint16": "ushort"
+ , "uint32": "uint"
+ , "uint64": "ulong"
+ , "size": "ulong"
+ , "ptrdiff": "long"
+ , "intptr": "System.IntPtr"
+ , "uintptr": "System.IntPtr"
+ , "void_ptr": "System.IntPtr"
+ , "void": "System.intPtr" #only if is out/inout
+ , "Error": "eina.Error"
+ , "string": "System.String"
+ , "mstring": "System.String"
+ , "stringshare": "System.String"
+ , "any_value": "eina.Value"
+ , "any_value_ptr": "eina.Value"
+ })
+
+def type_convert(eotype):
+ return dicttypes.get(eotype.name, eotype.name)
+
"""
It will find methods and functions with owned return and without other params
"""
@@ -75,6 +109,7 @@ class Template(pyratemp.Template):
# Build the context for the template
ctx = {}
ctx['suite'] = suite
+ ctx['type_convert'] = type_convert
# render with the augmented context
output = self(**ctx)
@@ -97,6 +132,12 @@ class SuiteCase():
self.ext = os.path.splitext(filename)[1]
self.template = os.path.join(script_path, "testgenerator_suite{}.template".format(self.ext))
self.clslist = []
+ self.verbs = ["add", "get", "is", "del", "thaw", "freeze", "save", "wait", "eject", "raise", "lower", "load",
+ "dup", "reset", "unload", "close", "set", "interpolate", "has", "grab", "check", "find", "ungrab",
+ "unset", "clear", "pop", "new", "peek", "push", "update", "show", "move", "hide", "calculate",
+ "resize", "attach", "pack", "unpack", "emit", "call", "append"]
+ if self.ext == '.cs':
+ cs_types()
def __del__(self):
for cls in self.clslist:
@@ -131,25 +172,31 @@ class SuiteCase():
cls.custom += load_file(os.path.join(filedir, func.name, "custom{}".format(self.ext))) or ''
func.init = load_file(os.path.join(filedir, func.name, "init{}".format(self.ext)))
func.shutdown = load_file(os.path.join(filedir, func.name, "shutdown{}".format(self.ext)))
- func.arg_init = load_file(os.path.join(filedir, func.name, "arg_init{}".format(self.ext))) or "/* Zero/NULL args initialized */"
+ func.arg_init = load_file(os.path.join(filedir, func.name, "arg_init{}".format(self.ext))) or ''
func.arg_shutdown = load_file(os.path.join(filedir, func.name, "arg_shutdown{}".format(self.ext))) or ''
cls.plist = [ p for p in cls.properties if p.getter_scope == p.getter_scope.PUBLIC or p.setter_scope == p.setter_scope.PUBLIC ]
for func in cls.plist:
if func.getter_scope == func.getter_scope.PUBLIC:
- cls.custom += load_file(os.path.join(filedir, '{}_get'.format(func.name), "custom{}".format(self.ext))) or ""
+ cls.custom += load_file(os.path.join(filedir, '{}_get'.format(func.name), "custom{}".format(self.ext))) or ''
func.get_init = load_file(os.path.join(filedir, '{}_get'.format(func.name), "init{}".format(self.ext)))
- func.get_shutdown = load_file(os.path.join(filedir, '{}_get'.format(func.name), "shutdown{}".format(self.ext)))
- func.arg_get_init = load_file(os.path.join(filedir, '{}_get'.format(func.name), "arg_init{}".format(self.ext))) or "/* Zero/NULL args initialized */"
+ func.get_shutdown = load_file(os.path.join(filedir, '{}_get'.format(func.name), "shutdown{}".format(self.ext))) or ''
+ func.arg_get_init = load_file(os.path.join(filedir, '{}_get'.format(func.name), "arg_init{}".format(self.ext))) or ''
func.arg_get_shutdown = load_file(os.path.join(filedir, '{}_set'.format(func.name), "arg_shutdown{}".format(self.ext))) or ''
if func.setter_scope == func.setter_scope.PUBLIC:
- cls.custom += load_file(os.path.join(filedir, '{}_set'.format(func.name), "custom{}".format(self.ext))) or ""
+ cls.custom += load_file(os.path.join(filedir, '{}_set'.format(func.name), "custom{}".format(self.ext))) or ''
func.set_init = load_file(os.path.join(filedir, '{}_set'.format(func.name), "init{}".format(self.ext)))
- func.set_shutdown = load_file(os.path.join(filedir, '{}_set'.format(func.name), "shutdown{}".format(self.ext)))
- func.arg_set_init = load_file(os.path.join(filedir, '{}_set'.format(func.name), "arg_init{}".format(self.ext))) or "/* Zero/NULL args initialized */"
+ func.set_shutdown = load_file(os.path.join(filedir, '{}_set'.format(func.name), "shutdown{}".format(self.ext))) or ''
+ func.arg_set_init = load_file(os.path.join(filedir, '{}_set'.format(func.name), "arg_init{}".format(self.ext))) or ''
func.arg_set_shutdown = load_file(os.path.join(filedir, '{}_set'.format(func.name), "arg_shutdown{}".format(self.ext))) or ''
+ if self.ext == ".cs":
+ for func in itertools.chain(cls.mlist, cls.plist):
+ names = func.name.split('_')
+ if names[-1] in self.verbs:
+ names.insert(0, names.pop())
+ func.csname = ''.join([ name.capitalize() for name in names ])
if __name__ == '__main__':
import argparse
diff --git a/src/scripts/pyolian/testgenerator_suite.cs.template b/src/scripts/pyolian/testgenerator_suite.cs.template
index 81214a7797..12ff935c19 100644
--- a/src/scripts/pyolian/testgenerator_suite.cs.template
+++ b/src/scripts/pyolian/testgenerator_suite.cs.template
@@ -1,52 +1,122 @@
-<!--(macro newconcrete)-->${'.'.join(cls.namespaces).lower()}$.${cls.short_name}$ obj = new ${'.'.join(cls.namespaces).lower()}$.${cls.short_name}$Concrete();<!--(end)-->
+<!--(macro def_obj)-->${'.'.join(param.type.namespaces).lower()}$.${param.type.short_name}$ arg_${param.name}$;<!--(end)-->
+<!--(macro def_param)-->
+ <!--(if param.type.type == param.type.type.CLASS)-->${def_obj(param=param)}$<!--(else)-->${type_convert(param.type)}$ arg_${param.name}$;<!--(end)-->
+<!--(end)-->
+<!--(macro def_params)-->
+ <!--(for p in parameters)-->
+ ${def_param(param=p)}$
+ <!--(end)-->
+<!--(end)-->
using System;
namespace TestSuite
{
-<!--(for cls in suite.clslist)-->
+<!--(if suite.custom)-->
+${suite.custom}$
+<!--(end)-->
+<!--(for cls in suite.clslist)-->
/**************** TEST CASE ${cls.c_name}$ ****************/
class Test${cls.name.replace('.','')}$
{
- <!--(if cls.init or suite.init)-->
+
+ ${'.'.join(cls.namespaces).lower()}$.${cls.short_name}$ obj;
+ <!--(if cls.custom)-->
+${cls.custom}$
+ <!--(end)-->
+
public static void SetUp()
{
+ <!--(if suite.init)-->
${suite.init}$
+ <!--(end)-->
+ <!--(if cls.init)-->
${cls.init}$
- }
+ <!--(else)-->
+ obj = new ${'.'.join(cls.namespaces).lower()}$.${cls.short_name}$Concrete();
<!--(end)-->
- <!--(if cls.shutdown or suite.shutdown)-->
+ }
+
public static void TearDown()
{
+ <!--(if suite.shutdown)-->
${suite.shutdown}$
+ <!--(end)-->
+ <!--(if cls.shutdown)-->
${cls.shutdown}$
- }
+ <!--(else)-->
+ obj.Dispose()
+ obj = null;
<!--(end)-->
+ }
public static void smoke()
{
- ${newconcrete}$
}
+#! METHODS
<!--(for func in cls.mlist)-->
public static void ${func.name}$()
{
- ${newconcrete}$
+ <!--(if len(list(func.parameters)) > 0)-->
+${def_params(parameters=func.parameters)}$
+ <!--(end)-->
+ <!--(if func.init or func.arg_init)-->
+${func.arg_init}$
+${func.init}$
+ <!--(end)-->
+ <!--(if func.method_return_type)-->var r = <!--(end)-->obj.${func.csname}$(${', '.join(['arg_{}'.format(param.name) for param in func.parameters])}$);
+ <!--(if func.arg_shutdown or func.shutdown)-->
+${func.arg_shutdown}$
+${func.shutdown}$
+ <!--(end)-->
}
<!--(end)-->
+#! PROPERTIES FUNCTION GET
<!--(for func in cls.plist)-->
<!--(if func.getter_scope == func.getter_scope.PUBLIC)-->
- public static void get_${func.name}$()
+ public static void ${func.name}$_pget()
{
- ${newconcrete}$
+ <!--(if len(list(func.getter_values)) > 1)-->
+${def_params(parameters=func.getter_values)}$
+ <!--(end)-->
+ <!--(if len(list(func.getter_keys)) > 0)-->
+${def_params(parameters=func.getter_keys)}$
+ <!--(end)-->
+ <!--(if func.get_init or func.arg_get_init)-->
+${func.arg_get_init}$
+${func.get_init}$
+ <!--(end)-->
+ <!--(if len(list(func.getter_values)) == 1)-->
+ var arg_${list(func.getter_values)[0].name}$ = obj.Get${func.csname}$(${', '.join(['arg_{}'.format(param.name) for param in func.getter_keys])}$);
+ <!--(else)-->
+ obj.Get${func.csname}$(${', '.join(['&arg_{}'.format(p.name) for p in func.getter_values])}$${''.join([', arg_{}'.format(p.name) for p in func.getter_keys])}$);
+ <!--(end)-->
+ <!--(if func.arg_get_shutdown or func.get_shutdown)-->
+${func.arg_get_shutdown}$
+${func.get_shutdown}$
+ <!--(end)-->
}
<!--(end)-->
+#! PROPERTIES FUNCTION SET
<!--(if func.setter_scope == func.setter_scope.PUBLIC)-->
- public static void set_${func.name}$()
+ public static void ${func.name}$_pset()
{
- ${newconcrete}$
+${def_params(parameters=func.setter_values)}$
+ <!--(if len(list(func.setter_keys)) > 0)-->
+${def_params(parameters=func.setter_keys)}$
+ <!--(end)-->
+ <!--(if func.set_init or func.arg_set_init)-->
+${func.arg_set_init}$
+${func.set_init}$
+ <!--(end)-->
+ obj.Set${func.csname}$(${', '.join(['arg_{}'.format(p.name) for p in func.setter_values])}$${''.join([', arg_{}'.format(p.name) for p in func.setter_keys])}$);
+ <!--(if func.arg_set_shutdown or func.set_shutdown)-->
+${func.arg_set_shutdown}$
+${func.set_shutdown}$
+ <!--(end)-->
}
<!--(end)-->