mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-26 17:43:14 +01:00
[svn r56] Initial support for TypeInfo.
Enums not work. Several other bugfixes.
This commit is contained in:
8
test/bug26.d
Normal file
8
test/bug26.d
Normal file
@@ -0,0 +1,8 @@
|
||||
module bug26;
|
||||
|
||||
extern int i;
|
||||
|
||||
void main()
|
||||
{
|
||||
int j = i;
|
||||
}
|
||||
17
test/bug27.d
Normal file
17
test/bug27.d
Normal file
@@ -0,0 +1,17 @@
|
||||
module bug27;
|
||||
|
||||
int func(int a, int b)
|
||||
{
|
||||
if (a == b)
|
||||
return 0;
|
||||
else if (a < b)
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
int i = func(3,4);
|
||||
assert(i == -1);
|
||||
}
|
||||
17
test/bug28.d
Normal file
17
test/bug28.d
Normal file
@@ -0,0 +1,17 @@
|
||||
module bug28;
|
||||
|
||||
void main()
|
||||
{
|
||||
char[] a = "hello";
|
||||
char[] b = "hello";
|
||||
char[] c = "world";
|
||||
char[] d = "somethingelse";
|
||||
assert(a == a);
|
||||
assert(a == b);
|
||||
assert(a != c);
|
||||
assert(b != c);
|
||||
assert(a != d);
|
||||
assert(b != d);
|
||||
assert(c != d);
|
||||
assert(d == d);
|
||||
}
|
||||
15
test/bug29.d
Normal file
15
test/bug29.d
Normal file
@@ -0,0 +1,15 @@
|
||||
module bug29;
|
||||
|
||||
void main()
|
||||
{
|
||||
int[] arr16 = new int[4];
|
||||
{
|
||||
void[] arr = arr16;
|
||||
{
|
||||
printf("%lu\n", arr.length);
|
||||
{
|
||||
assert(arr.length == 16);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
22
test/bug30.d
Normal file
22
test/bug30.d
Normal file
@@ -0,0 +1,22 @@
|
||||
module bug30;
|
||||
|
||||
void main()
|
||||
{
|
||||
int[] a = new int[4];
|
||||
{a[0] = 1;
|
||||
a[1] = 2;
|
||||
a[2] = 3;
|
||||
a[3] = 4;}
|
||||
int[] b = new int[4];
|
||||
{b[0] = 1;
|
||||
b[1] = 2;
|
||||
b[2] = 3;
|
||||
b[3] = 4;}
|
||||
int[] c = new int[4];
|
||||
{c[0] = 1;
|
||||
c[1] = 2;
|
||||
c[2] = 4;
|
||||
c[3] = 3;}
|
||||
{assert(a == b);}
|
||||
{assert(a != c);}
|
||||
}
|
||||
12
test/enum1.d
Normal file
12
test/enum1.d
Normal file
@@ -0,0 +1,12 @@
|
||||
module enum1;
|
||||
|
||||
void main()
|
||||
{
|
||||
enum {
|
||||
HELLO,
|
||||
WORLD
|
||||
}
|
||||
|
||||
assert(HELLO == 0);
|
||||
assert(WORLD == 1);
|
||||
}
|
||||
10
test/enum2.d
Normal file
10
test/enum2.d
Normal file
@@ -0,0 +1,10 @@
|
||||
module enum2;
|
||||
|
||||
void main()
|
||||
{
|
||||
enum E {
|
||||
A,B
|
||||
}
|
||||
E e = E.B;
|
||||
assert(e == E.B);
|
||||
}
|
||||
15
test/enum3.d
Normal file
15
test/enum3.d
Normal file
@@ -0,0 +1,15 @@
|
||||
module enum3;
|
||||
|
||||
enum GE : ushort
|
||||
{
|
||||
A,B,C
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
GE e = GE.B;
|
||||
size_t s = GE.sizeof;
|
||||
assert(e == 1);
|
||||
assert(e.sizeof == s);
|
||||
assert(s == 2);
|
||||
}
|
||||
@@ -8,8 +8,8 @@ struct S
|
||||
|
||||
void main()
|
||||
{
|
||||
S[4] arr;
|
||||
S[4] arr = void;
|
||||
foreach(i,v;arr) {
|
||||
v = S(i,i*2.5);
|
||||
v = S(i, i*2.5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,7 @@ module typeinfo;
|
||||
void main()
|
||||
{
|
||||
auto ti = typeid(int);
|
||||
char[] str = ti.toString();
|
||||
printf("%.*s\n", str.length, str.ptr);
|
||||
assert(str == "int");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user