lopin/
lib.rs

1//! # lopin - library of pipeline input
2//!
3//! `lopin` is a Query framework featuring a two-way pipeline and resources abstracted as stores. 
4//!
5
6mod core;
7mod async_core;
8pub mod util;
9pub mod testing;
10pub mod json;
11pub mod http_server;
12pub mod command;
13
14pub use core::*;
15pub use async_core::*;
16
17#[cfg(test)]
18mod tests {
19
20    use super::*;
21
22    #[test]
23    fn it_works() {
24        testing::test_ok(10, 10) ^ filter(|_| true, 0);
25    }
26    #[test]
27    fn it_works2() {
28        testing::test_error(10, 0) ^ filter(|_| false, 0);
29    }
30    #[test]
31    fn it_works3() {
32        testing::test_ok::<_,_,String>(10, "10".to_string()) ^ pipeline(|v : i32| Ok(v.to_string()));
33    }
34    #[test]
35    fn it_works4() {
36        testing::test_error::<_,i32,_>(10, 0) ^ pipeline(|_| Err(0));
37    }
38    #[test]
39    fn it_works5() {
40        let pipeline  = filter(|_| true, 1) & filter(|_| true, 2);
41        testing::test_ok(10, 10) ^ pipeline;
42    }
43    #[test]
44    fn it_works6() {
45        let pipeline  = filter(|_| false, 1) & filter(|_| true, 2);
46        testing::test_error(10, 1) ^ pipeline;
47    }
48    #[test]
49    fn it_works7() {
50        let pipeline  = filter(|_| true, 1) & filter(|_| false, 2);
51        testing::test_error(10, 2) ^ pipeline;
52    }
53    #[test]
54    fn it_works8() {
55        let pipeline  = filter(|_| true, 1) | filter(|_| false, 2);
56        testing::test_ok(10, 10) ^ pipeline;
57    }
58    #[test]
59    fn it_works9() {
60        let pipeline  = filter(|_| true, 1) | filter(|_| false, 2);
61        testing::test_ok(10, 10) ^ pipeline;
62    }
63    #[test]
64    fn it_works10() {
65        let pipeline  = filter(|v| v % 2 == 0, 1) & pipeline(|v| Ok(v / 2)) | pipeline(|v| Ok(v) );
66        testing::test_ok(10, 5) ^ pipeline;
67    }
68    #[test]
69    fn it_works11() {
70        let pipeline  = filter(|v| v % 2 == 0, 1) & pipeline(|v| Ok(v / 2)) | pipeline(|v| Ok(v) );
71        testing::test_ok(9, 9) ^ pipeline;
72    }
73}