nitc :: NitUnitGenerator :: gen_call
method
using args
.
# Generate call to `method` using `args`.
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(", ")}]"
if name == "[]=" then
var last = args.pop
return "subject[{args.join(", ")}] = {last}"
end
if name == "unary -" then return "-subject"
var tpl = new Template
if nodot.has(name) then
tpl.add "subject {name}"
if args.length == 1 then
tpl.add " {args.first}"
else if args.length > 1 then
tpl.add " ({args.join(", ")})"
end
return tpl
end
if name.has_suffix("=") then
name = name.substring(0, name.length - 1)
var last = args.pop
tpl.add "subject.{name}"
if not args.is_empty then
tpl.add "({args.join(", ")})"
end
tpl.add " = {last}"
return tpl
end
tpl.add "subject.{name}"
if args.length == 1 then
tpl.add " {args.first}"
else if args.length > 1 then
tpl.add "({args.join(", ")})"
end
return tpl
end
src/testing/testing_gen.nit:117,2--154,4