leo/compiler/tests/integers/u64/mod.rs

57 lines
1.6 KiB
Rust
Raw Normal View History

2020-06-06 02:35:50 +03:00
use crate::{
boolean::{output_expected_boolean, output_false, output_true},
2020-06-08 09:30:39 +03:00
compile_program,
get_output,
2020-06-08 07:26:49 +03:00
integers::{fail_integer, fail_synthesis, IntegerTester},
2020-06-08 09:30:39 +03:00
EdwardsConstrainedValue,
EdwardsTestCompiler,
2020-06-06 02:35:50 +03:00
};
2020-06-08 07:26:49 +03:00
use leo_compiler::ConstrainedValue;
2020-06-08 09:30:39 +03:00
use leo_types::{InputValue, Integer};
2020-06-06 02:35:50 +03:00
use snarkos_curves::edwards_bls12::Fq;
2020-06-08 09:30:39 +03:00
use snarkos_models::gadgets::{
r1cs::TestConstraintSystem,
utilities::{alloc::AllocGadget, uint::UInt64},
};
2020-06-06 02:35:50 +03:00
2020-06-08 07:26:49 +03:00
const DIRECTORY_NAME: &str = "tests/integers/u64/";
2020-06-06 02:35:50 +03:00
fn output_expected_allocated(program: EdwardsTestCompiler, expected: UInt64) {
let output = get_output(program);
match output {
EdwardsConstrainedValue::Return(vec) => match vec.as_slice() {
[ConstrainedValue::Integer(Integer::U64(actual))] => assert_eq!(*actual, expected),
_ => panic!("program output unknown return value"),
},
_ => panic!("program output unknown return value"),
}
}
#[test]
2020-06-08 08:53:45 +03:00
#[ignore] //temporarily ignore memory expensive tests for travis
2020-06-06 02:35:50 +03:00
fn test_u64() {
test_uint!(Testu64, u64, UInt64, DIRECTORY_NAME);
2020-06-06 02:51:26 +03:00
Testu64::test_min(std::u64::MIN);
Testu64::test_max(std::u64::MAX);
Testu64::test_input();
Testu64::test_add();
2020-06-06 02:35:50 +03:00
// Testu64::test_sub(); //Todo: Catch subtraction overflow error in gadget
2020-06-06 02:51:26 +03:00
Testu64::test_mul();
Testu64::test_div();
Testu64::test_pow(); // takes ~2mins
Testu64::test_eq();
Testu64::test_ge();
Testu64::test_gt();
Testu64::test_le();
Testu64::test_gt();
Testu64::test_assert_eq();
Testu64::test_ternary();
2020-06-06 02:35:50 +03:00
}