diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-05-07 14:51:57 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-05-07 14:51:57 +0800 |
commit | ecc745aec490518b1264fece8b5ab9c1aab8fadf (patch) | |
tree | 340167d5a691493a7b2d5567c7cfce80ded14671 | |
parent | e52d4d40a56f84ca4541154633a7508b0cc12a42 (diff) | |
download | mrust-ecc745aec490518b1264fece8b5ab9c1aab8fadf.tar.gz |
Tests - add a small set of tests that cover places rustc's don't
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | samples/test/for_underscore_drop.rs | 18 | ||||
-rw-r--r-- | samples/test/scoping_rules.rs | 21 |
3 files changed, 41 insertions, 2 deletions
@@ -342,7 +342,7 @@ output/local_test/%_out.txt: output/local_test/% ./$< > $@ output/local_test/%: samples/test/%.rs $(BIN) mkdir -p $(dir $@) - $(BIN) -L output/libs -g $< -o $@ $(PIPECMD) + $(BIN) -L output/libs -g $< -o $@ --test $(PIPECMD) # # RUSTC TESTS @@ -379,7 +379,7 @@ DISABLED_TESTS += run-pass/empty-struct-braces # Empty struct support DISABLED_TESTS += run-pass/explicit-self-generic # Tries to use HashMap as an iterator DISABLED_TESTS += run-pass/extern-compare-with-return-type # Specialisation with function pointers DISABLED_TESTS += run-pass/issue-14399 # Inferrence ran though a coercion point. -DISABLED_TESTS += run-pass/issue-26709 # ^ +#DISABLED_TESTS += run-pass/issue-26709 # ^ DISABLED_TESTS += run-pass/issue-20797 # Failed to find impl with associated type, possible incorrect coerce? DISABLED_TESTS += run-pass/issue-21245 # IntoIterator on core::slice::Iterator ? DISABLED_TESTS += run-pass/issue-21486 # Type mismatch diff --git a/samples/test/for_underscore_drop.rs b/samples/test/for_underscore_drop.rs new file mode 100644 index 00000000..e590fee0 --- /dev/null +++ b/samples/test/for_underscore_drop.rs @@ -0,0 +1,18 @@ + +struct DropFlag<'a>(&'a mut i32); +impl<'a> ::std::ops::Drop for DropFlag<'a> +{ + fn drop(&mut self) { + *self.0 += 1; + } +} + +#[test] +fn values_in_for_loop_dropped() +{ + let mut foo = 0; + for _ in Some(DropFlag(&mut foo)) + { + } + assert_eq!(foo, 1); +} diff --git a/samples/test/scoping_rules.rs b/samples/test/scoping_rules.rs new file mode 100644 index 00000000..9878fd16 --- /dev/null +++ b/samples/test/scoping_rules.rs @@ -0,0 +1,21 @@ + +struct DropFlag<'a>(&'a ::std::cell::Cell<i32>); +impl<'a> ::std::ops::Drop for DropFlag<'a> +{ + fn drop(&mut self) { + self.0.set( self.0.get() + 1 ); + } +} + +// Any temporaries defined in the expression part of a statement (i.e. in the yeilded part of a +// block) are stored in the parent scope. +#[test] +fn temporaries_in_yielded_expr() +{ + let drop_count = ::std::cell::Cell::new(0); + let _foo = ({ DropFlag(&drop_count).0 }, assert_eq!(drop_count.get(), 0) ); + drop(_foo); + assert_eq!(drop_count.get(), 1); +} + + |