From e1be69b8a97d48d579b5474907aab9199d1b8ab7 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 3 Apr 2015 05:56:27 +0300 Subject: Add tests for parsing of patterns --- src/test/parse-fail/pat-lt-bracket-1.rs | 17 +++++++++++++++++ src/test/parse-fail/pat-lt-bracket-2.rs | 12 ++++++++++++ src/test/parse-fail/pat-lt-bracket-3.rs | 22 ++++++++++++++++++++++ src/test/parse-fail/pat-lt-bracket-4.rs | 21 +++++++++++++++++++++ src/test/parse-fail/pat-lt-bracket-5.rs | 13 +++++++++++++ src/test/parse-fail/pat-lt-bracket-6.rs | 13 +++++++++++++ src/test/parse-fail/pat-lt-bracket-7.rs | 13 +++++++++++++ src/test/parse-fail/pat-ranges-1.rs | 15 +++++++++++++++ src/test/parse-fail/pat-ranges-2.rs | 15 +++++++++++++++ src/test/parse-fail/pat-ranges-3.rs | 15 +++++++++++++++ src/test/parse-fail/pat-ranges-4.rs | 15 +++++++++++++++ 11 files changed, 171 insertions(+) create mode 100644 src/test/parse-fail/pat-lt-bracket-1.rs create mode 100644 src/test/parse-fail/pat-lt-bracket-2.rs create mode 100644 src/test/parse-fail/pat-lt-bracket-3.rs create mode 100644 src/test/parse-fail/pat-lt-bracket-4.rs create mode 100644 src/test/parse-fail/pat-lt-bracket-5.rs create mode 100644 src/test/parse-fail/pat-lt-bracket-6.rs create mode 100644 src/test/parse-fail/pat-lt-bracket-7.rs create mode 100644 src/test/parse-fail/pat-ranges-1.rs create mode 100644 src/test/parse-fail/pat-ranges-2.rs create mode 100644 src/test/parse-fail/pat-ranges-3.rs create mode 100644 src/test/parse-fail/pat-ranges-4.rs (limited to 'src/test/parse-fail') diff --git a/src/test/parse-fail/pat-lt-bracket-1.rs b/src/test/parse-fail/pat-lt-bracket-1.rs new file mode 100644 index 00000000000..6d3d1207788 --- /dev/null +++ b/src/test/parse-fail/pat-lt-bracket-1.rs @@ -0,0 +1,17 @@ +// Copyright 2015 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. + +fn main() { + match 42 { + x < 7 => (), + //~^ error: expected one of `=>`, `@`, `if`, or `|`, found `<` + _ => () + } +} diff --git a/src/test/parse-fail/pat-lt-bracket-2.rs b/src/test/parse-fail/pat-lt-bracket-2.rs new file mode 100644 index 00000000000..6a0653041d4 --- /dev/null +++ b/src/test/parse-fail/pat-lt-bracket-2.rs @@ -0,0 +1,12 @@ +// Copyright 2015 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. + +fn a(B<) {} + //~^ error: expected one of `:` or `@`, found `<` diff --git a/src/test/parse-fail/pat-lt-bracket-3.rs b/src/test/parse-fail/pat-lt-bracket-3.rs new file mode 100644 index 00000000000..8ea2bcf900c --- /dev/null +++ b/src/test/parse-fail/pat-lt-bracket-3.rs @@ -0,0 +1,22 @@ +// Copyright 2015 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. + +struct Foo(T, T); + +impl Foo { + fn foo(&self) { + match *self { + Foo(x, y) => { + //~^ error: expected one of `=>`, `@`, `if`, or `|`, found `<` + println!("Goodbye, World!") + } + } + } +} diff --git a/src/test/parse-fail/pat-lt-bracket-4.rs b/src/test/parse-fail/pat-lt-bracket-4.rs new file mode 100644 index 00000000000..3d9b492307a --- /dev/null +++ b/src/test/parse-fail/pat-lt-bracket-4.rs @@ -0,0 +1,21 @@ +// Copyright 2015 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. + +enum BtNode { + Node(u32,Box,Box), + Leaf(u32), +} + +fn main() { + let y = match x { + Foo::A(value) => value, //~ error: expected one of `=>`, `@`, `if`, or `|`, found `<` + Foo::B => 7, + }; +} diff --git a/src/test/parse-fail/pat-lt-bracket-5.rs b/src/test/parse-fail/pat-lt-bracket-5.rs new file mode 100644 index 00000000000..3345845eee9 --- /dev/null +++ b/src/test/parse-fail/pat-lt-bracket-5.rs @@ -0,0 +1,13 @@ +// Copyright 2015 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. + +fn main() { + let v[0] = v[1]; //~ error: expected one of `:`, `;`, `=`, or `@`, found `[` +} diff --git a/src/test/parse-fail/pat-lt-bracket-6.rs b/src/test/parse-fail/pat-lt-bracket-6.rs new file mode 100644 index 00000000000..72fdae82260 --- /dev/null +++ b/src/test/parse-fail/pat-lt-bracket-6.rs @@ -0,0 +1,13 @@ +// Copyright 2015 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. + +fn main() { + let Test(&desc[..]) = x; //~ error: expected one of `,` or `@`, found `[` +} diff --git a/src/test/parse-fail/pat-lt-bracket-7.rs b/src/test/parse-fail/pat-lt-bracket-7.rs new file mode 100644 index 00000000000..c7731d156ad --- /dev/null +++ b/src/test/parse-fail/pat-lt-bracket-7.rs @@ -0,0 +1,13 @@ +// Copyright 2015 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. + +fn main() { + for thing(x[]) {} //~ error: expected one of `,` or `@`, found `[` +} diff --git a/src/test/parse-fail/pat-ranges-1.rs b/src/test/parse-fail/pat-ranges-1.rs new file mode 100644 index 00000000000..e1cbb961b1b --- /dev/null +++ b/src/test/parse-fail/pat-ranges-1.rs @@ -0,0 +1,15 @@ +// Copyright 2015 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. + +// Parsing of range patterns + +fn main() { + let macropus!() ... 11 = 12; //~ error: expected one of `:`, `;`, or `=`, found `...` +} diff --git a/src/test/parse-fail/pat-ranges-2.rs b/src/test/parse-fail/pat-ranges-2.rs new file mode 100644 index 00000000000..04ad5ff083b --- /dev/null +++ b/src/test/parse-fail/pat-ranges-2.rs @@ -0,0 +1,15 @@ +// Copyright 2015 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. + +// Parsing of range patterns + +fn main() { + let 10 ... makropulos!() = 12; //~ error: expected one of `::`, `:`, `;`, or `=`, found `!` +} diff --git a/src/test/parse-fail/pat-ranges-3.rs b/src/test/parse-fail/pat-ranges-3.rs new file mode 100644 index 00000000000..5f7aac71d29 --- /dev/null +++ b/src/test/parse-fail/pat-ranges-3.rs @@ -0,0 +1,15 @@ +// Copyright 2015 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. + +// Parsing of range patterns + +fn main() { + let 10 ... 10 + 3 = 12; //~ expected one of `:`, `;`, or `=`, found `+` +} diff --git a/src/test/parse-fail/pat-ranges-4.rs b/src/test/parse-fail/pat-ranges-4.rs new file mode 100644 index 00000000000..50dcb899527 --- /dev/null +++ b/src/test/parse-fail/pat-ranges-4.rs @@ -0,0 +1,15 @@ +// Copyright 2015 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. + +// Parsing of range patterns + +fn main() { + let 10 - 3 ... 10 = 8; //~ error: expected one of `...`, `:`, `;`, or `=`, found `-` +} -- cgit 1.4.1-3-g733a5