mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-24 07:48:04 +03:00
refactor all tests
This commit is contained in:
parent
47523f7f5d
commit
e6e02a0e50
@ -209,10 +209,16 @@ impl<F: Field + PrimeField> PartialOrd for FieldType<F> {
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> EvaluateEqGadget<F> for FieldType<F> {
|
||||
fn evaluate_equal<CS: ConstraintSystem<F>>(&self, _cs: CS, other: &Self) -> Result<Boolean, SynthesisError> {
|
||||
fn evaluate_equal<CS: ConstraintSystem<F>>(&self, mut cs: CS, other: &Self) -> Result<Boolean, SynthesisError> {
|
||||
match (self, other) {
|
||||
(FieldType::Constant(first), FieldType::Constant(second)) => Ok(Boolean::constant(first.eq(second))),
|
||||
_ => unimplemented!(),
|
||||
(FieldType::Allocated(fisrt), FieldType::Allocated(second)) => fisrt.evaluate_equal(cs, second),
|
||||
(FieldType::Constant(constant_value), FieldType::Allocated(allocated_value))
|
||||
| (FieldType::Allocated(allocated_value), FieldType::Constant(constant_value)) => {
|
||||
let allocated_constant_value =
|
||||
FpGadget::alloc(&mut cs.ns(|| format!("alloc constant for eq")), || Ok(constant_value))?;
|
||||
allocated_value.evaluate_equal(cs, &allocated_constant_value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -236,13 +236,48 @@ impl PartialEq for EdwardsGroupType {
|
||||
|
||||
impl Eq for EdwardsGroupType {}
|
||||
|
||||
fn compare_allocated_edwards_bls_gadgets<CS: ConstraintSystem<Fq>>(
|
||||
mut cs: CS,
|
||||
first: &EdwardsBlsGadget,
|
||||
second: &EdwardsBlsGadget,
|
||||
) -> Result<Boolean, SynthesisError> {
|
||||
// compare x coordinates
|
||||
let x_first = &first.x;
|
||||
let x_second = &second.x;
|
||||
|
||||
let compare_x = x_first.evaluate_equal(&mut cs.ns(|| format!("compare x")), x_second)?;
|
||||
|
||||
// compare y coordinates
|
||||
let y_first = &first.y;
|
||||
let y_second = &second.y;
|
||||
|
||||
let compare_y = y_first.evaluate_equal(&mut cs.ns(|| format!("compare y")), y_second)?;
|
||||
|
||||
Boolean::and(
|
||||
&mut cs.ns(|| format!("compare x and y results")),
|
||||
&compare_x,
|
||||
&compare_y,
|
||||
)
|
||||
}
|
||||
|
||||
impl EvaluateEqGadget<Fq> for EdwardsGroupType {
|
||||
fn evaluate_equal<CS: ConstraintSystem<Fq>>(&self, _cs: CS, other: &Self) -> Result<Boolean, SynthesisError> {
|
||||
fn evaluate_equal<CS: ConstraintSystem<Fq>>(&self, mut cs: CS, other: &Self) -> Result<Boolean, SynthesisError> {
|
||||
match (self, other) {
|
||||
(EdwardsGroupType::Constant(self_value), EdwardsGroupType::Constant(other_value)) => {
|
||||
Ok(Boolean::constant(self_value.eq(other_value)))
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
(EdwardsGroupType::Allocated(first), EdwardsGroupType::Allocated(second)) => {
|
||||
compare_allocated_edwards_bls_gadgets(cs, first, second)
|
||||
}
|
||||
(EdwardsGroupType::Constant(constant_value), EdwardsGroupType::Allocated(allocated_value))
|
||||
| (EdwardsGroupType::Allocated(allocated_value), EdwardsGroupType::Constant(constant_value)) => {
|
||||
let allocated_constant_value =
|
||||
<EdwardsBlsGadget as AllocGadget<GroupAffine<EdwardsParameters>, Fq>>::alloc(
|
||||
&mut cs.ns(|| format!("alloc constant for eq")),
|
||||
|| Ok(constant_value),
|
||||
)?;
|
||||
compare_allocated_edwards_bls_gadgets(cs, allocated_value, &allocated_constant_value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,14 +8,14 @@ use crate::{
|
||||
};
|
||||
|
||||
pub fn output_ones(program: EdwardsTestCompiler) {
|
||||
let expected = include_bytes!("output_/registers_ones.out");
|
||||
let expected = include_bytes!("output/registers_ones.out");
|
||||
let actual = get_output(program);
|
||||
|
||||
assert!(expected.eq(actual.bytes().as_slice()));
|
||||
}
|
||||
|
||||
pub fn output_zeros(program: EdwardsTestCompiler) {
|
||||
let expected = include_bytes!("output_/registers_zeros.out");
|
||||
let expected = include_bytes!("output/registers_zeros.out");
|
||||
let actual = get_output(program);
|
||||
|
||||
assert!(expected.eq(actual.bytes().as_slice()));
|
||||
|
@ -1,7 +1,6 @@
|
||||
use crate::{
|
||||
assert_satisfied,
|
||||
expect_compiler_error,
|
||||
expect_synthesis_error,
|
||||
get_output,
|
||||
parse_program,
|
||||
parse_program_with_input,
|
||||
@ -10,14 +9,14 @@ use crate::{
|
||||
use leo_compiler::errors::{BooleanError, CompilerError, ExpressionError, FunctionError, StatementError};
|
||||
|
||||
pub fn output_true(program: EdwardsTestCompiler) {
|
||||
let expected = include_bytes!("output_/registers_true.out");
|
||||
let expected = include_bytes!("output/registers_true.out");
|
||||
let actual = get_output(program);
|
||||
|
||||
assert_eq!(expected, actual.bytes().as_slice());
|
||||
}
|
||||
|
||||
pub fn output_false(program: EdwardsTestCompiler) {
|
||||
let expected = include_bytes!("output_/registers_false.out");
|
||||
let expected = include_bytes!("output/registers_false.out");
|
||||
let actual = get_output(program);
|
||||
|
||||
assert_eq!(expected, actual.bytes().as_slice());
|
||||
|
@ -21,5 +21,7 @@ function main() {
|
||||
let pedersen = PedersenHash::new(parameters);
|
||||
let input: bool[512] = [true; 512];
|
||||
|
||||
console.assert(pedersen.hash(input) == 0u32);
|
||||
let res = pedersen.hash(input);
|
||||
|
||||
console.assert(res == 0u32);
|
||||
}
|
||||
|
7
compiler/tests/console/conditional_assert.leo
Normal file
7
compiler/tests/console/conditional_assert.leo
Normal file
@ -0,0 +1,7 @@
|
||||
function main(a: bool) {
|
||||
if a {
|
||||
console.assert(a == true);
|
||||
} else {
|
||||
console.assert(a == false);
|
||||
}
|
||||
}
|
@ -109,3 +109,22 @@ fn test_assert() {
|
||||
|
||||
expect_compiler_error(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_conditional_assert() {
|
||||
let bytes = include_bytes!("conditional_assert.leo");
|
||||
let mut program = parse_program(bytes).unwrap();
|
||||
|
||||
let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]);
|
||||
program.set_main_input(main_input);
|
||||
|
||||
assert_satisfied(program);
|
||||
|
||||
let mut program = parse_program(bytes).unwrap();
|
||||
|
||||
let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(false)))]);
|
||||
|
||||
program.set_main_input(main_input);
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
function main(a: field, b: field, c: field) {
|
||||
assert_eq!(a + b, c);
|
||||
console.assert(a + b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: field, b: field) {
|
||||
assert_eq!(a, b);
|
||||
console.assert(a == b);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: field, b: field, c: field) {
|
||||
assert_eq!(a / b, c);
|
||||
console.assert(a / b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: field, b: field, c: bool) {
|
||||
assert_eq!(a == b, c);
|
||||
console.assert(a == b == c);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
use crate::{assert_satisfied, expect_synthesis_error, generate_main_input, parse_program};
|
||||
use crate::{assert_satisfied, expect_compiler_error, generate_main_input, parse_program};
|
||||
use leo_typed::InputValue;
|
||||
|
||||
use snarkos_curves::edwards_bls12::Fq;
|
||||
@ -169,7 +169,6 @@ fn test_mul() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_eq() {
|
||||
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
|
||||
|
||||
@ -214,7 +213,7 @@ fn test_eq() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_assert_eq_pass() {
|
||||
fn test_console_assert_pass() {
|
||||
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
|
||||
|
||||
for _ in 0..10 {
|
||||
@ -222,7 +221,7 @@ fn test_assert_eq_pass() {
|
||||
|
||||
let a_string = field_to_decimal_string(a);
|
||||
|
||||
let bytes = include_bytes!("assert_eq.leo");
|
||||
let bytes = include_bytes!("console_assert.leo");
|
||||
let mut program = parse_program(bytes).unwrap();
|
||||
|
||||
let main_input = generate_main_input(vec![
|
||||
@ -237,7 +236,7 @@ fn test_assert_eq_pass() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_assert_eq_fail() {
|
||||
fn test_console_assert_fail() {
|
||||
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
|
||||
|
||||
for _ in 0..10 {
|
||||
@ -251,7 +250,7 @@ fn test_assert_eq_fail() {
|
||||
let a_string = field_to_decimal_string(a);
|
||||
let b_string = field_to_decimal_string(b);
|
||||
|
||||
let bytes = include_bytes!("assert_eq.leo");
|
||||
let bytes = include_bytes!("console_assert.leo");
|
||||
let mut program = parse_program(bytes).unwrap();
|
||||
|
||||
let main_input = generate_main_input(vec![
|
||||
@ -261,7 +260,7 @@ fn test_assert_eq_fail() {
|
||||
|
||||
program.set_main_input(main_input);
|
||||
|
||||
expect_synthesis_error(program);
|
||||
expect_compiler_error(program);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
function main(a: field, b: field, c: field) {
|
||||
assert_eq!(a * b, c);
|
||||
console.assert(a * b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: field, b: field) {
|
||||
assert_eq!(-a, b);
|
||||
console.assert(-a == b);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: field, b: field, c: field) {
|
||||
assert_eq!(a - b, c);
|
||||
console.assert(a - b == c);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
function main(s: bool, a: field, b: field, c: field) {
|
||||
let r = if s ? a : b;
|
||||
|
||||
assert_eq!(r, c);
|
||||
console.assert(r == c);
|
||||
}
|
@ -9,5 +9,5 @@ function main() {
|
||||
a += one();
|
||||
}
|
||||
|
||||
assert_eq!(a, 10u32);
|
||||
console.assert(a == 10u32);
|
||||
}
|
@ -11,5 +11,5 @@ function iteration() -> u32 {
|
||||
function main() {
|
||||
let total = iteration() + iteration();
|
||||
|
||||
assert_eq!(total, 20);
|
||||
console.assert(total == 20);
|
||||
}
|
@ -47,7 +47,7 @@ fn test_newlines() {
|
||||
let program_bytes = include_bytes!("newlines.leo");
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
|
||||
let expected_bytes = include_bytes!("output_/newlines.out");
|
||||
let expected_bytes = include_bytes!("output/newlines.out");
|
||||
let expected = std::str::from_utf8(expected_bytes).unwrap();
|
||||
let actual_bytes = get_output(program);
|
||||
let actual = std::str::from_utf8(actual_bytes.bytes().as_slice()).unwrap();
|
||||
@ -70,7 +70,7 @@ fn test_multiple_returns_main() {
|
||||
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
|
||||
let expected_bytes = include_bytes!("output_/registers.out");
|
||||
let expected_bytes = include_bytes!("output/registers.out");
|
||||
let expected = std::str::from_utf8(expected_bytes).unwrap();
|
||||
let actual_bytes = get_output(program);
|
||||
let actual = std::str::from_utf8(actual_bytes.bytes().as_slice()).unwrap();
|
||||
|
@ -5,6 +5,6 @@ function tuple() -> (bool, bool) {
|
||||
function main() {
|
||||
let (a, b) = tuple();
|
||||
|
||||
assert_eq!(a, true);
|
||||
assert_eq!(b, false);
|
||||
console.assert(a == true);
|
||||
console.assert(b == false);
|
||||
}
|
@ -5,5 +5,5 @@ function one() -> bool {
|
||||
function main() {
|
||||
let a = one() && one();
|
||||
|
||||
assert_eq!(a, true);
|
||||
console.assert(a == true);
|
||||
}
|
@ -3,5 +3,5 @@ function one() -> u32 {
|
||||
}
|
||||
|
||||
function main() {
|
||||
assert_eq!(one(), 1u32);
|
||||
console.assert(one() == 1u32);
|
||||
}
|
@ -15,5 +15,5 @@ function main() {
|
||||
let a = 1u32;
|
||||
bad_mutate(a);
|
||||
|
||||
assert_eq!(a, 1u32); // <- value `a` is still `1u32`
|
||||
console.assert(a == 1u32); // <- value `a` is still `1u32`
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: group, b: group, c: group) {
|
||||
assert_eq!(a + b, c);
|
||||
console.assert(a + b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: group, b: group) {
|
||||
assert_eq!(a, b);
|
||||
console.assert(a == b);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: group, b: group, c: bool) {
|
||||
assert_eq!(a == b, c);
|
||||
console.assert(a == b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: group, b: group) {
|
||||
assert_eq!(a, b);
|
||||
console.assert(a == b);
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
use crate::{
|
||||
assert_satisfied,
|
||||
expect_compiler_error,
|
||||
expect_synthesis_error,
|
||||
field::field_to_decimal_string,
|
||||
generate_main_input,
|
||||
@ -66,7 +67,7 @@ fn test_input() {
|
||||
|
||||
let program = parse_program_with_input(program_bytes, input_bytes_fail).unwrap();
|
||||
|
||||
expect_synthesis_error(program);
|
||||
expect_compiler_error(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -154,7 +155,7 @@ fn test_sub() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_assert_eq_pass() {
|
||||
fn test_console_assert_pass() {
|
||||
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
|
||||
|
||||
for _ in 0..10 {
|
||||
@ -177,7 +178,7 @@ fn test_assert_eq_pass() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_assert_eq_fail() {
|
||||
fn test_console_assert_fail() {
|
||||
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
|
||||
|
||||
for _ in 0..10 {
|
||||
@ -201,12 +202,11 @@ fn test_assert_eq_fail() {
|
||||
|
||||
program.set_main_input(main_input);
|
||||
|
||||
expect_synthesis_error(program);
|
||||
expect_compiler_error(program);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_eq() {
|
||||
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
function main(a: group, b: group) {
|
||||
assert_eq!(-a, b);
|
||||
console.assert(-a == b);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: group, b: group, c: group) {
|
||||
assert_eq!(a - b, c);
|
||||
console.assert(a - b == c);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
function main(s: bool, a: group, b: group, c: group) {
|
||||
let r = if s ? a : b;
|
||||
|
||||
assert_eq!(r, c);
|
||||
console.assert(r == c);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import test_import.foo as bar;
|
||||
|
||||
function main() {
|
||||
assert_eq!(bar(), 1u32);
|
||||
console.assert(bar() == 1u32);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import test-import.foo;
|
||||
|
||||
function main() {
|
||||
assert_eq!(foo(), 1u32);
|
||||
console.assert(foo() == 1u32);
|
||||
}
|
@ -21,5 +21,5 @@ function main() {
|
||||
|
||||
const car = Car { c: 1u32 };
|
||||
|
||||
assert_eq!(car.c, 1u32);
|
||||
console.assert(car.c == 1u32);
|
||||
}
|
@ -15,5 +15,5 @@ function main() {
|
||||
|
||||
const car = Car { c: 1u32 };
|
||||
|
||||
assert_eq!(car.c, 1u32);
|
||||
console.assert(car.c == 1u32);
|
||||
}
|
@ -6,5 +6,5 @@ import test-import.(
|
||||
function main() {
|
||||
let a = Point { x: 1u32, y: 0u32 };
|
||||
|
||||
assert_eq!(a.x, 1u32);
|
||||
console.assert(a.x == 1u32);
|
||||
}
|
@ -3,5 +3,5 @@ import test-import.*;
|
||||
function main() {
|
||||
let a = Point { x: 1u32, y: 0u32 };
|
||||
|
||||
assert_eq!(foo(), 1u32);
|
||||
console.assert(foo() == 1u32);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: bool) {
|
||||
assert_eq!(a, true);
|
||||
console.assert(a == true);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
function main(a: bool, b: bool) {
|
||||
assert_eq!(a, true);
|
||||
assert_eq!(b, false);
|
||||
console.assert(a == true);
|
||||
console.assert(b == false);
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
function main(input, data: u8[32]) {
|
||||
assert_eq!(input.registers.value_balance, 0u64);
|
||||
console.assert(input.registers.value_balance == 0u64);
|
||||
|
||||
assert_eq!(input.state.leaf_index, 0u32);
|
||||
console.assert(input.state.leaf_index == 0u32);
|
||||
|
||||
assert_eq!(input.record.value, 5u64);
|
||||
console.assert(input.record.value == 5u64);
|
||||
|
||||
assert_eq!(input.state_leaf.network_id, 0u8);
|
||||
console.assert(input.state_leaf.network_id == 0u8);
|
||||
|
||||
assert_eq!(data, [0u8; 32]);
|
||||
console.assert(data == [0u8; 32]);
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
function main(input) {
|
||||
assert_eq!(input.state.root, [0u8; 32]);
|
||||
console.assert(input.state.root == [0u8; 32]);
|
||||
|
||||
let expected: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
|
||||
assert_eq!(input.record.owner, expected);
|
||||
//console.assert(input.record.owner, expected);
|
||||
|
||||
assert_eq!(input.state_leaf.network_id, 0u8);
|
||||
console.assert(input.state_leaf.network_id == 0u8);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(input) {
|
||||
assert_eq!(input.state.root, [0u8; 32]);
|
||||
console.assert(input.state.root == [0u8; 32]);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i128, b: i128, c: i128) {
|
||||
assert_eq!(a + b, c);
|
||||
console.assert(a + b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i128, b: i128) {
|
||||
assert_eq!(a, b);
|
||||
console.assert(a == b);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i128, b: i128, c: i128) {
|
||||
assert_eq!(a / b, c);
|
||||
console.assert(a / b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i128, b: i128, c: bool) {
|
||||
assert_eq!(a == b, c);
|
||||
console.assert(a == b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i128, b: i128, c: bool) {
|
||||
assert_eq!(a >= b, c);
|
||||
console.assert(a >= b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i128, b: i128, c: bool) {
|
||||
assert_eq!(a > b, c);
|
||||
console.assert(a > b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i128, b: i128) {
|
||||
assert_eq!(a, b);
|
||||
console.assert(a == b);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i128, b: i128, c: bool) {
|
||||
assert_eq!(a <= b, c);
|
||||
console.assert(a <= b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i128, b: i128, c: bool) {
|
||||
assert_eq!(a < b, c);
|
||||
console.assert(a < b == c);
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
assert_satisfied,
|
||||
expect_synthesis_error,
|
||||
expect_compiler_error,
|
||||
generate_main_input,
|
||||
integers::{expect_computation_error, expect_parsing_error, IntegerTester},
|
||||
parse_program,
|
||||
@ -108,7 +108,7 @@ fn test_i128_lt() {
|
||||
|
||||
#[test]
|
||||
fn test_i128_assert_eq() {
|
||||
TestI128::test_assert_eq();
|
||||
TestI128::test_console_assert();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1,3 +1,3 @@
|
||||
function main(a: i128, b: i128, c: i128) {
|
||||
assert_eq!(a * b, c);
|
||||
console.assert(a * b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i128, b: i128, c: bool) {
|
||||
assert_eq!(a != b, c);
|
||||
console.assert(a != b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i128, b: i128) {
|
||||
assert_eq!(-a, b);
|
||||
console.assert(-a == b);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
function main() {
|
||||
let a = 0i128;
|
||||
|
||||
assert_eq!(-a, 0i128);
|
||||
console.assert(-a == 0i128);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i128, b: i128, c: i128) {
|
||||
assert_eq!(a ** b, c);
|
||||
console.assert(a ** b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i128, b: i128, c: i128) {
|
||||
assert_eq!(a - b, c);
|
||||
console.assert(a - b == c);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
function main(s: bool, a: i128, b: i128, c: i128) {
|
||||
let r = if s ? a : b;
|
||||
|
||||
assert_eq!(r, c);
|
||||
console.assert(r == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i16, b: i16, c: i16) {
|
||||
assert_eq!(a + b, c);
|
||||
console.assert(a + b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i16, b: i16) {
|
||||
assert_eq!(a, b);
|
||||
console.assert(a == b);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i16, b: i16, c: i16) {
|
||||
assert_eq!(a / b, c);
|
||||
console.assert(a / b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i16, b: i16, c: bool) {
|
||||
assert_eq!(a == b, c);
|
||||
console.assert(a == b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i16, b: i16, c: bool) {
|
||||
assert_eq!(a >= b, c);
|
||||
console.assert(a >= b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i16, b: i16, c: bool) {
|
||||
assert_eq!(a > b, c);
|
||||
console.assert(a > b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i16, b: i16) {
|
||||
assert_eq!(a, b);
|
||||
console.assert(a == b);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i16, b: i16, c: bool) {
|
||||
assert_eq!(a <= b, c);
|
||||
console.assert(a <= b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i16, b: i16, c: bool) {
|
||||
assert_eq!(a < b, c);
|
||||
console.assert(a < b == c);
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
assert_satisfied,
|
||||
expect_synthesis_error,
|
||||
expect_compiler_error,
|
||||
generate_main_input,
|
||||
integers::{expect_computation_error, expect_parsing_error, IntegerTester},
|
||||
parse_program,
|
||||
@ -106,8 +106,8 @@ fn test_i16_lt() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_i16_assert_eq() {
|
||||
TestI16::test_assert_eq();
|
||||
fn test_i16_console_assert() {
|
||||
TestI16::test_console_assert();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1,3 +1,3 @@
|
||||
function main(a: i16, b: i16, c: i16) {
|
||||
assert_eq!(a * b, c);
|
||||
console.assert(a * b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i16, b: i16, c: bool) {
|
||||
assert_eq!(a != b, c);
|
||||
console.assert(a != b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i16, b: i16) {
|
||||
assert_eq!(-a, b);
|
||||
console.assert(-a == b);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
function main() {
|
||||
let a = 0i16;
|
||||
|
||||
assert_eq!(-a, 0i16);
|
||||
console.assert(-a == 0i16);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i16, b: i16, c: i16) {
|
||||
assert_eq!(a ** b, c);
|
||||
console.assert(a ** b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i16, b: i16, c: i16) {
|
||||
assert_eq!(a - b, c);
|
||||
console.assert(a - b == c);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
function main(s: bool, a: i16, b: i16, c: i16) {
|
||||
let r = if s ? a : b;
|
||||
|
||||
assert_eq!(r, c);
|
||||
console.assert(r == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i32, b: i32, c: i32) {
|
||||
assert_eq!(a + b, c);
|
||||
console.assert(a + b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i32, b: i32) {
|
||||
assert_eq!(a, b);
|
||||
console.assert(a == b);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i32, b: i32, c: i32) {
|
||||
assert_eq!(a / b, c);
|
||||
console.assert(a / b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i32, b: i32, c: bool) {
|
||||
assert_eq!(a == b, c);
|
||||
console.assert(a == b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i32, b: i32, c: bool) {
|
||||
assert_eq!(a >= b, c);
|
||||
console.assert(a >= b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i32, b: i32, c: bool) {
|
||||
assert_eq!(a > b, c);
|
||||
console.assert(a > b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i32, b: i32) {
|
||||
assert_eq!(a, b);
|
||||
console.assert(a == b);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i32, b: i32, c: bool) {
|
||||
assert_eq!(a <= b, c);
|
||||
console.assert(a <= b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i32, b: i32, c: bool) {
|
||||
assert_eq!(a < b, c);
|
||||
console.assert(a < b == c);
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
assert_satisfied,
|
||||
expect_synthesis_error,
|
||||
expect_compiler_error,
|
||||
generate_main_input,
|
||||
integers::{expect_computation_error, expect_parsing_error, IntegerTester},
|
||||
parse_program,
|
||||
@ -106,8 +106,8 @@ fn test_i32_lt() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_i32_assert_eq() {
|
||||
TestI32::test_assert_eq();
|
||||
fn test_i32_console_assert() {
|
||||
TestI32::test_console_assert();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1,3 +1,3 @@
|
||||
function main(a: i32, b: i32, c: i32) {
|
||||
assert_eq!(a * b, c);
|
||||
console.assert(a * b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i32, b: i32, c: bool) {
|
||||
assert_eq!(a != b, c);
|
||||
console.assert(a != b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i32, b: i32) {
|
||||
assert_eq!(-a, b);
|
||||
console.assert(-a == b);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
function main() {
|
||||
let a = 0i32;
|
||||
|
||||
assert_eq!(-a, 0i32);
|
||||
console.assert(-a == 0i32);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i32, b: i32, c: i32) {
|
||||
assert_eq!(a ** b, c);
|
||||
console.assert(a ** b == c);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: i32, b: i32, c: i32) {
|
||||
assert_eq!(a - b, c);
|
||||
console.assert(a - b == c);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user