diff options
Diffstat (limited to 'gcc/testsuite/gdc.test/runnable/test23.d')
-rw-r--r-- | gcc/testsuite/gdc.test/runnable/test23.d | 177 |
1 files changed, 29 insertions, 148 deletions
diff --git a/gcc/testsuite/gdc.test/runnable/test23.d b/gcc/testsuite/gdc.test/runnable/test23.d index abf8e37f83d..f1fd4a6c2bc 100644 --- a/gcc/testsuite/gdc.test/runnable/test23.d +++ b/gcc/testsuite/gdc.test/runnable/test23.d @@ -1,14 +1,8 @@ -// RUNNABLE_PHOBOS_TEST -// REQUIRED_ARGS: - module test; import core.vararg; import core.stdc.stdlib; -import std.stdio; -import std.string; -import core.stdc.stdlib; - +import core.stdc.stdio; /*******************************************/ @@ -69,13 +63,6 @@ void test3() /*******************************************/ -void test4() -{ - writeln("",true); -} - -/*******************************************/ - void test5() { int[] qwert = new int[6]; @@ -228,9 +215,9 @@ void test11() { Foo11 fooIt = new Foo11(); if (fooIt !is null) - writefln("fooIt should be valid"); + printf("fooIt should be valid\n"); fooIt.f.foo(); - writefln("it worked"); + printf("it worked\n"); } /*******************************************/ @@ -251,7 +238,7 @@ struct B12 { void test12() { A12 a; - printf("%d\n", A12.sizeof); + printf("%zd\n", A12.sizeof); assert(A12.sizeof == 12); } @@ -272,7 +259,7 @@ interface Father {} class Mother { Father test() { - writefln("Called Mother.test!"); + printf("Called Mother.test!\n"); return new Child(42); } } @@ -283,7 +270,7 @@ class Child : Mother, Father { this(int d) { data = d; } override Child test() { - writefln("Called Child.test!"); + printf("Called Child.test!\n"); return new Child(69); } } @@ -294,7 +281,7 @@ void test14() Mother childsMum = aChild; Child childsChild = aChild.test(); Child mumsChild = cast(Child) childsMum.test(); - writefln("Success2"); + printf("Success2\n"); } @@ -335,27 +322,6 @@ void test15() /*******************************************/ -creal x16; - -void foo16() -{ - x16 = -x16; -} - -void bar16() -{ - return foo16(); -} - -void test16() -{ - x16 = 2.0L + 0.0Li; - bar16(); - assert(x16 == -2.0L + 0.0Li); -} - -/*******************************************/ - void test17() { version(D_InlineAsm_X86_64) @@ -557,15 +523,12 @@ void test25() char[6] cstr = "123456"c; auto str1 = cast(wchar[3])(cstr); - writefln("str1: ", (cast(char[])str1).length , " : ", (cast(char[])str1)); assert(cast(char[])str1 == "123456"c); auto str2 = cast(wchar[3])("789abc"c); - writefln("str2: ", (cast(char[])str2).length , " : ", (cast(char[])str2)); assert(cast(char[])str2 == "789abc"c); auto str3 = cast(wchar[3])("defghi"); - writefln("str3: ", (cast(char[])str3).length , " : ", (cast(char[])str3)); version (LittleEndian) assert(cast(char[])str3 == "d\000e\000f\000"c); version (BigEndian) @@ -631,26 +594,20 @@ uint intRes() void test28() { - auto s = std.string.format("%s", "abc123"[intRes() % $] ); - writefln( "%s", s ); - assert(s == "2"); + auto s = "abc123"[intRes() % $]; + assert(s == '2'); static const char[] foo = "abc123"; - s = std.string.format("%s", foo[intRes() % $] ); - assert(s == "2"); - + assert(foo[intRes() % $] == '2'); static string bar = "abc123"; - s = std.string.format("%s", bar[intRes() % $] ); - assert(s == "2"); + assert(bar[intRes() % $] == '2'); const char[] abc = "abc123"; - s = std.string.format("%s", abc[intRes() % $] ); - assert(s == "2"); + assert(abc[intRes() % $] == '2'); string def = "abc123"; - s = std.string.format("%s", def[intRes() % $] ); - assert(s == "2"); + assert(def[intRes() % $] == '2'); } /*******************************************/ @@ -703,72 +660,6 @@ void test31() /*******************************************/ -class Foo32 -{ - static void* ps; - - new (size_t sz) - { - void* p = core.stdc.stdlib.malloc(sz); - printf("new(sz = %d) = %p\n", sz, p); - ps = p; - return p; - } - - delete(void* p) - { - printf("delete(p = %p)\n", p); - assert(p == ps); - if (p) core.stdc.stdlib.free(p); - } -} - -void test32() -{ - Foo32 f = new Foo32; - delete f; -} - -/*******************************************/ - -class Foo33 -{ -// this() { printf("this()\n"); } -// ~this() { printf("~this()\n"); } - - static void* ps; - static int del; - - new (size_t sz, int i) - { - void* p = core.stdc.stdlib.malloc(sz); - printf("new(sz = %d) = %p\n", sz, p); - ps = p; - return p; - } - - delete(void* p) - { - printf("delete(p = %p)\n", p); - assert(p == ps); - if (p) core.stdc.stdlib.free(p); - del += 1; - } -} - -void foo33() -{ - scope Foo33 f = new(3) Foo33; -} - -void test33() -{ - foo33(); - assert(Foo33.del == 1); -} - -/*******************************************/ - struct o_O { int a; } union O_O { int a; } class O_o { int a; } @@ -806,12 +697,6 @@ void test37() { Foo37 f = new Foo37(); - writefln("Foo.array[0] = %s", f.array[0] ); - writefln("Foo.array[1] = %s", f.array[1] ); - writefln("Foo.array[2] = %s", f.array[2] ); - writefln("Foo.array[3] = %s", f.array[3] ); - writefln("Foo.count = %s", f.count ); - assert(f.array[0] == 1.0); assert(f.array[1] == 1.0); assert(f.array[2] == 1.0); @@ -831,7 +716,7 @@ in checkParameters(); } -body +do { } @@ -848,7 +733,7 @@ void delegate() foo39() void dg() { - writefln("delegate!"); + printf("delegate!\n"); assert(a == 3); } }).dg; @@ -1019,7 +904,8 @@ void test45() buffer[i] -= cast(char)'a' - 'A'; // segfault here } } - writeln(buffer); + + assert(buffer == "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); } /*******************************************/ @@ -1189,10 +1075,10 @@ bool[void[]] reg57; void addToReg57(const(void)[] a, int b, bool v) { if (!v) - writefln("X"); + printf("X\n"); auto key = a~(cast(void*)&b)[0..4]; reg57[cast(immutable(void)[])key] = v; - writefln("OK"); + printf("OK\n"); } void test57() @@ -1232,10 +1118,9 @@ struct S59 void test59() { S59 s; - writefln("s = %s", s); string p; - p = std.string.format("s = %s", s); + p = "s = " ~ s.toString(); assert(p == "s = foo"); } @@ -1263,11 +1148,13 @@ void test60() void test61() { int[][] f = [[1,2],[3,4]]; + assert(f.length == 2); + assert(f[0].length == 2); + assert(f[1].length == 2); assert(f[0][0] == 1); assert(f[0][1] == 2); assert(f[1][0] == 3); assert(f[1][1] == 4); - writeln(f); } /*******************************************/ @@ -1304,7 +1191,7 @@ void test63() arr = [1] ~ 2; // runtime crash, the length == 1 - printf("%d\n", arr.length); + printf("%zd\n", arr.length); assert (arr.length == 2); assert(arr[0] == 1); assert(arr[1] == 2); @@ -1333,7 +1220,6 @@ void test64() foreach_reverse(v; x) { - writeln(v); assert(j == v); j--; } @@ -1342,7 +1228,6 @@ void test64() j = 4; foreach_reverse(i, v; x) { - writefln("[%s] = %s", i, v); assert(i + 1 == j); assert(j == v); j--; @@ -1411,11 +1296,11 @@ void test69() auto n = new NoBug; auto n2 = new NoBug2; - writefln("bug %d", b.t); + printf("bug %d\n", b.t); assert(b.t == 1); - writefln("nobug %d", n.t); + printf("nobug %d\n", n.t); assert(n.t == 2); - writefln("nobug2 %d", n2.t); + printf("nobug2 %d\n", n2.t); assert(n2.t == 3); } @@ -1428,8 +1313,6 @@ void test70() } static const char[0] altsep; - string s = std.string.format("test%spath", altsep); - assert(s == "testpath"); foo(altsep); } @@ -1502,7 +1385,6 @@ void main() test1(); test2(); test3(); - test4(); test5(); test6(); test7(); @@ -1514,7 +1396,6 @@ void main() test13(); test14(); test15(); - test16(); test17(); test18(); test19(); @@ -1530,8 +1411,8 @@ void main() test29(); test30(); test31(); - test32(); - test33(); + + test34(); test37(); test38(); |