mirror of
https://github.com/dlang/phobos.git
synced 2025-05-13 07:39:15 +03:00
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:
parent
d6fa6833fa
commit
fdf19251ee
1 changed files with 32 additions and 20 deletions
|
@ -201,7 +201,7 @@ log(LogLevel.warning, true, "Hello World", 3.1415);
|
||||||
void log(int line = __LINE__, string file = __FILE__,
|
void log(int line = __LINE__, string file = __FILE__,
|
||||||
string funcName = __FUNCTION__, string prettyFuncName = __PRETTY_FUNCTION__,
|
string funcName = __FUNCTION__, string prettyFuncName = __PRETTY_FUNCTION__,
|
||||||
string moduleName = __MODULE__, A...)(const LogLevel ll,
|
string moduleName = __MODULE__, A...)(const LogLevel ll,
|
||||||
lazy bool condition, lazy A args) @safe
|
lazy bool condition, lazy A args)
|
||||||
if (args.length != 1)
|
if (args.length != 1)
|
||||||
{
|
{
|
||||||
static if (isLoggingActive)
|
static if (isLoggingActive)
|
||||||
|
@ -479,7 +479,7 @@ template defaultLogFunction(LogLevel ll)
|
||||||
void defaultLogFunction(int line = __LINE__, string file = __FILE__,
|
void defaultLogFunction(int line = __LINE__, string file = __FILE__,
|
||||||
string funcName = __FUNCTION__,
|
string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_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)
|
if ((args.length > 0 && !is(Unqual!(A[0]) : bool)) || args.length == 0)
|
||||||
{
|
{
|
||||||
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
|
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
|
||||||
|
@ -493,7 +493,6 @@ template defaultLogFunction(LogLevel ll)
|
||||||
string funcName = __FUNCTION__,
|
string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_FUNCTION__,
|
string prettyFuncName = __PRETTY_FUNCTION__,
|
||||||
string moduleName = __MODULE__, A...)(lazy bool condition, lazy A args)
|
string moduleName = __MODULE__, A...)(lazy bool condition, lazy A args)
|
||||||
@safe
|
|
||||||
{
|
{
|
||||||
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
|
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
|
||||||
{
|
{
|
||||||
|
@ -555,7 +554,6 @@ template defaultLogFunctionf(LogLevel ll)
|
||||||
string funcName = __FUNCTION__,
|
string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_FUNCTION__,
|
string prettyFuncName = __PRETTY_FUNCTION__,
|
||||||
string moduleName = __MODULE__, A...)(lazy string msg, lazy A args)
|
string moduleName = __MODULE__, A...)(lazy string msg, lazy A args)
|
||||||
@safe
|
|
||||||
{
|
{
|
||||||
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
|
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
|
||||||
{
|
{
|
||||||
|
@ -568,7 +566,7 @@ template defaultLogFunctionf(LogLevel ll)
|
||||||
string funcName = __FUNCTION__,
|
string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_FUNCTION__,
|
string prettyFuncName = __PRETTY_FUNCTION__,
|
||||||
string moduleName = __MODULE__, A...)(lazy bool condition,
|
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)
|
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
|
||||||
{
|
{
|
||||||
|
@ -997,7 +995,7 @@ abstract class Logger
|
||||||
string funcName = __FUNCTION__,
|
string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_FUNCTION__,
|
string prettyFuncName = __PRETTY_FUNCTION__,
|
||||||
string moduleName = __MODULE__, A...)(lazy bool condition,
|
string moduleName = __MODULE__, A...)(lazy bool condition,
|
||||||
lazy A args) @safe
|
lazy A args)
|
||||||
{
|
{
|
||||||
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
|
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
|
||||||
synchronized (mutex)
|
synchronized (mutex)
|
||||||
|
@ -1046,7 +1044,7 @@ abstract class Logger
|
||||||
string funcName = __FUNCTION__,
|
string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_FUNCTION__,
|
string prettyFuncName = __PRETTY_FUNCTION__,
|
||||||
string moduleName = __MODULE__, A...)(lazy bool condition,
|
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)
|
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
|
||||||
synchronized (mutex)
|
synchronized (mutex)
|
||||||
|
@ -1093,7 +1091,6 @@ abstract class Logger
|
||||||
string funcName = __FUNCTION__,
|
string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_FUNCTION__,
|
string prettyFuncName = __PRETTY_FUNCTION__,
|
||||||
string moduleName = __MODULE__, A...)(lazy string msg, lazy A args)
|
string moduleName = __MODULE__, A...)(lazy string msg, lazy A args)
|
||||||
@safe
|
|
||||||
{
|
{
|
||||||
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
|
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
|
||||||
synchronized (mutex)
|
synchronized (mutex)
|
||||||
|
@ -1163,7 +1160,7 @@ abstract class Logger
|
||||||
string funcName = __FUNCTION__,
|
string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_FUNCTION__,
|
string prettyFuncName = __PRETTY_FUNCTION__,
|
||||||
string moduleName = __MODULE__, A...)(const LogLevel ll,
|
string moduleName = __MODULE__, A...)(const LogLevel ll,
|
||||||
lazy bool condition, lazy A args) @safe
|
lazy bool condition, lazy A args)
|
||||||
if (args.length != 1)
|
if (args.length != 1)
|
||||||
{
|
{
|
||||||
static if (isLoggingActive) synchronized (mutex)
|
static if (isLoggingActive) synchronized (mutex)
|
||||||
|
@ -1188,7 +1185,7 @@ abstract class Logger
|
||||||
final void log(T, string moduleName = __MODULE__)(const LogLevel ll,
|
final void log(T, string moduleName = __MODULE__)(const LogLevel ll,
|
||||||
lazy bool condition, lazy T args, int line = __LINE__,
|
lazy bool condition, lazy T args, int line = __LINE__,
|
||||||
string file = __FILE__, string funcName = __FUNCTION__,
|
string file = __FILE__, string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_FUNCTION__) @safe
|
string prettyFuncName = __PRETTY_FUNCTION__)
|
||||||
{
|
{
|
||||||
static if (isLoggingActive) synchronized (mutex)
|
static if (isLoggingActive) synchronized (mutex)
|
||||||
{
|
{
|
||||||
|
@ -1233,7 +1230,6 @@ abstract class Logger
|
||||||
string funcName = __FUNCTION__,
|
string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_FUNCTION__,
|
string prettyFuncName = __PRETTY_FUNCTION__,
|
||||||
string moduleName = __MODULE__, A...)(const LogLevel ll, lazy A args)
|
string moduleName = __MODULE__, A...)(const LogLevel ll, lazy A args)
|
||||||
@safe
|
|
||||||
if ((args.length > 1 && !is(Unqual!(A[0]) : bool)) || args.length == 0)
|
if ((args.length > 1 && !is(Unqual!(A[0]) : bool)) || args.length == 0)
|
||||||
{
|
{
|
||||||
static if (isLoggingActive) synchronized (mutex)
|
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__,
|
final void log(T)(const LogLevel ll, lazy T args, int line = __LINE__,
|
||||||
string file = __FILE__, string funcName = __FUNCTION__,
|
string file = __FILE__, string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_FUNCTION__,
|
string prettyFuncName = __PRETTY_FUNCTION__,
|
||||||
string moduleName = __MODULE__) @safe
|
string moduleName = __MODULE__)
|
||||||
{
|
{
|
||||||
static if (isLoggingActive) synchronized (mutex)
|
static if (isLoggingActive) synchronized (mutex)
|
||||||
{
|
{
|
||||||
|
@ -1303,7 +1299,6 @@ abstract class Logger
|
||||||
string funcName = __FUNCTION__,
|
string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_FUNCTION__,
|
string prettyFuncName = __PRETTY_FUNCTION__,
|
||||||
string moduleName = __MODULE__, A...)(lazy bool condition, lazy A args)
|
string moduleName = __MODULE__, A...)(lazy bool condition, lazy A args)
|
||||||
@safe
|
|
||||||
if (args.length != 1)
|
if (args.length != 1)
|
||||||
{
|
{
|
||||||
static if (isLoggingActive) synchronized (mutex)
|
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__,
|
final void log(T)(lazy bool condition, lazy T args, int line = __LINE__,
|
||||||
string file = __FILE__, string funcName = __FUNCTION__,
|
string file = __FILE__, string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_FUNCTION__,
|
string prettyFuncName = __PRETTY_FUNCTION__,
|
||||||
string moduleName = __MODULE__) @safe
|
string moduleName = __MODULE__)
|
||||||
{
|
{
|
||||||
static if (isLoggingActive) synchronized (mutex)
|
static if (isLoggingActive) synchronized (mutex)
|
||||||
{
|
{
|
||||||
|
@ -1373,7 +1368,6 @@ abstract class Logger
|
||||||
string funcName = __FUNCTION__,
|
string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_FUNCTION__,
|
string prettyFuncName = __PRETTY_FUNCTION__,
|
||||||
string moduleName = __MODULE__, A...)(lazy A args)
|
string moduleName = __MODULE__, A...)(lazy A args)
|
||||||
@safe
|
|
||||||
if ((args.length > 1
|
if ((args.length > 1
|
||||||
&& !is(Unqual!(A[0]) : bool)
|
&& !is(Unqual!(A[0]) : bool)
|
||||||
&& !is(Unqual!(A[0]) == LogLevel))
|
&& !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__,
|
final void log(T)(lazy T arg, int line = __LINE__, string file = __FILE__,
|
||||||
string funcName = __FUNCTION__,
|
string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_FUNCTION__,
|
string prettyFuncName = __PRETTY_FUNCTION__,
|
||||||
string moduleName = __MODULE__) @safe
|
string moduleName = __MODULE__)
|
||||||
{
|
{
|
||||||
static if (isLoggingActive) synchronized (mutex)
|
static if (isLoggingActive) synchronized (mutex)
|
||||||
{
|
{
|
||||||
|
@ -1448,7 +1442,7 @@ abstract class Logger
|
||||||
string funcName = __FUNCTION__,
|
string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_FUNCTION__,
|
string prettyFuncName = __PRETTY_FUNCTION__,
|
||||||
string moduleName = __MODULE__, A...)(const LogLevel ll,
|
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)
|
static if (isLoggingActive) synchronized (mutex)
|
||||||
{
|
{
|
||||||
|
@ -1494,7 +1488,7 @@ abstract class Logger
|
||||||
string funcName = __FUNCTION__,
|
string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_FUNCTION__,
|
string prettyFuncName = __PRETTY_FUNCTION__,
|
||||||
string moduleName = __MODULE__, A...)(const LogLevel ll,
|
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)
|
static if (isLoggingActive) synchronized (mutex)
|
||||||
{
|
{
|
||||||
|
@ -1541,7 +1535,7 @@ abstract class Logger
|
||||||
string funcName = __FUNCTION__,
|
string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_FUNCTION__,
|
string prettyFuncName = __PRETTY_FUNCTION__,
|
||||||
string moduleName = __MODULE__, A...)(lazy bool condition,
|
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)
|
static if (isLoggingActive) synchronized (mutex)
|
||||||
{
|
{
|
||||||
|
@ -1588,7 +1582,6 @@ abstract class Logger
|
||||||
string funcName = __FUNCTION__,
|
string funcName = __FUNCTION__,
|
||||||
string prettyFuncName = __PRETTY_FUNCTION__,
|
string prettyFuncName = __PRETTY_FUNCTION__,
|
||||||
string moduleName = __MODULE__, A...)(lazy string msg, lazy A args)
|
string moduleName = __MODULE__, A...)(lazy string msg, lazy A args)
|
||||||
@safe
|
|
||||||
{
|
{
|
||||||
static if (isLoggingActive) synchronized (mutex)
|
static if (isLoggingActive) synchronized (mutex)
|
||||||
{
|
{
|
||||||
|
@ -3052,3 +3045,22 @@ unittest
|
||||||
l.infof("log: %s", a);
|
l.infof("log: %s", a);
|
||||||
assert(l.msg == "log: 1");
|
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);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue