From 1f5760b5af60820b480cf7566fdedda0128145d6 Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Mon, 14 Jan 2008 05:32:24 +0100 Subject: [PATCH] [svn r138] forgot the latest tests --- tangotests/p.d | 18 ++++++++++++++++++ tangotests/q.d | 22 ++++++++++++++++++++++ tangotests/r.d | 27 +++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 tangotests/p.d create mode 100644 tangotests/q.d create mode 100644 tangotests/r.d diff --git a/tangotests/p.d b/tangotests/p.d new file mode 100644 index 00000000..a1206fc3 --- /dev/null +++ b/tangotests/p.d @@ -0,0 +1,18 @@ +extern(C) int printf(char*, ...); + +int main(char[][] args) +{ + printf("getint\n"); + int i = getint(); + printf("assert true\n"); + assert(i == 1234); + printf("assert false\n"); + assert(i != 1234); + printf("return\n"); + return 0; +} + +int getint() +{ + return 1234; +} diff --git a/tangotests/q.d b/tangotests/q.d new file mode 100644 index 00000000..1365ab6d --- /dev/null +++ b/tangotests/q.d @@ -0,0 +1,22 @@ +class E : Exception +{ + this(char[] msg) + { + super(msg); + } + + char[] toString() + { + return super.toString(); + } +} + +extern(C) int printf(char*, ...); + +void main() +{ + auto e = new E("hello world"); + auto msg = e.toString(); + printf("message should be: '%.*s'\n", msg.length, msg.ptr); + throw e; +} diff --git a/tangotests/r.d b/tangotests/r.d new file mode 100644 index 00000000..b36cec7a --- /dev/null +++ b/tangotests/r.d @@ -0,0 +1,27 @@ +extern(C) int printf(char*, ...); + +class C +{ + void dump() + { + printf("C dumped\n"); + } +} + +void heap() +{ + auto c = new C; + c.dump(); +} + +void stack() +{ + scope c = new C; + c.dump(); +} + +void main() +{ + heap(); + stack(); +}