about summary refs log tree commit diff
path: root/src/test/parse-fail
diff options
context:
space:
mode:
authorSimonas Kazlauskas <git@kazlauskas.me>2015-10-17 00:06:25 +0300
committerSimonas Kazlauskas <git@kazlauskas.me>2015-10-27 21:55:10 +0200
commitc1a238c4f53145a2fe3820d869cbdaa26a128307 (patch)
tree85bc9609066c18b0f7b13ddfaa6e0cf4eb6c79fb /src/test/parse-fail
parent662082cb7ec48d05aa40a9b176d46f49704c9127 (diff)
downloadrust-c1a238c4f53145a2fe3820d869cbdaa26a128307.tar.gz
rust-c1a238c4f53145a2fe3820d869cbdaa26a128307.zip
Add tests for newly introduced syntax
Also add some (regression) tests for discovered parser oddities
Diffstat (limited to 'src/test/parse-fail')
-rw-r--r--src/test/parse-fail/assoc-oddities-1.rs22
-rw-r--r--src/test/parse-fail/assoc-oddities-2.rs16
-rw-r--r--src/test/parse-fail/assoc-oddities-3.rs16
3 files changed, 54 insertions, 0 deletions
diff --git a/src/test/parse-fail/assoc-oddities-1.rs b/src/test/parse-fail/assoc-oddities-1.rs
new file mode 100644
index 00000000000..5c0c47de58a
--- /dev/null
+++ b/src/test/parse-fail/assoc-oddities-1.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 <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.
+
+// compile-flags: -Z parse-only
+
+fn that_odd_parse() {
+    // following lines below parse and must not fail
+    x = if c { a } else { b }();
+    x <- if c { a } else { b }[n];
+    x = if true { 1 } else { 0 } as *mut _;
+    // however this does not parse and probably should fail to retain compat?
+    // NB: `..` here is arbitrary, failure happens/should happen ∀ops that aren’t `=` or `<-`
+    // see assoc-oddities-2 and assoc-oddities-3
+    ..if c { a } else { b }[n]; //~ ERROR expected one of
+}
diff --git a/src/test/parse-fail/assoc-oddities-2.rs b/src/test/parse-fail/assoc-oddities-2.rs
new file mode 100644
index 00000000000..5679328edc9
--- /dev/null
+++ b/src/test/parse-fail/assoc-oddities-2.rs
@@ -0,0 +1,16 @@
+// 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 <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.
+
+// compile-flags: -Z parse-only
+
+fn that_odd_parse() {
+    // see assoc-oddities-1 for explanation
+    x..if c { a } else { b }[n]; //~ ERROR expected one of
+}
diff --git a/src/test/parse-fail/assoc-oddities-3.rs b/src/test/parse-fail/assoc-oddities-3.rs
new file mode 100644
index 00000000000..0d4f21f0dca
--- /dev/null
+++ b/src/test/parse-fail/assoc-oddities-3.rs
@@ -0,0 +1,16 @@
+// 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 <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.
+
+// compile-flags: -Z parse-only
+
+fn that_odd_parse() {
+    // see assoc-oddities-1 for explanation
+    x + if c { a } else { b }[n]; //~ ERROR expected one of
+}