changeset 16:0fcca61f008f

added "with" tests
author unknown
date Fri, 08 Oct 2004 07:38:21 +0000
parents fa94281987cf
children deb014248067
files nocompile/with_05.d nocompile/with_06.d nocompile/with_07.d run/with_04.d run/with_08.d run/with_09.d run/with_10.d
diffstat 7 files changed, 129 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nocompile/with_05.d	Fri Oct 08 07:38:21 2004 +0000
@@ -0,0 +1,14 @@
+class MyClass{
+	void test(){
+		byte b;
+		with(b){
+			assert(0);
+		}
+	}
+}
+
+int main(){
+	MyClass c = new MyClass();
+	c.test();
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nocompile/with_06.d	Fri Oct 08 07:38:21 2004 +0000
@@ -0,0 +1,14 @@
+class MyClass{
+	void test(){
+		char[] c="Inhalt";
+		with(c){
+			assert(0);
+		}
+	}
+}
+
+int main(){
+	MyClass c = new MyClass();
+	c.test();
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nocompile/with_07.d	Fri Oct 08 07:38:21 2004 +0000
@@ -0,0 +1,16 @@
+class MyClass{
+	int test(){
+		return 3;
+	}
+}
+
+int test(){
+	return 5;
+}
+
+int main(){
+	with(new MyClass()):
+		assert(test()==3);
+	
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/with_04.d	Fri Oct 08 07:38:21 2004 +0000
@@ -0,0 +1,30 @@
+Child dummySuper;
+
+int value=1;
+
+class Parent{
+	int value=2;
+}
+
+class Child : Parent{
+	int value=3;
+}
+
+class GrandChild :  Child {
+	int value=4;
+	
+	void test(){
+		dummySuper=super;
+		value=5;
+		with(new Child()){
+			assert(value==3);
+			assert(super==dummySuper);
+		}
+	}	
+}
+
+int main(){
+	GrandChild c = new GrandChild();
+	c.test();
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/with_08.d	Fri Oct 08 07:38:21 2004 +0000
@@ -0,0 +1,16 @@
+class MyClass{
+	int test(){
+		return 3;
+	}
+}
+
+int test(){
+	return 5;
+}
+
+int main(){
+	with(new MyClass()){
+		assert(test()==3);
+	}
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/with_09.d	Fri Oct 08 07:38:21 2004 +0000
@@ -0,0 +1,17 @@
+struct MyStruct{
+	int test(){
+		return 3;
+	}
+}
+
+int test(){
+	return 5;
+}
+
+int main(){
+	MyStruct myStruct;
+	with(myStruct){
+		assert(test()==3);
+	}
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/with_10.d	Fri Oct 08 07:38:21 2004 +0000
@@ -0,0 +1,22 @@
+MyClass dummyThis;
+
+int value=1;
+
+class MyClass{
+	int value=2;
+	
+	void test(){
+		dummyThis=this;
+		value=3;
+		with(new MyClass()){
+			assert(value==2);
+			assert(this==dummyThis);
+		}
+	}	
+}
+
+int main(){
+	MyClass c = new MyClass();
+	c.test();
+	return 0;
+}