Add tests for newly introduced syntax
Also add some (regression) tests for discovered parser oddities
This commit is contained in:
parent
662082cb7e
commit
c1a238c4f5
6 changed files with 62 additions and 6 deletions
|
|
@ -17,8 +17,8 @@ fn main() {
|
|||
use std::boxed::HEAP;
|
||||
|
||||
let p: *const i32 = &42;
|
||||
let _ = in HEAP { *p }; //~ ERROR requires unsafe
|
||||
let _ = HEAP <- *p; //~ ERROR requires unsafe
|
||||
|
||||
let p: *const _ = &HEAP;
|
||||
let _ = in *p { 42 }; //~ ERROR requires unsafe
|
||||
let _ = *p <- 42; //~ ERROR requires unsafe
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ extern crate core;
|
|||
fn main() {
|
||||
use std::boxed::HEAP; //~ ERROR use of unstable library feature
|
||||
|
||||
let _ = in HEAP { //~ ERROR use of unstable library feature
|
||||
let _ = HEAP <- { //~ ERROR use of unstable library feature
|
||||
::core::raw::Slice { //~ ERROR use of unstable library feature
|
||||
data: &42, //~ ERROR use of unstable library feature
|
||||
len: 1 //~ ERROR use of unstable library feature
|
||||
|
|
|
|||
22
src/test/parse-fail/assoc-oddities-1.rs
Normal file
22
src/test/parse-fail/assoc-oddities-1.rs
Normal file
|
|
@ -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
|
||||
}
|
||||
16
src/test/parse-fail/assoc-oddities-2.rs
Normal file
16
src/test/parse-fail/assoc-oddities-2.rs
Normal file
|
|
@ -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
|
||||
}
|
||||
16
src/test/parse-fail/assoc-oddities-3.rs
Normal file
16
src/test/parse-fail/assoc-oddities-3.rs
Normal file
|
|
@ -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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue