Fix keyword parsing tests

This commit is contained in:
Vadim Petrochenkov 2016-04-24 21:35:50 +03:00
parent 9108fb7bae
commit 4bd44be369
36 changed files with 178 additions and 75 deletions

View File

@ -34,15 +34,17 @@ template = """// Copyright %d The Rust Project Developers. See the COPYRIGHT
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags: -Z parse-only
// This file was auto-generated using 'src/etc/generate-keyword-tests.py %s'
fn main() {
let %s = "foo"; //~ error: ident
let %s = "foo"; //~ error: expected pattern, found keyword `%s`
}
"""
test_dir = os.path.abspath(
os.path.join(os.path.dirname(__file__), '../test/compile-fail')
os.path.join(os.path.dirname(__file__), '../test/parse-fail')
)
for kw in sys.argv[1:]:
@ -53,7 +55,7 @@ for kw in sys.argv[1:]:
os.chmod(test_file, stat.S_IWUSR)
with open(test_file, 'wt') as f:
f.write(template % (datetime.datetime.now().year, kw, kw))
f.write(template % (datetime.datetime.now().year, kw, kw, kw))
# mark file read-only
os.chmod(test_file, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -8,10 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-test -- FIXME #33010
// This file was auto-generated using 'src/etc/generate-keyword-tests.py false'
fn main() {
let false = "foo"; //~ error: ident
let false = "foo"; //~ error: mismatched types
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -8,10 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-test -- FIXME #33010
// This file was auto-generated using 'src/etc/generate-keyword-tests.py true'
fn main() {
let true = "foo"; //~ error: ident
let true = "foo"; //~ error: mismatched types
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py as'
fn main() {
let as = "foo"; //~ error: ident
let as = "foo"; //~ error: expected pattern, found keyword `as`
}

View File

@ -0,0 +1,15 @@
// Copyright 2016 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 main() {
let box = "foo"; //~ error: expected pattern, found `=`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py break'
fn main() {
let break = "foo"; //~ error: ident
let break = "foo"; //~ error: expected pattern, found keyword `break`
}

View File

@ -0,0 +1,17 @@
// Copyright 2016 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
// This file was auto-generated using 'src/etc/generate-keyword-tests.py const'
fn main() {
let const = "foo"; //~ error: expected pattern, found keyword `const`
}

View File

@ -0,0 +1,17 @@
// Copyright 2016 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
// This file was auto-generated using 'src/etc/generate-keyword-tests.py continue'
fn main() {
let continue = "foo"; //~ error: expected pattern, found keyword `continue`
}

View File

@ -0,0 +1,17 @@
// Copyright 2016 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
// This file was auto-generated using 'src/etc/generate-keyword-tests.py crate'
fn main() {
let crate = "foo"; //~ error: expected pattern, found keyword `crate`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py else'
fn main() {
let else = "foo"; //~ error: ident
let else = "foo"; //~ error: expected pattern, found keyword `else`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py enum'
fn main() {
let enum = "foo"; //~ error: ident
let enum = "foo"; //~ error: expected pattern, found keyword `enum`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py extern'
fn main() {
let extern = "foo"; //~ error: ident
let extern = "foo"; //~ error: expected pattern, found keyword `extern`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py fn'
fn main() {
let fn = "foo"; //~ error: ident
let fn = "foo"; //~ error: expected pattern, found keyword `fn`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py for'
fn main() {
let for = "foo"; //~ error: ident
let for = "foo"; //~ error: expected pattern, found keyword `for`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py if'
fn main() {
let if = "foo"; //~ error: ident
let if = "foo"; //~ error: expected pattern, found keyword `if`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py impl'
fn main() {
let impl = "foo"; //~ error: ident
let impl = "foo"; //~ error: expected pattern, found keyword `impl`
}

View File

@ -0,0 +1,17 @@
// Copyright 2016 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
// This file was auto-generated using 'src/etc/generate-keyword-tests.py in'
fn main() {
let in = "foo"; //~ error: expected pattern, found keyword `in`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py let'
fn main() {
let let = "foo"; //~ error: ident
let let = "foo"; //~ error: expected pattern, found keyword `let`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py loop'
fn main() {
let loop = "foo"; //~ error: ident
let loop = "foo"; //~ error: expected pattern, found keyword `loop`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py match'
fn main() {
let match = "foo"; //~ error: ident
let match = "foo"; //~ error: expected pattern, found keyword `match`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py mod'
fn main() {
let mod = "foo"; //~ error: ident
let mod = "foo"; //~ error: expected pattern, found keyword `mod`
}

View File

@ -0,0 +1,17 @@
// Copyright 2016 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
// This file was auto-generated using 'src/etc/generate-keyword-tests.py move'
fn main() {
let move = "foo"; //~ error: expected pattern, found keyword `move`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// compile-flags: -Z parse-only
// This file was auto-generated using 'src/etc/generate-keyword-tests.py mut'
fn main() {
let mut = "foo"; //~ error: ident
let mut = "foo"; //~ error: expected identifier, found `=`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py pub'
fn main() {
let pub = "foo"; //~ error: ident
let pub = "foo"; //~ error: expected pattern, found keyword `pub`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// compile-flags: -Z parse-only
// This file was auto-generated using 'src/etc/generate-keyword-tests.py ref'
fn main() {
let ref = "foo"; //~ error: ident
let ref = "foo"; //~ error: expected identifier, found `=`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py return'
fn main() {
let return = "foo"; //~ error: ident
let return = "foo"; //~ error: expected pattern, found keyword `return`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// compile-flags: -Z parse-only
// This file was auto-generated using 'src/etc/generate-keyword-tests.py self'
fn main() {
let self = "foo"; //~ error: ident
let Self = "foo"; //~ error: expected identifier, found keyword `Self`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py static'
fn main() {
let static = "foo"; //~ error: ident
let static = "foo"; //~ error: expected pattern, found keyword `static`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py struct'
fn main() {
let struct = "foo"; //~ error: ident
let struct = "foo"; //~ error: expected pattern, found keyword `struct`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// compile-flags: -Z parse-only
// This file was auto-generated using 'src/etc/generate-keyword-tests.py super'
fn main() {
let super = "foo"; //~ error: ident
let super = "foo"; //~ error: expected identifier, found keyword `super`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py trait'
fn main() {
let trait = "foo"; //~ error: ident
let trait = "foo"; //~ error: expected pattern, found keyword `trait`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py type'
fn main() {
let type = "foo"; //~ error: ident
let type = "foo"; //~ error: expected pattern, found keyword `type`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py unsafe'
fn main() {
let unsafe = "foo"; //~ error: ident
let unsafe = "foo"; //~ error: expected pattern, found keyword `unsafe`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py use'
fn main() {
let use = "foo"; //~ error: ident
let use = "foo"; //~ error: expected pattern, found keyword `use`
}

View File

@ -0,0 +1,17 @@
// Copyright 2016 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
// This file was auto-generated using 'src/etc/generate-keyword-tests.py where'
fn main() {
let where = "foo"; //~ error: expected pattern, found keyword `where`
}

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -13,5 +13,5 @@
// This file was auto-generated using 'src/etc/generate-keyword-tests.py while'
fn main() {
let while = "foo"; //~ error: ident
let while = "foo"; //~ error: expected pattern, found keyword `while`
}