Files
Iain Buclaw b3b54f9c9a libphobos: Merge changes in upstream druntime testsuite
libphobos/ChangeLog:

	* libdruntime/MERGE: Merge upstream druntime d2ee11364c.
	* testsuite/libphobos.aa/test_aa.d: Add new test.
	* testsuite/libphobos.betterc/test19933.d: Adjust imports.
	* testsuite/libphobos.config/test22523.d: Likewise.
	* testsuite/libphobos.exceptions/assert_fail.d: Adjust test.
	* testsuite/libphobos.exceptions/chain.d: Adjust imports.
	* testsuite/libphobos.exceptions/future_message.d: Likewise.
	* testsuite/libphobos.exceptions/line_trace.d: Likewise.
	* testsuite/libphobos.exceptions/long_backtrace_trunc.d: Likewise.
	* testsuite/libphobos.exceptions/static_dtor.d: Likewise.
	* testsuite/libphobos.gc/forkgc.d: Likewise.
	* testsuite/libphobos.gc/precisegc.d: Likewise.
	* testsuite/libphobos.gc/recoverfree.d: Likewise.
	* testsuite/libphobos.hash/test_hash.d: Likewise.
	* testsuite/libphobos.init_fini/custom_gc.d: Likewise.
	* testsuite/libphobos.init_fini/thread_join.d: Likewise.
	* testsuite/libphobos.thread/external_threads.d: Likewise.
	* testsuite/libphobos.thread/fiber_guard_page.d: Likewise.
	* testsuite/libphobos.thread/tlsgc_sections.d: Likewise.
	* testsuite/libphobos.thread/tlsstack.d: Likewise.
	* testsuite/libphobos.unittest/customhandler.d: Likewise.
2025-03-18 18:53:11 +01:00

72 lines
1.5 KiB
D

// { dg-options "-Wno-deprecated" }
import core.stdc.stdio : fprintf, stderr;
// Make sure basic stuff works with future Throwable.message
class NoMessage : Throwable
{
@nogc @safe pure nothrow this(string msg, Throwable next = null)
{
super(msg, next);
}
}
class WithMessage : Throwable
{
@nogc @safe pure nothrow this(string msg, Throwable next = null)
{
super(msg, next);
}
override const(char)[] message() const
{
return "I have a custom message.";
}
}
class WithMessageNoOverride : Throwable
{
@nogc @safe pure nothrow this(string msg, Throwable next = null)
{
super(msg, next);
}
const(char)[] message() const
{
return "I have a custom message and no override.";
}
}
class WithMessageNoOverrideAndDifferentSignature : Throwable
{
@nogc @safe pure nothrow this(string msg, Throwable next = null)
{
super(msg, next);
}
immutable(char)[] message()
{
return "I have a custom message and I'm nothing like Throwable.message.";
}
}
void test(Throwable t)
{
try
{
throw t;
}
catch (Throwable e)
{
fprintf(stderr, "%.*s ", cast(int)e.message.length, e.message.ptr);
}
}
void main()
{
test(new NoMessage("exception"));
test(new WithMessage("exception"));
test(new WithMessageNoOverride("exception"));
test(new WithMessageNoOverrideAndDifferentSignature("exception"));
fprintf(stderr, "\n");
}