lib: intro `prompt`, basic Apache 2.0 service to display a prompt
[nit.git] / src / testing / testing_gen.nit
index 19532c6..a444bee 100644 (file)
@@ -27,9 +27,8 @@ class NitUnitGenerator
        fun gen_unit(mmodule: MModule, test_file: String): Template do
                var with_private = toolcontext.opt_gen_private.value
                var tpl = new Template
-               tpl.addn "module test_{mmodule.name} is test_suite"
+               tpl.addn "module test_{mmodule.name} is test"
                tpl.addn ""
-               tpl.addn "import test_suite"
                if with_private then
                        tpl.addn "intrude import {mmodule.name}"
                else
@@ -39,7 +38,7 @@ class NitUnitGenerator
                        if mclassdef.mclass.kind != concrete_kind then continue
                        tpl.addn ""
                        tpl.addn "class Test{mclassdef.name}"
-                       tpl.addn "\tsuper TestSuite"
+                       tpl.addn "\ttest"
                        for mpropdef in mclassdef.mpropdefs do
                                if not mpropdef isa MMethodDef then continue
                                var mproperty = mpropdef.mproperty
@@ -48,7 +47,7 @@ class NitUnitGenerator
                                if not with_private and mproperty.visibility <= protected_visibility then continue
                                var case_name = case_name(mpropdef)
                                tpl.addn ""
-                               tpl.addn "\tfun {case_name} do"
+                               tpl.addn "\tfun {case_name} is test do"
                                tpl.addn "\t\tassert not_implemented: false # TODO remove once implemented"
                                tpl.addn ""
                                tpl.addn gen_init(mclassdef)
@@ -101,7 +100,7 @@ class NitUnitGenerator
        var nodot: Array[String] = ["+", "-", "*", "/", "%", "==", "!=", "<", "<=", "<=>", ">", ">=", ">"]
 
        # Generate subject init.
-       private fun gen_init(mclassdef: MClassDef): Streamable do
+       private fun gen_init(mclassdef: MClassDef): Writable do
                if mclassdef.mclass.arity == 0 then
                        return "\t\tvar subject: {mclassdef.name}"
                end
@@ -116,7 +115,7 @@ class NitUnitGenerator
        end
 
        # Generate call to `method` using `args`.
-       private fun gen_call(method: MMethodDef, args: Array[String]): Streamable do
+       private fun gen_call(method: MMethodDef, args: Array[String]): Writable do
                # Here we handle the magic of the Nit syntax, have fun :)
                var name = method.name
                if name == "[]" then return "subject[{args.join(", ")}]"
@@ -177,5 +176,5 @@ redef class ToolContext
        var opt_gen_unit = new OptionBool("Generate test suite skeleton for a module", "--gen-suite")
        var opt_gen_force = new OptionBool("Force test generation even if file exists", "-f", "--force")
        var opt_gen_private = new OptionBool("Also generate test case for private methods", "--private")
-       var opt_gen_show = new OptionBool("Only display skeleton, do not write file", "--only-show")
+       var opt_gen_show = new OptionBool("Only display the skeleton, do not write any file", "--only-show")
 end