mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-12 02:43:14 +01:00
[svn r362] Started merging the old 'test' dir as well as the newer 'tangotests' dir into 'tests/mini' and 'tests/minicomplex'.
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
class Foo
|
||||
{
|
||||
int i;
|
||||
}
|
||||
|
||||
class Bar : Foo
|
||||
{
|
||||
int j;
|
||||
}
|
||||
|
||||
void func()
|
||||
{
|
||||
scope c = new Bar;
|
||||
func2(c);
|
||||
}
|
||||
|
||||
void func2(Bar c)
|
||||
{
|
||||
c.i = 123;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
func();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
char* toStringz (char[] s)
|
||||
{
|
||||
if (s.ptr)
|
||||
if (! (s.length && s[$-1] is 0))
|
||||
s = s ~ '\0';
|
||||
return s.ptr;
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
extern(C)
|
||||
{
|
||||
private extern int integer;
|
||||
}
|
||||
|
||||
void func()
|
||||
{
|
||||
integer++;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
extern(C) int printf(char*,...);
|
||||
|
||||
class MyClass
|
||||
{
|
||||
this(int i = 4)
|
||||
{
|
||||
inner = this.new InnerClass;
|
||||
}
|
||||
|
||||
class InnerClass : Object.Monitor
|
||||
{
|
||||
void lock() {}
|
||||
void unlock() {}
|
||||
}
|
||||
|
||||
InnerClass inner;
|
||||
}
|
||||
|
||||
void func()
|
||||
{
|
||||
scope c = new MyClass(42);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
func();
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
extern(C) int printf(char*,...);
|
||||
|
||||
void main()
|
||||
{
|
||||
printf("Hello World!\n");
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
module tangotests.nested1;
|
||||
|
||||
void main()
|
||||
{
|
||||
int i = 42;
|
||||
assert(i == 42);
|
||||
void func()
|
||||
{
|
||||
assert(i == 42);
|
||||
}
|
||||
func();
|
||||
}
|
||||
12
test/fail1.d
12
test/fail1.d
@@ -1,12 +0,0 @@
|
||||
module fail1;
|
||||
|
||||
void func()
|
||||
{
|
||||
float* fp;
|
||||
float f = *fp;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
func();
|
||||
}
|
||||
27
test/fail2.d
27
test/fail2.d
@@ -1,27 +0,0 @@
|
||||
module fail2;
|
||||
|
||||
void a()
|
||||
{
|
||||
b();
|
||||
}
|
||||
|
||||
void b()
|
||||
{
|
||||
c();
|
||||
}
|
||||
|
||||
void c()
|
||||
{
|
||||
d();
|
||||
}
|
||||
|
||||
void d()
|
||||
{
|
||||
int* ip;
|
||||
int i = *ip;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
a();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
module tangotests.aa1;
|
||||
module tangotests.aa1_1;
|
||||
|
||||
extern(C) int printf(char*,...);
|
||||
|
||||
12
tests/mini/aa2_1.d
Normal file
12
tests/mini/aa2_1.d
Normal file
@@ -0,0 +1,12 @@
|
||||
module tangotests.aa2_1;
|
||||
|
||||
int main()
|
||||
{
|
||||
int[cdouble] x;
|
||||
cdouble d=22.0+0.0i;
|
||||
x[d] = 44;
|
||||
if(44 != x[d]){
|
||||
assert(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
19
tests/mini/align1.d
Normal file
19
tests/mini/align1.d
Normal file
@@ -0,0 +1,19 @@
|
||||
module tangotests.align1;
|
||||
|
||||
extern(C) int printf(char*, ...);
|
||||
|
||||
struct TLA
|
||||
{
|
||||
char[3] tla;
|
||||
char[] toString() { return tla; }
|
||||
void dump()
|
||||
{
|
||||
printf("%.*s\n", 3, tla.ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
TLA fbi = TLA("FBI");
|
||||
fbi.dump();
|
||||
}
|
||||
43
tests/mini/arrays1.d
Normal file
43
tests/mini/arrays1.d
Normal file
@@ -0,0 +1,43 @@
|
||||
module arrays1;
|
||||
|
||||
extern(C) int printf(char*, ...);
|
||||
|
||||
void integer()
|
||||
{
|
||||
auto arr = new int[16];
|
||||
arr[1] = 42;
|
||||
arr[6] = 555;
|
||||
print_int(arr);
|
||||
delete arr;
|
||||
}
|
||||
|
||||
void floating()
|
||||
{
|
||||
auto arr = new float[6];
|
||||
arr[1] = 3.14159265;
|
||||
arr[3] = 1.61803399;
|
||||
print_float(arr);
|
||||
delete arr;
|
||||
}
|
||||
|
||||
void print_int(int[] arr)
|
||||
{
|
||||
printf("arr[%lu] = [", arr.length);
|
||||
for (auto i=0; i<arr.length; i++)
|
||||
printf("%d,", arr[i]);
|
||||
printf("\b]\n");
|
||||
}
|
||||
|
||||
void print_float(float[] arr)
|
||||
{
|
||||
printf("arr[%lu] = [", arr.length);
|
||||
for (auto i=0; i<arr.length; i++)
|
||||
printf("%f,", arr[i]);
|
||||
printf("\b]\n");
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
integer();
|
||||
floating();
|
||||
}
|
||||
6
tests/mini/arrays17.d
Normal file
6
tests/mini/arrays17.d
Normal file
@@ -0,0 +1,6 @@
|
||||
module tangotests.arrays3;
|
||||
|
||||
void main()
|
||||
{
|
||||
const char[2][2] id = [1: "ab"];
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
module tangotests.asm1;
|
||||
module tangotests.asm1_1;
|
||||
|
||||
extern(C) int printf(char*, ...);
|
||||
|
||||
20
tests/mini/asm5.d
Normal file
20
tests/mini/asm5.d
Normal file
@@ -0,0 +1,20 @@
|
||||
module tangotests.asm5;
|
||||
|
||||
extern(C) int printf(char*, ...);
|
||||
|
||||
void main()
|
||||
{
|
||||
int i = func();
|
||||
printf("%d\n", i);
|
||||
assert(i == 42);
|
||||
}
|
||||
|
||||
int func()
|
||||
{
|
||||
asm
|
||||
{
|
||||
naked;
|
||||
mov EAX, 42;
|
||||
ret;
|
||||
}
|
||||
}
|
||||
23
tests/mini/asm6.d
Normal file
23
tests/mini/asm6.d
Normal file
@@ -0,0 +1,23 @@
|
||||
extern(C) int printf(char*, ...);
|
||||
|
||||
void main()
|
||||
{
|
||||
int a,b,c;
|
||||
a = int.max-1;
|
||||
b = 1;
|
||||
asm
|
||||
{
|
||||
mov EAX, a;
|
||||
mov ECX, b;
|
||||
add EAX, ECX;
|
||||
jo Loverflow;
|
||||
mov c, EAX;
|
||||
}
|
||||
|
||||
printf("c == %d\n", c);
|
||||
assert(c == a+b);
|
||||
return;
|
||||
|
||||
Loverflow:
|
||||
assert(0, "overflow");
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user