extern crate peano; use peano::{ToInt, Zero, P1, P2, P3, P4, N2, N3, N4}; use std::ops::{Add, Neg, Sub, Mul, Div}; #[test] fn test_peano() { // Testing equality // 0 == 0 assert_eq!( 0, ::to_int() ); // 2 == 2 assert_eq!( 2, ::to_int() ); // -2 == -2 assert_eq!( -2, ::to_int() ); // Testing addition // 0 + 0 == 0 assert_eq!( 0, <>::Output as ToInt>::to_int() ); // 0 + 3 == 3 assert_eq!( 3, <>::Output as ToInt>::to_int() ); // 0 + -3 == -3 assert_eq!( -3, <>::Output as ToInt>::to_int() ); // 2 + 0 == 2 assert_eq!( 2, <>::Output as ToInt>::to_int() ); // 2 + 3 == 5 assert_eq!( 5, <>::Output as ToInt>::to_int() ); // 2 + -3 == -1 assert_eq!( -1, <>::Output as ToInt>::to_int() ); // 3 + -2 == 1 assert_eq!( 1, <>::Output as ToInt>::to_int() ); // -2 + 0 == 2 assert_eq!( -2, <>::Output as ToInt>::to_int() ); // -2 + -3 == -5 assert_eq!( -5, <>::Output as ToInt>::to_int() ); // -2 + 3 == 1 assert_eq!( 1, <>::Output as ToInt>::to_int() ); // -3 + 2 == -1 assert_eq!( -1, <>::Output as ToInt>::to_int() ); // Testing Negation // -3 == -(3) assert_eq!( -3, <::Output as ToInt>::to_int() ); // 3 == -(-3) assert_eq!( 3, <::Output as ToInt>::to_int() ); // 0 == -0 assert_eq!( 0, <::Output as ToInt>::to_int() ); // Testing Subtraction // 0 - 0 == 0 assert_eq!( 0, <>::Output as ToInt>::to_int() ); // 0 - 3 == -3 assert_eq!( -3, <>::Output as ToInt>::to_int() ); // 0 - -3 == 3 assert_eq!( 3, <>::Output as ToInt>::to_int() ); // 2 - 0 == 2 assert_eq!( 2, <>::Output as ToInt>::to_int() ); // 2 - 3 == -1 assert_eq!( -1, <>::Output as ToInt>::to_int() ); // 2 - -3 == 5 assert_eq!( 5, <>::Output as ToInt>::to_int() ); // 3 - -2 == 5 assert_eq!( 5, <>::Output as ToInt>::to_int() ); // -2 - 0 == -2 assert_eq!( -2, <>::Output as ToInt>::to_int() ); // -2 - -3 == 1 assert_eq!( 1, <>::Output as ToInt>::to_int() ); // -2 - 3 == -5 assert_eq!( -5, <>::Output as ToInt>::to_int() ); // -3 - 2 == -5 assert_eq!( -5, <>::Output as ToInt>::to_int() ); // Testing Multiplication // 0 * 0 == 0 assert_eq!( 0, <>::Output as ToInt>::to_int() ); // 0 * 2 == 0 assert_eq!( 0, <>::Output as ToInt>::to_int() ); // 2 * 0 == 0 assert_eq!( 0, <>::Output as ToInt>::to_int() ); // 0 * -2 == 0 assert_eq!( 0, <>::Output as ToInt>::to_int() ); // -2 * 0 == 0 assert_eq!( 0, <>::Output as ToInt>::to_int() ); // 2 * 3 == 6 assert_eq!( 6, <>::Output as ToInt>::to_int() ); // 2 * -3 == -6 assert_eq!( -6, <>::Output as ToInt>::to_int() ); // -2 * 3 == -6 assert_eq!( -6, <>::Output as ToInt>::to_int() ); // -2 * -3 == 6 assert_eq!( 6, <>::Output as ToInt>::to_int() ); // Testing Division // 0 / 2 == 0 assert_eq!( 0, <>::Output as ToInt>::to_int() ); // 1 / 1 == 1 assert_eq!( 1, <>::Output as ToInt>::to_int() ); // 4 / 2 == 2 assert_eq!( 2, <>::Output as ToInt>::to_int() ); // 4 / -2 == -2 assert_eq!( -2, <>::Output as ToInt>::to_int() ); // -4 / 2 == -2 assert_eq!( -2, <>::Output as ToInt>::to_int() ); // -4 / -2 == 2 assert_eq!( 2, <>::Output as ToInt>::to_int() ); // // Uncomment for erroneous divisions // // 3 / 2 // <>::Output as ToInt>::to_int(); // // -3 / 2 // <>::Output as ToInt>::to_int(); // // 3 / -2 // <>::Output as ToInt>::to_int(); // // -3 / -2 // <>::Output as ToInt>::to_int(); // // 2 / 0 // <>::Output as ToInt>::to_int(); // // -2 / 0 // <>::Output as ToInt>::to_int(); } #[test] fn test_addition_time() { type A1 = >::Output; type A2 = >::Output; type A3 = >::Output; type A4 = >::Output; // type A5 = >::Output; // type A6 = >::Output; // type A7 = >::Output; // type A8 = >::Output; // type A9 = >::Output; // type Test = >::Output; // let x: TEST; println!("THING: {}", ::to_int()); }