changeset 585:01940e31c0f1

misplaced initialisers in static rectangular array Stewart Gordon <smjg_1998@yahoo.com> 2005-06-14 news:d8m7rs$mtv$2@digitaldaemon.com
author thomask
date Sat, 18 Jun 2005 08:27:57 +0000
parents 132fb528f935
children 32c5d683df56
files run/a/array_initialization_17_A.d run/a/array_initialization_17_B.d run/a/array_initialization_17_C.d
diffstat 3 files changed, 113 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/a/array_initialization_17_A.d	Sat Jun 18 08:27:57 2005 +0000
@@ -0,0 +1,33 @@
+// $HeadURL$
+// $Date$
+// $Author$
+
+// @author@	Stewart Gordon <smjg_1998@yahoo.com>
+// @date@	20005-06-14
+// @uri@	news:d8m7rs$mtv$2@digitaldaemon.com
+// @desc@	misplaced initialisers in static rectangular array
+
+module dstress.run.a.array_initialization_17_A;
+
+const char[3][13] month = [
+	1: "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+	8: "Aug", "Sep", "Oct", "Nov", "Dec"
+];
+
+
+int main(){	
+	assert(month[1]=="Jan");
+	assert(month[6]=="Jun");
+	assert(month[8]=="Aug");
+	assert(month[12]=="Dec");
+
+	foreach(char c; month[0]){
+		assert(c==char.init);
+	}
+
+	foreach(char c; month[7]){
+		assert(c==char.init);
+	}
+
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/a/array_initialization_17_B.d	Sat Jun 18 08:27:57 2005 +0000
@@ -0,0 +1,40 @@
+// $HeadURL$
+// $Date$
+// $Author$
+
+// @author@	Stewart Gordon <smjg_1998@yahoo.com>
+// @date@	20005-06-14
+// @uri@	news:d8m7rs$mtv$2@digitaldaemon.com
+// @desc@	misplaced initialisers in static rectangular array
+
+module dstress.run.a.array_initialization_17_B;
+
+const float[6] arr = [
+	1: 1.0f, 2.0f,
+	4: 4.0f
+];
+
+bit equal(float a, float b){
+	byte* aa = cast(byte*) &a;
+	byte* bb = cast(byte*) &b;
+
+	for(int index=0; index<a.sizeof; index++){
+		if(*aa != *bb)
+			return false;
+		aa++;
+		bb++;
+	}
+
+	return true;
+}
+
+int main(){	
+	assert(equal(arr[0], float.nan));
+	assert(arr[1]==1.0f);
+	assert(arr[2]==2.0f);
+	assert(equal(arr[3], float.nan));
+	assert(arr[4]==4.0f);
+	assert(equal(arr[5], float.nan));
+
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/a/array_initialization_17_C.d	Sat Jun 18 08:27:57 2005 +0000
@@ -0,0 +1,40 @@
+// $HeadURL$
+// $Date$
+// $Author$
+
+// @author@	Stewart Gordon <smjg_1998@yahoo.com>
+// @date@	20005-06-14
+// @uri@	news:d8m7rs$mtv$2@digitaldaemon.com
+// @desc@	misplaced initialisers in static rectangular array
+
+module dstress.run.a.array_initialization_17_C;
+
+const cfloat[6] arr = [
+	1: 1.0f, 2.0f,
+	4: 4.0f
+];
+
+bit equal(cfloat a, cfloat b){
+	byte* aa = cast(byte*) &a;
+	byte* bb = cast(byte*) &b;
+
+	for(int index=0; index<a.sizeof; index++){
+		if(*aa != *bb)
+			return false;
+		aa++;
+		bb++;
+	}
+
+	return true;
+}
+
+int main(){	
+	assert(equal(arr[0], cfloat.nan));
+	assert(arr[1]==1.0f);
+	assert(arr[2]==2.0f);
+	assert(equal(arr[3], cfloat.nan));
+	assert(arr[4]==4.0f);
+	assert(equal(arr[5], cfloat.nan));
+
+	return 0;
+}