diff options
author | Akshay <[email protected]> | 2020-05-05 08:11:36 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2020-05-05 08:11:36 +0100 |
commit | 2275ce14ee7bed99271fc8dc3dabab56d47a3138 (patch) | |
tree | f4d4a02170f35f43fd4a4db546da057aa53ecbaf | |
parent | 3efc84e557e74d131993804a2829b6e66c2807cc (diff) |
change name to cutlass
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | tests/smoke.rs | 36 | ||||
-rw-r--r-- | tests/with_map.rs | 33 |
3 files changed, 42 insertions, 29 deletions
@@ -1,5 +1,5 @@ | |||
1 | [package] | 1 | [package] |
2 | name = "currying" | 2 | name = "cutlass" |
3 | version = "0.1.0" | 3 | version = "0.1.0" |
4 | authors = ["Akshay <[email protected]>"] | 4 | authors = ["Akshay <[email protected]>"] |
5 | edition = "2018" | 5 | edition = "2018" |
diff --git a/tests/smoke.rs b/tests/smoke.rs index 059cf9f..a9ee367 100644 --- a/tests/smoke.rs +++ b/tests/smoke.rs | |||
@@ -1,33 +1,13 @@ | |||
1 | #![feature(type_alias_impl_trait)] | 1 | #![feature(type_alias_impl_trait)] |
2 | 2 | ||
3 | pub mod helper_functions { | 3 | #[cutlass::curry] |
4 | use currying::curry; | 4 | fn add(x: u32, y: u32, z: u32) -> u32 { |
5 | 5 | return x + y + z; | |
6 | #[curry] | ||
7 | pub fn product(x: u32, y: u32) -> u32 { | ||
8 | return x * y; | ||
9 | } | ||
10 | #[curry] | ||
11 | pub fn add(x: u32, y: u32) -> u32 { | ||
12 | x + y | ||
13 | } | ||
14 | } | 6 | } |
15 | 7 | ||
16 | #[cfg(test)] | 8 | #[test] |
17 | mod tests { | 9 | fn add_works() { |
18 | use super::helper_functions::{add, product}; | 10 | let plus_3 = add(1)(2); |
19 | #[test] | 11 | let v: Vec<u32> = (1..=3).map(plus_3).collect(); |
20 | fn test_product() { | 12 | assert_eq!(v, vec![4, 5, 6]); |
21 | assert_eq!( | ||
22 | (1..=3).map(product(5)).collect::<Vec<u32>>(), | ||
23 | vec![5, 10, 15] | ||
24 | ); | ||
25 | } | ||
26 | |||
27 | #[test] | ||
28 | fn test_add() { | ||
29 | let increment = add(1); | ||
30 | let v: Vec<u32> = (1..=3).map(increment).collect(); | ||
31 | assert_eq!(v, vec![2, 3, 4]); | ||
32 | } | ||
33 | } | 13 | } |
diff --git a/tests/with_map.rs b/tests/with_map.rs new file mode 100644 index 0000000..141ee5d --- /dev/null +++ b/tests/with_map.rs | |||
@@ -0,0 +1,33 @@ | |||
1 | #![feature(type_alias_impl_trait)] | ||
2 | |||
3 | pub mod helper_functions { | ||
4 | use cutlass::curry; | ||
5 | |||
6 | #[curry] | ||
7 | pub fn product(x: u32, y: u32) -> u32 { | ||
8 | return x * y; | ||
9 | } | ||
10 | #[curry] | ||
11 | pub fn add(x: u32, y: u32) -> u32 { | ||
12 | x + y | ||
13 | } | ||
14 | } | ||
15 | |||
16 | #[cfg(test)] | ||
17 | mod tests { | ||
18 | use super::helper_functions::{add, product}; | ||
19 | #[test] | ||
20 | fn test_product() { | ||
21 | assert_eq!( | ||
22 | (1..=3).map(product(5)).collect::<Vec<u32>>(), | ||
23 | vec![5, 10, 15] | ||
24 | ); | ||
25 | } | ||
26 | |||
27 | #[test] | ||
28 | fn test_add() { | ||
29 | let increment = add(1); | ||
30 | let v: Vec<u32> = (1..=3).map(increment).collect(); | ||
31 | assert_eq!(v, vec![2, 3, 4]); | ||
32 | } | ||
33 | } | ||