about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2012-03-28 10:31:14 -0700
committerTim Chevalier <chevalier@alum.wellesley.edu>2012-03-28 10:38:57 -0700
commit52f2a9a1c9fe705aa4ef5a4d7d7d4018b40b1f3a (patch)
tree28447102541d3526e1110cdf018bedb2d702f8ba
parent90cf9e0d6ff9c7788939ee100db6de9faeff3734 (diff)
downloadrust-52f2a9a1c9fe705aa4ef5a4d7d7d4018b40b1f3a.tar.gz
rust-52f2a9a1c9fe705aa4ef5a4d7d7d4018b40b1f3a.zip
Test case to make sure typestate checks the body of class constructors
-rw-r--r--src/test/compile-fail/ctor-uninit-var.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/compile-fail/ctor-uninit-var.rs b/src/test/compile-fail/ctor-uninit-var.rs
new file mode 100644
index 00000000000..b2af5e48f01
--- /dev/null
+++ b/src/test/compile-fail/ctor-uninit-var.rs
@@ -0,0 +1,23 @@
+// error-pattern:unsatisfied precondition
+class cat {
+  priv {
+    let mutable meows : uint;
+  }
+
+  let how_hungry : int;
+
+  fn eat() {
+    how_hungry -= 5;
+  }
+
+  new(in_x : uint, in_y : int) {
+    let foo;
+    meows = in_x + (in_y as uint);
+    how_hungry = foo;
+  }
+}
+
+fn main() {
+  let nyan : cat = cat(52u, 99);
+  nyan.eat();
+}