1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2014 Carl Lerche, Oliver Mader, Alex Crichton, Thiago Pontes,
//                Yehuda Katz
// Copyright 2015 Carl Lerche, Oliver Mader
// Copyright 2016 Urban Hafner
//
// 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.

#![crate_name = "hamcrest"]
#![crate_type = "lib"]

extern crate num;
extern crate regex;

pub use prelude::*;

#[macro_export]
macro_rules! assert_that {
    ($actual:expr, $matcher:expr) => ({
        // The separate statement is necessary to keep the compiler happy.
        let m = $matcher;
        match m.matches($actual) {
            Ok(_) => {},
            Err(mismatch) => {
                // The panic macro produces the correct file and line number
                // when used in a macro like this, i.e. it's the line where
                // the macro was originally written.
                panic!("\nExpected: {}\n    but: {}", m, mismatch);
            }
        }
    }
    );
}

pub mod core;
pub mod matchers;
pub mod prelude {
    #[allow(deprecated)]
    pub use core::assert_that;
    pub use core::Matcher as HamcrestMatcher;
    pub use matchers::close_to::close_to;
    pub use matchers::compared_to::less_than;
    pub use matchers::compared_to::less_than_or_equal_to;
    pub use matchers::compared_to::greater_than;
    pub use matchers::compared_to::greater_than_or_equal_to;
    pub use matchers::equal_to::equal_to;
    pub use matchers::existing_path::existing_dir;
    pub use matchers::existing_path::existing_file;
    pub use matchers::existing_path::existing_path;
    pub use matchers::is::is_not as does_not;
    pub use matchers::is::is_not as not;
    pub use matchers::is::is_not;
    pub use matchers::is::is;
    pub use matchers::none::none;
    pub use matchers::regex::matches_regex as match_regex;
    pub use matchers::regex::matches_regex;
    pub use matchers::vecs::contains;
    pub use matchers::vecs::of_len;
    pub use matchers::anything::anything;
    pub use matchers::type_of::type_of;
    pub use matchers::all_of::all_of;
    pub use matchers::all_of::all_of as and;
    pub use matchers::any_of::any_of;
    pub use matchers::any_of::any_of as or;
}