changeset 66:33346dff2640

extended invariant tests
author thomask
date Sat, 23 Oct 2004 10:09:46 +0000
parents e632533062c6
children ff32878c78da
files nocompile/invariant_16.d nocompile/invariant_17.d run/invariant_18.d
diffstat 3 files changed, 61 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nocompile/invariant_16.d	Sat Oct 23 10:09:46 2004 +0000
@@ -0,0 +1,24 @@
+// invariant is only allowed in classes (dmd-0.104 documentation)
+
+module dstress.nocompile.invariant_16;
+
+interface MyInterface{
+	private int check();
+	invariant{
+		assert(check()!=4);
+	}
+}
+class MyClass : MyInterface {
+	void test(){
+	}
+
+	private int check(){
+		return 4;
+	}
+}
+
+int main(){
+	Myclass c = new MyClass();
+	c.test();
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nocompile/invariant_17.d	Sat Oct 23 10:09:46 2004 +0000
@@ -0,0 +1,21 @@
+// invariant may not call non-static public class member functions (stack overflow)
+
+module dstress.nocompile.invariant_17;
+
+class MyClass{
+	this(){
+	}
+
+	int test(){
+		return 0;
+	}
+
+	invariant{
+		assert(test()!=0);
+	}
+}
+
+int main(){
+	MyClass c = new MyClass();
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/invariant_18.d	Sat Oct 23 10:09:46 2004 +0000
@@ -0,0 +1,16 @@
+module dstress.run.invariant_18;
+
+class MyClass{
+	invariant{
+		assert(0);
+	}
+}
+
+int main(){
+	try{
+		MyClass c = new MyClass();
+	}catch{
+		return 0;
+	}
+	assert(0);
+}