about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-09-06 23:35:57 -0700
committerbors <bors@rust-lang.org>2013-09-06 23:35:57 -0700
commit124eb2119c78651cfaaa7a046a101fa2e20f83ca (patch)
tree7efa84a80df29080ae0314d0e3788131c72bdceb /src/test
parent3e6de6b7da8ee88bf84b0e217900051334be08da (diff)
parentb6f3d3f24546a525d1eb80923692c1296eddc4dc (diff)
downloadrust-124eb2119c78651cfaaa7a046a101fa2e20f83ca.tar.gz
rust-124eb2119c78651cfaaa7a046a101fa2e20f83ca.zip
auto merge of #9026 : jbclements/rust/let-var-hygiene, r=jbclements
This is a rebase of my approved pull request from ... the end of June? It introduces hygiene for let-bound variables.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/bench/core-std.rs16
-rw-r--r--src/test/run-pass/hygiene-dodging-1.rs21
-rw-r--r--src/test/run-pass/let-var-hygiene.rs16
-rw-r--r--src/test/run-pass/syntax-extension-minor.rs3
4 files changed, 48 insertions, 8 deletions
diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs
index 6735d623e6c..5bfef47902b 100644
--- a/src/test/bench/core-std.rs
+++ b/src/test/bench/core-std.rs
@@ -22,20 +22,20 @@ use std::util;
 use std::vec;
 
 macro_rules! bench (
-    ($id:ident) => (maybe_run_test(argv, stringify!($id).to_owned(), $id))
+    ($argv:expr, $id:ident) => (maybe_run_test($argv, stringify!($id).to_owned(), $id))
 )
 
 fn main() {
     let argv = os::args();
     let _tests = argv.slice(1, argv.len());
 
-    bench!(shift_push);
-    bench!(read_line);
-    bench!(vec_plus);
-    bench!(vec_append);
-    bench!(vec_push_all);
-    bench!(is_utf8_ascii);
-    bench!(is_utf8_multibyte);
+    bench!(argv, shift_push);
+    bench!(argv, read_line);
+    bench!(argv, vec_plus);
+    bench!(argv, vec_append);
+    bench!(argv, vec_push_all);
+    bench!(argv, is_utf8_ascii);
+    bench!(argv, is_utf8_multibyte);
 }
 
 fn maybe_run_test(argv: &[~str], name: ~str, test: &fn()) {
diff --git a/src/test/run-pass/hygiene-dodging-1.rs b/src/test/run-pass/hygiene-dodging-1.rs
new file mode 100644
index 00000000000..55e15cc02dd
--- /dev/null
+++ b/src/test/run-pass/hygiene-dodging-1.rs
@@ -0,0 +1,21 @@
+// Copyright 2012 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.
+
+mod x {
+    pub fn g() -> uint {14}
+}
+
+fn main(){
+    // should *not* shadow the module x:
+    let x = 9;
+    // use it to avoid warnings:
+    x+3;
+    assert_eq!(x::g(),14);
+}
diff --git a/src/test/run-pass/let-var-hygiene.rs b/src/test/run-pass/let-var-hygiene.rs
new file mode 100644
index 00000000000..1e29d2e8969
--- /dev/null
+++ b/src/test/run-pass/let-var-hygiene.rs
@@ -0,0 +1,16 @@
+// Copyright 2012 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.
+
+// shouldn't affect evaluation of $ex:
+macro_rules! bad_macro (($ex:expr) => ({let _x = 9; $ex}))
+fn main() {
+    let _x = 8;
+    assert_eq!(bad_macro!(_x),8)
+}
diff --git a/src/test/run-pass/syntax-extension-minor.rs b/src/test/run-pass/syntax-extension-minor.rs
index 819bcbf53f5..60294e6f21e 100644
--- a/src/test/run-pass/syntax-extension-minor.rs
+++ b/src/test/run-pass/syntax-extension-minor.rs
@@ -8,6 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// xfail-test
+// this now fails (correctly, I claim) because hygiene prevents
+// the assembled identifier from being a reference to the binding.
 
 pub fn main() {
     let asdf_fdsa = ~"<.<";