From c880d0ab7688af2cf5ed547019c22e10d81f7cb4 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Thu, 27 Dec 2012 14:58:45 -0800 Subject: [PATCH] Add an xfailed test case and a CONTRIBUTING.md file --- CONTRIBUTING.md | 12 ++++++++++++ src/test/run-pass/recursion.rs | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 CONTRIBUTING.md create mode 100644 src/test/run-pass/recursion.rs diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000000..6528ffa134d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,12 @@ +## Pull request procedure + +Pull requests should be targeted at Rust's `incoming` branch (note that by default Github will aim them at the `master` branch) -- see "Changing The Commit Range and Destination Repository" in Github's documentation on [pull requests](https://help.github.com/articles/using-pull-requests). Before pushing to your Github repo and issuing the pull request, please do two things: + +1. [Rebase](http://git-scm.com/book/en/Git-Branching-Rebasing) your local changes against the `incoming` branch. Resolve any conflicts that arise. +2. Run the full Rust test suite with the `make check` command. You're not off the hook even if you just stick to documentation; code examples in the docs are tested as well! + +Pull requests will be treated as "review requests", and we will give feedback we expect to see corrected on [style](https://github.com/mozilla/rust/wiki/Note-style-guide) and substance before pulling. Changes contributed via pull request should focus on a single issue at a time, like any other. We will not look kindly on pull-requests that try to "sneak" unrelated changes in. + +Normally, all pull requests must include regression tests (see [[Note-testsuite]]) that test your change. Occasionally, a change will be very difficult to test for. In those cases, please include a note in your commit message explaining why. + +For more details, please refer to [[Note-development-policy]]. \ No newline at end of file diff --git a/src/test/run-pass/recursion.rs b/src/test/run-pass/recursion.rs new file mode 100644 index 00000000000..8cc2c8cc80a --- /dev/null +++ b/src/test/run-pass/recursion.rs @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// xfail-test +enum Nil {Nil} +struct Cons {head:int, tail:T} +trait Dot {fn dot(other:self) -> int;} +impl Nil:Dot { + fn dot(_:Nil) -> int {0} +} +impl Cons:Dot { + fn dot(other:Cons) -> int { + self.head * other.head + self.tail.dot(other.tail) + } +} +fn test (n:int, i:int, first:T, second:T) ->int { + match n { + 0 => {first.dot(second)} + // Error message should be here. It should be a type error + // to instantiate `test` at a type other than T. (See #4287) + _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})} + } +} +fn main() { + let n = test(1, 0, Nil, Nil); + io::println(fmt!("%d", n)); +}