Skip to content

Commit

Permalink
Auto merge of rust-lang#1134 - RalfJung:macos-hashmap, r=RalfJung
Browse files Browse the repository at this point in the history
test macOS hashmap

With rust-lang#1130 landed, this should work now. Thanks @christianpoveda!

Fixes rust-lang#686
  • Loading branch information
bors committed Dec 31, 2019
2 parents 39146c4 + 31fbb5a commit 86d7db4
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions tests/run-pass/hashmap.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use std::collections::{self, HashMap};
use std::hash::{BuildHasherDefault, BuildHasher};
// macOS needs FS access for its HashMap:
// compile-flags: -Zmiri-disable-isolation

use std::collections::HashMap;
use std::hash::BuildHasher;

fn test_map<S: BuildHasher>(mut map: HashMap<i32, i32, S>) {
map.insert(0, 0);
Expand All @@ -18,14 +21,8 @@ fn test_map<S: BuildHasher>(mut map: HashMap<i32, i32, S>) {
assert_eq!(map.values().fold(0, |x, y| x+y), num*(num-1)/2);

// TODO: Test Entry API, Iterators, ...

}

fn main() {
if cfg!(target_os = "macos") { // TODO: Implement libstd HashMap seeding for macOS (https://github.com/rust-lang/miri/issues/686).
// Until then, use a deterministic map.
test_map::<BuildHasherDefault<collections::hash_map::DefaultHasher>>(HashMap::default());
} else {
test_map(HashMap::new());
}
test_map(HashMap::new());
}

0 comments on commit 86d7db4

Please sign in to comment.