structs and classes with @system or @trusted toString methodes did not

used to work. This test checks that it does work now

comment fix
This commit is contained in:
Robert burner Schadek 2015-10-01 14:38:31 +02:00 committed by Robert burner Schadek
parent d6fa6833fa
commit fdf19251ee

View file

@ -201,7 +201,7 @@ log(LogLevel.warning, true, "Hello World", 3.1415);
void log(int line = __LINE__, string file = __FILE__,
string funcName = __FUNCTION__, string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(const LogLevel ll,
lazy bool condition, lazy A args) @safe
lazy bool condition, lazy A args)
if (args.length != 1)
{
static if (isLoggingActive)
@ -479,7 +479,7 @@ template defaultLogFunction(LogLevel ll)
void defaultLogFunction(int line = __LINE__, string file = __FILE__,
string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(lazy A args) @safe
string moduleName = __MODULE__, A...)(lazy A args)
if ((args.length > 0 && !is(Unqual!(A[0]) : bool)) || args.length == 0)
{
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
@ -493,7 +493,6 @@ template defaultLogFunction(LogLevel ll)
string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(lazy bool condition, lazy A args)
@safe
{
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
{
@ -555,7 +554,6 @@ template defaultLogFunctionf(LogLevel ll)
string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(lazy string msg, lazy A args)
@safe
{
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
{
@ -568,7 +566,7 @@ template defaultLogFunctionf(LogLevel ll)
string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(lazy bool condition,
lazy string msg, lazy A args) @safe
lazy string msg, lazy A args)
{
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
{
@ -997,7 +995,7 @@ abstract class Logger
string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(lazy bool condition,
lazy A args) @safe
lazy A args)
{
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
synchronized (mutex)
@ -1046,7 +1044,7 @@ abstract class Logger
string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(lazy bool condition,
lazy string msg, lazy A args) @safe
lazy string msg, lazy A args)
{
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
synchronized (mutex)
@ -1093,7 +1091,6 @@ abstract class Logger
string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(lazy string msg, lazy A args)
@safe
{
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
synchronized (mutex)
@ -1163,7 +1160,7 @@ abstract class Logger
string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(const LogLevel ll,
lazy bool condition, lazy A args) @safe
lazy bool condition, lazy A args)
if (args.length != 1)
{
static if (isLoggingActive) synchronized (mutex)
@ -1188,7 +1185,7 @@ abstract class Logger
final void log(T, string moduleName = __MODULE__)(const LogLevel ll,
lazy bool condition, lazy T args, int line = __LINE__,
string file = __FILE__, string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__) @safe
string prettyFuncName = __PRETTY_FUNCTION__)
{
static if (isLoggingActive) synchronized (mutex)
{
@ -1233,7 +1230,6 @@ abstract class Logger
string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(const LogLevel ll, lazy A args)
@safe
if ((args.length > 1 && !is(Unqual!(A[0]) : bool)) || args.length == 0)
{
static if (isLoggingActive) synchronized (mutex)
@ -1258,7 +1254,7 @@ abstract class Logger
final void log(T)(const LogLevel ll, lazy T args, int line = __LINE__,
string file = __FILE__, string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__) @safe
string moduleName = __MODULE__)
{
static if (isLoggingActive) synchronized (mutex)
{
@ -1303,7 +1299,6 @@ abstract class Logger
string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(lazy bool condition, lazy A args)
@safe
if (args.length != 1)
{
static if (isLoggingActive) synchronized (mutex)
@ -1329,7 +1324,7 @@ abstract class Logger
final void log(T)(lazy bool condition, lazy T args, int line = __LINE__,
string file = __FILE__, string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__) @safe
string moduleName = __MODULE__)
{
static if (isLoggingActive) synchronized (mutex)
{
@ -1373,7 +1368,6 @@ abstract class Logger
string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(lazy A args)
@safe
if ((args.length > 1
&& !is(Unqual!(A[0]) : bool)
&& !is(Unqual!(A[0]) == LogLevel))
@ -1401,7 +1395,7 @@ abstract class Logger
final void log(T)(lazy T arg, int line = __LINE__, string file = __FILE__,
string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__) @safe
string moduleName = __MODULE__)
{
static if (isLoggingActive) synchronized (mutex)
{
@ -1448,7 +1442,7 @@ abstract class Logger
string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(const LogLevel ll,
lazy bool condition, lazy string msg, lazy A args) @safe
lazy bool condition, lazy string msg, lazy A args)
{
static if (isLoggingActive) synchronized (mutex)
{
@ -1494,7 +1488,7 @@ abstract class Logger
string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(const LogLevel ll,
lazy string msg, lazy A args) @safe
lazy string msg, lazy A args)
{
static if (isLoggingActive) synchronized (mutex)
{
@ -1541,7 +1535,7 @@ abstract class Logger
string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(lazy bool condition,
lazy string msg, lazy A args) @safe
lazy string msg, lazy A args)
{
static if (isLoggingActive) synchronized (mutex)
{
@ -1588,7 +1582,6 @@ abstract class Logger
string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(lazy string msg, lazy A args)
@safe
{
static if (isLoggingActive) synchronized (mutex)
{
@ -3052,3 +3045,22 @@ unittest
l.infof("log: %s", a);
assert(l.msg == "log: 1");
}
// Ensure @system toString methods work
unittest
{
enum SystemToStringMsg = "SystemToString";
static struct SystemToString
{
string toString() @system
{
return SystemToStringMsg;
}
}
auto tl = new TestLogger();
SystemToString sts;
tl.logf("%s", sts);
assert(tl.msg == SystemToStringMsg);
}