Skip to content

Commit

Permalink
Fix keyword parsing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Apr 24, 2016
1 parent 9108fb7 commit 4bd44be
Show file tree
Hide file tree
Showing 36 changed files with 178 additions and 75 deletions.
8 changes: 5 additions & 3 deletions src/etc/generate-keyword-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@
// 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:]:
Expand All @@ -53,7 +55,7 @@
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)
8 changes: 2 additions & 6 deletions src/test/compile-fail/keyword-false-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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
}
8 changes: 2 additions & 6 deletions src/test/compile-fail/keyword-true-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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
}
4 changes: 2 additions & 2 deletions src/test/parse-fail/keyword-as-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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`
}
15 changes: 15 additions & 0 deletions src/test/parse-fail/keyword-box-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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 `=`
}
4 changes: 2 additions & 2 deletions src/test/parse-fail/keyword-break-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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`
}
17 changes: 17 additions & 0 deletions src/test/parse-fail/keyword-const-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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`
}
17 changes: 17 additions & 0 deletions src/test/parse-fail/keyword-continue-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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`
}
17 changes: 17 additions & 0 deletions src/test/parse-fail/keyword-crate-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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`
}
4 changes: 2 additions & 2 deletions src/test/parse-fail/keyword-else-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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`
}
4 changes: 2 additions & 2 deletions src/test/parse-fail/keyword-enum-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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`
}
4 changes: 2 additions & 2 deletions src/test/parse-fail/keyword-extern-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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`
}
4 changes: 2 additions & 2 deletions src/test/parse-fail/keyword-fn-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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`
}
4 changes: 2 additions & 2 deletions src/test/parse-fail/keyword-for-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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`
}
4 changes: 2 additions & 2 deletions src/test/parse-fail/keyword-if-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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`
}
4 changes: 2 additions & 2 deletions src/test/parse-fail/keyword-impl-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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`
}
17 changes: 17 additions & 0 deletions src/test/parse-fail/keyword-in-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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`
}
4 changes: 2 additions & 2 deletions src/test/parse-fail/keyword-let-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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`
}
4 changes: 2 additions & 2 deletions src/test/parse-fail/keyword-loop-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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`
}
4 changes: 2 additions & 2 deletions src/test/parse-fail/keyword-match-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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`
}
4 changes: 2 additions & 2 deletions src/test/parse-fail/keyword-mod-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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`
}
17 changes: 17 additions & 0 deletions src/test/parse-fail/keyword-move-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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`
}
6 changes: 2 additions & 4 deletions src/test/parse-fail/keyword-mut-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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 `=`
}
4 changes: 2 additions & 2 deletions src/test/parse-fail/keyword-pub-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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`
}
6 changes: 2 additions & 4 deletions src/test/parse-fail/keyword-ref-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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 `=`
}
4 changes: 2 additions & 2 deletions src/test/parse-fail/keyword-return-as-identifier.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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`
}
Loading

0 comments on commit 4bd44be

Please sign in to comment.