From 2275ce14ee7bed99271fc8dc3dabab56d47a3138 Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 5 May 2020 12:41:36 +0530 Subject: change name to cutlass --- Cargo.toml | 2 +- tests/smoke.rs | 36 ++++++++---------------------------- tests/with_map.rs | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 29 deletions(-) create mode 100644 tests/with_map.rs diff --git a/Cargo.toml b/Cargo.toml index bb0fb84..de8f86d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "currying" +name = "cutlass" version = "0.1.0" authors = ["Akshay "] 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 @@ #![feature(type_alias_impl_trait)] -pub mod helper_functions { - use currying::curry; - - #[curry] - pub fn product(x: u32, y: u32) -> u32 { - return x * y; - } - #[curry] - pub fn add(x: u32, y: u32) -> u32 { - x + y - } +#[cutlass::curry] +fn add(x: u32, y: u32, z: u32) -> u32 { + return x + y + z; } -#[cfg(test)] -mod tests { - use super::helper_functions::{add, product}; - #[test] - fn test_product() { - assert_eq!( - (1..=3).map(product(5)).collect::>(), - vec![5, 10, 15] - ); - } - - #[test] - fn test_add() { - let increment = add(1); - let v: Vec = (1..=3).map(increment).collect(); - assert_eq!(v, vec![2, 3, 4]); - } +#[test] +fn add_works() { + let plus_3 = add(1)(2); + let v: Vec = (1..=3).map(plus_3).collect(); + assert_eq!(v, vec![4, 5, 6]); } 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 @@ +#![feature(type_alias_impl_trait)] + +pub mod helper_functions { + use cutlass::curry; + + #[curry] + pub fn product(x: u32, y: u32) -> u32 { + return x * y; + } + #[curry] + pub fn add(x: u32, y: u32) -> u32 { + x + y + } +} + +#[cfg(test)] +mod tests { + use super::helper_functions::{add, product}; + #[test] + fn test_product() { + assert_eq!( + (1..=3).map(product(5)).collect::>(), + vec![5, 10, 15] + ); + } + + #[test] + fn test_add() { + let increment = add(1); + let v: Vec = (1..=3).map(increment).collect(); + assert_eq!(v, vec![2, 3, 4]); + } +} -- cgit v1.2.3