about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2015-05-28 15:20:32 -0400
committerNiko Matsakis <niko@alum.mit.edu>2015-05-29 09:42:54 -0400
commit1f29fd4eb0eefc6df81e6b4c77cf6d48678e7563 (patch)
tree096162ed4f481b2469b1c1b90dcc2ac86cbb55a7
parent57c75b6b10c329ed1c9c1957e98a990dd04608f2 (diff)
downloadrust-1f29fd4eb0eefc6df81e6b4c77cf6d48678e7563.tar.gz
rust-1f29fd4eb0eefc6df81e6b4c77cf6d48678e7563.zip
add a test for const fn methods, as suggested by @pnkfelix
-rw-r--r--src/test/run-pass/const-fn-method.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/run-pass/const-fn-method.rs b/src/test/run-pass/const-fn-method.rs
new file mode 100644
index 00000000000..dc02758fe50
--- /dev/null
+++ b/src/test/run-pass/const-fn-method.rs
@@ -0,0 +1,25 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(const_fn)]
+
+struct Foo { val: u32 }
+
+impl Foo {
+    const fn new() -> Foo {
+        Foo { value: 22 }
+    }
+}
+
+const FOO: Foo = Foo::new();
+
+pub fn main() {
+    assert_eq!(FOO.value, 22);
+}