summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorLuqman Aden <me@luqman.ca>2014-07-29 12:35:38 -0700
committerLuqman Aden <me@luqman.ca>2014-08-11 19:20:10 -0700
commitd3028138889d8eb2aaa3dce899d556f8bbf04d13 (patch)
treef7ea02b97f9cb08a2c73b666ce6faae9ed088f29 /src
parent68cbd6c9294cadd7ff868be0bd756fcde84d757d (diff)
downloadrust-d3028138889d8eb2aaa3dce899d556f8bbf04d13.tar.gz
rust-d3028138889d8eb2aaa3dce899d556f8bbf04d13.zip
Reenable ignored test and add run-pass test.
Diffstat (limited to 'src')
-rw-r--r--src/libserialize/json.rs1
-rw-r--r--src/test/run-pass/issue-15763.rs96
2 files changed, 96 insertions, 1 deletions
diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs
index 58d69e38cc6..51b8985e655 100644
--- a/src/libserialize/json.rs
+++ b/src/libserialize/json.rs
@@ -2800,7 +2800,6 @@ mod tests {
         }
     }
     #[test]
-    #[ignore] // FIXME(#15763)
     fn test_decode_errors_struct() {
         check_err::<DecodeStruct>("[]", ExpectedError("Object".to_string(), "[]".to_string()));
         check_err::<DecodeStruct>("{\"x\": true, \"y\": true, \"z\": \"\", \"w\": []}",
diff --git a/src/test/run-pass/issue-15763.rs b/src/test/run-pass/issue-15763.rs
new file mode 100644
index 00000000000..6e3599bda14
--- /dev/null
+++ b/src/test/run-pass/issue-15763.rs
@@ -0,0 +1,96 @@
+// Copyright 2014 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.
+
+
+#[deriving(PartialEq, Show)]
+struct Bar {
+    x: int
+}
+impl Drop for Bar {
+    fn drop(&mut self) {
+        assert_eq!(self.x, 22);
+    }
+}
+
+#[deriving(PartialEq, Show)]
+struct Foo {
+    x: Bar,
+    a: int
+}
+
+fn foo() -> Result<Foo, int> {
+    return Ok(Foo {
+        x: Bar { x: 22 },
+        a: return Err(32)
+    });
+}
+
+fn baz() -> Result<Foo, int> {
+    Ok(Foo {
+        x: Bar { x: 22 },
+        a: return Err(32)
+    })
+}
+
+// explicit immediate return
+fn aa() -> int {
+    return 3;
+}
+
+// implicit immediate return
+fn bb() -> int {
+    3
+}
+
+// implicit outptr return
+fn cc() -> Result<int, int> {
+    Ok(3)
+}
+
+// explicit outptr return
+fn dd() -> Result<int, int> {
+    return Ok(3);
+}
+
+trait A {
+    fn aaa(self) -> int {
+        3
+    }
+    fn bbb(self) -> int {
+        return 3;
+    }
+    fn ccc(self) -> Result<int, int> {
+        Ok(3)
+    }
+    fn ddd(self) -> Result<int, int> {
+        return Ok(3);
+    }
+}
+
+impl A for int {}
+
+fn main() {
+    assert_eq!(foo(), Err(32));
+    assert_eq!(baz(), Err(32));
+
+    assert_eq!(aa(), 3);
+    assert_eq!(bb(), 3);
+    assert_eq!(cc().unwrap(), 3);
+    assert_eq!(dd().unwrap(), 3);
+
+    let i = box 32i as Box<A>;
+    assert_eq!(i.aaa(), 3);
+    let i = box 32i as Box<A>;
+    assert_eq!(i.bbb(), 3);
+    let i = box 32i as Box<A>;
+    assert_eq!(i.ccc().unwrap(), 3);
+    let i = box 32i as Box<A>;
+    assert_eq!(i.ddd().unwrap(), 3);
+}