From e3bfcdaf84cdca5d317369751d29c6e740581f50 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Tue, 24 Nov 2020 11:02:46 +0100 Subject: [PATCH 01/41] perf(arithmetic): reuse some vectors used in mul and pow Signed-off-by: ljedrz --- gadgets/src/signed_integer/arithmetic/mul.rs | 14 +++++++++++--- gadgets/src/signed_integer/arithmetic/pow.rs | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/gadgets/src/signed_integer/arithmetic/mul.rs b/gadgets/src/signed_integer/arithmetic/mul.rs index 2d4a8c4d12..214b5d0982 100644 --- a/gadgets/src/signed_integer/arithmetic/mul.rs +++ b/gadgets/src/signed_integer/arithmetic/mul.rs @@ -37,6 +37,8 @@ use snarkos_models::{ }, }; +use std::iter; + macro_rules! mul_int_impl { ($($gadget: ident)*) => ($( /// Bitwise multiplication of two signed integer objects. @@ -77,14 +79,16 @@ macro_rules! mul_int_impl { let mut bits = vec![false_bit; size]; // Compute double and add algorithm + let mut to_add = Vec::new(); + let mut a_shifted = Vec::new(); for (i, b_bit) in b.iter().enumerate() { // double - let mut a_shifted = vec![false_bit; i]; - a_shifted.append(&mut a.clone()); + a_shifted.extend(iter::repeat(false_bit).take(i)); + a_shifted.extend(a.iter()); a_shifted.truncate(size); // conditionally add - let mut to_add = Vec::with_capacity(a_shifted.len()); + to_add.reserve(a_shifted.len()); for (j, a_bit) in a_shifted.iter().enumerate() { let selected_bit = Boolean::conditionally_select( &mut cs.ns(|| format!("select product bit {} {}", i, j)), @@ -101,7 +105,11 @@ macro_rules! mul_int_impl { &to_add )?; let _carry = bits.pop(); + to_add.clear(); + a_shifted.clear(); } + drop(to_add); + drop(a_shifted); // Compute the maximum value of the sum let max_bits = <$gadget as Int>::SIZE; diff --git a/gadgets/src/signed_integer/arithmetic/pow.rs b/gadgets/src/signed_integer/arithmetic/pow.rs index 25e4aa8d48..dc90b34bbe 100644 --- a/gadgets/src/signed_integer/arithmetic/pow.rs +++ b/gadgets/src/signed_integer/arithmetic/pow.rs @@ -71,7 +71,7 @@ macro_rules! pow_int_impl { result = Self::conditionally_select( &mut cs.ns(|| format!("mul_by_self_or_result_{}", i)), - &bit, + bit, &mul_by_self?, &result, )?; From b94c70588eeb31bc08051d6498f50347b07fdf03 Mon Sep 17 00:00:00 2001 From: collin Date: Thu, 3 Dec 2020 13:24:23 -0500 Subject: [PATCH 02/41] refactor execution of branch indicators and function returns --- compiler/src/console/assert.rs | 18 +-- compiler/src/console/console.rs | 23 +--- compiler/src/errors/statement.rs | 16 +++ compiler/src/function/function.rs | 30 +---- compiler/src/function/result/result.rs | 115 ++++++++++++------ compiler/src/statement/assign/array.rs | 8 +- compiler/src/statement/assign/assign.rs | 5 +- .../src/statement/assign/circuit_variable.rs | 6 +- compiler/src/statement/assign/tuple.rs | 7 +- compiler/src/statement/branch/branch.rs | 2 +- .../src/statement/conditional/conditional.rs | 16 +-- compiler/src/statement/iteration/iteration.rs | 2 +- compiler/src/statement/statement.rs | 15 ++- 13 files changed, 145 insertions(+), 118 deletions(-) diff --git a/compiler/src/console/assert.rs b/compiler/src/console/assert.rs index 66465bd11f..e3df68ba9d 100644 --- a/compiler/src/console/assert.rs +++ b/compiler/src/console/assert.rs @@ -16,7 +16,13 @@ //! Enforces an assert equals statement in a compiled Leo program. -use crate::{errors::ConsoleError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; +use crate::{ + errors::ConsoleError, + get_indicator_value, + program::ConstrainedProgram, + value::ConstrainedValue, + GroupType, +}; use leo_ast::{Expression, Span, Type}; use snarkos_models::{ @@ -30,7 +36,7 @@ impl> ConstrainedProgram { cs: &mut CS, file_scope: &str, function_scope: &str, - indicator: Option, + indicator: &Boolean, expression: Expression, span: &Span, ) -> Result<(), ConsoleError> { @@ -42,12 +48,8 @@ impl> ConstrainedProgram { // If the indicator bit is false, do not evaluate the assertion // This is okay since we are not enforcing any constraints - let false_boolean = Boolean::Constant(false); - - if let Some(indicator_bool) = indicator { - if indicator_bool.eq(&false_boolean) { - return Ok(()); // continue execution - } + if !get_indicator_value(indicator) { + return Ok(()); // Continue execution. } // Unwrap assertion value and handle errors diff --git a/compiler/src/console/console.rs b/compiler/src/console/console.rs index 1be1d801cb..23a7276cfa 100644 --- a/compiler/src/console/console.rs +++ b/compiler/src/console/console.rs @@ -16,7 +16,7 @@ //! Evaluates a macro in a compiled Leo program. -use crate::{errors::ConsoleError, program::ConstrainedProgram, GroupType}; +use crate::{errors::ConsoleError, program::ConstrainedProgram, statement::get_indicator_value, GroupType}; use leo_ast::{ConsoleFunction, ConsoleFunctionCall}; use snarkos_models::{ @@ -30,7 +30,7 @@ impl> ConstrainedProgram { cs: &mut CS, file_scope: &str, function_scope: &str, - indicator: Option, + indicator: &Boolean, console: ConsoleFunctionCall, ) -> Result<(), ConsoleError> { match console.function { @@ -40,21 +40,21 @@ impl> ConstrainedProgram { ConsoleFunction::Debug(string) => { let string = self.format(cs, file_scope, function_scope, string)?; - if unwrap_indicator_value(indicator) { + if get_indicator_value(indicator) { tracing::debug!("{}", string); } } ConsoleFunction::Error(string) => { let string = self.format(cs, file_scope, function_scope, string)?; - if unwrap_indicator_value(indicator) { + if get_indicator_value(indicator) { tracing::error!("{}", string); } } ConsoleFunction::Log(string) => { let string = self.format(cs, file_scope, function_scope, string)?; - if unwrap_indicator_value(indicator) { + if get_indicator_value(indicator) { tracing::info!("{}", string); } } @@ -63,16 +63,3 @@ impl> ConstrainedProgram { Ok(()) } } - -// Return the indicator boolean gadget value or true if it is None -// This is okay since we are not enforcing any constraints -fn unwrap_indicator_value(indicator: Option) -> bool { - let false_boolean = Boolean::constant(false); - - if let Some(indicator_bool) = indicator { - if indicator_bool.eq(&false_boolean) { - return false; - } - } - true -} diff --git a/compiler/src/errors/statement.rs b/compiler/src/errors/statement.rs index a70770ca53..4fd0dc7d5e 100644 --- a/compiler/src/errors/statement.rs +++ b/compiler/src/errors/statement.rs @@ -135,6 +135,22 @@ impl StatementError { Self::new_from_span(message, span) } + pub fn multiple_returns(span: Span) -> Self { + let message = + format!("This function returns multiple times and produces unreachable circuits with undefined behavior."); + + Self::new_from_span(message, span) + } + + pub fn no_returns(expected: Type, span: Span) -> Self { + let message = format!( + "function expected `{}` return type but no valid branches returned a result", + expected + ); + + Self::new_from_span(message, span) + } + pub fn select_fail(first: String, second: String, span: Span) -> Self { let message = format!( "Conditional select gadget failed to select between `{}` or `{}`", diff --git a/compiler/src/function/function.rs b/compiler/src/function/function.rs index ab944103f0..ea79ddeb46 100644 --- a/compiler/src/function/function.rs +++ b/compiler/src/function/function.rs @@ -23,11 +23,11 @@ use crate::{ GroupType, }; -use leo_ast::{Expression, Function, FunctionInput, Span, Type}; +use leo_ast::{Expression, Function, FunctionInput, Span}; use snarkos_models::{ curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, + gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; pub fn check_arguments_length(expected: usize, actual: usize, span: &Span) -> Result<(), FunctionError> { @@ -89,13 +89,14 @@ impl> ConstrainedProgram { // Evaluate every statement in the function and save all potential results let mut results = vec![]; + let indicator = Boolean::constant(true); for statement in function.statements.iter() { let mut result = self.enforce_statement( cs, scope, &function_name, - None, + &indicator, statement.clone(), function.output.clone(), declared_circuit_reference, @@ -105,26 +106,7 @@ impl> ConstrainedProgram { } // Conditionally select a result based on returned indicators - let mut return_values = ConstrainedValue::Tuple(vec![]); - - Self::conditionally_select_result(cs, &mut return_values, results, &function.span)?; - - if let ConstrainedValue::Tuple(ref returns) = return_values { - let return_types = match function.output { - Some(Type::Tuple(types)) => types.len(), - Some(_) => 1usize, - None => 0usize, - }; - - if return_types != returns.len() { - return Err(FunctionError::return_arguments_length( - return_types, - returns.len(), - function.span.clone(), - )); - } - } - - Ok(return_values) + Self::conditionally_select_result(cs, function.output, results, &function.span) + .map_err(|err| FunctionError::StatementError(err)) } } diff --git a/compiler/src/function/result/result.rs b/compiler/src/function/result/result.rs index cec2a05810..4bfa4a8165 100644 --- a/compiler/src/function/result/result.rs +++ b/compiler/src/function/result/result.rs @@ -16,9 +16,15 @@ //! Enforces that one return value is produced in a compiled Leo program. -use crate::{errors::StatementError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; +use crate::{ + errors::StatementError, + get_indicator_value, + program::ConstrainedProgram, + value::ConstrainedValue, + GroupType, +}; -use leo_ast::Span; +use leo_ast::{Span, Type}; use snarkos_models::{ curves::{Field, PrimeField}, @@ -29,49 +35,84 @@ use snarkos_models::{ }; impl> ConstrainedProgram { - /// iterates through a vector of results and selects one based off of indicators + /// + /// Returns a conditionally selected result from the given possible function returns and + /// given function return type. + /// pub fn conditionally_select_result>( cs: &mut CS, - return_value: &mut ConstrainedValue, - results: Vec<(Option, ConstrainedValue)>, + expected_return: Option, + results: Vec<(Boolean, ConstrainedValue)>, span: &Span, - ) -> Result<(), StatementError> { - // if there are no results, continue - if results.is_empty() { - return Ok(()); + ) -> Result, StatementError> { + // Initialize empty return value. + let mut return_value = ConstrainedValue::Tuple(vec![]); + + // If the function does not expect a return type, then make sure there are no returned results. + let return_type = match expected_return { + Some(return_type) => return_type, + None => { + if results.is_empty() { + // If the function has no returns, then return an empty tuple. + return Ok(return_value); + } else { + return Err(StatementError::invalid_number_of_returns( + 0, + results.len(), + span.to_owned(), + )); + } + } + }; + + // Error if the function or one of its branches does not return. + if let None = results.iter().find(|(indicator, _res)| get_indicator_value(indicator)) { + return Err(StatementError::no_returns(return_type, span.to_owned())); } - // If all indicators are none, then there are no branch conditions in the function. - // We simply return the last result. - - if results.iter().all(|(indicator, _res)| indicator.is_none()) { - let result = &results[results.len() - 1].1; - - *return_value = result.clone(); - - return Ok(()); - } - - // If there are branches in the function we need to use the `ConditionalSelectGadget` to parse through and select the correct one. - // This can be thought of as de-multiplexing all previous wires that may have returned results into one. - for (i, (indicator, result)) in results.into_iter().enumerate() { - // Set the first value as the starting point - if i == 0 { - *return_value = result.clone(); + // Find the return value + let mut ignored = vec![]; + let mut found_return = false; + for (indicator, result) in results.into_iter() { + // Error if a statement returned a result with an incorrect type + let result_type = result.to_type(span)?; + if return_type != result_type { + return Err(StatementError::arguments_type( + &return_type, + &result_type, + span.to_owned(), + )); } - let condition = indicator.unwrap_or(Boolean::Constant(true)); - let selected_value = ConstrainedValue::conditionally_select( - cs.ns(|| format!("select {} {}:{}", result, span.line, span.start)), - &condition, - &result, - return_value, - ) - .map_err(|_| StatementError::select_fail(result.to_string(), return_value.to_string(), span.to_owned()))?; - - *return_value = selected_value; + if get_indicator_value(&indicator) { + // Error if we already have a return value. + if found_return { + return Err(StatementError::multiple_returns(span.to_owned())); + } else { + // Set the function return value. + return_value = result; + found_return = true; + } + } else { + // Ignore a possible function return value. + ignored.push((indicator, result)) + } } - Ok(()) + // Conditionally select out the ignored results in the circuit. + // + // If there are branches in the function we need to use the `ConditionalSelectGadget` to parse through and select the correct one. + // This can be thought of as de-multiplexing all previous wires that may have returned results into one. + for (i, (indicator, result)) in ignored.into_iter().enumerate() { + return_value = ConstrainedValue::conditionally_select( + cs.ns(|| format!("select result {} {}:{}", i, span.line, span.start)), + &indicator, + &result, + &return_value, + ) + .map_err(|_| StatementError::select_fail(result.to_string(), return_value.to_string(), span.to_owned()))?; + } + + Ok(return_value) } } diff --git a/compiler/src/statement/assign/array.rs b/compiler/src/statement/assign/array.rs index 842cdefbfe..0f56d9461b 100644 --- a/compiler/src/statement/assign/array.rs +++ b/compiler/src/statement/assign/array.rs @@ -34,14 +34,12 @@ impl> ConstrainedProgram { cs: &mut CS, file_scope: &str, function_scope: &str, - indicator: Option, + indicator: &Boolean, name: &str, range_or_expression: RangeOrExpression, mut new_value: ConstrainedValue, span: &Span, ) -> Result<(), StatementError> { - let condition = indicator.unwrap_or(Boolean::Constant(true)); - // Resolve index so we know if we are assigning to a single value or a range of values match range_or_expression { RangeOrExpression::Expression(index) => { @@ -54,7 +52,7 @@ impl> ConstrainedProgram { let selected_value = ConstrainedValue::conditionally_select( cs.ns(|| format!("select {} {}:{}", new_value, span.line, span.start)), - &condition, + indicator, &new_value, &old[index], ) @@ -90,7 +88,7 @@ impl> ConstrainedProgram { }; let selected_array = ConstrainedValue::conditionally_select( cs.ns(|| format!("select {} {}:{}", new_array, span.line, span.start)), - &condition, + indicator, &new_array, old_array, ) diff --git a/compiler/src/statement/assign/assign.rs b/compiler/src/statement/assign/assign.rs index 8899c9b286..25006a05e6 100644 --- a/compiler/src/statement/assign/assign.rs +++ b/compiler/src/statement/assign/assign.rs @@ -42,7 +42,7 @@ impl> ConstrainedProgram { file_scope: &str, function_scope: &str, declared_circuit_reference: &str, - indicator: Option, + indicator: &Boolean, assignee: Assignee, expression: Expression, span: &Span, @@ -55,14 +55,13 @@ impl> ConstrainedProgram { // Mutate the old value into the new value if assignee.accesses.is_empty() { - let condition = indicator.unwrap_or(Boolean::Constant(true)); let old_value = self.get_mutable_assignee(&variable_name, span)?; new_value.resolve_type(Some(old_value.to_type(&span)?), span)?; let selected_value = ConstrainedValue::conditionally_select( cs.ns(|| format!("select {} {}:{}", new_value, span.line, span.start)), - &condition, + indicator, &new_value, old_value, ) diff --git a/compiler/src/statement/assign/circuit_variable.rs b/compiler/src/statement/assign/circuit_variable.rs index 146c95f983..60d0ebb7f6 100644 --- a/compiler/src/statement/assign/circuit_variable.rs +++ b/compiler/src/statement/assign/circuit_variable.rs @@ -31,14 +31,12 @@ impl> ConstrainedProgram { pub fn mutate_circuit_variable>( &mut self, cs: &mut CS, - indicator: Option, + indicator: &Boolean, circuit_name: &str, variable_name: Identifier, mut new_value: ConstrainedValue, span: &Span, ) -> Result, StatementError> { - let condition = indicator.unwrap_or(Boolean::Constant(true)); - // Get the mutable circuit by name match self.get_mutable_assignee(circuit_name, span)? { ConstrainedValue::CircuitExpression(_variable, members) => { @@ -70,7 +68,7 @@ impl> ConstrainedProgram { // Conditionally select the value if this branch is executed. let mut selected_value = ConstrainedValue::conditionally_select( cs.ns(|| format!("select {} {}:{}", new_value, span.line, span.start)), - &condition, + indicator, &new_value, &member.1, ) diff --git a/compiler/src/statement/assign/tuple.rs b/compiler/src/statement/assign/tuple.rs index 5ecb0dd767..4209a1d570 100644 --- a/compiler/src/statement/assign/tuple.rs +++ b/compiler/src/statement/assign/tuple.rs @@ -31,15 +31,12 @@ impl> ConstrainedProgram { pub fn assign_tuple>( &mut self, cs: &mut CS, - indicator: Option, + indicator: &Boolean, name: &str, index: PositiveNumber, mut new_value: ConstrainedValue, span: &Span, ) -> Result<(), StatementError> { - // Get the indicator value. - let condition = indicator.unwrap_or(Boolean::Constant(true)); - // Parse the index. let index_usize = parse_index(&index, &span)?; @@ -50,7 +47,7 @@ impl> ConstrainedProgram { let selected_value = ConstrainedValue::conditionally_select( cs.ns(|| format!("select {} {}:{}", new_value, span.line, span.start)), - &condition, + indicator, &new_value, &old[index_usize], ) diff --git a/compiler/src/statement/branch/branch.rs b/compiler/src/statement/branch/branch.rs index 9d0d208036..f948c85a73 100644 --- a/compiler/src/statement/branch/branch.rs +++ b/compiler/src/statement/branch/branch.rs @@ -30,7 +30,7 @@ impl> ConstrainedProgram { cs: &mut CS, file_scope: &str, function_scope: &str, - indicator: Option, + indicator: &Boolean, statements: Vec, return_type: Option, ) -> StatementResult>> { diff --git a/compiler/src/statement/conditional/conditional.rs b/compiler/src/statement/conditional/conditional.rs index 48bad283b8..94e3a8726e 100644 --- a/compiler/src/statement/conditional/conditional.rs +++ b/compiler/src/statement/conditional/conditional.rs @@ -49,15 +49,15 @@ impl> ConstrainedProgram { cs: &mut CS, file_scope: &str, function_scope: &str, - indicator: Option, + indicator: &Boolean, statement: ConditionalStatement, return_type: Option, span: &Span, ) -> StatementResult>> { let statement_string = statement.to_string(); - // Inherit the indicator from a previous conditional statement or assume that we are the outer parent - let outer_indicator = indicator.unwrap_or(Boolean::Constant(true)); + // Inherit an indicator from a previous statement. + let outer_indicator = indicator; // Evaluate the conditional boolean as the inner indicator let inner_indicator = match self.enforce_expression( @@ -72,7 +72,7 @@ impl> ConstrainedProgram { }; // If outer_indicator && inner_indicator, then select branch 1 - let outer_indicator_string = indicator_to_string(&outer_indicator); + let outer_indicator_string = indicator_to_string(outer_indicator); let inner_indicator_string = indicator_to_string(&inner_indicator); let branch_1_name = format!( "branch indicator 1 {} && {}", @@ -80,7 +80,7 @@ impl> ConstrainedProgram { ); let branch_1_indicator = Boolean::and( &mut cs.ns(|| format!("branch 1 {} {}:{}", statement_string, span.line, span.start)), - &outer_indicator, + outer_indicator, &inner_indicator, ) .map_err(|_| StatementError::indicator_calculation(branch_1_name, span.to_owned()))?; @@ -92,7 +92,7 @@ impl> ConstrainedProgram { cs, file_scope, function_scope, - Some(branch_1_indicator), + &branch_1_indicator, statement.statements, return_type.clone(), )?; @@ -120,7 +120,7 @@ impl> ConstrainedProgram { cs, file_scope, function_scope, - Some(branch_2_indicator), + &branch_2_indicator, *nested, return_type, span, @@ -129,7 +129,7 @@ impl> ConstrainedProgram { cs, file_scope, function_scope, - Some(branch_2_indicator), + &branch_2_indicator, statements, return_type, )?, diff --git a/compiler/src/statement/iteration/iteration.rs b/compiler/src/statement/iteration/iteration.rs index 64104cbb45..509d4c22bd 100644 --- a/compiler/src/statement/iteration/iteration.rs +++ b/compiler/src/statement/iteration/iteration.rs @@ -42,7 +42,7 @@ impl> ConstrainedProgram { cs: &mut CS, file_scope: &str, function_scope: &str, - indicator: Option, + indicator: &Boolean, index: Identifier, start: Expression, stop: Expression, diff --git a/compiler/src/statement/statement.rs b/compiler/src/statement/statement.rs index 763ea328a7..16d9577e29 100644 --- a/compiler/src/statement/statement.rs +++ b/compiler/src/statement/statement.rs @@ -25,7 +25,7 @@ use snarkos_models::{ }; pub type StatementResult = Result; -pub type IndicatorAndConstrainedValue = (Option, ConstrainedValue); +pub type IndicatorAndConstrainedValue = (Boolean, ConstrainedValue); impl> ConstrainedProgram { /// @@ -41,7 +41,7 @@ impl> ConstrainedProgram { cs: &mut CS, file_scope: &str, function_scope: &str, - indicator: Option, + indicator: &Boolean, statement: Statement, return_type: Option, declared_circuit_reference: &str, @@ -51,7 +51,7 @@ impl> ConstrainedProgram { match statement { Statement::Return(expression, span) => { let return_value = ( - indicator, + indicator.to_owned(), self.enforce_return_statement(cs, file_scope, function_scope, expression, return_type, &span)?, ); @@ -126,7 +126,7 @@ impl> ConstrainedProgram { _ => return Err(StatementError::unassigned(expression_string, span)), } - let result = (indicator, value); + let result = (indicator.to_owned(), value); results.push(result); } @@ -135,3 +135,10 @@ impl> ConstrainedProgram { Ok(results) } } + +/// Returns the indicator boolean gadget value. +/// We can directly compare a boolean constant to the indicator since we are not enforcing any +/// constraints +pub fn get_indicator_value(indicator: &Boolean) -> bool { + indicator.eq(&Boolean::constant(true)) +} From dfcc77a860d4c8dd11280621962bd14769b0de3f Mon Sep 17 00:00:00 2001 From: collin Date: Thu, 3 Dec 2020 13:38:05 -0500 Subject: [PATCH 03/41] add test for bug #430 early returns --- compiler/src/statement/statement.rs | 8 ++------ compiler/tests/function/mod.rs | 12 ++++++++++-- .../function/{multiple.leo => multiple_returns.leo} | 0 compiler/tests/function/multiple_returns_fail.leo | 7 +++++++ .../{multiple_main.leo => multiple_returns_main.leo} | 0 5 files changed, 19 insertions(+), 8 deletions(-) rename compiler/tests/function/{multiple.leo => multiple_returns.leo} (100%) create mode 100644 compiler/tests/function/multiple_returns_fail.leo rename compiler/tests/function/{multiple_main.leo => multiple_returns_main.leo} (100%) diff --git a/compiler/src/statement/statement.rs b/compiler/src/statement/statement.rs index 16d9577e29..854d46c7cc 100644 --- a/compiler/src/statement/statement.rs +++ b/compiler/src/statement/statement.rs @@ -116,19 +116,15 @@ impl> ConstrainedProgram { let expression_string = expression.to_string(); let value = self.enforce_expression(cs, file_scope, function_scope, None, expression)?; - // handle empty return value cases + // Handle empty return value cases. match &value { ConstrainedValue::Tuple(values) => { if !values.is_empty() { - return Err(StatementError::unassigned(expression_string, span)); + results.push((indicator.clone(), value)); } } _ => return Err(StatementError::unassigned(expression_string, span)), } - - let result = (indicator.to_owned(), value); - - results.push(result); } }; diff --git a/compiler/tests/function/mod.rs b/compiler/tests/function/mod.rs index dc31094f76..9a2306b17e 100644 --- a/compiler/tests/function/mod.rs +++ b/compiler/tests/function/mod.rs @@ -64,15 +64,23 @@ fn test_newlines() { #[test] fn test_multiple_returns() { - let bytes = include_bytes!("multiple.leo"); + let bytes = include_bytes!("multiple_returns.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); } +#[test] +fn test_multiple_returns_fail() { + let bytes = include_bytes!("multiple_returns_fail.leo"); + let program = parse_program(bytes).unwrap(); + + expect_compiler_error(program); +} + #[test] fn test_multiple_returns_main() { - let program_bytes = include_bytes!("multiple_main.leo"); + let program_bytes = include_bytes!("multiple_returns_main.leo"); let input_bytes = include_bytes!("input/registers.in"); let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); diff --git a/compiler/tests/function/multiple.leo b/compiler/tests/function/multiple_returns.leo similarity index 100% rename from compiler/tests/function/multiple.leo rename to compiler/tests/function/multiple_returns.leo diff --git a/compiler/tests/function/multiple_returns_fail.leo b/compiler/tests/function/multiple_returns_fail.leo new file mode 100644 index 0000000000..d4a8b36eac --- /dev/null +++ b/compiler/tests/function/multiple_returns_fail.leo @@ -0,0 +1,7 @@ +function main () -> i8 { + if true { + return 1i8 //ignored + } + return 2i8 //ignored + return 3i8 //returns +} \ No newline at end of file diff --git a/compiler/tests/function/multiple_main.leo b/compiler/tests/function/multiple_returns_main.leo similarity index 100% rename from compiler/tests/function/multiple_main.leo rename to compiler/tests/function/multiple_returns_main.leo From 87c0dd738a8331e1b588f2a8c197b0a67c84e7c1 Mon Sep 17 00:00:00 2001 From: collin Date: Thu, 3 Dec 2020 13:44:47 -0500 Subject: [PATCH 04/41] add test for bug #427 incomplete conditional --- compiler/tests/function/mod.rs | 8 ++++++++ .../tests/function/multiple_returns_fail_conditional.leo | 9 +++++++++ 2 files changed, 17 insertions(+) create mode 100644 compiler/tests/function/multiple_returns_fail_conditional.leo diff --git a/compiler/tests/function/mod.rs b/compiler/tests/function/mod.rs index 9a2306b17e..90346098e9 100644 --- a/compiler/tests/function/mod.rs +++ b/compiler/tests/function/mod.rs @@ -78,6 +78,14 @@ fn test_multiple_returns_fail() { expect_compiler_error(program); } +#[test] +fn test_multiple_returns_fail_conditional() { + let bytes = include_bytes!("multiple_returns_fail_conditional.leo"); + let program = parse_program(bytes).unwrap(); + + expect_compiler_error(program); +} + #[test] fn test_multiple_returns_main() { let program_bytes = include_bytes!("multiple_returns_main.leo"); diff --git a/compiler/tests/function/multiple_returns_fail_conditional.leo b/compiler/tests/function/multiple_returns_fail_conditional.leo new file mode 100644 index 0000000000..04ebb9e306 --- /dev/null +++ b/compiler/tests/function/multiple_returns_fail_conditional.leo @@ -0,0 +1,9 @@ +function main () -> u16 { + if false { + let a = 1u16; + let b = a + 1u16; + return b + } else if false { + return 0u16 + } +} \ No newline at end of file From b2246f1151e76c2d50b6f333ce55840bf4302238 Mon Sep 17 00:00:00 2001 From: collin Date: Fri, 4 Dec 2020 12:51:39 -0500 Subject: [PATCH 05/41] use include_str in program state tests --- .../tests/input_files/program_state/mod.rs | 30 +++++++++---------- compiler/tests/mod.rs | 15 +++++----- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/compiler/tests/input_files/program_state/mod.rs b/compiler/tests/input_files/program_state/mod.rs index d3e46194b1..f065d09d4f 100644 --- a/compiler/tests/input_files/program_state/mod.rs +++ b/compiler/tests/input_files/program_state/mod.rs @@ -18,32 +18,32 @@ use crate::{assert_satisfied, parse_program_with_state, parse_state}; #[test] fn test_basic() { - let bytes = include_bytes!("input/basic.state"); + let state_string = include_str!("input/basic.state"); - parse_state(bytes).unwrap(); + parse_state(state_string).unwrap(); } #[test] fn test_token_withdraw() { - let bytes = include_bytes!("input/token_withdraw.state"); + let state_string = include_str!("input/token_withdraw.state"); - parse_state(bytes).unwrap(); + parse_state(state_string).unwrap(); } #[test] fn test_access_state() { - let program_bytes = include_bytes!("access_state.leo"); - let state_bytes = include_bytes!("input/token_withdraw.state"); + let program_string = include_str!("access_state.leo"); + let state_string = include_str!("input/token_withdraw.state"); - let program = parse_program_with_state(program_bytes, state_bytes).unwrap(); + let program = parse_program_with_state(program_string, state_string).unwrap(); assert_satisfied(program); } #[test] fn test_access_all() { - let program_bytes = include_bytes!("access_all.leo"); - let state_bytes = include_bytes!("input/token_withdraw.state"); + let program_bytes = include_str!("access_all.leo"); + let state_bytes = include_str!("input/token_withdraw.state"); let program = parse_program_with_state(program_bytes, state_bytes).unwrap(); @@ -52,27 +52,27 @@ fn test_access_all() { #[test] fn test_visibility_fail() { - let state_bytes = include_bytes!("input/visibility_fail.state"); + let state_string = include_str!("input/visibility_fail.state"); - let is_err = parse_state(state_bytes).is_err(); + let is_err = parse_state(state_string).is_err(); assert!(is_err); } #[test] fn test_section_undefined() { - let state_bytes = include_bytes!("input/section_undefined.state"); + let state_string = include_str!("input/section_undefined.state"); - let is_err = parse_state(state_bytes).is_err(); + let is_err = parse_state(state_string).is_err(); assert!(is_err); } #[test] fn test_section_invalid() { - let state_bytes = include_bytes!("input/section_invalid.state"); + let state_string = include_str!("input/section_invalid.state"); - let is_err = parse_state(state_bytes).is_err(); + let is_err = parse_state(state_string).is_err(); assert!(is_err); } diff --git a/compiler/tests/mod.rs b/compiler/tests/mod.rs index a18efa9428..da31698251 100644 --- a/compiler/tests/mod.rs +++ b/compiler/tests/mod.rs @@ -83,9 +83,8 @@ pub(crate) fn parse_input(bytes: &[u8]) -> Result Result { +pub(crate) fn parse_state(state_string: &str) -> Result { let mut compiler = new_compiler(); - let state_string = String::from_utf8_lossy(bytes); let path = PathBuf::new(); compiler.parse_input(EMPTY_FILE, &path, &state_string, &path)?; @@ -124,17 +123,17 @@ pub fn parse_program_with_input( } pub fn parse_program_with_state( - program_bytes: &[u8], - state_bytes: &[u8], + program_string: &str, + state_string: &str, ) -> Result { let mut compiler = new_compiler(); - let program_string = String::from_utf8_lossy(program_bytes); - let state_string = String::from_utf8_lossy(state_bytes); + // let program_string = String::from_utf8_lossy(program_bytes); + // let state_string = String::from_utf8_lossy(state_bytes); let path = PathBuf::new(); - compiler.parse_input(EMPTY_FILE, &path, &state_string, &path)?; - compiler.parse_program_from_string(&program_string)?; + compiler.parse_input(EMPTY_FILE, &path, state_string, &path)?; + compiler.parse_program_from_string(program_string)?; Ok(compiler) } From 675937ba13287f859845a68b3ebadc7c98e9b8f3 Mon Sep 17 00:00:00 2001 From: collin Date: Fri, 4 Dec 2020 12:57:08 -0500 Subject: [PATCH 06/41] use include_str in program input tests --- .../program_input_and_program_state/mod.rs | 20 ++++++------- compiler/tests/mod.rs | 30 +++++++------------ compiler/tests/syntax/mod.rs | 5 ++-- 3 files changed, 22 insertions(+), 33 deletions(-) diff --git a/compiler/tests/input_files/program_input_and_program_state/mod.rs b/compiler/tests/input_files/program_input_and_program_state/mod.rs index c80bd98b7b..302f6fd433 100644 --- a/compiler/tests/input_files/program_input_and_program_state/mod.rs +++ b/compiler/tests/input_files/program_input_and_program_state/mod.rs @@ -18,27 +18,27 @@ use crate::{assert_satisfied, parse_input_and_state, parse_program_with_input_an #[test] fn test_basic() { - let input_bytes = include_bytes!("input/basic.in"); - let state_bytes = include_bytes!("input/basic.state"); + let input_string = include_str!("input/basic.in"); + let state_string = include_str!("input/basic.state"); - parse_input_and_state(input_bytes, state_bytes).unwrap(); + parse_input_and_state(input_string, state_string).unwrap(); } #[test] fn test_full() { - let input_bytes = include_bytes!("input/token_withdraw.in"); - let state_bytes = include_bytes!("input/token_withdraw.state"); + let input_string = include_str!("input/token_withdraw.in"); + let state_string = include_str!("input/token_withdraw.state"); - parse_input_and_state(input_bytes, state_bytes).unwrap(); + parse_input_and_state(input_string, state_string).unwrap(); } #[test] fn test_access() { - let program_bytes = include_bytes!("access.leo"); - let input_bytes = include_bytes!("input/token_withdraw.in"); - let state_bytes = include_bytes!("input/token_withdraw.state"); + let program_string = include_str!("access.leo"); + let input_string = include_str!("input/token_withdraw.in"); + let state_string = include_str!("input/token_withdraw.state"); - let program = parse_program_with_input_and_state(program_bytes, input_bytes, state_bytes).unwrap(); + let program = parse_program_with_input_and_state(program_strin, input_string, state_string).unwrap(); assert_satisfied(program); } diff --git a/compiler/tests/mod.rs b/compiler/tests/mod.rs index da31698251..2b7aa6bef0 100644 --- a/compiler/tests/mod.rs +++ b/compiler/tests/mod.rs @@ -73,12 +73,11 @@ pub(crate) fn parse_program(bytes: &[u8]) -> Result Result { +pub(crate) fn parse_input(input_string: &str) -> Result { let mut compiler = new_compiler(); - let input_string = String::from_utf8_lossy(bytes); let path = PathBuf::new(); - compiler.parse_input(&input_string, &path, EMPTY_FILE, &path)?; + compiler.parse_input(input_string, &path, EMPTY_FILE, &path)?; Ok(compiler) } @@ -87,21 +86,19 @@ pub(crate) fn parse_state(state_string: &str) -> Result Result { let mut compiler = new_compiler(); - let input_string = String::from_utf8_lossy(input_bytes); - let state_string = String::from_utf8_lossy(state_bytes); let path = PathBuf::new(); - compiler.parse_input(&input_string, &path, &state_string, &path)?; + compiler.parse_input(input_string, &path, state_string, &path)?; Ok(compiler) } @@ -127,9 +124,6 @@ pub fn parse_program_with_state( state_string: &str, ) -> Result { let mut compiler = new_compiler(); - - // let program_string = String::from_utf8_lossy(program_bytes); - // let state_string = String::from_utf8_lossy(state_bytes); let path = PathBuf::new(); compiler.parse_input(EMPTY_FILE, &path, state_string, &path)?; @@ -139,18 +133,14 @@ pub fn parse_program_with_state( } pub fn parse_program_with_input_and_state( - program_bytes: &[u8], - input_bytes: &[u8], - state_bytes: &[u8], + program_string: &str, + input_string: &str, + state_string: &str, ) -> Result { let mut compiler = new_compiler(); - - let program_string = String::from_utf8_lossy(program_bytes); - let input_string = String::from_utf8_lossy(input_bytes); - let state_string = String::from_utf8_lossy(state_bytes); let path = PathBuf::new(); - compiler.parse_input(&input_string, &path, &state_string, &path)?; + compiler.parse_input(input_string, &path, state_string, &path)?; compiler.parse_program_from_string(&program_string)?; Ok(compiler) diff --git a/compiler/tests/syntax/mod.rs b/compiler/tests/syntax/mod.rs index 55b7292d2a..a4fd56f095 100644 --- a/compiler/tests/syntax/mod.rs +++ b/compiler/tests/syntax/mod.rs @@ -63,10 +63,9 @@ fn test_undefined() { } #[test] -#[ignore] fn input_syntax_error() { - let bytes = include_bytes!("input_semicolon.leo"); - let error = parse_input(bytes).err().unwrap(); + let input_string = include_str!("input_semicolon.leo"); + let error = parse_input(input_string).err().unwrap(); // Expect an input parser error. match error { From 7976c739e9b92fb792876ae6c132d561c16f691c Mon Sep 17 00:00:00 2001 From: collin Date: Fri, 4 Dec 2020 15:20:59 -0500 Subject: [PATCH 07/41] use include_str in program input + state tests --- compiler/tests/array/mod.rs | 172 +++++++++--------- compiler/tests/boolean/mod.rs | 22 +-- .../core/packages/unstable/blake2s/mod.rs | 13 +- compiler/tests/function/mod.rs | 26 ++- .../tests/input_files/program_input/mod.rs | 22 +-- .../program_input_and_program_state/mod.rs | 2 +- compiler/tests/mod.rs | 11 +- compiler/tests/statements/conditional/mod.rs | 10 +- 8 files changed, 136 insertions(+), 142 deletions(-) diff --git a/compiler/tests/array/mod.rs b/compiler/tests/array/mod.rs index 59610476e5..c26c21edc6 100644 --- a/compiler/tests/array/mod.rs +++ b/compiler/tests/array/mod.rs @@ -41,17 +41,17 @@ pub fn output_zeros(program: EdwardsTestCompiler) { #[test] fn test_registers() { - let program_bytes = include_bytes!("registers.leo"); - let ones_input_bytes = include_bytes!("input/registers_ones.in"); - let zeros_input_bytes = include_bytes!("input/registers_zeros.in"); + let program_string = include_str!("registers.leo"); + let ones_input_string = include_str!("input/registers_ones.in"); + let zeros_input_string = include_str!("input/registers_zeros.in"); // test ones input register => ones output register - let program = parse_program_with_input(program_bytes, ones_input_bytes).unwrap(); + let program = parse_program_with_input(program_string, ones_input_string).unwrap(); output_ones(program); // test zeros input register => zeros output register - let program = parse_program_with_input(program_bytes, zeros_input_bytes).unwrap(); + let program = parse_program_with_input(program_string, zeros_input_string).unwrap(); output_zeros(program); } @@ -60,9 +60,9 @@ fn test_registers() { #[test] fn test_inline() { - let program_bytes = include_bytes!("inline.leo"); - let input_bytes = include_bytes!("input/three_ones.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program_string = include_str!("inline.leo"); + let input_string = include_str!("input/three_ones.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); assert_satisfied(program); } @@ -77,72 +77,72 @@ fn test_inline_fail() { #[test] fn test_initializer() { - let program_bytes = include_bytes!("initializer.leo"); - let input_bytes = include_bytes!("input/three_ones.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program_string = include_str!("initializer.leo"); + let input_string = include_str!("input/three_ones.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); assert_satisfied(program); } #[test] fn test_initializer_fail() { - let program_bytes = include_bytes!("initializer_fail.leo"); - let input_bytes = include_bytes!("input/three_ones.in"); - let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err(); + let program_string = include_str!("initializer_fail.leo"); + let input_string = include_str!("input/three_ones.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); assert!(syntax_error); } #[test] fn test_initializer_input() { - let program_bytes = include_bytes!("initializer_input.leo"); - let input_bytes = include_bytes!("input/six_zeros.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program_string = include_str!("initializer_input.leo"); + let input_string = include_str!("input/six_zeros.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); assert_satisfied(program); } #[test] fn test_initializer_input_fail() { - let program_bytes = include_bytes!("initializer_input.leo"); - let input_bytes = include_bytes!("input/initializer_fail.in"); - let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err(); + let program_string = include_str!("initializer_input.leo"); + let input_string = include_str!("input/initializer_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); assert!(syntax_error); } #[test] fn test_input_nested_3x2() { - let program_bytes = include_bytes!("input_nested_3x2.leo"); - let input_bytes = include_bytes!("input/input_nested_3x2.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program_string = include_str!("input_nested_3x2.leo"); + let input_string = include_str!("input/input_nested_3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); assert_satisfied(program); } #[test] fn test_input_nested_3x2_fail() { - let program_bytes = include_bytes!("input_nested_3x2_fail.leo"); - let input_bytes = include_bytes!("input/input_nested_3x2_fail.in"); - let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err(); + let program_string = include_str!("input_nested_3x2_fail.leo"); + let input_string = include_str!("input/input_nested_3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); assert!(syntax_error); } #[test] fn test_input_tuple_3x2() { - let program_bytes = include_bytes!("input_tuple_3x2.leo"); - let input_bytes = include_bytes!("input/input_tuple_3x2.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program_string = include_str!("input_tuple_3x2.leo"); + let input_string = include_str!("input/input_tuple_3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); assert_satisfied(program); } #[test] fn test_input_tuple_3x2_fail() { - let program_bytes = include_bytes!("input_tuple_3x2_fail.leo"); - let input_bytes = include_bytes!("input/input_tuple_3x2_fail.in"); - let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err(); + let program_string = include_str!("input_tuple_3x2_fail.leo"); + let input_string = include_str!("input/input_tuple_3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); assert!(syntax_error); } @@ -213,18 +213,18 @@ fn test_tuple_3x2_value_fail() { #[test] fn test_spread() { - let program_bytes = include_bytes!("spread.leo"); - let input_bytes = include_bytes!("input/three_ones.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program_string = include_str!("spread.leo"); + let input_string = include_str!("input/three_ones.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); assert_satisfied(program); } #[test] fn test_slice() { - let program_bytes = include_bytes!("slice.leo"); - let input_bytes = include_bytes!("input/three_ones.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program_string = include_str!("slice.leo"); + let input_string = include_str!("input/three_ones.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); assert_satisfied(program); } @@ -371,72 +371,72 @@ fn test_type_tuple_value_tuple_4x3x2_fail() { #[test] fn test_input_type_nested_value_nested_3x2() { - let program_bytes = include_bytes!("type_input_3x2.leo"); - let input_bytes = include_bytes!("input/type_nested_value_nested_3x2.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program_string = include_str!("type_input_3x2.leo"); + let input_string = include_str!("input/type_nested_value_nested_3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); assert_satisfied(program); } #[test] fn test_input_type_nested_value_nested_3x2_fail() { - let program_bytes = include_bytes!("type_input_3x2.leo"); - let input_bytes = include_bytes!("input/type_nested_value_nested_3x2_fail.in"); - let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err(); + let program_string = include_str!("type_input_3x2.leo"); + let input_string = include_str!("input/type_nested_value_nested_3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); assert!(syntax_error); } #[test] fn test_input_type_nested_value_nested_4x3x2() { - let program_bytes = include_bytes!("type_input_4x3x2.leo"); - let input_bytes = include_bytes!("input/type_nested_value_nested_4x3x2.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program_string = include_str!("type_input_4x3x2.leo"); + let input_string = include_str!("input/type_nested_value_nested_4x3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); assert_satisfied(program); } #[test] fn test_input_type_nested_value_nested_4x3x2_fail() { - let program_bytes = include_bytes!("type_input_4x3x2.leo"); - let input_bytes = include_bytes!("input/type_nested_value_nested_4x3x2_fail.in"); - let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err(); + let program_string = include_str!("type_input_4x3x2.leo"); + let input_string = include_str!("input/type_nested_value_nested_4x3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); assert!(syntax_error); } #[test] fn test_input_type_nested_value_tuple_3x2() { - let program_bytes = include_bytes!("type_input_3x2.leo"); - let input_bytes = include_bytes!("input/type_nested_value_tuple_3x2.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program_string = include_str!("type_input_3x2.leo"); + let input_string = include_str!("input/type_nested_value_tuple_3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); assert_satisfied(program); } #[test] fn test_input_type_nested_value_tuple_3x2_fail() { - let program_bytes = include_bytes!("type_input_3x2.leo"); - let input_bytes = include_bytes!("input/type_nested_value_tuple_3x2_fail.in"); - let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err(); + let program_string = include_str!("type_input_3x2.leo"); + let input_string = include_str!("input/type_nested_value_tuple_3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); assert!(syntax_error); } #[test] fn test_input_type_nested_value_tuple_4x3x2() { - let program_bytes = include_bytes!("type_input_4x3x2.leo"); - let input_bytes = include_bytes!("input/type_nested_value_tuple_4x3x2.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program_string = include_str!("type_input_4x3x2.leo"); + let input_string = include_str!("input/type_nested_value_tuple_4x3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); assert_satisfied(program) } #[test] fn test_input_type_nested_value_tuple_4x3x2_fail() { - let program_bytes = include_bytes!("type_input_4x3x2.leo"); - let input_bytes = include_bytes!("input/type_nested_value_tuple_4x3x2_fail.in"); - let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err(); + let program_string = include_str!("type_input_4x3x2.leo"); + let input_string = include_str!("input/type_nested_value_tuple_4x3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); assert!(syntax_error); } @@ -445,72 +445,72 @@ fn test_input_type_nested_value_tuple_4x3x2_fail() { #[test] fn test_input_type_tuple_value_nested_3x2() { - let program_bytes = include_bytes!("type_input_3x2.leo"); - let input_bytes = include_bytes!("input/type_tuple_value_nested_3x2.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program_string = include_str!("type_input_3x2.leo"); + let input_string = include_str!("input/type_tuple_value_nested_3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); assert_satisfied(program); } #[test] fn test_input_type_tuple_value_nested_3x2_fail() { - let program_bytes = include_bytes!("type_input_3x2.leo"); - let input_bytes = include_bytes!("input/type_tuple_value_nested_3x2_fail.in"); - let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err(); + let program_string = include_str!("type_input_3x2.leo"); + let input_string = include_str!("input/type_tuple_value_nested_3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); assert!(syntax_error); } #[test] fn test_input_type_tuple_value_nested_4x3x2() { - let program_bytes = include_bytes!("type_input_4x3x2.leo"); - let input_bytes = include_bytes!("input/type_tuple_value_nested_4x3x2.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program_string = include_str!("type_input_4x3x2.leo"); + let input_string = include_str!("input/type_tuple_value_nested_4x3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); assert_satisfied(program); } #[test] fn test_input_type_tuple_value_nested_4x3x2_fail() { - let program_bytes = include_bytes!("type_input_4x3x2.leo"); - let input_bytes = include_bytes!("input/type_tuple_value_nested_4x3x2_fail.in"); - let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err(); + let program_string = include_str!("type_input_4x3x2.leo"); + let input_string = include_str!("input/type_tuple_value_nested_4x3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); assert!(syntax_error); } #[test] fn test_input_type_tuple_value_tuple_3x2() { - let program_bytes = include_bytes!("type_input_3x2.leo"); - let input_bytes = include_bytes!("input/type_tuple_value_tuple_3x2.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program_string = include_str!("type_input_3x2.leo"); + let input_string = include_str!("input/type_tuple_value_tuple_3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); assert_satisfied(program); } #[test] fn test_input_type_tuple_value_tuple_3x2_fail() { - let program_bytes = include_bytes!("type_input_3x2.leo"); - let input_bytes = include_bytes!("input/type_tuple_value_tuple_3x2_fail.in"); - let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err(); + let program_string = include_str!("type_input_3x2.leo"); + let input_string = include_str!("input/type_tuple_value_tuple_3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); assert!(syntax_error); } #[test] fn test_input_type_tuple_value_tuple_4x3x2() { - let program_bytes = include_bytes!("type_input_4x3x2.leo"); - let input_bytes = include_bytes!("input/type_tuple_value_tuple_4x3x2.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program_string = include_str!("type_input_4x3x2.leo"); + let input_string = include_str!("input/type_tuple_value_tuple_4x3x2.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); assert_satisfied(program); } #[test] fn test_input_type_tuple_value_tuple_4x3x2_fail() { - let program_bytes = include_bytes!("type_input_4x3x2.leo"); - let input_bytes = include_bytes!("input/type_tuple_value_tuple_4x3x2_fail.in"); - let syntax_error = parse_program_with_input(program_bytes, input_bytes).is_err(); + let program_string = include_str!("type_input_4x3x2.leo"); + let input_string = include_str!("input/type_tuple_value_tuple_4x3x2_fail.in"); + let syntax_error = parse_program_with_input(program_string, input_string).is_err(); assert!(syntax_error); } diff --git a/compiler/tests/boolean/mod.rs b/compiler/tests/boolean/mod.rs index 82eaeb8cf2..175ebce138 100644 --- a/compiler/tests/boolean/mod.rs +++ b/compiler/tests/boolean/mod.rs @@ -40,37 +40,37 @@ pub fn output_false(program: EdwardsTestCompiler) { #[test] fn test_input_pass() { - let program_bytes = include_bytes!("assert_eq_input.leo"); - let input_bytes = include_bytes!("input/true_true.in"); + let program_string = include_str!("assert_eq_input.leo"); + let input_string = include_str!("input/true_true.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program = parse_program_with_input(program_string, input_string).unwrap(); assert_satisfied(program); } #[test] fn test_input_fail() { - let program_bytes = include_bytes!("assert_eq_input.leo"); - let input_bytes = include_bytes!("input/true_false.in"); + let program_string = include_str!("assert_eq_input.leo"); + let input_string = include_str!("input/true_false.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program = parse_program_with_input(program_string, input_string).unwrap(); expect_compiler_error(program); } #[test] fn test_registers() { - let program_bytes = include_bytes!("output_register.leo"); - let true_input_bytes = include_bytes!("input/registers_true.in"); - let false_input_bytes = include_bytes!("input/registers_false.in"); + let program_string = include_str!("output_register.leo"); + let true_input_string = include_str!("input/registers_true.in"); + let false_input_string = include_str!("input/registers_false.in"); // test true input register => true output register - let program = parse_program_with_input(program_bytes, true_input_bytes).unwrap(); + let program = parse_program_with_input(program_string, true_input_string).unwrap(); output_true(program); // test false input register => false output register - let program = parse_program_with_input(program_bytes, false_input_bytes).unwrap(); + let program = parse_program_with_input(program_string, false_input_string).unwrap(); output_false(program); } diff --git a/compiler/tests/core/packages/unstable/blake2s/mod.rs b/compiler/tests/core/packages/unstable/blake2s/mod.rs index 2b308db42e..2a94859fdd 100644 --- a/compiler/tests/core/packages/unstable/blake2s/mod.rs +++ b/compiler/tests/core/packages/unstable/blake2s/mod.rs @@ -48,17 +48,16 @@ fn test_arguments_type_fail() { #[test] fn test_blake2s_input() { - let input_bytes = include_bytes!("inputs/valid_input.in"); - let program_bytes = include_bytes!("blake2s_input.leo"); - let expected_bytes = include_bytes!("outputs/valid_output.out"); + let input_string = include_str!("inputs/valid_input.in"); + let program_string = include_str!("blake2s_input.leo"); + let expected_string = include_str!("outputs/valid_output.out"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program = parse_program_with_input(program_string, input_string).unwrap(); - 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(); + let actual_string = std::str::from_utf8(actual_bytes.bytes().as_slice()).unwrap(); - assert_eq!(expected, actual) + assert_eq!(expected_string, actual_string) } #[test] diff --git a/compiler/tests/function/mod.rs b/compiler/tests/function/mod.rs index dc31094f76..8c8e7cb31a 100644 --- a/compiler/tests/function/mod.rs +++ b/compiler/tests/function/mod.rs @@ -50,16 +50,15 @@ fn test_iteration_repeated() { #[test] fn test_newlines() { - let input_bytes = include_bytes!("input/newlines.in"); - let program_bytes = include_bytes!("newlines.leo"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let input_string = include_str!("input/newlines.in"); + let program_string = include_str!("newlines.leo"); + let program = parse_program_with_input(program_string, input_string).unwrap(); - let expected_bytes = include_bytes!("output/newlines.out"); - let expected = std::str::from_utf8(expected_bytes).unwrap(); + let expected_string = include_str!("output/newlines.out"); let actual_bytes = get_output(program); - let actual = std::str::from_utf8(actual_bytes.bytes().as_slice()).unwrap(); + let actual_string = std::str::from_utf8(actual_bytes.bytes().as_slice()).unwrap(); - assert_eq!(expected, actual); + assert_eq!(expected_string, actual_string); } #[test] @@ -72,17 +71,16 @@ fn test_multiple_returns() { #[test] fn test_multiple_returns_main() { - let program_bytes = include_bytes!("multiple_main.leo"); - let input_bytes = include_bytes!("input/registers.in"); + let program_string = include_str!("multiple_main.leo"); + let input_string = include_str!("input/registers.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program = parse_program_with_input(program_string, input_string).unwrap(); - let expected_bytes = include_bytes!("output/registers.out"); - let expected = std::str::from_utf8(expected_bytes).unwrap(); + let expected_string = include_str!("output/registers.out"); let actual_bytes = get_output(program); - let actual = std::str::from_utf8(actual_bytes.bytes().as_slice()).unwrap(); + let actual_string = std::str::from_utf8(actual_bytes.bytes().as_slice()).unwrap(); - assert_eq!(expected, actual); + assert_eq!(expected_string, actual_string); } #[test] diff --git a/compiler/tests/input_files/program_input/mod.rs b/compiler/tests/input_files/program_input/mod.rs index 830e3b8651..cf77a8e3ed 100644 --- a/compiler/tests/input_files/program_input/mod.rs +++ b/compiler/tests/input_files/program_input/mod.rs @@ -26,8 +26,8 @@ fn expect_fail(program: EdwardsTestCompiler) { #[test] fn test_input_pass() { - let program_bytes = include_bytes!("main.leo"); - let input_bytes = include_bytes!("input/main.in"); + let program_bytes = include_str!("main.leo"); + let input_bytes = include_str!("input/main.in"); let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); @@ -36,30 +36,30 @@ fn test_input_pass() { #[test] fn test_input_fail_name() { - let program_bytes = include_bytes!("main.leo"); - let input_bytes = include_bytes!("input/main_fail_name.in"); + let program_string = include_str!("main.leo"); + let input_string = include_str!("input/main_fail_name.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program = parse_program_with_input(program_string, input_string).unwrap(); expect_fail(program); } #[test] fn test_input_fail_type() { - let program_bytes = include_bytes!("main.leo"); - let input_bytes = include_bytes!("input/main_fail_type.in"); + let program_string = include_str!("main.leo"); + let input_string = include_str!("input/main_fail_type.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program = parse_program_with_input(program_string, input_string).unwrap(); expect_fail(program); } #[test] fn test_input_multiple() { - let program_bytes = include_bytes!("main_multiple.leo"); - let input_bytes = include_bytes!("input/main_multiple.in"); + let program_string = include_str!("main_multiple.leo"); + let input_string = include_str!("input/main_multiple.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program = parse_program_with_input(program_string, input_string).unwrap(); assert_satisfied(program); } diff --git a/compiler/tests/input_files/program_input_and_program_state/mod.rs b/compiler/tests/input_files/program_input_and_program_state/mod.rs index 302f6fd433..26f2fead35 100644 --- a/compiler/tests/input_files/program_input_and_program_state/mod.rs +++ b/compiler/tests/input_files/program_input_and_program_state/mod.rs @@ -38,7 +38,7 @@ fn test_access() { let input_string = include_str!("input/token_withdraw.in"); let state_string = include_str!("input/token_withdraw.state"); - let program = parse_program_with_input_and_state(program_strin, input_string, state_string).unwrap(); + let program = parse_program_with_input_and_state(program_string, input_string, state_string).unwrap(); assert_satisfied(program); } diff --git a/compiler/tests/mod.rs b/compiler/tests/mod.rs index 2b7aa6bef0..d2d66b8d8b 100644 --- a/compiler/tests/mod.rs +++ b/compiler/tests/mod.rs @@ -104,17 +104,14 @@ pub(crate) fn parse_input_and_state( } pub fn parse_program_with_input( - program_bytes: &[u8], - input_bytes: &[u8], + program_string: &str, + input_string: &str, ) -> Result { let mut compiler = new_compiler(); - - let program_string = String::from_utf8_lossy(program_bytes); - let input_string = String::from_utf8_lossy(input_bytes); let path = PathBuf::new(); - compiler.parse_input(&input_string, &path, EMPTY_FILE, &path)?; - compiler.parse_program_from_string(&program_string)?; + compiler.parse_input(input_string, &path, EMPTY_FILE, &path)?; + compiler.parse_program_from_string(program_string)?; Ok(compiler) } diff --git a/compiler/tests/statements/conditional/mod.rs b/compiler/tests/statements/conditional/mod.rs index 3c243c9804..958032c411 100644 --- a/compiler/tests/statements/conditional/mod.rs +++ b/compiler/tests/statements/conditional/mod.rs @@ -205,19 +205,19 @@ fn output_zero(program: EdwardsTestCompiler) { #[test] fn test_multiple_returns() { - let program_bytes = include_bytes!("multiple_returns.leo"); + let program_string = include_str!("multiple_returns.leo"); // Check that an input value of 1 writes 1 to the output registers - let registers_one_bytes = include_bytes!("input/registers_one.in"); - let program = parse_program_with_input(program_bytes, registers_one_bytes).unwrap(); + let registers_one_string = include_str!("input/registers_one.in"); + let program = parse_program_with_input(program_string, registers_one_string).unwrap(); output_one(program); // Check that an input value of 0 writes 0 to the output registers - let registers_zero_bytes = include_bytes!("input/registers_zero.in"); - let program = parse_program_with_input(program_bytes, registers_zero_bytes).unwrap(); + let registers_zero_string = include_str!("input/registers_zero.in"); + let program = parse_program_with_input(program_string, registers_zero_string).unwrap(); output_zero(program); } From 674caf590278253ef08370ca88b53f37ccf4b3a0 Mon Sep 17 00:00:00 2001 From: collin Date: Fri, 4 Dec 2020 15:34:51 -0500 Subject: [PATCH 08/41] use include_str in all program tests --- compiler/tests/address/mod.rs | 44 ++++---- compiler/tests/array/mod.rs | 104 +++++++++--------- compiler/tests/boolean/mod.rs | 26 ++--- compiler/tests/circuits/mod.rs | 56 +++++----- compiler/tests/console/mod.rs | 24 ++-- compiler/tests/core/mod.rs | 10 +- .../core/packages/unstable/blake2s/mod.rs | 6 +- compiler/tests/definition/mod.rs | 4 +- compiler/tests/field/mod.rs | 28 ++--- compiler/tests/function/mod.rs | 32 +++--- compiler/tests/group/mod.rs | 57 +++++----- compiler/tests/import/mod.rs | 24 ++-- compiler/tests/integers/int_macro.rs | 40 +++---- compiler/tests/integers/uint_macro.rs | 34 +++--- compiler/tests/mod.rs | 5 +- compiler/tests/mutability/mod.rs | 26 ++--- compiler/tests/statements/conditional/mod.rs | 10 +- compiler/tests/statements/mod.rs | 6 +- compiler/tests/syntax/identifiers/mod.rs | 20 ++-- compiler/tests/syntax/mod.rs | 6 +- compiler/tests/tuples/mod.rs | 26 ++--- 21 files changed, 296 insertions(+), 292 deletions(-) diff --git a/compiler/tests/address/mod.rs b/compiler/tests/address/mod.rs index 3d892a5fb7..eb93b660f9 100644 --- a/compiler/tests/address/mod.rs +++ b/compiler/tests/address/mod.rs @@ -22,72 +22,72 @@ static TEST_ADDRESS_2: &str = "aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams #[test] fn test_valid() { - let bytes = include_bytes!("valid.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("valid.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program) } #[test] fn test_invalid_prefix() { - let bytes = include_bytes!("invalid_prefix.leo"); - let syntax_error = parse_program(bytes).is_err(); + let program_string = include_str!("invalid_prefix.leo"); + let syntax_error = parse_program(program_string).is_err(); assert!(syntax_error); } #[test] fn test_invalid_length() { - let bytes = include_bytes!("invalid_length.leo"); - let syntax_error = parse_program(bytes).is_err(); + let program_string = include_str!("invalid_length.leo"); + let syntax_error = parse_program(program_string).is_err(); assert!(syntax_error); } #[test] fn test_empty() { - let bytes = include_bytes!("empty.leo"); - let syntax_error = parse_program(bytes).is_err(); + let program_string = include_str!("empty.leo"); + let syntax_error = parse_program(program_string).is_err(); assert!(syntax_error); } #[test] fn test_implicit_valid() { - let bytes = include_bytes!("implicit_valid.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("implicit_valid.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_implicit_invalid() { - let bytes = include_bytes!("implicit_invalid.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("implicit_invalid.leo"); + let program = parse_program(program_string).unwrap(); let _output = expect_compiler_error(program); } #[test] fn test_console_assert_pass() { - let bytes = include_bytes!("console_assert_pass.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("console_assert_pass.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_console_assert_fail() { - let bytes = include_bytes!("console_assert_fail.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("console_assert_fail.leo"); + let program = parse_program(program_string).unwrap(); let _output = expect_compiler_error(program); } #[test] fn test_ternary() { - let bytes = include_bytes!("ternary.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("ternary.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("s", Some(InputValue::Boolean(true))), @@ -98,7 +98,7 @@ fn test_ternary() { assert_satisfied(program); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("s", Some(InputValue::Boolean(false))), @@ -112,8 +112,8 @@ fn test_ternary() { #[test] fn test_equal() { - let bytes = include_bytes!("equal.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("equal.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Address(TEST_ADDRESS_1.to_string()))), @@ -125,7 +125,7 @@ fn test_equal() { assert_satisfied(program); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Address(TEST_ADDRESS_1.to_string()))), diff --git a/compiler/tests/array/mod.rs b/compiler/tests/array/mod.rs index c26c21edc6..6d4684ad18 100644 --- a/compiler/tests/array/mod.rs +++ b/compiler/tests/array/mod.rs @@ -69,8 +69,8 @@ fn test_inline() { #[test] fn test_inline_fail() { - let program_bytes = include_bytes!("inline.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("inline.leo"); + let program = parse_program(program_string).unwrap(); let _err = expect_compiler_error(program); } @@ -149,64 +149,64 @@ fn test_input_tuple_3x2_fail() { #[test] fn test_multi_fail_initializer() { - let program_bytes = include_bytes!("multi_fail_initializer.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("multi_fail_initializer.leo"); + let program = parse_program(program_string).unwrap(); let _err = expect_compiler_error(program); } #[test] fn test_multi_inline_fail() { - let program_bytes = include_bytes!("multi_fail_inline.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("multi_fail_inline.leo"); + let program = parse_program(program_string).unwrap(); let _err = expect_compiler_error(program); } #[test] fn test_multi_initializer() { - let program_bytes = include_bytes!("multi_initializer.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("multi_initializer.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_multi_initializer_fail() { - let program_bytes = include_bytes!("multi_initializer_fail.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("multi_initializer_fail.leo"); + let program = parse_program(program_string).unwrap(); let _err = expect_compiler_error(program); } #[test] fn test_nested_3x2_value() { - let program_bytes = include_bytes!("nested_3x2_value.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("nested_3x2_value.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_nested_3x2_value_fail() { - let program_bytes = include_bytes!("nested_3x2_value_fail.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("nested_3x2_value_fail.leo"); + let program = parse_program(program_string).unwrap(); let _err = expect_compiler_error(program); } #[test] fn test_tuple_3x2_value() { - let program_bytes = include_bytes!("tuple_3x2_value.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("tuple_3x2_value.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_tuple_3x2_value_fail() { - let program_bytes = include_bytes!("tuple_3x2_value_fail.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("tuple_3x2_value_fail.leo"); + let program = parse_program(program_string).unwrap(); let _err = expect_compiler_error(program); } @@ -233,136 +233,136 @@ fn test_slice() { #[test] fn test_type_fail() { - let program_bytes = include_bytes!("type_fail.leo"); - let syntax_error = parse_program(program_bytes).is_err(); + let program_string = include_str!("type_fail.leo"); + let syntax_error = parse_program(program_string).is_err(); assert!(syntax_error); } #[test] fn test_type_nested_value_nested_3x2() { - let program_bytes = include_bytes!("type_nested_value_nested_3x2.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("type_nested_value_nested_3x2.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_type_nested_value_nested_3x2_fail() { - let program_bytes = include_bytes!("type_nested_value_nested_3x2_fail.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("type_nested_value_nested_3x2_fail.leo"); + let program = parse_program(program_string).unwrap(); let _err = expect_compiler_error(program); } #[test] fn test_type_nested_value_nested_4x3x2() { - let program_bytes = include_bytes!("type_nested_value_nested_4x3x2.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("type_nested_value_nested_4x3x2.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_type_nested_value_nested_4x3x2_fail() { - let program_bytes = include_bytes!("type_nested_value_nested_4x3x2_fail.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("type_nested_value_nested_4x3x2_fail.leo"); + let program = parse_program(program_string).unwrap(); let _err = expect_compiler_error(program); } #[test] fn test_type_nested_value_tuple_3x2() { - let program_bytes = include_bytes!("type_nested_value_tuple_3x2.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("type_nested_value_tuple_3x2.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_type_nested_value_tuple_3x2_fail() { - let program_bytes = include_bytes!("type_nested_value_tuple_3x2_fail.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("type_nested_value_tuple_3x2_fail.leo"); + let program = parse_program(program_string).unwrap(); let _err = expect_compiler_error(program); } #[test] fn test_type_nested_value_tuple_4x3x2() { - let program_bytes = include_bytes!("type_nested_value_tuple_4x3x2.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("type_nested_value_tuple_4x3x2.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_type_nested_value_tuple_4x3x2_fail() { - let program_bytes = include_bytes!("type_nested_value_tuple_4x3x2_fail.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("type_nested_value_tuple_4x3x2_fail.leo"); + let program = parse_program(program_string).unwrap(); let _err = expect_compiler_error(program); } #[test] fn test_type_tuple_value_nested_3x2() { - let program_bytes = include_bytes!("type_tuple_value_nested_3x2.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("type_tuple_value_nested_3x2.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_type_tuple_value_nested_3x2_fail() { - let program_bytes = include_bytes!("type_tuple_value_nested_3x2_fail.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("type_tuple_value_nested_3x2_fail.leo"); + let program = parse_program(program_string).unwrap(); let _err = expect_compiler_error(program); } #[test] fn test_type_tuple_value_nested_4x3x2() { - let program_bytes = include_bytes!("type_tuple_value_nested_4x3x2.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("type_tuple_value_nested_4x3x2.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_type_tuple_value_nested_4x3x2_fail() { - let program_bytes = include_bytes!("type_tuple_value_nested_4x3x2_fail.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("type_tuple_value_nested_4x3x2_fail.leo"); + let program = parse_program(program_string).unwrap(); let _err = expect_compiler_error(program); } #[test] fn test_type_tuple_value_tuple_3x2() { - let program_bytes = include_bytes!("type_tuple_value_tuple_3x2.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("type_tuple_value_tuple_3x2.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_type_tuple_value_tuple_3x2_fail() { - let program_bytes = include_bytes!("type_tuple_value_tuple_3x2_fail.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("type_tuple_value_tuple_3x2_fail.leo"); + let program = parse_program(program_string).unwrap(); let _err = expect_compiler_error(program); } #[test] fn test_type_tuple_value_tuple_4x3x2() { - let program_bytes = include_bytes!("type_tuple_value_tuple_4x3x2.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("type_tuple_value_tuple_4x3x2.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_type_tuple_value_tuple_4x3x2_fail() { - let program_bytes = include_bytes!("type_tuple_value_tuple_4x3x2_fail.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("type_tuple_value_tuple_4x3x2_fail.leo"); + let program = parse_program(program_string).unwrap(); let _err = expect_compiler_error(program); } diff --git a/compiler/tests/boolean/mod.rs b/compiler/tests/boolean/mod.rs index 175ebce138..d71ff3def0 100644 --- a/compiler/tests/boolean/mod.rs +++ b/compiler/tests/boolean/mod.rs @@ -79,7 +79,7 @@ fn test_registers() { #[test] fn test_not_true() { - let bytes = include_bytes!("not_true.leo"); + let bytes = include_str!("not_true.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -87,7 +87,7 @@ fn test_not_true() { #[test] fn test_not_false() { - let bytes = include_bytes!("not_false.leo"); + let bytes = include_str!("not_false.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -95,7 +95,7 @@ fn test_not_false() { #[test] fn test_not_mutable() { - let bytes = include_bytes!("not_mutable.leo"); + let bytes = include_str!("not_mutable.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -103,7 +103,7 @@ fn test_not_mutable() { #[test] fn test_not_u32() { - let bytes = include_bytes!("not_u32.leo"); + let bytes = include_str!("not_u32.leo"); let program = parse_program(bytes).unwrap(); expect_compiler_error(program); @@ -113,7 +113,7 @@ fn test_not_u32() { #[test] fn test_true_or_true() { - let bytes = include_bytes!("true_or_true.leo"); + let bytes = include_str!("true_or_true.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -121,7 +121,7 @@ fn test_true_or_true() { #[test] fn test_true_or_false() { - let bytes = include_bytes!("true_or_false.leo"); + let bytes = include_str!("true_or_false.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -129,7 +129,7 @@ fn test_true_or_false() { #[test] fn test_false_or_false() { - let bytes = include_bytes!("false_or_false.leo"); + let bytes = include_str!("false_or_false.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -137,7 +137,7 @@ fn test_false_or_false() { #[test] fn test_true_or_u32() { - let bytes = include_bytes!("true_or_u32.leo"); + let bytes = include_str!("true_or_u32.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error); @@ -147,7 +147,7 @@ fn test_true_or_u32() { #[test] fn test_true_and_true() { - let bytes = include_bytes!("true_and_true.leo"); + let bytes = include_str!("true_and_true.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -155,7 +155,7 @@ fn test_true_and_true() { #[test] fn test_true_and_false() { - let bytes = include_bytes!("true_and_false.leo"); + let bytes = include_str!("true_and_false.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -163,7 +163,7 @@ fn test_true_and_false() { #[test] fn test_false_and_false() { - let bytes = include_bytes!("false_and_false.leo"); + let bytes = include_str!("false_and_false.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -171,7 +171,7 @@ fn test_false_and_false() { #[test] fn test_true_and_u32() { - let bytes = include_bytes!("true_and_u32.leo"); + let bytes = include_str!("true_and_u32.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error); @@ -181,7 +181,7 @@ fn test_true_and_u32() { #[test] fn test_all() { - let bytes = include_bytes!("all.leo"); + let bytes = include_str!("all.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); diff --git a/compiler/tests/circuits/mod.rs b/compiler/tests/circuits/mod.rs index 33d0d41ea9..4bfdcdac34 100644 --- a/compiler/tests/circuits/mod.rs +++ b/compiler/tests/circuits/mod.rs @@ -20,7 +20,7 @@ use crate::{assert_satisfied, expect_compiler_error, expect_type_inference_error #[test] fn test_inline() { - let bytes = include_bytes!("inline.leo"); + let bytes = include_str!("inline.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -28,7 +28,7 @@ fn test_inline() { #[test] fn test_inline_fail() { - let bytes = include_bytes!("inline_fail.leo"); + let bytes = include_str!("inline_fail.leo"); let program = parse_program(bytes).unwrap(); expect_compiler_error(program); @@ -36,7 +36,7 @@ fn test_inline_fail() { #[test] fn test_inline_undefined() { - let bytes = include_bytes!("inline_undefined.leo"); + let bytes = include_str!("inline_undefined.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error); @@ -46,7 +46,7 @@ fn test_inline_undefined() { #[test] fn test_member_variable() { - let bytes = include_bytes!("member_variable.leo"); + let bytes = include_str!("member_variable.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -54,7 +54,7 @@ fn test_member_variable() { #[test] fn test_member_variable_fail() { - let bytes = include_bytes!("member_variable_fail.leo"); + let bytes = include_str!("member_variable_fail.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error); @@ -62,7 +62,7 @@ fn test_member_variable_fail() { #[test] fn test_member_variable_and_function() { - let bytes = include_bytes!("member_variable_and_function.leo"); + let bytes = include_str!("member_variable_and_function.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -70,7 +70,7 @@ fn test_member_variable_and_function() { #[test] fn test_member_function() { - let bytes = include_bytes!("member_function.leo"); + let bytes = include_str!("member_function.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -78,7 +78,7 @@ fn test_member_function() { #[test] fn test_member_function_fail() { - let bytes = include_bytes!("member_function_fail.leo"); + let bytes = include_str!("member_function_fail.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error); @@ -86,7 +86,7 @@ fn test_member_function_fail() { #[test] fn test_member_function_invalid() { - let bytes = include_bytes!("member_function_invalid.leo"); + let bytes = include_str!("member_function_invalid.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error); @@ -94,7 +94,7 @@ fn test_member_function_invalid() { #[test] fn test_member_function_nested() { - let bytes = include_bytes!("member_function_nested.leo"); + let bytes = include_str!("member_function_nested.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -102,7 +102,7 @@ fn test_member_function_nested() { #[test] fn test_member_static_function() { - let bytes = include_bytes!("member_static_function.leo"); + let bytes = include_str!("member_static_function.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -110,7 +110,7 @@ fn test_member_static_function() { #[test] fn test_member_static_function_nested() { - let bytes = include_bytes!("member_static_function_nested.leo"); + let bytes = include_str!("member_static_function_nested.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -118,7 +118,7 @@ fn test_member_static_function_nested() { #[test] fn test_member_static_function_invalid() { - let bytes = include_bytes!("member_static_function_invalid.leo"); + let bytes = include_str!("member_static_function_invalid.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error) @@ -126,7 +126,7 @@ fn test_member_static_function_invalid() { #[test] fn test_member_static_function_undefined() { - let bytes = include_bytes!("member_static_function_undefined.leo"); + let bytes = include_str!("member_static_function_undefined.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error) @@ -136,7 +136,7 @@ fn test_member_static_function_undefined() { #[test] fn test_mutate_function_fail() { - let bytes = include_bytes!("mut_function_fail.leo"); + let bytes = include_str!("mut_function_fail.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error); @@ -144,7 +144,7 @@ fn test_mutate_function_fail() { #[test] fn test_mutate_self_variable() { - let bytes = include_bytes!("mut_self_variable.leo"); + let bytes = include_str!("mut_self_variable.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -152,7 +152,7 @@ fn test_mutate_self_variable() { #[test] fn test_mutate_self_variable_fail() { - let bytes = include_bytes!("mut_self_variable_fail.leo"); + let bytes = include_str!("mut_self_variable_fail.leo"); let program = parse_program(bytes).unwrap(); expect_compiler_error(program); @@ -160,7 +160,7 @@ fn test_mutate_self_variable_fail() { #[test] fn test_mutate_self_function_fail() { - let bytes = include_bytes!("mut_self_function_fail.leo"); + let bytes = include_str!("mut_self_function_fail.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error); @@ -168,7 +168,7 @@ fn test_mutate_self_function_fail() { #[test] fn test_mutate_self_static_function_fail() { - let bytes = include_bytes!("mut_self_static_function_fail.leo"); + let bytes = include_str!("mut_self_static_function_fail.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error); @@ -176,7 +176,7 @@ fn test_mutate_self_static_function_fail() { #[test] fn test_mutate_static_function_fail() { - let bytes = include_bytes!("mut_static_function_fail.leo"); + let bytes = include_str!("mut_static_function_fail.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error); @@ -184,7 +184,7 @@ fn test_mutate_static_function_fail() { #[test] fn test_mutate_variable() { - let bytes = include_bytes!("mut_variable.leo"); + let bytes = include_str!("mut_variable.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -192,7 +192,7 @@ fn test_mutate_variable() { #[test] fn test_mutate_variable_fail() { - let bytes = include_bytes!("mut_variable_fail.leo"); + let bytes = include_str!("mut_variable_fail.leo"); let program = parse_program(bytes).unwrap(); expect_compiler_error(program); @@ -202,7 +202,7 @@ fn test_mutate_variable_fail() { #[test] fn test_self_fail() { - let bytes = include_bytes!("self_fail.leo"); + let bytes = include_str!("self_fail.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error); @@ -210,7 +210,7 @@ fn test_self_fail() { #[test] fn test_self_member_pass() { - let bytes = include_bytes!("self_member.leo"); + let bytes = include_str!("self_member.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -218,7 +218,7 @@ fn test_self_member_pass() { #[test] fn test_self_member_invalid() { - let bytes = include_bytes!("self_member_invalid.leo"); + let bytes = include_str!("self_member_invalid.leo"); let program = parse_program(bytes).unwrap(); let _err = expect_compiler_error(program); @@ -226,7 +226,7 @@ fn test_self_member_invalid() { #[test] fn test_self_member_undefined() { - let bytes = include_bytes!("self_member_undefined.leo"); + let bytes = include_str!("self_member_undefined.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error); @@ -236,7 +236,7 @@ fn test_self_member_undefined() { #[test] fn test_pedersen_mock() { - let bytes = include_bytes!("pedersen_mock.leo"); + let bytes = include_str!("pedersen_mock.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -244,7 +244,7 @@ fn test_pedersen_mock() { #[test] fn test_define_circuit_inside_circuit_function() { - let bytes = include_bytes!("define_circuit_inside_circuit_function.leo"); + let bytes = include_str!("define_circuit_inside_circuit_function.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); diff --git a/compiler/tests/console/mod.rs b/compiler/tests/console/mod.rs index ba7c48aae9..9bf1f820df 100644 --- a/compiler/tests/console/mod.rs +++ b/compiler/tests/console/mod.rs @@ -19,7 +19,7 @@ use leo_ast::InputValue; #[test] fn test_log() { - let bytes = include_bytes!("log.leo"); + let bytes = include_str!("log.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -27,14 +27,14 @@ fn test_log() { #[test] fn test_log_fail() { - let bytes = include_bytes!("log_fail.leo"); + let bytes = include_str!("log_fail.leo"); assert!(parse_program(bytes).is_err()); } #[test] fn test_log_parameter() { - let bytes = include_bytes!("log_parameter.leo"); + let bytes = include_str!("log_parameter.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -42,7 +42,7 @@ fn test_log_parameter() { #[test] fn test_log_parameter_many() { - let bytes = include_bytes!("log_parameter_many.leo"); + let bytes = include_str!("log_parameter_many.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -50,7 +50,7 @@ fn test_log_parameter_many() { #[test] fn test_log_parameter_fail_unknown() { - let bytes = include_bytes!("log_parameter_fail_unknown.leo"); + let bytes = include_str!("log_parameter_fail_unknown.leo"); let program = parse_program(bytes).unwrap(); expect_compiler_error(program); @@ -58,7 +58,7 @@ fn test_log_parameter_fail_unknown() { #[test] fn test_log_parameter_fail_empty() { - let bytes = include_bytes!("log_parameter_fail_empty.leo"); + let bytes = include_str!("log_parameter_fail_empty.leo"); let program = parse_program(bytes).unwrap(); expect_compiler_error(program); @@ -66,7 +66,7 @@ fn test_log_parameter_fail_empty() { #[test] fn test_log_parameter_fail_none() { - let bytes = include_bytes!("log_parameter_fail_empty.leo"); + let bytes = include_str!("log_parameter_fail_empty.leo"); let program = parse_program(bytes).unwrap(); expect_compiler_error(program); @@ -74,7 +74,7 @@ fn test_log_parameter_fail_none() { #[test] fn test_log_input() { - let bytes = include_bytes!("log_input.leo"); + let bytes = include_str!("log_input.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]); @@ -88,7 +88,7 @@ fn test_log_input() { #[test] fn test_debug() { - let bytes = include_bytes!("debug.leo"); + let bytes = include_str!("debug.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -98,7 +98,7 @@ fn test_debug() { #[test] fn test_error() { - let bytes = include_bytes!("error.leo"); + let bytes = include_str!("error.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -108,7 +108,7 @@ fn test_error() { #[test] fn test_assert() { - let bytes = include_bytes!("assert.leo"); + let bytes = include_str!("assert.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]); @@ -128,7 +128,7 @@ fn test_assert() { #[test] fn test_conditional_assert() { - let bytes = include_bytes!("conditional_assert.leo"); + let bytes = include_str!("conditional_assert.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]); diff --git a/compiler/tests/core/mod.rs b/compiler/tests/core/mod.rs index 20943b7c36..293b84f536 100644 --- a/compiler/tests/core/mod.rs +++ b/compiler/tests/core/mod.rs @@ -20,7 +20,7 @@ use crate::{assert_satisfied, expect_symbol_table_error, parse_program}; #[test] fn test_core_circuit_invalid() { - let program_bytes = include_bytes!("core_package_invalid.leo"); + let program_bytes = include_str!("core_package_invalid.leo"); let program = parse_program(program_bytes).err().unwrap(); expect_symbol_table_error(program); @@ -28,7 +28,7 @@ fn test_core_circuit_invalid() { #[test] fn test_core_circuit_star_fail() { - let program_bytes = include_bytes!("core_circuit_star_fail.leo"); + let program_bytes = include_str!("core_circuit_star_fail.leo"); let error = parse_program(program_bytes).err().unwrap(); expect_symbol_table_error(error); @@ -36,7 +36,7 @@ fn test_core_circuit_star_fail() { #[test] fn test_core_package_invalid() { - let program_bytes = include_bytes!("core_package_invalid.leo"); + let program_bytes = include_str!("core_package_invalid.leo"); let error = parse_program(program_bytes).err().unwrap(); expect_symbol_table_error(error); @@ -44,7 +44,7 @@ fn test_core_package_invalid() { #[test] fn test_core_unstable_package_invalid() { - let program_bytes = include_bytes!("core_unstable_package_invalid.leo"); + let program_bytes = include_str!("core_unstable_package_invalid.leo"); let error = parse_program(program_bytes).err().unwrap(); expect_symbol_table_error(error); @@ -52,7 +52,7 @@ fn test_core_unstable_package_invalid() { #[test] fn test_unstable_blake2s_sanity() { - let program_bytes = include_bytes!("unstable_blake2s.leo"); + let program_bytes = include_str!("unstable_blake2s.leo"); let program = parse_program(program_bytes).unwrap(); assert_satisfied(program); diff --git a/compiler/tests/core/packages/unstable/blake2s/mod.rs b/compiler/tests/core/packages/unstable/blake2s/mod.rs index 2a94859fdd..0f59efcd20 100644 --- a/compiler/tests/core/packages/unstable/blake2s/mod.rs +++ b/compiler/tests/core/packages/unstable/blake2s/mod.rs @@ -32,7 +32,7 @@ use snarkos_models::algorithms::PRF; #[test] fn test_arguments_length_fail() { - let program_bytes = include_bytes!("arguments_length_fail.leo"); + let program_bytes = include_str!("arguments_length_fail.leo"); let error = parse_program(program_bytes).err().unwrap(); expect_type_inference_error(error); @@ -40,7 +40,7 @@ fn test_arguments_length_fail() { #[test] fn test_arguments_type_fail() { - let program_bytes = include_bytes!("arguments_type_fail.leo"); + let program_bytes = include_str!("arguments_type_fail.leo"); let error = parse_program(program_bytes).err().unwrap(); expect_type_inference_error(error); @@ -80,7 +80,7 @@ fn test_blake2s_random() { // The `blake2s_random.leo` program will compute a blake2s hash digest and compare it against // the expected value - let bytes = include_bytes!("blake2s_random.leo"); + let bytes = include_str!("blake2s_random.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ diff --git a/compiler/tests/definition/mod.rs b/compiler/tests/definition/mod.rs index 7b38d695fc..7cec04fcd5 100644 --- a/compiler/tests/definition/mod.rs +++ b/compiler/tests/definition/mod.rs @@ -18,7 +18,7 @@ use crate::{assert_satisfied, import::set_local_dir, parse_program}; #[test] fn test_out_of_order() { - let program_bytes = include_bytes!("out_of_order.leo"); + let program_bytes = include_str!("out_of_order.leo"); let program = parse_program(program_bytes).unwrap(); @@ -30,7 +30,7 @@ fn test_out_of_order() { fn test_out_of_order_with_import() { set_local_dir(); - let program_bytes = include_bytes!("out_of_order_with_import.leo"); + let program_bytes = include_str!("out_of_order_with_import.leo"); let program = parse_program(program_bytes).unwrap(); diff --git a/compiler/tests/field/mod.rs b/compiler/tests/field/mod.rs index 0cb5e4198c..a36dcd3539 100644 --- a/compiler/tests/field/mod.rs +++ b/compiler/tests/field/mod.rs @@ -52,7 +52,7 @@ fn test_negate() { let a_string = field_to_decimal_string(a); let b_string = field_to_decimal_string(b); - let bytes = include_bytes!("negate.leo"); + let bytes = include_str!("negate.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -81,7 +81,7 @@ fn test_add() { let b_string = field_to_decimal_string(b); let c_string = field_to_decimal_string(c); - let bytes = include_bytes!("add.leo"); + let bytes = include_str!("add.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -111,7 +111,7 @@ fn test_sub() { let b_string = field_to_decimal_string(b); let c_string = field_to_decimal_string(c); - let bytes = include_bytes!("sub.leo"); + let bytes = include_str!("sub.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -140,7 +140,7 @@ fn test_div() { let b_string = field_to_decimal_string(b); let c_string = field_to_decimal_string(c); - let bytes = include_bytes!("div.leo"); + let bytes = include_str!("div.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -169,7 +169,7 @@ fn test_mul() { let b_string = field_to_decimal_string(b); let c_string = field_to_decimal_string(c); - let bytes = include_bytes!("mul.leo"); + let bytes = include_str!("mul.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -197,7 +197,7 @@ fn test_eq() { // test equal - let bytes = include_bytes!("eq.leo"); + let bytes = include_str!("eq.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -237,7 +237,7 @@ fn test_console_assert_pass() { let a_string = field_to_decimal_string(a); - let bytes = include_bytes!("console_assert.leo"); + let bytes = include_str!("console_assert.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -266,7 +266,7 @@ fn test_console_assert_fail() { let a_string = field_to_decimal_string(a); let b_string = field_to_decimal_string(b); - let bytes = include_bytes!("console_assert.leo"); + let bytes = include_str!("console_assert.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -290,7 +290,7 @@ fn test_ternary() { let a_string = field_to_decimal_string(a); let b_string = field_to_decimal_string(b); - let bytes = include_bytes!("ternary.leo"); + let bytes = include_str!("ternary.leo"); let mut program = parse_program(bytes).unwrap(); // true -> field a @@ -322,14 +322,14 @@ fn test_ternary() { // // pub fn output_one(program: EdwardsTestCompiler) { -// let expected = include_bytes!("output_/register_one.out"); +// let expected = include_str!("output_/register_one.out"); // let actual = get_output(program); // // assert_eq!(expected, actual.bytes().as_slice()); // } // // pub fn output_zero(program: EdwardsTestCompiler) { -// let expected = include_bytes!("output_/register_zero.out"); +// let expected = include_str!("output_/register_zero.out"); // let actual = get_output(program); // // assert_eq!(expected, actual.bytes().as_slice()); @@ -337,9 +337,9 @@ fn test_ternary() { // // #[test] // fn test_registers() { -// let program_bytes = include_bytes!("output_register.leo"); -// let one_input_bytes = include_bytes!("input/register_one.in"); -// let zero_input_bytes = include_bytes!("input/register_zero.in"); +// let program_bytes = include_str!("output_register.leo"); +// let one_input_bytes = include_str!("input/register_one.in"); +// let zero_input_bytes = include_str!("input/register_zero.in"); // // // test 1field input register => 1field output register // let program = parse_program_with_input(program_bytes, one_input_bytes).unwrap(); diff --git a/compiler/tests/function/mod.rs b/compiler/tests/function/mod.rs index 8c8e7cb31a..8849e57f4f 100644 --- a/compiler/tests/function/mod.rs +++ b/compiler/tests/function/mod.rs @@ -26,7 +26,7 @@ use leo_compiler::errors::{CompilerError, ExpressionError, FunctionError, Statem #[test] fn test_empty() { - let bytes = include_bytes!("empty.leo"); + let bytes = include_str!("empty.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -34,7 +34,7 @@ fn test_empty() { #[test] fn test_iteration() { - let bytes = include_bytes!("iteration.leo"); + let bytes = include_str!("iteration.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -42,7 +42,7 @@ fn test_iteration() { #[test] fn test_iteration_repeated() { - let bytes = include_bytes!("iteration_repeated.leo"); + let bytes = include_str!("iteration_repeated.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -63,7 +63,7 @@ fn test_newlines() { #[test] fn test_multiple_returns() { - let bytes = include_bytes!("multiple.leo"); + let bytes = include_str!("multiple.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -85,7 +85,7 @@ fn test_multiple_returns_main() { #[test] fn test_repeated_function_call() { - let bytes = include_bytes!("repeated.leo"); + let bytes = include_str!("repeated.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -93,7 +93,7 @@ fn test_repeated_function_call() { #[test] fn test_return() { - let bytes = include_bytes!("return.leo"); + let bytes = include_str!("return.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -101,7 +101,7 @@ fn test_return() { #[test] fn test_scope_fail() { - let bytes = include_bytes!("scope_fail.leo"); + let bytes = include_str!("scope_fail.leo"); let program = parse_program(bytes).unwrap(); match expect_compiler_error(program) { @@ -117,7 +117,7 @@ fn test_scope_fail() { #[test] fn test_undefined() { - let bytes = include_bytes!("undefined.leo"); + let bytes = include_str!("undefined.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error); @@ -125,7 +125,7 @@ fn test_undefined() { #[test] fn test_value_unchanged() { - let bytes = include_bytes!("value_unchanged.leo"); + let bytes = include_str!("value_unchanged.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -133,7 +133,7 @@ fn test_value_unchanged() { #[test] fn test_array_input() { - let bytes = include_bytes!("array_input.leo"); + let bytes = include_str!("array_input.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error) @@ -143,7 +143,7 @@ fn test_array_input() { #[test] fn test_return_array_nested_fail() { - let bytes = include_bytes!("return_array_nested_fail.leo"); + let bytes = include_str!("return_array_nested_fail.leo"); let program = parse_program(bytes).unwrap(); let _err = expect_compiler_error(program); @@ -151,7 +151,7 @@ fn test_return_array_nested_fail() { #[test] fn test_return_array_nested_pass() { - let bytes = include_bytes!("return_array_nested_pass.leo"); + let bytes = include_str!("return_array_nested_pass.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -159,7 +159,7 @@ fn test_return_array_nested_pass() { #[test] fn test_return_array_tuple_fail() { - let bytes = include_bytes!("return_array_tuple_fail.leo"); + let bytes = include_str!("return_array_tuple_fail.leo"); let program = parse_program(bytes).unwrap(); let _err = expect_compiler_error(program); @@ -167,7 +167,7 @@ fn test_return_array_tuple_fail() { #[test] fn test_return_array_tuple_pass() { - let bytes = include_bytes!("return_array_tuple_pass.leo"); + let bytes = include_str!("return_array_tuple_pass.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -177,7 +177,7 @@ fn test_return_array_tuple_pass() { #[test] fn test_return_tuple() { - let bytes = include_bytes!("return_tuple.leo"); + let bytes = include_str!("return_tuple.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -185,7 +185,7 @@ fn test_return_tuple() { #[test] fn test_return_tuple_conditional() { - let bytes = include_bytes!("return_tuple_conditional.leo"); + let bytes = include_str!("return_tuple_conditional.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); diff --git a/compiler/tests/group/mod.rs b/compiler/tests/group/mod.rs index c560afdc57..58548b93e3 100644 --- a/compiler/tests/group/mod.rs +++ b/compiler/tests/group/mod.rs @@ -15,8 +15,13 @@ // along with the Leo library. If not, see . use crate::{ - assert_satisfied, expect_compiler_error, expect_synthesis_error, field::field_to_decimal_string, - generate_main_input, parse_program, parse_program_with_input, + assert_satisfied, + expect_compiler_error, + expect_synthesis_error, + field::field_to_decimal_string, + generate_main_input, + parse_program, + parse_program_with_input, }; use leo_ast::{GroupCoordinate, GroupTuple, GroupValue, InputValue, Span}; @@ -47,7 +52,7 @@ pub fn group_element_to_input_value(g: EdwardsAffine) -> GroupValue { #[test] fn test_one() { - let bytes = include_bytes!("one.leo"); + let bytes = include_str!("one.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -55,7 +60,7 @@ fn test_one() { #[test] fn test_zero() { - let bytes = include_bytes!("zero.leo"); + let bytes = include_str!("zero.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -63,7 +68,7 @@ fn test_zero() { #[test] fn test_point() { - let bytes = include_bytes!("point.leo"); + let bytes = include_str!("point.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -71,7 +76,7 @@ fn test_point() { #[test] fn test_x_sign_high() { - let bytes = include_bytes!("x_sign_high.leo"); + let bytes = include_str!("x_sign_high.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -79,7 +84,7 @@ fn test_x_sign_high() { #[test] fn test_x_sign_low() { - let bytes = include_bytes!("x_sign_low.leo"); + let bytes = include_str!("x_sign_low.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -87,7 +92,7 @@ fn test_x_sign_low() { #[test] fn test_x_sign_inferred() { - let bytes = include_bytes!("x_sign_inferred.leo"); + let bytes = include_str!("x_sign_inferred.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -95,7 +100,7 @@ fn test_x_sign_inferred() { #[test] fn test_y_sign_high() { - let bytes = include_bytes!("y_sign_high.leo"); + let bytes = include_str!("y_sign_high.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -103,7 +108,7 @@ fn test_y_sign_high() { #[test] fn test_y_sign_low() { - let bytes = include_bytes!("y_sign_low.leo"); + let bytes = include_str!("y_sign_low.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -111,7 +116,7 @@ fn test_y_sign_low() { #[test] fn test_y_sign_inferred() { - let bytes = include_bytes!("y_sign_inferred.leo"); + let bytes = include_str!("y_sign_inferred.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -119,7 +124,7 @@ fn test_y_sign_inferred() { #[test] fn test_both_sign_high() { - let bytes = include_bytes!("both_sign_high.leo"); + let bytes = include_str!("both_sign_high.leo"); let program = parse_program(bytes).unwrap(); @@ -128,7 +133,7 @@ fn test_both_sign_high() { #[test] fn test_both_sign_low() { - let bytes = include_bytes!("both_sign_low.leo"); + let bytes = include_str!("both_sign_low.leo"); let program = parse_program(bytes).unwrap(); @@ -137,7 +142,7 @@ fn test_both_sign_low() { #[test] fn test_both_sign_inferred() { - let bytes = include_bytes!("both_sign_inferred.leo"); + let bytes = include_str!("both_sign_inferred.leo"); let program = parse_program(bytes).unwrap(); @@ -146,8 +151,8 @@ fn test_both_sign_inferred() { #[test] fn test_point_input() { - let program_bytes = include_bytes!("point_input.leo"); - let input_bytes = include_bytes!("input/point.in"); + let program_bytes = include_str!("point_input.leo"); + let input_bytes = include_str!("input/point.in"); let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); @@ -156,9 +161,9 @@ fn test_point_input() { #[test] fn test_input() { - let program_bytes = include_bytes!("input.leo"); - let input_bytes_pass = include_bytes!("input/valid.in"); - let input_bytes_fail = include_bytes!("input/invalid.in"); + let program_bytes = include_str!("input.leo"); + let input_bytes_pass = include_str!("input/valid.in"); + let input_bytes_fail = include_str!("input/invalid.in"); let program = parse_program_with_input(program_bytes, input_bytes_pass).unwrap(); @@ -182,7 +187,7 @@ fn test_negate() { let a_element = group_element_to_input_value(a); let b_element = group_element_to_input_value(b); - let bytes = include_bytes!("negate.leo"); + let bytes = include_str!("negate.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -210,7 +215,7 @@ fn test_add() { let b_element = group_element_to_input_value(b); let c_element = group_element_to_input_value(c); - let bytes = include_bytes!("add.leo"); + let bytes = include_str!("add.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -239,7 +244,7 @@ fn test_sub() { let b_element = group_element_to_input_value(b); let c_element = group_element_to_input_value(c); - let bytes = include_bytes!("sub.leo"); + let bytes = include_str!("sub.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -262,7 +267,7 @@ fn test_console_assert_pass() { let a_element = group_element_to_input_value(a); - let bytes = include_bytes!("assert_eq.leo"); + let bytes = include_str!("assert_eq.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -291,7 +296,7 @@ fn test_console_assert_fail() { let a_element = group_element_to_input_value(a); let b_element = group_element_to_input_value(b); - let bytes = include_bytes!("assert_eq.leo"); + let bytes = include_str!("assert_eq.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -318,7 +323,7 @@ fn test_eq() { // test equal - let bytes = include_bytes!("eq.leo"); + let bytes = include_str!("eq.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -359,7 +364,7 @@ fn test_ternary() { let a_element = group_element_to_input_value(a); let b_element = group_element_to_input_value(b); - let bytes = include_bytes!("ternary.leo"); + let bytes = include_str!("ternary.leo"); let mut program = parse_program(bytes).unwrap(); // true -> field a diff --git a/compiler/tests/import/mod.rs b/compiler/tests/import/mod.rs index d4bd578c0b..54857438ea 100644 --- a/compiler/tests/import/mod.rs +++ b/compiler/tests/import/mod.rs @@ -34,7 +34,7 @@ pub fn set_local_dir() { fn test_basic() { set_local_dir(); - let bytes = include_bytes!("basic.leo"); + let bytes = include_str!("basic.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -45,7 +45,7 @@ fn test_basic() { fn test_multiple() { set_local_dir(); - let bytes = include_bytes!("multiple.leo"); + let bytes = include_str!("multiple.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -56,7 +56,7 @@ fn test_multiple() { fn test_star() { set_local_dir(); - let bytes = include_bytes!("star.leo"); + let bytes = include_str!("star.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -67,7 +67,7 @@ fn test_star() { fn test_star_fail() { set_local_dir(); - let bytes = include_bytes!("star_fail.leo"); + let bytes = include_str!("star_fail.leo"); assert!(parse_program(bytes).is_err()); } @@ -76,7 +76,7 @@ fn test_star_fail() { fn test_alias() { set_local_dir(); - let bytes = include_bytes!("alias.leo"); + let bytes = include_str!("alias.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -88,7 +88,7 @@ fn test_alias() { fn test_names_pass() { set_local_dir(); - let bytes = include_bytes!("names.leo"); + let bytes = include_str!("names.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -99,7 +99,7 @@ fn test_names_pass() { fn test_names_fail_1() { set_local_dir(); - let bytes = include_bytes!("names_dash_a.leo"); + let bytes = include_str!("names_dash_a.leo"); assert!(parse_program(bytes).is_err()); } @@ -108,7 +108,7 @@ fn test_names_fail_1() { fn test_names_fail_2() { set_local_dir(); - let bytes = include_bytes!("names_a_dash.leo"); + let bytes = include_str!("names_a_dash.leo"); assert!(parse_program(bytes).is_err()); } @@ -117,7 +117,7 @@ fn test_names_fail_2() { fn test_names_fail_3() { set_local_dir(); - let bytes = include_bytes!("names_underscore.leo"); + let bytes = include_str!("names_underscore.leo"); assert!(parse_program(bytes).is_err()); } @@ -126,7 +126,7 @@ fn test_names_fail_3() { fn test_names_fail_4() { set_local_dir(); - let bytes = include_bytes!("names_dollar.leo"); + let bytes = include_str!("names_dollar.leo"); assert!(parse_program(bytes).is_err()); } @@ -136,7 +136,7 @@ fn test_names_fail_4() { fn test_many_import() { set_local_dir(); - let bytes = include_bytes!("many_import.leo"); + let bytes = include_str!("many_import.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -147,7 +147,7 @@ fn test_many_import() { fn test_many_import_star() { set_local_dir(); - let bytes = include_bytes!("many_import_star.leo"); + let bytes = include_str!("many_import_star.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); diff --git a/compiler/tests/integers/int_macro.rs b/compiler/tests/integers/int_macro.rs index cdcd3e7f3d..271c98c239 100644 --- a/compiler/tests/integers/int_macro.rs +++ b/compiler/tests/integers/int_macro.rs @@ -28,7 +28,7 @@ macro_rules! test_int { None => continue, }; - let bytes = include_bytes!("negate.leo"); + let bytes = include_str!("negate.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -42,14 +42,14 @@ macro_rules! test_int { } fn test_negate_min_fail() { - let bytes = include_bytes!("negate_min.leo"); + let bytes = include_str!("negate_min.leo"); let program = parse_program(bytes).unwrap(); expect_computation_error(program); } fn test_negate_zero() { - let bytes = include_bytes!("negate_zero.leo"); + let bytes = include_str!("negate_zero.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -58,28 +58,28 @@ macro_rules! test_int { impl IntegerTester for $name { fn test_min() { - let bytes = include_bytes!("min.leo"); + let bytes = include_str!("min.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); } fn test_min_fail() { - let bytes = include_bytes!("min_fail.leo"); + let bytes = include_str!("min_fail.leo"); let program = parse_program(bytes).unwrap(); expect_parsing_error(program); } fn test_max() { - let bytes = include_bytes!("max.leo"); + let bytes = include_str!("max.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); } fn test_max_fail() { - let bytes = include_bytes!("max_fail.leo"); + let bytes = include_str!("max_fail.leo"); let program = parse_program(bytes).unwrap(); expect_parsing_error(program); @@ -95,7 +95,7 @@ macro_rules! test_int { None => continue, }; - let bytes = include_bytes!("add.leo"); + let bytes = include_str!("add.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -124,7 +124,7 @@ macro_rules! test_int { None => continue, }; - let bytes = include_bytes!("sub.leo"); + let bytes = include_str!("sub.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -149,7 +149,7 @@ macro_rules! test_int { None => continue, }; - let bytes = include_bytes!("mul.leo"); + let bytes = include_str!("mul.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -176,7 +176,7 @@ macro_rules! test_int { continue; } - let bytes = include_bytes!("div.leo"); + let bytes = include_str!("div.leo"); let mut program = parse_program(bytes).unwrap(); // expect an error when dividing by zero @@ -220,7 +220,7 @@ macro_rules! test_int { None => continue, }; - let bytes = include_bytes!("pow.leo"); + let bytes = include_str!("pow.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -242,7 +242,7 @@ macro_rules! test_int { // test equal - let bytes = include_bytes!("eq.leo"); + let bytes = include_str!("eq.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -280,7 +280,7 @@ macro_rules! test_int { // test a != a == false - let bytes = include_bytes!("ne.leo"); + let bytes = include_str!("ne.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -318,7 +318,7 @@ macro_rules! test_int { // test equal - let bytes = include_bytes!("ge.leo"); + let bytes = include_str!("ge.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -356,7 +356,7 @@ macro_rules! test_int { // test equal - let bytes = include_bytes!("gt.leo"); + let bytes = include_str!("gt.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -394,7 +394,7 @@ macro_rules! test_int { // test equal - let bytes = include_bytes!("le.leo"); + let bytes = include_str!("le.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -432,7 +432,7 @@ macro_rules! test_int { // test equal - let bytes = include_bytes!("lt.leo"); + let bytes = include_str!("lt.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -468,7 +468,7 @@ macro_rules! test_int { let a: $type_ = rand::random(); // test equal - let bytes = include_bytes!("console_assert.leo"); + let bytes = include_str!("console_assert.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -504,7 +504,7 @@ macro_rules! test_int { let a: $type_ = rand::random(); let b: $type_ = rand::random(); - let bytes = include_bytes!("ternary.leo"); + let bytes = include_str!("ternary.leo"); let mut program = parse_program(bytes).unwrap(); // true -> field 1 diff --git a/compiler/tests/integers/uint_macro.rs b/compiler/tests/integers/uint_macro.rs index c85b6a68c4..15616370ae 100644 --- a/compiler/tests/integers/uint_macro.rs +++ b/compiler/tests/integers/uint_macro.rs @@ -20,28 +20,28 @@ macro_rules! test_uint { impl IntegerTester for $name { fn test_min() { - let bytes = include_bytes!("min.leo"); + let bytes = include_str!("min.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); } fn test_min_fail() { - let bytes = include_bytes!("min_fail.leo"); + let bytes = include_str!("min_fail.leo"); let program = parse_program(bytes).unwrap(); expect_parsing_error(program); } fn test_max() { - let bytes = include_bytes!("max.leo"); + let bytes = include_str!("max.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); } fn test_max_fail() { - let bytes = include_bytes!("max_fail.leo"); + let bytes = include_str!("max_fail.leo"); let program = parse_program(bytes).unwrap(); expect_parsing_error(program); @@ -57,7 +57,7 @@ macro_rules! test_uint { None => continue, }; - let bytes = include_bytes!("add.leo"); + let bytes = include_str!("add.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -82,7 +82,7 @@ macro_rules! test_uint { None => continue, }; - let bytes = include_bytes!("sub.leo"); + let bytes = include_str!("sub.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -107,7 +107,7 @@ macro_rules! test_uint { None => continue, }; - let bytes = include_bytes!("mul.leo"); + let bytes = include_str!("mul.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -132,7 +132,7 @@ macro_rules! test_uint { None => continue, }; - let bytes = include_bytes!("div.leo"); + let bytes = include_str!("div.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -158,7 +158,7 @@ macro_rules! test_uint { None => continue, }; - let bytes = include_bytes!("pow.leo"); + let bytes = include_str!("pow.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -180,7 +180,7 @@ macro_rules! test_uint { // test equal - let bytes = include_bytes!("eq.leo"); + let bytes = include_str!("eq.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -218,7 +218,7 @@ macro_rules! test_uint { // test a != a == false - let bytes = include_bytes!("ne.leo"); + let bytes = include_str!("ne.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -256,7 +256,7 @@ macro_rules! test_uint { // test equal - let bytes = include_bytes!("ge.leo"); + let bytes = include_str!("ge.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -294,7 +294,7 @@ macro_rules! test_uint { // test equal - let bytes = include_bytes!("gt.leo"); + let bytes = include_str!("gt.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -332,7 +332,7 @@ macro_rules! test_uint { // test equal - let bytes = include_bytes!("le.leo"); + let bytes = include_str!("le.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -370,7 +370,7 @@ macro_rules! test_uint { // test equal - let bytes = include_bytes!("lt.leo"); + let bytes = include_str!("lt.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -406,7 +406,7 @@ macro_rules! test_uint { let a: $type_ = rand::random(); // test equal - let bytes = include_bytes!("console_assert.leo"); + let bytes = include_str!("console_assert.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -442,7 +442,7 @@ macro_rules! test_uint { let a: $type_ = rand::random(); let b: $type_ = rand::random(); - let bytes = include_bytes!("ternary.leo"); + let bytes = include_str!("ternary.leo"); let mut program = parse_program(bytes).unwrap(); // true -> field 1 diff --git a/compiler/tests/mod.rs b/compiler/tests/mod.rs index d2d66b8d8b..434a19ff16 100644 --- a/compiler/tests/mod.rs +++ b/compiler/tests/mod.rs @@ -64,11 +64,10 @@ fn new_compiler() -> EdwardsTestCompiler { EdwardsTestCompiler::new(program_name, path, output_dir) } -pub(crate) fn parse_program(bytes: &[u8]) -> Result { +pub(crate) fn parse_program(program_string: &str) -> Result { let mut compiler = new_compiler(); - let program_string = String::from_utf8_lossy(bytes); - compiler.parse_program_from_string(&program_string)?; + compiler.parse_program_from_string(program_string)?; Ok(compiler) } diff --git a/compiler/tests/mutability/mod.rs b/compiler/tests/mutability/mod.rs index 8442357044..9bcfa25225 100644 --- a/compiler/tests/mutability/mod.rs +++ b/compiler/tests/mutability/mod.rs @@ -19,7 +19,7 @@ use leo_ast::InputValue; #[test] fn test_let() { - let bytes = include_bytes!("let.leo"); + let bytes = include_str!("let.leo"); let program = parse_program(bytes).unwrap(); expect_compiler_error(program); @@ -27,7 +27,7 @@ fn test_let() { #[test] fn test_let_mut() { - let bytes = include_bytes!("let_mut.leo"); + let bytes = include_str!("let_mut.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -35,7 +35,7 @@ fn test_let_mut() { #[test] fn test_const_fail() { - let bytes = include_bytes!("const.leo"); + let bytes = include_str!("const.leo"); let program = parse_program(bytes).unwrap(); expect_compiler_error(program); @@ -43,7 +43,7 @@ fn test_const_fail() { #[test] fn test_const_mut_fail() { - let bytes = include_bytes!("const_mut.leo"); + let bytes = include_str!("const_mut.leo"); let program = parse_program(bytes).unwrap(); expect_compiler_error(program); @@ -51,7 +51,7 @@ fn test_const_mut_fail() { #[test] fn test_array() { - let bytes = include_bytes!("array.leo"); + let bytes = include_str!("array.leo"); let program = parse_program(bytes).unwrap(); expect_compiler_error(program); @@ -59,7 +59,7 @@ fn test_array() { #[test] fn test_array_mut() { - let bytes = include_bytes!("array_mut.leo"); + let bytes = include_str!("array_mut.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -67,7 +67,7 @@ fn test_array_mut() { #[test] fn test_circuit() { - let bytes = include_bytes!("circuit.leo"); + let bytes = include_str!("circuit.leo"); let program = parse_program(bytes).unwrap(); expect_compiler_error(program); @@ -75,7 +75,7 @@ fn test_circuit() { #[test] fn test_circuit_mut() { - let bytes = include_bytes!("circuit_mut.leo"); + let bytes = include_str!("circuit_mut.leo"); let program = parse_program(bytes).unwrap(); expect_compiler_error(program); @@ -83,7 +83,7 @@ fn test_circuit_mut() { #[test] fn test_circuit_variable_mut() { - let bytes = include_bytes!("circuit_variable_mut.leo"); + let bytes = include_str!("circuit_variable_mut.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -91,7 +91,7 @@ fn test_circuit_variable_mut() { #[test] fn test_circuit_function_mut() { - let bytes = include_bytes!("circuit_function_mut.leo"); + let bytes = include_str!("circuit_function_mut.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error); @@ -99,7 +99,7 @@ fn test_circuit_function_mut() { #[test] fn test_circuit_static_function_mut() { - let bytes = include_bytes!("circuit_static_function_mut.leo"); + let bytes = include_str!("circuit_static_function_mut.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error); @@ -107,7 +107,7 @@ fn test_circuit_static_function_mut() { #[test] fn test_function_input() { - let bytes = include_bytes!("function_input.leo"); + let bytes = include_str!("function_input.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]); @@ -119,7 +119,7 @@ fn test_function_input() { #[test] fn test_function_input_mut() { - let bytes = include_bytes!("function_input_mut.leo"); + let bytes = include_str!("function_input_mut.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]); diff --git a/compiler/tests/statements/conditional/mod.rs b/compiler/tests/statements/conditional/mod.rs index 958032c411..f9bdc2c47b 100644 --- a/compiler/tests/statements/conditional/mod.rs +++ b/compiler/tests/statements/conditional/mod.rs @@ -28,7 +28,7 @@ use leo_ast::InputValue; #[test] fn test_assert() { - let bytes = include_bytes!("assert.leo"); + let bytes = include_str!("assert.leo"); let mut program_1_pass = parse_program(bytes).unwrap(); let mut program_0_pass = program_1_pass.clone(); let mut program_2_fail = program_1_pass.clone(); @@ -60,7 +60,7 @@ fn test_assert() { #[test] fn test_mutate() { - let bytes = include_bytes!("mutate.leo"); + let bytes = include_str!("mutate.leo"); let mut program_1_pass = parse_program(bytes).unwrap(); let mut program_0_pass = program_1_pass.clone(); @@ -83,7 +83,7 @@ fn test_mutate() { #[test] fn test_for_loop() { - let bytes = include_bytes!("for_loop.leo"); + let bytes = include_str!("for_loop.leo"); let mut program_true_6 = parse_program(bytes).unwrap(); let mut program_false_0 = program_true_6.clone(); @@ -106,7 +106,7 @@ fn test_for_loop() { #[test] fn test_chain() { - let bytes = include_bytes!("chain.leo"); + let bytes = include_str!("chain.leo"); let mut program_1_1 = parse_program(bytes).unwrap(); let mut program_2_2 = program_1_1.clone(); let mut program_4_3 = program_1_1.clone(); @@ -147,7 +147,7 @@ fn test_chain() { #[test] fn test_nested() { - let bytes = include_bytes!("nested.leo"); + let bytes = include_str!("nested.leo"); let mut program_true_true_3 = parse_program(bytes).unwrap(); let mut program_true_false_1 = program_true_true_3.clone(); let mut program_false_false_0 = program_true_true_3.clone(); diff --git a/compiler/tests/statements/mod.rs b/compiler/tests/statements/mod.rs index 4680bee86d..68b4a38be6 100644 --- a/compiler/tests/statements/mod.rs +++ b/compiler/tests/statements/mod.rs @@ -23,7 +23,7 @@ pub mod conditional; #[test] fn test_ternary_basic() { - let bytes = include_bytes!("ternary_basic.leo"); + let bytes = include_str!("ternary_basic.leo"); let mut program = parse_program(bytes).unwrap(); let main_input = generate_main_input(vec![ @@ -51,7 +51,7 @@ fn test_ternary_basic() { #[test] fn test_iteration_basic() { - let bytes = include_bytes!("iteration_basic.leo"); + let bytes = include_str!("iteration_basic.leo"); let program = parse_program(bytes).unwrap(); assert_satisfied(program); @@ -59,7 +59,7 @@ fn test_iteration_basic() { #[test] fn test_num_returns_fail() { - let bytes = include_bytes!("num_returns_fail.leo"); + let bytes = include_str!("num_returns_fail.leo"); let error = parse_program(bytes).err().unwrap(); expect_type_inference_error(error); diff --git a/compiler/tests/syntax/identifiers/mod.rs b/compiler/tests/syntax/identifiers/mod.rs index c1d6fb7f86..f4dece3f59 100644 --- a/compiler/tests/syntax/identifiers/mod.rs +++ b/compiler/tests/syntax/identifiers/mod.rs @@ -18,7 +18,7 @@ use crate::parse_program; #[test] fn test_address_name_fail() { - let bytes = include_bytes!("address_fail.leo"); + let bytes = include_str!("address_fail.leo"); let syntax_error = parse_program(bytes).is_err(); assert!(syntax_error); @@ -26,7 +26,7 @@ fn test_address_name_fail() { #[test] fn test_console_name_fail() { - let bytes = include_bytes!("console_fail.leo"); + let bytes = include_str!("console_fail.leo"); let syntax_error = parse_program(bytes).is_err(); assert!(syntax_error); @@ -34,7 +34,7 @@ fn test_console_name_fail() { #[test] fn test_field_name_fail() { - let bytes = include_bytes!("field_fail.leo"); + let bytes = include_str!("field_fail.leo"); let syntax_error = parse_program(bytes).is_err(); assert!(syntax_error); @@ -42,7 +42,7 @@ fn test_field_name_fail() { #[test] fn test_group_name_fail() { - let bytes = include_bytes!("group_fail.leo"); + let bytes = include_str!("group_fail.leo"); let syntax_error = parse_program(bytes).is_err(); assert!(syntax_error); @@ -50,7 +50,7 @@ fn test_group_name_fail() { #[test] fn test_i8_name_fail() { - let bytes = include_bytes!("i8_fail.leo"); + let bytes = include_str!("i8_fail.leo"); let syntax_error = parse_program(bytes).is_err(); assert!(syntax_error); @@ -58,7 +58,7 @@ fn test_i8_name_fail() { #[test] fn test_input_name_fail() { - let bytes = include_bytes!("input_fail.leo"); + let bytes = include_str!("input_fail.leo"); let syntax_error = parse_program(bytes).is_err(); assert!(syntax_error); @@ -66,7 +66,7 @@ fn test_input_name_fail() { #[test] fn test_self_type_name_fail() { - let bytes = include_bytes!("self_type_fail.leo"); + let bytes = include_str!("self_type_fail.leo"); let syntax_error = parse_program(bytes).is_err(); assert!(syntax_error); @@ -74,7 +74,7 @@ fn test_self_type_name_fail() { #[test] fn test_self_keyword_name_fail() { - let bytes = include_bytes!("self_keyword_fail.leo"); + let bytes = include_str!("self_keyword_fail.leo"); let syntax_error = parse_program(bytes).is_err(); assert!(syntax_error); @@ -82,7 +82,7 @@ fn test_self_keyword_name_fail() { #[test] fn test_true_name_fail() { - let bytes = include_bytes!("true_fail.leo"); + let bytes = include_str!("true_fail.leo"); let syntax_error = parse_program(bytes).is_err(); assert!(syntax_error); @@ -90,7 +90,7 @@ fn test_true_name_fail() { #[test] fn test_u8_name_fail() { - let bytes = include_bytes!("u8_fail.leo"); + let bytes = include_str!("u8_fail.leo"); let syntax_error = parse_program(bytes).is_err(); assert!(syntax_error); diff --git a/compiler/tests/syntax/mod.rs b/compiler/tests/syntax/mod.rs index a4fd56f095..f8429a28c6 100644 --- a/compiler/tests/syntax/mod.rs +++ b/compiler/tests/syntax/mod.rs @@ -25,7 +25,7 @@ pub mod identifiers; #[test] #[ignore] fn test_semicolon() { - let bytes = include_bytes!("semicolon.leo"); + let bytes = include_str!("semicolon.leo"); let error = parse_program(bytes).err().unwrap(); match error { @@ -36,7 +36,7 @@ fn test_semicolon() { #[test] fn test_undefined() { - let bytes = include_bytes!("undefined.leo"); + let bytes = include_str!("undefined.leo"); let program = parse_program(bytes).unwrap(); let error = expect_compiler_error(program); @@ -76,7 +76,7 @@ fn input_syntax_error() { #[test] fn test_compare_mismatched_types() { - let bytes = include_bytes!("compare_mismatched_types.leo"); + let bytes = include_str!("compare_mismatched_types.leo"); let error = parse_program(bytes).err().unwrap(); // Expect a type inference error. diff --git a/compiler/tests/tuples/mod.rs b/compiler/tests/tuples/mod.rs index 9c52764c5f..4ec0ee3873 100644 --- a/compiler/tests/tuples/mod.rs +++ b/compiler/tests/tuples/mod.rs @@ -18,7 +18,7 @@ use crate::{assert_satisfied, parse_program}; #[test] fn test_tuple_basic() { - let program_bytes = include_bytes!("basic.leo"); + let program_bytes = include_str!("basic.leo"); let program = parse_program(program_bytes).unwrap(); @@ -27,7 +27,7 @@ fn test_tuple_basic() { #[test] fn test_tuple_access() { - let program_bytes = include_bytes!("access.leo"); + let program_bytes = include_str!("access.leo"); let program = parse_program(program_bytes).unwrap(); @@ -36,7 +36,7 @@ fn test_tuple_access() { #[test] fn test_tuple_typed() { - let program_bytes = include_bytes!("typed.leo"); + let program_bytes = include_str!("typed.leo"); let program = parse_program(program_bytes).unwrap(); @@ -45,7 +45,7 @@ fn test_tuple_typed() { #[test] fn test_multiple() { - let program_bytes = include_bytes!("multiple.leo"); + let program_bytes = include_str!("multiple.leo"); let program = parse_program(program_bytes).unwrap(); @@ -54,7 +54,7 @@ fn test_multiple() { #[test] fn test_multiple_typed() { - let program_bytes = include_bytes!("multiple_typed.leo"); + let program_bytes = include_str!("multiple_typed.leo"); let program = parse_program(program_bytes).unwrap(); @@ -63,7 +63,7 @@ fn test_multiple_typed() { #[test] fn test_function() { - let program_bytes = include_bytes!("function.leo"); + let program_bytes = include_str!("function.leo"); let program = parse_program(program_bytes).unwrap(); @@ -72,7 +72,7 @@ fn test_function() { #[test] fn test_function_typed() { - let program_bytes = include_bytes!("function_typed.leo"); + let program_bytes = include_str!("function_typed.leo"); let program = parse_program(program_bytes).unwrap(); @@ -81,7 +81,7 @@ fn test_function_typed() { #[test] fn test_function_multiple() { - let progam_bytes = include_bytes!("function_multiple.leo"); + let progam_bytes = include_str!("function_multiple.leo"); let program = parse_program(progam_bytes).unwrap(); @@ -90,7 +90,7 @@ fn test_function_multiple() { #[test] fn test_nested() { - let program_bytes = include_bytes!("nested.leo"); + let program_bytes = include_str!("nested.leo"); let program = parse_program(program_bytes).unwrap(); @@ -99,7 +99,7 @@ fn test_nested() { #[test] fn test_nested_access() { - let program_bytes = include_bytes!("nested_access.leo"); + let program_bytes = include_str!("nested_access.leo"); let program = parse_program(program_bytes).unwrap(); @@ -108,7 +108,7 @@ fn test_nested_access() { #[test] fn test_nested_typed() { - let program_bytes = include_bytes!("nested_typed.leo"); + let program_bytes = include_str!("nested_typed.leo"); let program = parse_program(program_bytes).unwrap(); @@ -117,6 +117,6 @@ fn test_nested_typed() { // #[test] // fn test_input() { -// let input_bytes = include_bytes!("inputs/input.in"); -// let program_bytes = include_bytes!("") +// let input_bytes = include_str!("inputs/input.in"); +// let program_bytes = include_str!("") // } From 2352ebaf2c3357de6f0f814c78ba00e838faeb14 Mon Sep 17 00:00:00 2001 From: collin Date: Fri, 4 Dec 2020 15:48:43 -0500 Subject: [PATCH 09/41] rename all bytes variables to string --- compiler/tests/boolean/mod.rs | 52 ++++---- compiler/tests/circuits/mod.rs | 112 +++++++++--------- compiler/tests/console/mod.rs | 52 ++++---- compiler/tests/core/mod.rs | 22 ++-- .../core/packages/unstable/blake2s/mod.rs | 8 +- compiler/tests/definition/mod.rs | 8 +- compiler/tests/field/mod.rs | 44 +++---- compiler/tests/function/mod.rs | 64 +++++----- compiler/tests/group/mod.rs | 94 +++++++-------- compiler/tests/import/mod.rs | 48 ++++---- .../tests/input_files/program_input/mod.rs | 6 +- .../tests/input_files/program_state/mod.rs | 6 +- compiler/tests/integers/int_macro.rs | 96 +++++++-------- compiler/tests/integers/uint_macro.rs | 84 ++++++------- compiler/tests/mutability/mod.rs | 52 ++++---- compiler/tests/statements/conditional/mod.rs | 20 ++-- compiler/tests/statements/mod.rs | 14 +-- compiler/tests/syntax/identifiers/mod.rs | 40 +++---- compiler/tests/syntax/mod.rs | 12 +- compiler/tests/tuples/mod.rs | 48 ++++---- 20 files changed, 441 insertions(+), 441 deletions(-) diff --git a/compiler/tests/boolean/mod.rs b/compiler/tests/boolean/mod.rs index d71ff3def0..02d5dad962 100644 --- a/compiler/tests/boolean/mod.rs +++ b/compiler/tests/boolean/mod.rs @@ -79,32 +79,32 @@ fn test_registers() { #[test] fn test_not_true() { - let bytes = include_str!("not_true.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("not_true.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_not_false() { - let bytes = include_str!("not_false.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("not_false.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_not_mutable() { - let bytes = include_str!("not_mutable.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("not_mutable.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_not_u32() { - let bytes = include_str!("not_u32.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("not_u32.leo"); + let program = parse_program(program_string).unwrap(); expect_compiler_error(program); } @@ -113,32 +113,32 @@ fn test_not_u32() { #[test] fn test_true_or_true() { - let bytes = include_str!("true_or_true.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("true_or_true.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_true_or_false() { - let bytes = include_str!("true_or_false.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("true_or_false.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_false_or_false() { - let bytes = include_str!("false_or_false.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("false_or_false.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_true_or_u32() { - let bytes = include_str!("true_or_u32.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("true_or_u32.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error); } @@ -147,32 +147,32 @@ fn test_true_or_u32() { #[test] fn test_true_and_true() { - let bytes = include_str!("true_and_true.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("true_and_true.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_true_and_false() { - let bytes = include_str!("true_and_false.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("true_and_false.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_false_and_false() { - let bytes = include_str!("false_and_false.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("false_and_false.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_true_and_u32() { - let bytes = include_str!("true_and_u32.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("true_and_u32.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error); } @@ -181,8 +181,8 @@ fn test_true_and_u32() { #[test] fn test_all() { - let bytes = include_str!("all.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("all.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } diff --git a/compiler/tests/circuits/mod.rs b/compiler/tests/circuits/mod.rs index 4bfdcdac34..8cad1e7b49 100644 --- a/compiler/tests/circuits/mod.rs +++ b/compiler/tests/circuits/mod.rs @@ -20,24 +20,24 @@ use crate::{assert_satisfied, expect_compiler_error, expect_type_inference_error #[test] fn test_inline() { - let bytes = include_str!("inline.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("inline.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_inline_fail() { - let bytes = include_str!("inline_fail.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("inline_fail.leo"); + let program = parse_program(program_string).unwrap(); expect_compiler_error(program); } #[test] fn test_inline_undefined() { - let bytes = include_str!("inline_undefined.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("inline_undefined.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error); } @@ -46,88 +46,88 @@ fn test_inline_undefined() { #[test] fn test_member_variable() { - let bytes = include_str!("member_variable.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("member_variable.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_member_variable_fail() { - let bytes = include_str!("member_variable_fail.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("member_variable_fail.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error); } #[test] fn test_member_variable_and_function() { - let bytes = include_str!("member_variable_and_function.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("member_variable_and_function.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_member_function() { - let bytes = include_str!("member_function.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("member_function.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_member_function_fail() { - let bytes = include_str!("member_function_fail.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("member_function_fail.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error); } #[test] fn test_member_function_invalid() { - let bytes = include_str!("member_function_invalid.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("member_function_invalid.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error); } #[test] fn test_member_function_nested() { - let bytes = include_str!("member_function_nested.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("member_function_nested.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_member_static_function() { - let bytes = include_str!("member_static_function.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("member_static_function.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_member_static_function_nested() { - let bytes = include_str!("member_static_function_nested.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("member_static_function_nested.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_member_static_function_invalid() { - let bytes = include_str!("member_static_function_invalid.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("member_static_function_invalid.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error) } #[test] fn test_member_static_function_undefined() { - let bytes = include_str!("member_static_function_undefined.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("member_static_function_undefined.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error) } @@ -136,64 +136,64 @@ fn test_member_static_function_undefined() { #[test] fn test_mutate_function_fail() { - let bytes = include_str!("mut_function_fail.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("mut_function_fail.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error); } #[test] fn test_mutate_self_variable() { - let bytes = include_str!("mut_self_variable.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("mut_self_variable.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_mutate_self_variable_fail() { - let bytes = include_str!("mut_self_variable_fail.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("mut_self_variable_fail.leo"); + let program = parse_program(program_string).unwrap(); expect_compiler_error(program); } #[test] fn test_mutate_self_function_fail() { - let bytes = include_str!("mut_self_function_fail.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("mut_self_function_fail.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error); } #[test] fn test_mutate_self_static_function_fail() { - let bytes = include_str!("mut_self_static_function_fail.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("mut_self_static_function_fail.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error); } #[test] fn test_mutate_static_function_fail() { - let bytes = include_str!("mut_static_function_fail.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("mut_static_function_fail.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error); } #[test] fn test_mutate_variable() { - let bytes = include_str!("mut_variable.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("mut_variable.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_mutate_variable_fail() { - let bytes = include_str!("mut_variable_fail.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("mut_variable_fail.leo"); + let program = parse_program(program_string).unwrap(); expect_compiler_error(program); } @@ -202,32 +202,32 @@ fn test_mutate_variable_fail() { #[test] fn test_self_fail() { - let bytes = include_str!("self_fail.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("self_fail.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error); } #[test] fn test_self_member_pass() { - let bytes = include_str!("self_member.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("self_member.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_self_member_invalid() { - let bytes = include_str!("self_member_invalid.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("self_member_invalid.leo"); + let program = parse_program(program_string).unwrap(); let _err = expect_compiler_error(program); } #[test] fn test_self_member_undefined() { - let bytes = include_str!("self_member_undefined.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("self_member_undefined.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error); } @@ -236,16 +236,16 @@ fn test_self_member_undefined() { #[test] fn test_pedersen_mock() { - let bytes = include_str!("pedersen_mock.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("pedersen_mock.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_define_circuit_inside_circuit_function() { - let bytes = include_str!("define_circuit_inside_circuit_function.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("define_circuit_inside_circuit_function.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } diff --git a/compiler/tests/console/mod.rs b/compiler/tests/console/mod.rs index 9bf1f820df..15b7c309a9 100644 --- a/compiler/tests/console/mod.rs +++ b/compiler/tests/console/mod.rs @@ -19,63 +19,63 @@ use leo_ast::InputValue; #[test] fn test_log() { - let bytes = include_str!("log.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("log.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_log_fail() { - let bytes = include_str!("log_fail.leo"); + let program_string = include_str!("log_fail.leo"); - assert!(parse_program(bytes).is_err()); + assert!(parse_program(program_string).is_err()); } #[test] fn test_log_parameter() { - let bytes = include_str!("log_parameter.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("log_parameter.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_log_parameter_many() { - let bytes = include_str!("log_parameter_many.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("log_parameter_many.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_log_parameter_fail_unknown() { - let bytes = include_str!("log_parameter_fail_unknown.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("log_parameter_fail_unknown.leo"); + let program = parse_program(program_string).unwrap(); expect_compiler_error(program); } #[test] fn test_log_parameter_fail_empty() { - let bytes = include_str!("log_parameter_fail_empty.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("log_parameter_fail_empty.leo"); + let program = parse_program(program_string).unwrap(); expect_compiler_error(program); } #[test] fn test_log_parameter_fail_none() { - let bytes = include_str!("log_parameter_fail_empty.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("log_parameter_fail_empty.leo"); + let program = parse_program(program_string).unwrap(); expect_compiler_error(program); } #[test] fn test_log_input() { - let bytes = include_str!("log_input.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("log_input.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]); @@ -88,8 +88,8 @@ fn test_log_input() { #[test] fn test_debug() { - let bytes = include_str!("debug.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("debug.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } @@ -98,8 +98,8 @@ fn test_debug() { #[test] fn test_error() { - let bytes = include_str!("error.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("error.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } @@ -108,8 +108,8 @@ fn test_error() { #[test] fn test_assert() { - let bytes = include_str!("assert.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("assert.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]); @@ -117,7 +117,7 @@ fn test_assert() { assert_satisfied(program); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(false)))]); @@ -128,15 +128,15 @@ fn test_assert() { #[test] fn test_conditional_assert() { - let bytes = include_str!("conditional_assert.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("conditional_assert.leo"); + let mut program = parse_program(program_string).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 mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(false)))]); diff --git a/compiler/tests/core/mod.rs b/compiler/tests/core/mod.rs index 293b84f536..11ad5f71df 100644 --- a/compiler/tests/core/mod.rs +++ b/compiler/tests/core/mod.rs @@ -20,40 +20,40 @@ use crate::{assert_satisfied, expect_symbol_table_error, parse_program}; #[test] fn test_core_circuit_invalid() { - let program_bytes = include_str!("core_package_invalid.leo"); - let program = parse_program(program_bytes).err().unwrap(); + let program_string = include_str!("core_package_invalid.leo"); + let error = parse_program(program_string).err().unwrap(); - expect_symbol_table_error(program); + expect_symbol_table_error(error); } #[test] fn test_core_circuit_star_fail() { - let program_bytes = include_str!("core_circuit_star_fail.leo"); - let error = parse_program(program_bytes).err().unwrap(); + let program_string = include_str!("core_circuit_star_fail.leo"); + let error = parse_program(program_string).err().unwrap(); expect_symbol_table_error(error); } #[test] fn test_core_package_invalid() { - let program_bytes = include_str!("core_package_invalid.leo"); - let error = parse_program(program_bytes).err().unwrap(); + let program_string = include_str!("core_package_invalid.leo"); + let error = parse_program(program_string).err().unwrap(); expect_symbol_table_error(error); } #[test] fn test_core_unstable_package_invalid() { - let program_bytes = include_str!("core_unstable_package_invalid.leo"); - let error = parse_program(program_bytes).err().unwrap(); + let program_string = include_str!("core_unstable_package_invalid.leo"); + let error = parse_program(program_string).err().unwrap(); expect_symbol_table_error(error); } #[test] fn test_unstable_blake2s_sanity() { - let program_bytes = include_str!("unstable_blake2s.leo"); - let program = parse_program(program_bytes).unwrap(); + let program_string = include_str!("unstable_blake2s.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } diff --git a/compiler/tests/core/packages/unstable/blake2s/mod.rs b/compiler/tests/core/packages/unstable/blake2s/mod.rs index 0f59efcd20..7bef75b1c4 100644 --- a/compiler/tests/core/packages/unstable/blake2s/mod.rs +++ b/compiler/tests/core/packages/unstable/blake2s/mod.rs @@ -32,16 +32,16 @@ use snarkos_models::algorithms::PRF; #[test] fn test_arguments_length_fail() { - let program_bytes = include_str!("arguments_length_fail.leo"); - let error = parse_program(program_bytes).err().unwrap(); + let program_string = include_str!("arguments_length_fail.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error); } #[test] fn test_arguments_type_fail() { - let program_bytes = include_str!("arguments_type_fail.leo"); - let error = parse_program(program_bytes).err().unwrap(); + let program_string = include_str!("arguments_type_fail.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error); } diff --git a/compiler/tests/definition/mod.rs b/compiler/tests/definition/mod.rs index 7cec04fcd5..75dff4e557 100644 --- a/compiler/tests/definition/mod.rs +++ b/compiler/tests/definition/mod.rs @@ -18,9 +18,9 @@ use crate::{assert_satisfied, import::set_local_dir, parse_program}; #[test] fn test_out_of_order() { - let program_bytes = include_str!("out_of_order.leo"); + let program_string = include_str!("out_of_order.leo"); - let program = parse_program(program_bytes).unwrap(); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } @@ -30,9 +30,9 @@ fn test_out_of_order() { fn test_out_of_order_with_import() { set_local_dir(); - let program_bytes = include_str!("out_of_order_with_import.leo"); + let program_string = include_str!("out_of_order_with_import.leo"); - let program = parse_program(program_bytes).unwrap(); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } diff --git a/compiler/tests/field/mod.rs b/compiler/tests/field/mod.rs index a36dcd3539..fa57001223 100644 --- a/compiler/tests/field/mod.rs +++ b/compiler/tests/field/mod.rs @@ -52,8 +52,8 @@ fn test_negate() { let a_string = field_to_decimal_string(a); let b_string = field_to_decimal_string(b); - let bytes = include_str!("negate.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("negate.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Field(a_string))), @@ -81,8 +81,8 @@ fn test_add() { let b_string = field_to_decimal_string(b); let c_string = field_to_decimal_string(c); - let bytes = include_str!("add.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("add.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Field(a_string))), @@ -111,8 +111,8 @@ fn test_sub() { let b_string = field_to_decimal_string(b); let c_string = field_to_decimal_string(c); - let bytes = include_str!("sub.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("sub.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Field(a_string))), @@ -140,8 +140,8 @@ fn test_div() { let b_string = field_to_decimal_string(b); let c_string = field_to_decimal_string(c); - let bytes = include_str!("div.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("div.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Field(a_string))), @@ -169,8 +169,8 @@ fn test_mul() { let b_string = field_to_decimal_string(b); let c_string = field_to_decimal_string(c); - let bytes = include_str!("mul.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("mul.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Field(a_string))), @@ -197,8 +197,8 @@ fn test_eq() { // test equal - let bytes = include_str!("eq.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("eq.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Field(a_string.clone()))), @@ -214,7 +214,7 @@ fn test_eq() { let c = a.eq(&b); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Field(a_string))), @@ -237,8 +237,8 @@ fn test_console_assert_pass() { let a_string = field_to_decimal_string(a); - let bytes = include_str!("console_assert.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("console_assert.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Field(a_string.clone()))), @@ -266,8 +266,8 @@ fn test_console_assert_fail() { let a_string = field_to_decimal_string(a); let b_string = field_to_decimal_string(b); - let bytes = include_str!("console_assert.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("console_assert.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Field(a_string))), @@ -290,8 +290,8 @@ fn test_ternary() { let a_string = field_to_decimal_string(a); let b_string = field_to_decimal_string(b); - let bytes = include_str!("ternary.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("ternary.leo"); + let mut program = parse_program(program_string).unwrap(); // true -> field a let main_input = generate_main_input(vec![ @@ -305,7 +305,7 @@ fn test_ternary() { assert_satisfied(program); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); // false -> field b let main_input = generate_main_input(vec![ @@ -325,14 +325,14 @@ fn test_ternary() { // let expected = include_str!("output_/register_one.out"); // let actual = get_output(program); // -// assert_eq!(expected, actual.bytes().as_slice()); +// assert_eq!(expected, actual.program_string().as_slice()); // } // // pub fn output_zero(program: EdwardsTestCompiler) { // let expected = include_str!("output_/register_zero.out"); // let actual = get_output(program); // -// assert_eq!(expected, actual.bytes().as_slice()); +// assert_eq!(expected, actual.program_string().as_slice()); // } // // #[test] diff --git a/compiler/tests/function/mod.rs b/compiler/tests/function/mod.rs index 8849e57f4f..ac7202ce06 100644 --- a/compiler/tests/function/mod.rs +++ b/compiler/tests/function/mod.rs @@ -26,24 +26,24 @@ use leo_compiler::errors::{CompilerError, ExpressionError, FunctionError, Statem #[test] fn test_empty() { - let bytes = include_str!("empty.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("empty.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_iteration() { - let bytes = include_str!("iteration.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("iteration.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_iteration_repeated() { - let bytes = include_str!("iteration_repeated.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("iteration_repeated.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } @@ -63,8 +63,8 @@ fn test_newlines() { #[test] fn test_multiple_returns() { - let bytes = include_str!("multiple.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("multiple.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } @@ -85,24 +85,24 @@ fn test_multiple_returns_main() { #[test] fn test_repeated_function_call() { - let bytes = include_str!("repeated.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("repeated.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_return() { - let bytes = include_str!("return.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("return.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_scope_fail() { - let bytes = include_str!("scope_fail.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("scope_fail.leo"); + let program = parse_program(program_string).unwrap(); match expect_compiler_error(program) { CompilerError::FunctionError(FunctionError::StatementError(StatementError::ExpressionError( @@ -117,24 +117,24 @@ fn test_scope_fail() { #[test] fn test_undefined() { - let bytes = include_str!("undefined.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("undefined.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error); } #[test] fn test_value_unchanged() { - let bytes = include_str!("value_unchanged.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("value_unchanged.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_array_input() { - let bytes = include_str!("array_input.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("array_input.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error) } @@ -143,32 +143,32 @@ fn test_array_input() { #[test] fn test_return_array_nested_fail() { - let bytes = include_str!("return_array_nested_fail.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("return_array_nested_fail.leo"); + let program = parse_program(program_string).unwrap(); let _err = expect_compiler_error(program); } #[test] fn test_return_array_nested_pass() { - let bytes = include_str!("return_array_nested_pass.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("return_array_nested_pass.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_return_array_tuple_fail() { - let bytes = include_str!("return_array_tuple_fail.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("return_array_tuple_fail.leo"); + let program = parse_program(program_string).unwrap(); let _err = expect_compiler_error(program); } #[test] fn test_return_array_tuple_pass() { - let bytes = include_str!("return_array_tuple_pass.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("return_array_tuple_pass.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } @@ -177,16 +177,16 @@ fn test_return_array_tuple_pass() { #[test] fn test_return_tuple() { - let bytes = include_str!("return_tuple.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("return_tuple.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_return_tuple_conditional() { - let bytes = include_str!("return_tuple_conditional.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("return_tuple_conditional.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } diff --git a/compiler/tests/group/mod.rs b/compiler/tests/group/mod.rs index 58548b93e3..ca383a33e3 100644 --- a/compiler/tests/group/mod.rs +++ b/compiler/tests/group/mod.rs @@ -52,124 +52,124 @@ pub fn group_element_to_input_value(g: EdwardsAffine) -> GroupValue { #[test] fn test_one() { - let bytes = include_str!("one.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("one.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_zero() { - let bytes = include_str!("zero.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("zero.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_point() { - let bytes = include_str!("point.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("point.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_x_sign_high() { - let bytes = include_str!("x_sign_high.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("x_sign_high.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_x_sign_low() { - let bytes = include_str!("x_sign_low.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("x_sign_low.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_x_sign_inferred() { - let bytes = include_str!("x_sign_inferred.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("x_sign_inferred.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_y_sign_high() { - let bytes = include_str!("y_sign_high.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("y_sign_high.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_y_sign_low() { - let bytes = include_str!("y_sign_low.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("y_sign_low.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_y_sign_inferred() { - let bytes = include_str!("y_sign_inferred.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("y_sign_inferred.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_both_sign_high() { - let bytes = include_str!("both_sign_high.leo"); + let program_string = include_str!("both_sign_high.leo"); - let program = parse_program(bytes).unwrap(); + let program = parse_program(program_string).unwrap(); expect_compiler_error(program); } #[test] fn test_both_sign_low() { - let bytes = include_str!("both_sign_low.leo"); + let program_string = include_str!("both_sign_low.leo"); - let program = parse_program(bytes).unwrap(); + let program = parse_program(program_string).unwrap(); expect_compiler_error(program); } #[test] fn test_both_sign_inferred() { - let bytes = include_str!("both_sign_inferred.leo"); + let program_string = include_str!("both_sign_inferred.leo"); - let program = parse_program(bytes).unwrap(); + let program = parse_program(program_string).unwrap(); expect_compiler_error(program); } #[test] fn test_point_input() { - let program_bytes = include_str!("point_input.leo"); + let program_string = include_str!("point_input.leo"); let input_bytes = include_str!("input/point.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program = parse_program_with_input(program_string, input_bytes).unwrap(); assert_satisfied(program); } #[test] fn test_input() { - let program_bytes = include_str!("input.leo"); - let input_bytes_pass = include_str!("input/valid.in"); - let input_bytes_fail = include_str!("input/invalid.in"); + let program_string = include_str!("input.leo"); + let input_string_pass = include_str!("input/valid.in"); + let input_string_fail = include_str!("input/invalid.in"); - let program = parse_program_with_input(program_bytes, input_bytes_pass).unwrap(); + let program = parse_program_with_input(program_string, input_string_pass).unwrap(); assert_satisfied(program); - let program = parse_program_with_input(program_bytes, input_bytes_fail).unwrap(); + let program = parse_program_with_input(program_string, input_string_fail).unwrap(); expect_compiler_error(program); } @@ -187,8 +187,8 @@ fn test_negate() { let a_element = group_element_to_input_value(a); let b_element = group_element_to_input_value(b); - let bytes = include_str!("negate.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("negate.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Group(a_element))), @@ -215,8 +215,8 @@ fn test_add() { let b_element = group_element_to_input_value(b); let c_element = group_element_to_input_value(c); - let bytes = include_str!("add.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("add.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Group(a_element))), @@ -244,8 +244,8 @@ fn test_sub() { let b_element = group_element_to_input_value(b); let c_element = group_element_to_input_value(c); - let bytes = include_str!("sub.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("sub.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Group(a_element))), @@ -267,8 +267,8 @@ fn test_console_assert_pass() { let a_element = group_element_to_input_value(a); - let bytes = include_str!("assert_eq.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("assert_eq.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Group(a_element.clone()))), @@ -296,8 +296,8 @@ fn test_console_assert_fail() { let a_element = group_element_to_input_value(a); let b_element = group_element_to_input_value(b); - let bytes = include_str!("assert_eq.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("assert_eq.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Group(a_element))), @@ -323,8 +323,8 @@ fn test_eq() { // test equal - let bytes = include_str!("eq.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("eq.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Group(a_element.clone()))), @@ -340,7 +340,7 @@ fn test_eq() { let c = a.eq(&b); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Group(a_element))), @@ -364,8 +364,8 @@ fn test_ternary() { let a_element = group_element_to_input_value(a); let b_element = group_element_to_input_value(b); - let bytes = include_str!("ternary.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("ternary.leo"); + let mut program = parse_program(program_string).unwrap(); // true -> field a let main_input = generate_main_input(vec![ @@ -379,7 +379,7 @@ fn test_ternary() { assert_satisfied(program); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); // false -> field b let main_input = generate_main_input(vec![ diff --git a/compiler/tests/import/mod.rs b/compiler/tests/import/mod.rs index 54857438ea..2218046389 100644 --- a/compiler/tests/import/mod.rs +++ b/compiler/tests/import/mod.rs @@ -34,8 +34,8 @@ pub fn set_local_dir() { fn test_basic() { set_local_dir(); - let bytes = include_str!("basic.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("basic.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } @@ -45,8 +45,8 @@ fn test_basic() { fn test_multiple() { set_local_dir(); - let bytes = include_str!("multiple.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("multiple.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } @@ -56,8 +56,8 @@ fn test_multiple() { fn test_star() { set_local_dir(); - let bytes = include_str!("star.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("star.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } @@ -67,8 +67,8 @@ fn test_star() { fn test_star_fail() { set_local_dir(); - let bytes = include_str!("star_fail.leo"); - assert!(parse_program(bytes).is_err()); + let program_string = include_str!("star_fail.leo"); + assert!(parse_program(program_string).is_err()); } #[test] @@ -76,8 +76,8 @@ fn test_star_fail() { fn test_alias() { set_local_dir(); - let bytes = include_str!("alias.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("alias.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } @@ -88,8 +88,8 @@ fn test_alias() { fn test_names_pass() { set_local_dir(); - let bytes = include_str!("names.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("names.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } @@ -99,8 +99,8 @@ fn test_names_pass() { fn test_names_fail_1() { set_local_dir(); - let bytes = include_str!("names_dash_a.leo"); - assert!(parse_program(bytes).is_err()); + let program_string = include_str!("names_dash_a.leo"); + assert!(parse_program(program_string).is_err()); } #[test] @@ -108,8 +108,8 @@ fn test_names_fail_1() { fn test_names_fail_2() { set_local_dir(); - let bytes = include_str!("names_a_dash.leo"); - assert!(parse_program(bytes).is_err()); + let program_string = include_str!("names_a_dash.leo"); + assert!(parse_program(program_string).is_err()); } #[test] @@ -117,8 +117,8 @@ fn test_names_fail_2() { fn test_names_fail_3() { set_local_dir(); - let bytes = include_str!("names_underscore.leo"); - assert!(parse_program(bytes).is_err()); + let program_string = include_str!("names_underscore.leo"); + assert!(parse_program(program_string).is_err()); } #[test] @@ -126,8 +126,8 @@ fn test_names_fail_3() { fn test_names_fail_4() { set_local_dir(); - let bytes = include_str!("names_dollar.leo"); - assert!(parse_program(bytes).is_err()); + let program_string = include_str!("names_dollar.leo"); + assert!(parse_program(program_string).is_err()); } // more complex tests @@ -136,8 +136,8 @@ fn test_names_fail_4() { fn test_many_import() { set_local_dir(); - let bytes = include_str!("many_import.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("many_import.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } @@ -147,8 +147,8 @@ fn test_many_import() { fn test_many_import_star() { set_local_dir(); - let bytes = include_str!("many_import_star.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("many_import_star.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } diff --git a/compiler/tests/input_files/program_input/mod.rs b/compiler/tests/input_files/program_input/mod.rs index cf77a8e3ed..befe97057e 100644 --- a/compiler/tests/input_files/program_input/mod.rs +++ b/compiler/tests/input_files/program_input/mod.rs @@ -26,10 +26,10 @@ fn expect_fail(program: EdwardsTestCompiler) { #[test] fn test_input_pass() { - let program_bytes = include_str!("main.leo"); - let input_bytes = include_str!("input/main.in"); + let program_string = include_str!("main.leo"); + let input_string = include_str!("input/main.in"); - let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + let program = parse_program_with_input(program_string, input_string).unwrap(); assert_satisfied(program); } diff --git a/compiler/tests/input_files/program_state/mod.rs b/compiler/tests/input_files/program_state/mod.rs index f065d09d4f..ac775270b1 100644 --- a/compiler/tests/input_files/program_state/mod.rs +++ b/compiler/tests/input_files/program_state/mod.rs @@ -42,10 +42,10 @@ fn test_access_state() { #[test] fn test_access_all() { - let program_bytes = include_str!("access_all.leo"); - let state_bytes = include_str!("input/token_withdraw.state"); + let program_string = include_str!("access_all.leo"); + let state_string = include_str!("input/token_withdraw.state"); - let program = parse_program_with_state(program_bytes, state_bytes).unwrap(); + let program = parse_program_with_state(program_string, state_string).unwrap(); assert_satisfied(program); } diff --git a/compiler/tests/integers/int_macro.rs b/compiler/tests/integers/int_macro.rs index 271c98c239..9346ced2d8 100644 --- a/compiler/tests/integers/int_macro.rs +++ b/compiler/tests/integers/int_macro.rs @@ -28,8 +28,8 @@ macro_rules! test_int { None => continue, }; - let bytes = include_str!("negate.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("negate.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), ("b", Some(InputValue::Integer($integer_type, b.to_string()))), @@ -42,15 +42,15 @@ macro_rules! test_int { } fn test_negate_min_fail() { - let bytes = include_str!("negate_min.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("negate_min.leo"); + let program = parse_program(program_string).unwrap(); expect_computation_error(program); } fn test_negate_zero() { - let bytes = include_str!("negate_zero.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("negate_zero.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } @@ -58,29 +58,29 @@ macro_rules! test_int { impl IntegerTester for $name { fn test_min() { - let bytes = include_str!("min.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("min.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } fn test_min_fail() { - let bytes = include_str!("min_fail.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("min_fail.leo"); + let program = parse_program(program_string).unwrap(); expect_parsing_error(program); } fn test_max() { - let bytes = include_str!("max.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("max.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } fn test_max_fail() { - let bytes = include_str!("max_fail.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("max_fail.leo"); + let program = parse_program(program_string).unwrap(); expect_parsing_error(program); } @@ -95,8 +95,8 @@ macro_rules! test_int { None => continue, }; - let bytes = include_str!("add.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("add.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -124,8 +124,8 @@ macro_rules! test_int { None => continue, }; - let bytes = include_str!("sub.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("sub.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -149,8 +149,8 @@ macro_rules! test_int { None => continue, }; - let bytes = include_str!("mul.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("mul.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -176,8 +176,8 @@ macro_rules! test_int { continue; } - let bytes = include_str!("div.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("div.leo"); + let mut program = parse_program(program_string).unwrap(); // expect an error when dividing by zero if b == 0 { @@ -220,8 +220,8 @@ macro_rules! test_int { None => continue, }; - let bytes = include_str!("pow.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("pow.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -242,8 +242,8 @@ macro_rules! test_int { // test equal - let bytes = include_str!("eq.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("eq.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -259,7 +259,7 @@ macro_rules! test_int { let c = a.eq(&b); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -280,8 +280,8 @@ macro_rules! test_int { // test a != a == false - let bytes = include_str!("ne.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("ne.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -297,7 +297,7 @@ macro_rules! test_int { let c = a.ne(&b); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -318,8 +318,8 @@ macro_rules! test_int { // test equal - let bytes = include_str!("ge.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("ge.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -335,7 +335,7 @@ macro_rules! test_int { let c = a.ge(&b); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -356,8 +356,8 @@ macro_rules! test_int { // test equal - let bytes = include_str!("gt.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("gt.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -373,7 +373,7 @@ macro_rules! test_int { let c = a.gt(&b); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -394,8 +394,8 @@ macro_rules! test_int { // test equal - let bytes = include_str!("le.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("le.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -411,7 +411,7 @@ macro_rules! test_int { let c = a.le(&b); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -432,8 +432,8 @@ macro_rules! test_int { // test equal - let bytes = include_str!("lt.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("lt.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -449,7 +449,7 @@ macro_rules! test_int { let c = a.lt(&b); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -468,8 +468,8 @@ macro_rules! test_int { let a: $type_ = rand::random(); // test equal - let bytes = include_str!("console_assert.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("console_assert.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -487,7 +487,7 @@ macro_rules! test_int { continue; } - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -504,8 +504,8 @@ macro_rules! test_int { let a: $type_ = rand::random(); let b: $type_ = rand::random(); - let bytes = include_str!("ternary.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("ternary.leo"); + let mut program = parse_program(program_string).unwrap(); // true -> field 1 let main_input = generate_main_input(vec![ @@ -520,7 +520,7 @@ macro_rules! test_int { assert_satisfied(program); // false -> field 2 - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("s", Some(InputValue::Boolean(false))), diff --git a/compiler/tests/integers/uint_macro.rs b/compiler/tests/integers/uint_macro.rs index 15616370ae..e220a82be7 100644 --- a/compiler/tests/integers/uint_macro.rs +++ b/compiler/tests/integers/uint_macro.rs @@ -20,29 +20,29 @@ macro_rules! test_uint { impl IntegerTester for $name { fn test_min() { - let bytes = include_str!("min.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("min.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } fn test_min_fail() { - let bytes = include_str!("min_fail.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("min_fail.leo"); + let program = parse_program(program_string).unwrap(); expect_parsing_error(program); } fn test_max() { - let bytes = include_str!("max.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("max.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } fn test_max_fail() { - let bytes = include_str!("max_fail.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("max_fail.leo"); + let program = parse_program(program_string).unwrap(); expect_parsing_error(program); } @@ -57,8 +57,8 @@ macro_rules! test_uint { None => continue, }; - let bytes = include_str!("add.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("add.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -82,8 +82,8 @@ macro_rules! test_uint { None => continue, }; - let bytes = include_str!("sub.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("sub.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -107,8 +107,8 @@ macro_rules! test_uint { None => continue, }; - let bytes = include_str!("mul.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("mul.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -132,8 +132,8 @@ macro_rules! test_uint { None => continue, }; - let bytes = include_str!("div.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("div.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -158,8 +158,8 @@ macro_rules! test_uint { None => continue, }; - let bytes = include_str!("pow.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("pow.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -180,8 +180,8 @@ macro_rules! test_uint { // test equal - let bytes = include_str!("eq.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("eq.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -197,7 +197,7 @@ macro_rules! test_uint { let c = a.eq(&b); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -218,8 +218,8 @@ macro_rules! test_uint { // test a != a == false - let bytes = include_str!("ne.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("ne.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -235,7 +235,7 @@ macro_rules! test_uint { let c = a.ne(&b); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -256,8 +256,8 @@ macro_rules! test_uint { // test equal - let bytes = include_str!("ge.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("ge.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -273,7 +273,7 @@ macro_rules! test_uint { let c = a.ge(&b); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -294,8 +294,8 @@ macro_rules! test_uint { // test equal - let bytes = include_str!("gt.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("gt.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -311,7 +311,7 @@ macro_rules! test_uint { let c = a.gt(&b); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -332,8 +332,8 @@ macro_rules! test_uint { // test equal - let bytes = include_str!("le.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("le.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -349,7 +349,7 @@ macro_rules! test_uint { let c = a.le(&b); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -370,8 +370,8 @@ macro_rules! test_uint { // test equal - let bytes = include_str!("lt.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("lt.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -387,7 +387,7 @@ macro_rules! test_uint { let c = a.lt(&b); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -406,8 +406,8 @@ macro_rules! test_uint { let a: $type_ = rand::random(); // test equal - let bytes = include_str!("console_assert.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("console_assert.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -425,7 +425,7 @@ macro_rules! test_uint { continue; } - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Integer($integer_type, a.to_string()))), @@ -442,8 +442,8 @@ macro_rules! test_uint { let a: $type_ = rand::random(); let b: $type_ = rand::random(); - let bytes = include_str!("ternary.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("ternary.leo"); + let mut program = parse_program(program_string).unwrap(); // true -> field 1 let main_input = generate_main_input(vec![ @@ -458,7 +458,7 @@ macro_rules! test_uint { assert_satisfied(program); // false -> field 2 - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("s", Some(InputValue::Boolean(false))), diff --git a/compiler/tests/mutability/mod.rs b/compiler/tests/mutability/mod.rs index 9bcfa25225..8f07c5746f 100644 --- a/compiler/tests/mutability/mod.rs +++ b/compiler/tests/mutability/mod.rs @@ -19,96 +19,96 @@ use leo_ast::InputValue; #[test] fn test_let() { - let bytes = include_str!("let.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("let.leo"); + let program = parse_program(program_string).unwrap(); expect_compiler_error(program); } #[test] fn test_let_mut() { - let bytes = include_str!("let_mut.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("let_mut.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_const_fail() { - let bytes = include_str!("const.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("const.leo"); + let program = parse_program(program_string).unwrap(); expect_compiler_error(program); } #[test] fn test_const_mut_fail() { - let bytes = include_str!("const_mut.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("const_mut.leo"); + let program = parse_program(program_string).unwrap(); expect_compiler_error(program); } #[test] fn test_array() { - let bytes = include_str!("array.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("array.leo"); + let program = parse_program(program_string).unwrap(); expect_compiler_error(program); } #[test] fn test_array_mut() { - let bytes = include_str!("array_mut.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("array_mut.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_circuit() { - let bytes = include_str!("circuit.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("circuit.leo"); + let program = parse_program(program_string).unwrap(); expect_compiler_error(program); } #[test] fn test_circuit_mut() { - let bytes = include_str!("circuit_mut.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("circuit_mut.leo"); + let program = parse_program(program_string).unwrap(); expect_compiler_error(program); } #[test] fn test_circuit_variable_mut() { - let bytes = include_str!("circuit_variable_mut.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("circuit_variable_mut.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_circuit_function_mut() { - let bytes = include_str!("circuit_function_mut.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("circuit_function_mut.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error); } #[test] fn test_circuit_static_function_mut() { - let bytes = include_str!("circuit_static_function_mut.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("circuit_static_function_mut.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error); } #[test] fn test_function_input() { - let bytes = include_str!("function_input.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("function_input.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]); @@ -119,8 +119,8 @@ fn test_function_input() { #[test] fn test_function_input_mut() { - let bytes = include_str!("function_input_mut.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("function_input_mut.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![("a", Some(InputValue::Boolean(true)))]); diff --git a/compiler/tests/statements/conditional/mod.rs b/compiler/tests/statements/conditional/mod.rs index f9bdc2c47b..84d03eb71b 100644 --- a/compiler/tests/statements/conditional/mod.rs +++ b/compiler/tests/statements/conditional/mod.rs @@ -28,8 +28,8 @@ use leo_ast::InputValue; #[test] fn test_assert() { - let bytes = include_str!("assert.leo"); - let mut program_1_pass = parse_program(bytes).unwrap(); + let program_string = include_str!("assert.leo"); + let mut program_1_pass = parse_program(program_string).unwrap(); let mut program_0_pass = program_1_pass.clone(); let mut program_2_fail = program_1_pass.clone(); @@ -60,8 +60,8 @@ fn test_assert() { #[test] fn test_mutate() { - let bytes = include_str!("mutate.leo"); - let mut program_1_pass = parse_program(bytes).unwrap(); + let program_string = include_str!("mutate.leo"); + let mut program_1_pass = parse_program(program_string).unwrap(); let mut program_0_pass = program_1_pass.clone(); // Check that an input value of 1 satisfies the constraint system @@ -83,8 +83,8 @@ fn test_mutate() { #[test] fn test_for_loop() { - let bytes = include_str!("for_loop.leo"); - let mut program_true_6 = parse_program(bytes).unwrap(); + let program_string = include_str!("for_loop.leo"); + let mut program_true_6 = parse_program(program_string).unwrap(); let mut program_false_0 = program_true_6.clone(); // Check that an input value of true satisfies the constraint system @@ -106,8 +106,8 @@ fn test_for_loop() { #[test] fn test_chain() { - let bytes = include_str!("chain.leo"); - let mut program_1_1 = parse_program(bytes).unwrap(); + let program_string = include_str!("chain.leo"); + let mut program_1_1 = parse_program(program_string).unwrap(); let mut program_2_2 = program_1_1.clone(); let mut program_4_3 = program_1_1.clone(); @@ -147,8 +147,8 @@ fn test_chain() { #[test] fn test_nested() { - let bytes = include_str!("nested.leo"); - let mut program_true_true_3 = parse_program(bytes).unwrap(); + let program_string = include_str!("nested.leo"); + let mut program_true_true_3 = parse_program(program_string).unwrap(); let mut program_true_false_1 = program_true_true_3.clone(); let mut program_false_false_0 = program_true_true_3.clone(); diff --git a/compiler/tests/statements/mod.rs b/compiler/tests/statements/mod.rs index 68b4a38be6..b06386769c 100644 --- a/compiler/tests/statements/mod.rs +++ b/compiler/tests/statements/mod.rs @@ -23,8 +23,8 @@ pub mod conditional; #[test] fn test_ternary_basic() { - let bytes = include_str!("ternary_basic.leo"); - let mut program = parse_program(bytes).unwrap(); + let program_string = include_str!("ternary_basic.leo"); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Boolean(true))), @@ -35,7 +35,7 @@ fn test_ternary_basic() { assert_satisfied(program); - let mut program = parse_program(bytes).unwrap(); + let mut program = parse_program(program_string).unwrap(); let main_input = generate_main_input(vec![ ("a", Some(InputValue::Boolean(false))), @@ -51,16 +51,16 @@ fn test_ternary_basic() { #[test] fn test_iteration_basic() { - let bytes = include_str!("iteration_basic.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("iteration_basic.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_num_returns_fail() { - let bytes = include_str!("num_returns_fail.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("num_returns_fail.leo"); + let error = parse_program(program_string).err().unwrap(); expect_type_inference_error(error); } diff --git a/compiler/tests/syntax/identifiers/mod.rs b/compiler/tests/syntax/identifiers/mod.rs index f4dece3f59..1adf8697d9 100644 --- a/compiler/tests/syntax/identifiers/mod.rs +++ b/compiler/tests/syntax/identifiers/mod.rs @@ -18,80 +18,80 @@ use crate::parse_program; #[test] fn test_address_name_fail() { - let bytes = include_str!("address_fail.leo"); - let syntax_error = parse_program(bytes).is_err(); + let program_string = include_str!("address_fail.leo"); + let syntax_error = parse_program(program_string).is_err(); assert!(syntax_error); } #[test] fn test_console_name_fail() { - let bytes = include_str!("console_fail.leo"); - let syntax_error = parse_program(bytes).is_err(); + let program_string = include_str!("console_fail.leo"); + let syntax_error = parse_program(program_string).is_err(); assert!(syntax_error); } #[test] fn test_field_name_fail() { - let bytes = include_str!("field_fail.leo"); - let syntax_error = parse_program(bytes).is_err(); + let program_string = include_str!("field_fail.leo"); + let syntax_error = parse_program(program_string).is_err(); assert!(syntax_error); } #[test] fn test_group_name_fail() { - let bytes = include_str!("group_fail.leo"); - let syntax_error = parse_program(bytes).is_err(); + let program_string = include_str!("group_fail.leo"); + let syntax_error = parse_program(program_string).is_err(); assert!(syntax_error); } #[test] fn test_i8_name_fail() { - let bytes = include_str!("i8_fail.leo"); - let syntax_error = parse_program(bytes).is_err(); + let program_string = include_str!("i8_fail.leo"); + let syntax_error = parse_program(program_string).is_err(); assert!(syntax_error); } #[test] fn test_input_name_fail() { - let bytes = include_str!("input_fail.leo"); - let syntax_error = parse_program(bytes).is_err(); + let program_string = include_str!("input_fail.leo"); + let syntax_error = parse_program(program_string).is_err(); assert!(syntax_error); } #[test] fn test_self_type_name_fail() { - let bytes = include_str!("self_type_fail.leo"); - let syntax_error = parse_program(bytes).is_err(); + let program_string = include_str!("self_type_fail.leo"); + let syntax_error = parse_program(program_string).is_err(); assert!(syntax_error); } #[test] fn test_self_keyword_name_fail() { - let bytes = include_str!("self_keyword_fail.leo"); - let syntax_error = parse_program(bytes).is_err(); + let program_string = include_str!("self_keyword_fail.leo"); + let syntax_error = parse_program(program_string).is_err(); assert!(syntax_error); } #[test] fn test_true_name_fail() { - let bytes = include_str!("true_fail.leo"); - let syntax_error = parse_program(bytes).is_err(); + let program_string = include_str!("true_fail.leo"); + let syntax_error = parse_program(program_string).is_err(); assert!(syntax_error); } #[test] fn test_u8_name_fail() { - let bytes = include_str!("u8_fail.leo"); - let syntax_error = parse_program(bytes).is_err(); + let program_string = include_str!("u8_fail.leo"); + let syntax_error = parse_program(program_string).is_err(); assert!(syntax_error); } diff --git a/compiler/tests/syntax/mod.rs b/compiler/tests/syntax/mod.rs index f8429a28c6..195fad9834 100644 --- a/compiler/tests/syntax/mod.rs +++ b/compiler/tests/syntax/mod.rs @@ -25,8 +25,8 @@ pub mod identifiers; #[test] #[ignore] fn test_semicolon() { - let bytes = include_str!("semicolon.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("semicolon.leo"); + let error = parse_program(program_string).err().unwrap(); match error { CompilerError::ParserError(ParserError::SyntaxError(_)) => {} @@ -36,8 +36,8 @@ fn test_semicolon() { #[test] fn test_undefined() { - let bytes = include_str!("undefined.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("undefined.leo"); + let program = parse_program(program_string).unwrap(); let error = expect_compiler_error(program); @@ -76,8 +76,8 @@ fn input_syntax_error() { #[test] fn test_compare_mismatched_types() { - let bytes = include_str!("compare_mismatched_types.leo"); - let error = parse_program(bytes).err().unwrap(); + let program_string = include_str!("compare_mismatched_types.leo"); + let error = parse_program(program_string).err().unwrap(); // Expect a type inference error. match error { diff --git a/compiler/tests/tuples/mod.rs b/compiler/tests/tuples/mod.rs index 4ec0ee3873..5ed5cd357f 100644 --- a/compiler/tests/tuples/mod.rs +++ b/compiler/tests/tuples/mod.rs @@ -18,105 +18,105 @@ use crate::{assert_satisfied, parse_program}; #[test] fn test_tuple_basic() { - let program_bytes = include_str!("basic.leo"); + let program_string = include_str!("basic.leo"); - let program = parse_program(program_bytes).unwrap(); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_tuple_access() { - let program_bytes = include_str!("access.leo"); + let program_string = include_str!("access.leo"); - let program = parse_program(program_bytes).unwrap(); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_tuple_typed() { - let program_bytes = include_str!("typed.leo"); + let program_string = include_str!("typed.leo"); - let program = parse_program(program_bytes).unwrap(); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_multiple() { - let program_bytes = include_str!("multiple.leo"); + let program_string = include_str!("multiple.leo"); - let program = parse_program(program_bytes).unwrap(); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_multiple_typed() { - let program_bytes = include_str!("multiple_typed.leo"); + let program_string = include_str!("multiple_typed.leo"); - let program = parse_program(program_bytes).unwrap(); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_function() { - let program_bytes = include_str!("function.leo"); + let program_string = include_str!("function.leo"); - let program = parse_program(program_bytes).unwrap(); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_function_typed() { - let program_bytes = include_str!("function_typed.leo"); + let program_string = include_str!("function_typed.leo"); - let program = parse_program(program_bytes).unwrap(); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_function_multiple() { - let progam_bytes = include_str!("function_multiple.leo"); + let progam_string = include_str!("function_multiple.leo"); - let program = parse_program(progam_bytes).unwrap(); + let program = parse_program(progam_string).unwrap(); assert_satisfied(program); } #[test] fn test_nested() { - let program_bytes = include_str!("nested.leo"); + let program_string = include_str!("nested.leo"); - let program = parse_program(program_bytes).unwrap(); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_nested_access() { - let program_bytes = include_str!("nested_access.leo"); + let program_string = include_str!("nested_access.leo"); - let program = parse_program(program_bytes).unwrap(); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } #[test] fn test_nested_typed() { - let program_bytes = include_str!("nested_typed.leo"); + let program_string = include_str!("nested_typed.leo"); - let program = parse_program(program_bytes).unwrap(); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } // #[test] // fn test_input() { -// let input_bytes = include_str!("inputs/input.in"); -// let program_bytes = include_str!("") +// let input_string = include_str!("inputs/input.in"); +// let program_string = include_str!("") // } From 3a66d989191978813f443db4426317e0749975a6 Mon Sep 17 00:00:00 2001 From: collin Date: Fri, 4 Dec 2020 16:40:17 -0500 Subject: [PATCH 10/41] use include_str in symbol-table and type-inference modules --- symbol-table/tests/mod.rs | 7 ++----- symbol-table/tests/symbol_table/mod.rs | 16 ++++++++-------- type-inference/tests/arrays/mod.rs | 12 ++++++------ type-inference/tests/circuits/mod.rs | 4 ++-- type-inference/tests/functions/mod.rs | 4 ++-- type-inference/tests/mod.rs | 11 ++++------- type-inference/tests/tuples/mod.rs | 4 ++-- type-inference/tests/variables/mod.rs | 16 ++++++++-------- 8 files changed, 34 insertions(+), 40 deletions(-) diff --git a/symbol-table/tests/mod.rs b/symbol-table/tests/mod.rs index fb8a5ee290..21c7710cb6 100644 --- a/symbol-table/tests/mod.rs +++ b/symbol-table/tests/mod.rs @@ -34,15 +34,12 @@ impl TestSymbolTable { /// /// Returns a Leo syntax tree given a Leo program. /// - pub fn new(bytes: &[u8]) -> Self { - // Get file string from bytes. - let file_string = String::from_utf8_lossy(bytes); - + pub fn new(program_string: &str) -> Self { // Get test file path. let file_path = PathBuf::from(TEST_PROGRAM_PATH); // Get parser syntax tree. - let grammar = Grammar::new(&file_path, &*file_string).unwrap(); + let grammar = Grammar::new(&file_path, program_string).unwrap(); // Get Leo syntax tree. let ast = Ast::new(TEST_PROGRAM_PATH, &grammar); diff --git a/symbol-table/tests/symbol_table/mod.rs b/symbol-table/tests/symbol_table/mod.rs index 4d40891377..e5b820d4a4 100644 --- a/symbol-table/tests/symbol_table/mod.rs +++ b/symbol-table/tests/symbol_table/mod.rs @@ -25,8 +25,8 @@ use crate::TestSymbolTable; /// #[test] fn test_duplicate_circuit() { - let program_bytes = include_bytes!("duplicate_circuit.leo"); - let resolver = TestSymbolTable::new(program_bytes); + let program_string = include_str!("duplicate_circuit.leo"); + let resolver = TestSymbolTable::new(program_string); resolver.expect_pass_one_error(); } @@ -40,8 +40,8 @@ fn test_duplicate_circuit() { /// #[test] fn test_duplicate_function() { - let program_bytes = include_bytes!("duplicate_function.leo"); - let resolver = TestSymbolTable::new(program_bytes); + let program_string = include_str!("duplicate_function.leo"); + let resolver = TestSymbolTable::new(program_string); resolver.expect_pass_one_error(); } @@ -54,8 +54,8 @@ fn test_duplicate_function() { /// #[test] fn test_self_not_available() { - let program_bytes = include_bytes!("self_not_available.leo"); - let resolver = TestSymbolTable::new(program_bytes); + let program_string = include_str!("self_not_available.leo"); + let resolver = TestSymbolTable::new(program_string); resolver.expect_pass_two_error(); } @@ -68,8 +68,8 @@ fn test_self_not_available() { /// #[test] fn test_undefined_circuit() { - let program_bytes = include_bytes!("undefined_circuit.leo"); - let resolver = TestSymbolTable::new(program_bytes); + let program_string = include_str!("undefined_circuit.leo"); + let resolver = TestSymbolTable::new(program_string); resolver.expect_pass_two_error(); } diff --git a/type-inference/tests/arrays/mod.rs b/type-inference/tests/arrays/mod.rs index 72ab79478e..6877b90b76 100644 --- a/type-inference/tests/arrays/mod.rs +++ b/type-inference/tests/arrays/mod.rs @@ -18,27 +18,27 @@ use crate::TestTypeInference; #[test] fn test_empty_array() { - let bytes = include_bytes!("empty_array.leo"); + let program_string = include_str!("empty_array.leo"); - let check = TestTypeInference::new(bytes); + let check = TestTypeInference::new(program_string); check.expect_error(); } #[test] fn test_invalid_array_access() { - let bytes = include_bytes!("invalid_array_access.leo"); + let program_string = include_str!("invalid_array_access.leo"); - let check = TestTypeInference::new(bytes); + let check = TestTypeInference::new(program_string); check.expect_error(); } #[test] fn test_invalid_spread() { - let bytes = include_bytes!("invalid_spread.leo"); + let program_string = include_str!("invalid_spread.leo"); - let check = TestTypeInference::new(bytes); + let check = TestTypeInference::new(program_string); check.expect_error(); } diff --git a/type-inference/tests/circuits/mod.rs b/type-inference/tests/circuits/mod.rs index 8b8d585bd6..e05837c4d0 100644 --- a/type-inference/tests/circuits/mod.rs +++ b/type-inference/tests/circuits/mod.rs @@ -18,8 +18,8 @@ use crate::TestTypeInference; #[test] fn test_invalid_circuit() { - let bytes = include_bytes!("invalid_circuit.leo"); - let check = TestTypeInference::new(bytes); + let program_string = include_str!("invalid_circuit.leo"); + let check = TestTypeInference::new(program_string); check.expect_error(); } diff --git a/type-inference/tests/functions/mod.rs b/type-inference/tests/functions/mod.rs index 20e873cbaf..c353cad388 100644 --- a/type-inference/tests/functions/mod.rs +++ b/type-inference/tests/functions/mod.rs @@ -18,8 +18,8 @@ use crate::TestTypeInference; #[test] fn test_invalid_function() { - let bytes = include_bytes!("invalid_function.leo"); - let check = TestTypeInference::new(bytes); + let program_string = include_str!("invalid_function.leo"); + let check = TestTypeInference::new(program_string); check.expect_error(); } diff --git a/type-inference/tests/mod.rs b/type-inference/tests/mod.rs index e72bb9f005..40924eabfe 100644 --- a/type-inference/tests/mod.rs +++ b/type-inference/tests/mod.rs @@ -38,15 +38,12 @@ pub struct TestTypeInference { } impl TestTypeInference { - pub fn new(bytes: &[u8]) -> Self { - // Get file string from bytes. - let file_string = String::from_utf8_lossy(bytes); - + pub fn new(program_string: &str) -> Self { // Get test file path. let file_path = PathBuf::from(TEST_PROGRAM_PATH); // Get parser syntax tree. - let ast = Grammar::new(&file_path, &*file_string).unwrap(); + let ast = Grammar::new(&file_path, program_string).unwrap(); // Get typed syntax tree. let typed = Ast::new(TEST_PROGRAM_NAME, &ast); @@ -76,9 +73,9 @@ impl TestTypeInference { #[test] fn test_new() { - let bytes = include_bytes!("empty.leo"); + let program_string = include_str!("empty.leo"); - let type_inference = TestTypeInference::new(bytes); + let type_inference = TestTypeInference::new(program_string); type_inference.check() } diff --git a/type-inference/tests/tuples/mod.rs b/type-inference/tests/tuples/mod.rs index cc0549cffe..9667e11971 100644 --- a/type-inference/tests/tuples/mod.rs +++ b/type-inference/tests/tuples/mod.rs @@ -18,8 +18,8 @@ use crate::TestTypeInference; #[test] fn test_invalid_tuple_access() { - let bytes = include_bytes!("invalid_tuple_access.leo"); - let check = TestTypeInference::new(bytes); + let program_string = include_str!("invalid_tuple_access.leo"); + let check = TestTypeInference::new(program_string); check.expect_error(); } diff --git a/type-inference/tests/variables/mod.rs b/type-inference/tests/variables/mod.rs index 9e7b3dd1ea..1cadaa5e68 100644 --- a/type-inference/tests/variables/mod.rs +++ b/type-inference/tests/variables/mod.rs @@ -18,32 +18,32 @@ use crate::TestTypeInference; #[test] fn test_duplicate_variable() { - let bytes = include_bytes!("duplicate_variable.leo"); - let check = TestTypeInference::new(bytes); + let program_string = include_str!("duplicate_variable.leo"); + let check = TestTypeInference::new(program_string); check.expect_error(); } #[test] fn test_duplicate_variable_multi() { - let bytes = include_bytes!("duplicate_variable_multi.leo"); - let check = TestTypeInference::new(bytes); + let program_string = include_str!("duplicate_variable_multi.leo"); + let check = TestTypeInference::new(program_string); check.expect_error(); } #[test] fn test_not_enough_values() { - let bytes = include_bytes!("not_enough_values.leo"); - let check = TestTypeInference::new(bytes); + let program_string = include_str!("not_enough_values.leo"); + let check = TestTypeInference::new(program_string); check.expect_error(); } #[test] fn test_too_many_values() { - let bytes = include_bytes!("too_many_values.leo"); - let check = TestTypeInference::new(bytes); + let program_string = include_str!("too_many_values.leo"); + let check = TestTypeInference::new(program_string); check.expect_error(); } From cd53cba77a5b06bc6fa5827053193387a1280392 Mon Sep 17 00:00:00 2001 From: collin Date: Fri, 4 Dec 2020 17:56:59 -0500 Subject: [PATCH 11/41] fix circuit selftype error bug --- compiler/src/function/result/result.rs | 9 ++------ compiler/src/statement/return_/return_.rs | 25 +++++++++++------------ 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/compiler/src/function/result/result.rs b/compiler/src/function/result/result.rs index 4bfa4a8165..f8fae3bb17 100644 --- a/compiler/src/function/result/result.rs +++ b/compiler/src/function/result/result.rs @@ -17,6 +17,7 @@ //! Enforces that one return value is produced in a compiled Leo program. use crate::{ + check_return_type, errors::StatementError, get_indicator_value, program::ConstrainedProgram, @@ -76,13 +77,7 @@ impl> ConstrainedProgram { for (indicator, result) in results.into_iter() { // Error if a statement returned a result with an incorrect type let result_type = result.to_type(span)?; - if return_type != result_type { - return Err(StatementError::arguments_type( - &return_type, - &result_type, - span.to_owned(), - )); - } + check_return_type(&return_type, &result_type, span)?; if get_indicator_value(&indicator) { // Error if we already have a return value. diff --git a/compiler/src/statement/return_/return_.rs b/compiler/src/statement/return_/return_.rs index f70b69ca79..55d548dbcf 100644 --- a/compiler/src/statement/return_/return_.rs +++ b/compiler/src/statement/return_/return_.rs @@ -24,20 +24,17 @@ use snarkos_models::{ gadgets::r1cs::ConstraintSystem, }; -fn check_return_type(expected: Option, actual: Type, span: &Span) -> Result<(), StatementError> { - match expected { - Some(expected) => { - if expected.ne(&actual) { - if (expected.is_self() && actual.is_circuit()) || expected.eq_flat(&actual) { - return Ok(()); - } else { - return Err(StatementError::arguments_type(&expected, &actual, span.to_owned())); - } - } +/// Returns `Ok` if the expected type == actual type, returns `Err` otherwise. +pub fn check_return_type(expected: &Type, actual: &Type, span: &Span) -> Result<(), StatementError> { + if expected.ne(&actual) { + // If the return type is `SelfType` returning the circuit type is okay. + return if (expected.is_self() && actual.is_circuit()) || expected.eq_flat(&actual) { Ok(()) - } - None => Ok(()), + } else { + Err(StatementError::arguments_type(&expected, &actual, span.to_owned())) + }; } + Ok(()) } impl> ConstrainedProgram { @@ -53,7 +50,9 @@ impl> ConstrainedProgram { let result = self.enforce_operand(cs, file_scope, function_scope, return_type.clone(), expression, span)?; // Make sure we return the correct type. - check_return_type(return_type, result.to_type(&span)?, span)?; + if let Some(expected) = return_type { + check_return_type(&expected, &result.to_type(span)?, span)?; + } Ok(result) } From 7745710dc40b55c516b14027938e427b3c76aa5d Mon Sep 17 00:00:00 2001 From: collin Date: Fri, 4 Dec 2020 19:06:29 -0500 Subject: [PATCH 12/41] cargo +nightly clippy --- compiler/src/errors/statement.rs | 4 ++-- compiler/src/function/function.rs | 2 +- compiler/src/function/result/result.rs | 6 +++++- compiler/src/statement/statement.rs | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/compiler/src/errors/statement.rs b/compiler/src/errors/statement.rs index 4fd0dc7d5e..b1e7cf908d 100644 --- a/compiler/src/errors/statement.rs +++ b/compiler/src/errors/statement.rs @@ -136,8 +136,8 @@ impl StatementError { } pub fn multiple_returns(span: Span) -> Self { - let message = - format!("This function returns multiple times and produces unreachable circuits with undefined behavior."); + let message = "This function returns multiple times and produces unreachable circuits with undefined behavior." + .to_string(); Self::new_from_span(message, span) } diff --git a/compiler/src/function/function.rs b/compiler/src/function/function.rs index 53ac0a82ba..d1f1d96f1d 100644 --- a/compiler/src/function/function.rs +++ b/compiler/src/function/function.rs @@ -111,6 +111,6 @@ impl> ConstrainedProgram { // Conditionally select a result based on returned indicators Self::conditionally_select_result(cs, function.output, results, &function.span) - .map_err(|err| FunctionError::StatementError(err)) + .map_err(FunctionError::StatementError) } } diff --git a/compiler/src/function/result/result.rs b/compiler/src/function/result/result.rs index f8fae3bb17..1971dd7c4e 100644 --- a/compiler/src/function/result/result.rs +++ b/compiler/src/function/result/result.rs @@ -67,7 +67,11 @@ impl> ConstrainedProgram { }; // Error if the function or one of its branches does not return. - if let None = results.iter().find(|(indicator, _res)| get_indicator_value(indicator)) { + if results + .iter() + .find(|(indicator, _res)| get_indicator_value(indicator)) + .is_none() + { return Err(StatementError::no_returns(return_type, span.to_owned())); } diff --git a/compiler/src/statement/statement.rs b/compiler/src/statement/statement.rs index 61ad80c87a..6e96c88c9a 100644 --- a/compiler/src/statement/statement.rs +++ b/compiler/src/statement/statement.rs @@ -124,7 +124,7 @@ impl> ConstrainedProgram { match &value { ConstrainedValue::Tuple(values) => { if !values.is_empty() { - results.push((indicator.clone(), value)); + results.push((*indicator, value)); } } _ => return Err(StatementError::unassigned(expression_string, span)), From 3b23eb595a1b4720f43575af5b37cfe0344651e8 Mon Sep 17 00:00:00 2001 From: collin Date: Mon, 7 Dec 2020 11:22:45 -0500 Subject: [PATCH 13/41] return iterator instead of vector --- ast/src/functions/function.rs | 9 +++------ compiler/src/function/function.rs | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/ast/src/functions/function.rs b/ast/src/functions/function.rs index c55daf03d3..efc3a6405e 100644 --- a/ast/src/functions/function.rs +++ b/ast/src/functions/function.rs @@ -77,13 +77,10 @@ impl Function { } /// - /// Returns a vector of [&FunctionInput] removing `self` and `mut self` inputs. + /// Returns an iterator of [&FunctionInput] removing `self` and `mut self` inputs. /// - pub fn filter_self_inputs(&self) -> Vec<&FunctionInput> { - self.input - .iter() - .filter(|input| !input.is_self()) - .collect::>() + pub fn filter_self_inputs(&self) -> impl Iterator { + self.input.iter().filter(|input| !input.is_self()) } fn format(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/compiler/src/function/function.rs b/compiler/src/function/function.rs index d1f1d96f1d..4d58fc4a05 100644 --- a/compiler/src/function/function.rs +++ b/compiler/src/function/function.rs @@ -46,7 +46,7 @@ impl> ConstrainedProgram { let mut_self = function.contains_mut_self(); // Store input values as new variables in resolved program - for (input_model, input_expression) in function.filter_self_inputs().iter().zip(input.into_iter()) { + for (input_model, input_expression) in function.filter_self_inputs().zip(input.into_iter()) { let (name, value) = match input_model { FunctionInput::InputKeyword(keyword) => { let value = From ed4e0943770bc6e27b73e45c379775d3b77c5d34 Mon Sep 17 00:00:00 2001 From: collin Date: Mon, 7 Dec 2020 11:33:45 -0500 Subject: [PATCH 14/41] symbol table optimizations --- symbol-table/src/types/functions/function.rs | 13 ++++++------- symbol-table/src/types/functions/function_input.rs | 9 --------- type-inference/src/objects/frame.rs | 4 +--- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/symbol-table/src/types/functions/function.rs b/symbol-table/src/types/functions/function.rs index ffc35fde98..3c84176fdc 100644 --- a/symbol-table/src/types/functions/function.rs +++ b/symbol-table/src/types/functions/function.rs @@ -127,7 +127,9 @@ impl FunctionType { pub fn num_inputs(&self) -> usize { self.inputs .iter() - .fold(0, |acc, function_input| acc + function_input.count()) + .filter(|function_input| !function_input.is_self()) + .count() + // .fold(0, |acc, function_input| acc + function_input.arguments()) } /// @@ -139,13 +141,10 @@ impl FunctionType { } /// - /// Returns a vector of [&FunctionInputType] removing `self` and `mut self` inputs. + /// Returns an iterator of [&FunctionInputType] removing `self` and `mut self` inputs. /// - pub fn filter_self_inputs(&self) -> Vec<&FunctionInputType> { - self.inputs - .iter() - .filter(|input| !input.is_self()) - .collect::>() + pub fn filter_self_inputs(&self) -> impl Iterator { + self.inputs.iter().filter(|input| !input.is_self()) } } diff --git a/symbol-table/src/types/functions/function_input.rs b/symbol-table/src/types/functions/function_input.rs index 66a8180f98..cee5ed1df5 100644 --- a/symbol-table/src/types/functions/function_input.rs +++ b/symbol-table/src/types/functions/function_input.rs @@ -77,15 +77,6 @@ impl FunctionInputType { } } - /// - /// Returns `0` if the function input is a `self` or `mut self` keyword which does not have to - /// provided in a call to the function. - /// Returns `1` if a variable must be provided in a call to the function. - /// - pub fn count(&self) -> usize { - if self.is_self() { 0 } else { 1 } - } - /// /// Return a new `FunctionInputType` from a given `FunctionInput`. /// diff --git a/type-inference/src/objects/frame.rs b/type-inference/src/objects/frame.rs index e725bff39b..20b1c44612 100644 --- a/type-inference/src/objects/frame.rs +++ b/type-inference/src/objects/frame.rs @@ -1120,10 +1120,8 @@ impl Frame { } // Filter out `self` and `mut self` keywords. - let expected_inputs = function_type.filter_self_inputs(); - // Assert function inputs are correct types. - for (expected_input, actual_input) in expected_inputs.iter().zip(inputs) { + for (expected_input, actual_input) in function_type.filter_self_inputs().zip(inputs) { // Parse expected input type. let expected_type = expected_input.type_(); From 51049857434e52d2d52f0bec246d465607389fd7 Mon Sep 17 00:00:00 2001 From: collin Date: Mon, 7 Dec 2020 11:34:45 -0500 Subject: [PATCH 15/41] remove unused check --- type-inference/src/objects/frame.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/type-inference/src/objects/frame.rs b/type-inference/src/objects/frame.rs index 20b1c44612..52e97b803c 100644 --- a/type-inference/src/objects/frame.rs +++ b/type-inference/src/objects/frame.rs @@ -1092,8 +1092,6 @@ impl Frame { return Err(FrameError::static_call_invalid(&identifier)); } - if is_static && function_type.contains_self() {} - // Return the function type. Ok(function_type.to_owned()) } From 5d2136b5187d347242110298fba9d075f02f70ed Mon Sep 17 00:00:00 2001 From: collin Date: Mon, 7 Dec 2020 12:05:55 -0500 Subject: [PATCH 16/41] use index map in ast module --- ast/Cargo.toml | 4 ++++ ast/src/annotation.rs | 12 +++++------ ast/src/input/macros.rs | 6 +++--- ast/src/input/program_input/main_input.rs | 5 +++-- ast/src/input/program_input/registers.rs | 2 +- .../program_state/private_state/record.rs | 2 +- .../program_state/private_state/state_leaf.rs | 2 +- .../input/program_state/public_state/state.rs | 2 +- ast/src/program.rs | 21 +++++++++---------- 9 files changed, 30 insertions(+), 26 deletions(-) diff --git a/ast/Cargo.toml b/ast/Cargo.toml index eec77394f0..06c5d997ac 100644 --- a/ast/Cargo.toml +++ b/ast/Cargo.toml @@ -42,6 +42,10 @@ default-features = false version = "1.1.3" default-features = false +[dependencies.indexmap] +version = "1.6.0" +features = ["serde-1"] + [dependencies.pest] version = "2.0" diff --git a/ast/src/annotation.rs b/ast/src/annotation.rs index 2a882c1fc0..50348b7dfe 100644 --- a/ast/src/annotation.rs +++ b/ast/src/annotation.rs @@ -20,14 +20,14 @@ use leo_grammar::{ definitions::{AnnotatedDefinition, Definition}, }; -use std::collections::HashMap; +use indexmap::IndexMap; pub fn load_annotation( annotated_definition: AnnotatedDefinition, _imports: &mut Vec, - _circuits: &mut HashMap, - _functions: &mut HashMap, - tests: &mut HashMap, + _circuits: &mut IndexMap, + _functions: &mut IndexMap, + tests: &mut IndexMap, _expected: &mut Vec, ) { let ast_annotation = annotated_definition.annotation; @@ -45,7 +45,7 @@ pub fn load_annotation( } } -pub fn load_annotated_test(test: TestFunction, annotation: Annotation, tests: &mut HashMap) { +pub fn load_annotated_test(test: TestFunction, annotation: Annotation, tests: &mut IndexMap) { let name = annotation.name; let ast_arguments = annotation.arguments; @@ -57,7 +57,7 @@ pub fn load_annotated_test(test: TestFunction, annotation: Annotation, tests: &m pub fn load_annotated_test_context( mut test: TestFunction, ast_arguments: AnnotationArguments, - tests: &mut HashMap, + tests: &mut IndexMap, ) { let arguments = ast_arguments.arguments; diff --git a/ast/src/input/macros.rs b/ast/src/input/macros.rs index 16276d4e1d..75a04d8f3e 100644 --- a/ast/src/input/macros.rs +++ b/ast/src/input/macros.rs @@ -22,7 +22,7 @@ macro_rules! input_section_impl { #[derive(Clone, PartialEq, Eq, Default)] pub struct $name { is_present: bool, - values: HashMap>, + values: IndexMap>, } impl $name { @@ -63,8 +63,8 @@ macro_rules! input_section_impl { Ok(()) } - /// Returns this section's hashmap of values - pub fn values(&self) -> HashMap> { + /// Returns this section's [IndexMap] of values + pub fn values(&self) -> IndexMap> { self.values.clone() } } diff --git a/ast/src/input/program_input/main_input.rs b/ast/src/input/program_input/main_input.rs index 26f77c7400..d930a0b050 100644 --- a/ast/src/input/program_input/main_input.rs +++ b/ast/src/input/program_input/main_input.rs @@ -16,11 +16,12 @@ use crate::InputValue; use leo_input::{definitions::Definition, InputParserError}; -use std::collections::HashMap; + +use indexmap::IndexMap; #[derive(Clone, PartialEq, Eq, Default)] pub struct MainInput { - input: HashMap>, + input: IndexMap>, } #[allow(clippy::len_without_is_empty)] diff --git a/ast/src/input/program_input/registers.rs b/ast/src/input/program_input/registers.rs index e3d7217d4c..e0981602ad 100644 --- a/ast/src/input/program_input/registers.rs +++ b/ast/src/input/program_input/registers.rs @@ -17,6 +17,6 @@ use crate::{InputValue, Parameter}; use leo_input::{definitions::Definition, InputParserError}; -use std::collections::HashMap; +use indexmap::IndexMap; input_section_impl!(Registers); diff --git a/ast/src/input/program_state/private_state/record.rs b/ast/src/input/program_state/private_state/record.rs index f2e1645449..0aef9d50e1 100644 --- a/ast/src/input/program_state/private_state/record.rs +++ b/ast/src/input/program_state/private_state/record.rs @@ -17,6 +17,6 @@ use crate::{InputValue, Parameter}; use leo_input::{definitions::Definition, InputParserError}; -use std::collections::HashMap; +use indexmap::IndexMap; input_section_impl!(Record); diff --git a/ast/src/input/program_state/private_state/state_leaf.rs b/ast/src/input/program_state/private_state/state_leaf.rs index e66c51f0ab..2fd1c01d72 100644 --- a/ast/src/input/program_state/private_state/state_leaf.rs +++ b/ast/src/input/program_state/private_state/state_leaf.rs @@ -17,6 +17,6 @@ use crate::{InputValue, Parameter}; use leo_input::{definitions::Definition, InputParserError}; -use std::collections::HashMap; +use indexmap::IndexMap; input_section_impl!(StateLeaf); diff --git a/ast/src/input/program_state/public_state/state.rs b/ast/src/input/program_state/public_state/state.rs index e6afcb7d6e..04b1a37923 100644 --- a/ast/src/input/program_state/public_state/state.rs +++ b/ast/src/input/program_state/public_state/state.rs @@ -17,6 +17,6 @@ use crate::{InputValue, Parameter}; use leo_input::{definitions::Definition, InputParserError}; -use std::collections::HashMap; +use indexmap::IndexMap; input_section_impl!(State); diff --git a/ast/src/program.rs b/ast/src/program.rs index ac016363e5..4794267217 100644 --- a/ast/src/program.rs +++ b/ast/src/program.rs @@ -20,18 +20,17 @@ use crate::{load_annotation, Circuit, Function, FunctionInput, Identifier, ImportStatement, TestFunction}; use leo_grammar::{definitions::Definition, files::File}; +use indexmap::IndexMap; use serde::{Deserialize, Serialize}; -use std::collections::HashMap; - /// Stores the Leo program abstract syntax tree. #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] pub struct Program { pub name: String, pub expected_input: Vec, pub imports: Vec, - pub circuits: HashMap, - pub functions: HashMap, - pub tests: HashMap, + pub circuits: IndexMap, + pub functions: IndexMap, + pub tests: IndexMap, } const MAIN_FUNCTION_NAME: &str = "main"; @@ -40,9 +39,9 @@ impl<'ast> Program { //! Logic to convert from an abstract syntax tree (ast) representation to a Leo program. pub fn from(program_name: &str, program_ast: &File<'ast>) -> Self { let mut imports = vec![]; - let mut circuits = HashMap::new(); - let mut functions = HashMap::new(); - let mut tests = HashMap::new(); + let mut circuits = IndexMap::new(); + let mut functions = IndexMap::new(); + let mut tests = IndexMap::new(); let mut expected_input = vec![]; program_ast @@ -94,9 +93,9 @@ impl Program { name, expected_input: vec![], imports: vec![], - circuits: HashMap::new(), - functions: HashMap::new(), - tests: HashMap::new(), + circuits: IndexMap::new(), + functions: IndexMap::new(), + tests: IndexMap::new(), } } From ae6ee186ade3579db8487a2d93708b07bb916410 Mon Sep 17 00:00:00 2001 From: collin Date: Mon, 7 Dec 2020 12:10:42 -0500 Subject: [PATCH 17/41] use index map in imports module --- imports/Cargo.toml | 4 ++++ imports/src/parser/import_parser.rs | 10 ++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/imports/Cargo.toml b/imports/Cargo.toml index 3a4bd13771..909269250f 100644 --- a/imports/Cargo.toml +++ b/imports/Cargo.toml @@ -25,6 +25,10 @@ version = "1.0.6" path = "../grammar" version = "1.0.6" +[dependencies.indexmap] +version = "1.6.0" +features = ["serde-1"] + [dependencies.thiserror] version = "1.0" diff --git a/imports/src/parser/import_parser.rs b/imports/src/parser/import_parser.rs index 2466448ec9..3b4dc2fe7b 100644 --- a/imports/src/parser/import_parser.rs +++ b/imports/src/parser/import_parser.rs @@ -17,10 +17,8 @@ use crate::errors::ImportParserError; use leo_ast::{Package, Program}; -use std::{ - collections::{HashMap, HashSet}, - env::current_dir, -}; +use indexmap::{IndexMap, IndexSet}; +use std::env::current_dir; /// Stores imported packages. /// @@ -28,8 +26,8 @@ use std::{ /// directory, foreign in the imports directory, or part of the core package list. #[derive(Clone, Default)] pub struct ImportParser { - imports: HashMap, - core_packages: HashSet, + imports: IndexMap, + core_packages: IndexSet, } impl ImportParser { From bcaf7d3e666dc45c49611faa0f27afef116bc099 Mon Sep 17 00:00:00 2001 From: collin Date: Mon, 7 Dec 2020 12:12:31 -0500 Subject: [PATCH 18/41] use index map in state module --- state/Cargo.toml | 4 ++++ state/src/utilities/input_value.rs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/state/Cargo.toml b/state/Cargo.toml index e2a3f143ea..5e08e52011 100644 --- a/state/Cargo.toml +++ b/state/Cargo.toml @@ -52,6 +52,10 @@ default-features = false [dependencies.snarkos-utilities] version = "1.1.3" +[dependencies.indexmap] +version = "1.6.0" +features = ["serde-1"] + [dependencies.rand] version = "0.7" diff --git a/state/src/utilities/input_value.rs b/state/src/utilities/input_value.rs index 63da26329d..a6ad950ce8 100644 --- a/state/src/utilities/input_value.rs +++ b/state/src/utilities/input_value.rs @@ -17,13 +17,13 @@ use crate::InputValueError; use leo_ast::{InputValue, Parameter}; -use std::collections::HashMap; +use indexmap::IndexMap; /// Returns the input parameter with the given name. /// If a parameter with the given name does not exist, then an error is returned. pub fn find_input( name: String, - parameters: &HashMap>, + parameters: &IndexMap>, ) -> Result { let matched_parameter = parameters .iter() From 6797a1e046f518c8dd7269daf54e546f64b5ea3c Mon Sep 17 00:00:00 2001 From: collin Date: Mon, 7 Dec 2020 12:15:32 -0500 Subject: [PATCH 19/41] use index map in symbol-table module --- symbol-table/Cargo.toml | 4 ++++ symbol-table/src/symbol_table.rs | 21 ++++++++++++--------- symbol-table/src/types/circuits/circuit.rs | 9 ++++----- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/symbol-table/Cargo.toml b/symbol-table/Cargo.toml index 809f0de36f..aa9f5e1a50 100644 --- a/symbol-table/Cargo.toml +++ b/symbol-table/Cargo.toml @@ -33,6 +33,10 @@ version = "1.0.6" path = "../imports" version = "1.0.6" +[dependencies.indexmap] +version = "1.6.0" +features = ["serde-1"] + [dependencies.serde] version = "1.0" diff --git a/symbol-table/src/symbol_table.rs b/symbol-table/src/symbol_table.rs index 0e5a56b121..9c58914ada 100644 --- a/symbol-table/src/symbol_table.rs +++ b/symbol-table/src/symbol_table.rs @@ -19,7 +19,7 @@ use leo_ast::{Circuit, Function, Identifier, ImportStatement, ImportSymbol, Inpu use leo_core::CorePackageList; use leo_imports::ImportParser; -use std::collections::{HashMap, HashSet}; +use indexmap::{IndexMap, IndexSet}; pub const INPUT_VARIABLE_NAME: &str = "input"; pub const RECORD_VARIABLE_NAME: &str = "record"; @@ -35,13 +35,13 @@ pub const STATE_LEAF_VARIABLE_NAME: &str = "state_leaf"; #[derive(Clone, Default)] pub struct SymbolTable { /// Maps name -> parameter type. - names: HashMap, + names: IndexMap, /// Maps circuit name -> circuit type. - circuits: HashMap, + circuits: IndexMap, /// Maps function name -> function type. - functions: HashMap, + functions: IndexMap, /// The parent of this symbol table. parent: Option>, @@ -214,7 +214,7 @@ impl SymbolTable { /// If a circuit name has no duplicates, then it is inserted into the symbol table. /// Types defined later in the program cannot have the same name. /// - pub fn check_circuit_names(&mut self, circuits: &HashMap) -> Result<(), SymbolTableError> { + pub fn check_circuit_names(&mut self, circuits: &IndexMap) -> Result<(), SymbolTableError> { // Iterate over circuit names and definitions. for (identifier, circuit) in circuits.iter() { // Attempt to insert the circuit name into the symbol table. @@ -230,7 +230,7 @@ impl SymbolTable { /// If a function name has no duplicates, then it is inserted into the symbol table. /// Types defined later in the program cannot have the same name. /// - pub fn check_function_names(&mut self, functions: &HashMap) -> Result<(), SymbolTableError> { + pub fn check_function_names(&mut self, functions: &IndexMap) -> Result<(), SymbolTableError> { // Iterate over function names and definitions. for (identifier, function) in functions.iter() { // Attempt to insert the function name into the symbol table. @@ -326,7 +326,7 @@ impl SymbolTable { // Import all symbols from an imported file for now. // Keep track of which import files have already been checked. - let mut checked = HashSet::new(); + let mut checked = IndexSet::new(); // Iterate over each imported symbol. for (name, symbol) in imported_symbols.symbols { @@ -416,7 +416,7 @@ impl SymbolTable { /// symbol table. Variables defined later in the program can lookup the definition /// and refer to its expected types /// - pub fn check_types_circuits(&mut self, circuits: &HashMap) -> Result<(), SymbolTableError> { + pub fn check_types_circuits(&mut self, circuits: &IndexMap) -> Result<(), SymbolTableError> { // Iterate over circuit names and definitions. for circuit in circuits.values() { // Get the identifier of the circuit. @@ -439,7 +439,10 @@ impl SymbolTable { /// symbol table. Variables defined later in the program can lookup the definition /// and refer to its expected types /// - pub fn check_types_functions(&mut self, functions: &HashMap) -> Result<(), SymbolTableError> { + pub fn check_types_functions( + &mut self, + functions: &IndexMap, + ) -> Result<(), SymbolTableError> { // Iterate over function names and definitions. for function in functions.values() { // Get the identifier of the function. diff --git a/symbol-table/src/types/circuits/circuit.rs b/symbol-table/src/types/circuits/circuit.rs index 2e6ea923f0..688f35f4c0 100644 --- a/symbol-table/src/types/circuits/circuit.rs +++ b/symbol-table/src/types/circuits/circuit.rs @@ -25,10 +25,9 @@ use crate::{ use leo_ast::{Circuit, CircuitMember, Identifier, InputValue, Parameter, Span}; use serde::{Deserialize, Serialize}; -use std::{ - collections::HashMap, - hash::{Hash, Hasher}, -}; +use std::hash::{Hash, Hasher}; + +use indexmap::IndexMap; /// Stores circuit definition details. /// @@ -152,7 +151,7 @@ impl CircuitType { pub fn from_input_section( table: &SymbolTable, name: String, - section: HashMap>, + section: IndexMap>, ) -> Result { // Create a new `CircuitVariableType` for each section pair. let mut variables = Vec::new(); From 05effde9b4d31106dc6a3a3e3605c96b97612c63 Mon Sep 17 00:00:00 2001 From: collin Date: Mon, 7 Dec 2020 12:17:26 -0500 Subject: [PATCH 20/41] use index map in type-inference module --- type-inference/Cargo.toml | 4 ++++ type-inference/src/objects/variable_table.rs | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/type-inference/Cargo.toml b/type-inference/Cargo.toml index 4728d0e3d9..2841ba3f58 100644 --- a/type-inference/Cargo.toml +++ b/type-inference/Cargo.toml @@ -33,6 +33,10 @@ version = "1.0.6" path = "../symbol-table" version = "1.0.6" +[dependencies.indexmap] +version = "1.6.0" +features = ["serde-1"] + [dependencies.serde_json] version = "1.0" diff --git a/type-inference/src/objects/variable_table.rs b/type-inference/src/objects/variable_table.rs index c48dcff583..9d15007cf3 100644 --- a/type-inference/src/objects/variable_table.rs +++ b/type-inference/src/objects/variable_table.rs @@ -16,11 +16,12 @@ use crate::VariableTableError; use leo_symbol_table::{FunctionInputType, Type}; -use std::collections::HashMap; + +use indexmap::IndexMap; /// Mapping of variable names to types #[derive(Clone)] -pub struct VariableTable(pub HashMap); +pub struct VariableTable(pub IndexMap); impl VariableTable { /// @@ -67,6 +68,6 @@ impl VariableTable { impl Default for VariableTable { fn default() -> Self { - Self(HashMap::new()) + Self(IndexMap::new()) } } From 1dbdf23d5a8cfbe98fed9d1681c20af93a83612d Mon Sep 17 00:00:00 2001 From: collin Date: Mon, 7 Dec 2020 12:18:20 -0500 Subject: [PATCH 21/41] use index map in compiler module --- Cargo.lock | 7 +++++++ compiler/Cargo.toml | 4 ++++ compiler/src/function/input/input_section.rs | 7 ++++--- compiler/src/program/program.rs | 6 +++--- symbol-table/src/types/circuits/circuit.rs | 3 +-- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d04a8d65f7..7a4b8c47b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1153,6 +1153,7 @@ checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" dependencies = [ "autocfg", "hashbrown", + "serde", ] [[package]] @@ -1299,6 +1300,7 @@ name = "leo-ast" version = "1.0.6" dependencies = [ "criterion", + "indexmap", "leo-grammar", "leo-input", "pest", @@ -1314,6 +1316,7 @@ version = "1.0.6" dependencies = [ "bincode", "hex", + "indexmap", "leo-ast", "leo-core", "leo-gadgets", @@ -1392,6 +1395,7 @@ dependencies = [ name = "leo-imports" version = "1.0.6" dependencies = [ + "indexmap", "leo-ast", "leo-grammar", "thiserror", @@ -1478,6 +1482,7 @@ dependencies = [ name = "leo-state" version = "1.0.6" dependencies = [ + "indexmap", "leo-ast", "leo-input", "rand", @@ -1497,6 +1502,7 @@ dependencies = [ name = "leo-symbol-table" version = "1.0.6" dependencies = [ + "indexmap", "leo-ast", "leo-core", "leo-grammar", @@ -1509,6 +1515,7 @@ dependencies = [ name = "leo-type-inference" version = "1.0.6" dependencies = [ + "indexmap", "leo-ast", "leo-grammar", "leo-imports", diff --git a/compiler/Cargo.toml b/compiler/Cargo.toml index cbf0636741..fe242bf7d0 100644 --- a/compiler/Cargo.toml +++ b/compiler/Cargo.toml @@ -90,6 +90,10 @@ version = "1.0" [dependencies.hex] version = "0.4.2" +[dependencies.indexmap] +version = "1.6.0" +features = ["serde-1"] + [dependencies.pest] version = "2.0" diff --git a/compiler/src/function/input/input_section.rs b/compiler/src/function/input/input_section.rs index 88b3e77da6..c33bc39636 100644 --- a/compiler/src/function/input/input_section.rs +++ b/compiler/src/function/input/input_section.rs @@ -15,20 +15,21 @@ // along with the Leo library. If not, see . use crate::{errors::FunctionError, ConstrainedCircuitMember, ConstrainedProgram, ConstrainedValue, GroupType}; - use leo_ast::{Identifier, InputValue, Parameter}; + use snarkos_models::{ curves::{Field, PrimeField}, gadgets::r1cs::ConstraintSystem, }; -use std::collections::HashMap; + +use indexmap::IndexMap; impl> ConstrainedProgram { pub fn allocate_input_section>( &mut self, cs: &mut CS, identifier: Identifier, - section: HashMap>, + section: IndexMap>, ) -> Result, FunctionError> { let mut members = Vec::with_capacity(section.len()); diff --git a/compiler/src/program/program.rs b/compiler/src/program/program.rs index 596c59b23e..75f36f4677 100644 --- a/compiler/src/program/program.rs +++ b/compiler/src/program/program.rs @@ -20,16 +20,16 @@ use crate::{value::ConstrainedValue, GroupType}; use snarkos_models::curves::{Field, PrimeField}; -use std::collections::HashMap; +use indexmap::IndexMap; pub struct ConstrainedProgram> { - pub identifiers: HashMap>, + pub identifiers: IndexMap>, } impl> Default for ConstrainedProgram { fn default() -> Self { Self { - identifiers: HashMap::new(), + identifiers: IndexMap::new(), } } } diff --git a/symbol-table/src/types/circuits/circuit.rs b/symbol-table/src/types/circuits/circuit.rs index 688f35f4c0..53ca088aad 100644 --- a/symbol-table/src/types/circuits/circuit.rs +++ b/symbol-table/src/types/circuits/circuit.rs @@ -24,11 +24,10 @@ use crate::{ }; use leo_ast::{Circuit, CircuitMember, Identifier, InputValue, Parameter, Span}; +use indexmap::IndexMap; use serde::{Deserialize, Serialize}; use std::hash::{Hash, Hasher}; -use indexmap::IndexMap; - /// Stores circuit definition details. /// /// This type should be added to the circuit symbol table for a resolved syntax tree. From 64f2a6586ee8364853e1f1ac23fc7b140035d152 Mon Sep 17 00:00:00 2001 From: collin Date: Mon, 7 Dec 2020 15:49:06 -0500 Subject: [PATCH 22/41] use filter_self_inputs in num_inputs method --- symbol-table/src/types/functions/function.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/symbol-table/src/types/functions/function.rs b/symbol-table/src/types/functions/function.rs index 3c84176fdc..05fc6c43fb 100644 --- a/symbol-table/src/types/functions/function.rs +++ b/symbol-table/src/types/functions/function.rs @@ -120,18 +120,6 @@ impl FunctionType { Ok(()) } - /// - /// Returns the number of input variables to the function. - /// The `self` and `mut self` keywords are not counted as input variables. - /// - pub fn num_inputs(&self) -> usize { - self.inputs - .iter() - .filter(|function_input| !function_input.is_self()) - .count() - // .fold(0, |acc, function_input| acc + function_input.arguments()) - } - /// /// Returns `true` if the input `self` or `mut self` is present. /// Returns `false` otherwise. @@ -146,6 +134,14 @@ impl FunctionType { pub fn filter_self_inputs(&self) -> impl Iterator { self.inputs.iter().filter(|input| !input.is_self()) } + + /// + /// Returns the number of input variables to the function. + /// The `self` and `mut self` keywords are not counted as input variables. + /// + pub fn num_inputs(&self) -> usize { + self.filter_self_inputs().count() + } } impl PartialEq for FunctionType { From 2ef3a820a7aa3fd7fd121a2aa39ee81b0550e4cd Mon Sep 17 00:00:00 2001 From: collin Date: Mon, 7 Dec 2020 15:55:46 -0500 Subject: [PATCH 23/41] cargo +nightly clippy --- state/src/utilities/input_value.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/state/src/utilities/input_value.rs b/state/src/utilities/input_value.rs index 63da26329d..70dff7d22f 100644 --- a/state/src/utilities/input_value.rs +++ b/state/src/utilities/input_value.rs @@ -30,11 +30,8 @@ pub fn find_input( .find(|(parameter, _value)| parameter.variable.name == name); match matched_parameter { - Some((_parameter, value_option)) => match value_option { - Some(value) => Ok(value.clone()), - None => Err(InputValueError::MissingParameter(name)), - }, - None => Err(InputValueError::MissingParameter(name)), + Some((_parameter, Some(value))) => Ok(value.clone()), + _ => Err(InputValueError::MissingParameter(name)), } } From b7e5cd13df992d5884dcad2ad08e4b2699a3ba3a Mon Sep 17 00:00:00 2001 From: collin Date: Tue, 8 Dec 2020 10:47:07 -0500 Subject: [PATCH 24/41] fix failing test --- compiler/tests/circuits/member_static_function_invalid.leo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/tests/circuits/member_static_function_invalid.leo b/compiler/tests/circuits/member_static_function_invalid.leo index 513d78b67d..09fec386d9 100644 --- a/compiler/tests/circuits/member_static_function_invalid.leo +++ b/compiler/tests/circuits/member_static_function_invalid.leo @@ -5,5 +5,5 @@ circuit Foo { } function main() { - let err = Foo::echo(1u32); // Correct, echo is a static function and must be accessed using `::` + let err = Foo.echo(1u32); // Invalid, echo is a static function and must be accessed using `::` } \ No newline at end of file From 8541eb3fb8199ec883472c779c1de8249e41a721 Mon Sep 17 00:00:00 2001 From: Collin Chin Date: Tue, 8 Dec 2020 12:21:18 -0500 Subject: [PATCH 25/41] Update mod.rs --- compiler/tests/function/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/tests/function/mod.rs b/compiler/tests/function/mod.rs index 03a8b239d9..652964fafb 100644 --- a/compiler/tests/function/mod.rs +++ b/compiler/tests/function/mod.rs @@ -63,7 +63,7 @@ fn test_newlines() { #[test] fn test_multiple_returns() { - let program_string = include_str!("multiple.leo"); + let program_string = include_str!("multiple_returns.leo"); let program = parse_program(program_string).unwrap(); assert_satisfied(program); @@ -71,23 +71,23 @@ fn test_multiple_returns() { #[test] fn test_multiple_returns_fail() { - let bytes = include_bytes!("multiple_returns_fail.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("multiple_returns_fail.leo"); + let program = parse_program(program_string).unwrap(); expect_compiler_error(program); } #[test] fn test_multiple_returns_fail_conditional() { - let bytes = include_bytes!("multiple_returns_fail_conditional.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("multiple_returns_fail_conditional.leo"); + let program = parse_program(program_string).unwrap(); expect_compiler_error(program); } #[test] fn test_multiple_returns_main() { - let program_string = include_str!("multiple_main.leo"); + let program_string = include_str!("multiple_returns_main.leo"); let input_string = include_str!("input/registers.in"); let program = parse_program_with_input(program_string, input_string).unwrap(); From 5222fcfe93dcf0d4285393eeeedd198392668d0b Mon Sep 17 00:00:00 2001 From: collin Date: Tue, 8 Dec 2020 13:02:13 -0500 Subject: [PATCH 26/41] cargo update --- Cargo.lock | 238 +++++++++++++++++++++++------------------------------ 1 file changed, 105 insertions(+), 133 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3e4bb95f50..071601c2fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.54" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2baad346b2d4e94a24347adeee9c7a93f412ee94b9cc26e5b59dea23848e9f28" +checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598" dependencies = [ "addr2line", "cfg-if 1.0.0", @@ -107,12 +107,6 @@ dependencies = [ "safemem", ] -[[package]] -name = "base64" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" - [[package]] name = "base64" version = "0.13.0" @@ -296,9 +290,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.62" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1770ced377336a88a67c473594ccc14eca6f4559217c34f64aac8f83d641b40" +checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" dependencies = [ "jobserver", ] @@ -373,15 +367,6 @@ dependencies = [ "vec_map", ] -[[package]] -name = "cloudabi" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4344512281c643ae7638bbabc3af17a11307803ec8f0fcad9fae512a8bf36467" -dependencies = [ - "bitflags", -] - [[package]] name = "colored" version = "2.0.0" @@ -505,7 +490,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.0", + "crossbeam-utils", ] [[package]] @@ -516,18 +501,18 @@ checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" dependencies = [ "cfg-if 1.0.0", "crossbeam-epoch", - "crossbeam-utils 0.8.0", + "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f" +checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" dependencies = [ "cfg-if 1.0.0", "const_fn", - "crossbeam-utils 0.8.0", + "crossbeam-utils", "lazy_static", "memoffset", "scopeguard", @@ -535,24 +520,12 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.7.2" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -dependencies = [ - "autocfg", - "cfg-if 0.1.10", - "lazy_static", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec91540d98355f690a86367e566ecad2e9e579f230230eb7c21398372be73ea5" +checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d" dependencies = [ "autocfg", "cfg-if 1.0.0", - "const_fn", "lazy_static", ] @@ -568,9 +541,9 @@ dependencies = [ [[package]] name = "csv" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4666154fd004af3fd6f1da2e81a96fd5a81927fe8ddb6ecc79e2aa6e138b54" +checksum = "f9d58633299b24b515ac72a3f869f8b91306a3cec616a602843a383acd6f9e97" dependencies = [ "bstr", "csv-core", @@ -626,7 +599,7 @@ checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", ] [[package]] @@ -748,7 +721,7 @@ checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", "synstructure", ] @@ -916,7 +889,7 @@ dependencies = [ "futures-io", "futures-task", "memchr", - "pin-project 1.0.1", + "pin-project 1.0.2", "pin-utils", "slab", ] @@ -1096,7 +1069,7 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project 1.0.1", + "pin-project 1.0.2", "socket2", "tokio", "tower-service", @@ -1189,9 +1162,9 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb1fc4429a33e1f80d41dc9fea4d108a88bec1de8053878898ae448a0b52f613" +checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" dependencies = [ "cfg-if 1.0.0", ] @@ -1246,9 +1219,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.45" +version = "0.3.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca059e81d9486668f12d455a4ea6daa600bd408134cd17e3d3fb5a32d1f016f8" +checksum = "cf3d7383929f7c9c7c2d0fa596f325832df98c3704f2c60553080f7127a58175" dependencies = [ "wasm-bindgen", ] @@ -1520,9 +1493,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.80" +version = "0.2.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" +checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" [[package]] name = "libloading" @@ -1560,9 +1533,9 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28247cc5a5be2f05fbcd76dd0cf2c7d3b5400cb978a28042abcd4fa0b3f8261c" +checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" dependencies = [ "scopeguard", ] @@ -1618,9 +1591,9 @@ checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" [[package]] name = "memoffset" -version = "0.5.6" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" dependencies = [ "autocfg", ] @@ -1662,9 +1635,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.6.22" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" dependencies = [ "cfg-if 0.1.10", "fuchsia-zircon", @@ -1693,9 +1666,9 @@ dependencies = [ [[package]] name = "miow" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" dependencies = [ "kernel32-sys", "net2", @@ -1723,9 +1696,9 @@ dependencies = [ [[package]] name = "net2" -version = "0.2.35" +version = "0.2.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853" +checksum = "d7cf75f38f16cb05ea017784dc6dbfd354f76c223dba37701734c4f5a9337d02" dependencies = [ "cfg-if 0.1.10", "libc", @@ -1820,15 +1793,15 @@ checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" [[package]] name = "once_cell" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f53cef67919d7d247eb9a2f128ca9e522789967ef1eb4ccd8c71a95a8aedf596" +checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" [[package]] name = "oorandom" -version = "11.1.2" +version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a170cebd8021a008ea92e4db85a72f80b35df514ec664b296fdcbb654eac0b2c" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "opaque-debug" @@ -1877,9 +1850,9 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4893845fa2ca272e647da5d0e46660a314ead9c2fdd9a883aabc32e481a8733" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" dependencies = [ "instant", "lock_api", @@ -1888,12 +1861,11 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b" +checksum = "d7c6d9b8427445284a09c55be860a15855ab580a417ccad9da88f5a06787ced0" dependencies = [ - "cfg-if 0.1.10", - "cloudabi", + "cfg-if 1.0.0", "instant", "libc", "redox_syscall", @@ -1961,7 +1933,7 @@ dependencies = [ "pest_meta", "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", ] [[package]] @@ -1986,11 +1958,11 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee41d838744f60d959d7074e3afb6b35c7456d0f61cad38a24e35e6553f73841" +checksum = "9ccc2237c2c489783abd8c4c80e5450fc0e98644555b1364da68cc29aa151ca7" dependencies = [ - "pin-project-internal 1.0.1", + "pin-project-internal 1.0.2", ] [[package]] @@ -2001,18 +1973,18 @@ checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", ] [[package]] name = "pin-project-internal" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81a4ffa594b66bff340084d4081df649a7dc049ac8d7fc458d8e628bfbbb2f86" +checksum = "f8e8d2bf0b23038a4424865103a4df472855692821aab4e4f5c3312d461d9e5f" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", ] [[package]] @@ -2178,7 +2150,7 @@ checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" dependencies = [ "crossbeam-channel", "crossbeam-deque", - "crossbeam-utils 0.8.0", + "crossbeam-utils", "lazy_static", "num_cpus", ] @@ -2286,14 +2258,14 @@ dependencies = [ [[package]] name = "rust-argon2" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dab61250775933275e84053ac235621dfb739556d5c54a2f2e9313b7cf43a19" +checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" dependencies = [ - "base64 0.12.3", + "base64 0.13.0", "blake2b_simd", "constant_time_eq", - "crossbeam-utils 0.7.2", + "crossbeam-utils", ] [[package]] @@ -2448,9 +2420,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.117" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" +checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" dependencies = [ "serde_derive", ] @@ -2467,13 +2439,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.117" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" +checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", ] [[package]] @@ -2557,9 +2529,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] name = "smallvec" -version = "1.4.2" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" +checksum = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75" [[package]] name = "snarkos-algorithms" @@ -2606,7 +2578,7 @@ checksum = "a8f6ce35f9f73c13e5381c6938747935ca105e22717998489c3e5ddb8c13120d" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", ] [[package]] @@ -2757,11 +2729,11 @@ dependencies = [ [[package]] name = "socket2" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fd8b795c389288baa5f355489c65e71fd48a02104600d15c4cfbc561e9e429d" +checksum = "2c29947abdee2a218277abeca306f25789c938e500ea5a9d4b12a5a504466902" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", "redox_syscall", "winapi 0.3.9", @@ -2792,9 +2764,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.48" +version = "1.0.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" +checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", @@ -2809,7 +2781,7 @@ checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", "unicode-xid 0.2.1", ] @@ -2829,18 +2801,18 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" dependencies = [ "winapi-util", ] [[package]] name = "terminal_size" -version = "0.1.13" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a14cd9f8c72704232f0bfc8455c0e861f0ad4eb60cc9ec8a170e231414c1e13" +checksum = "4bd2d183bd3fac5f5fe38ddbeb4dc9aec4a39a9d7d59e7491d900302da01cbe1" dependencies = [ "libc", "winapi 0.3.9", @@ -2872,7 +2844,7 @@ checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", ] [[package]] @@ -2907,9 +2879,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b78a366903f506d2ad52ca8dc552102ffdd3e937ba8a227f024dc1d1eae28575" +checksum = "ccf8dbc19eb42fba10e8feaaec282fb50e2c14b2726d6301dbfeed0f73306a6f" dependencies = [ "tinyvec_macros", ] @@ -2922,9 +2894,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "0.2.22" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" +checksum = "a6d7ad61edd59bfcc7e80dababf0f4aed2e6d5e0ba1659356ae889752dfc12ff" dependencies = [ "bytes 0.5.6", "fnv", @@ -2998,7 +2970,7 @@ checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", ] [[package]] @@ -3101,9 +3073,9 @@ dependencies = [ [[package]] name = "unicode-normalization" -version = "0.1.14" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f98e67a4d84f730d343392f9bfff7d21e3fca562b9cb7a43b768350beeddc6" +checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606" dependencies = [ "tinyvec", ] @@ -3197,11 +3169,11 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] name = "wasm-bindgen" -version = "0.2.68" +version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42" +checksum = "3cd364751395ca0f68cafb17666eee36b63077fb5ecd972bbcd74c90c4bf736e" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "serde", "serde_json", "wasm-bindgen-macro", @@ -3209,26 +3181,26 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.68" +version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f22b422e2a757c35a73774860af8e112bff612ce6cb604224e8e47641a9e4f68" +checksum = "1114f89ab1f4106e5b55e688b828c0ab0ea593a1ea7c094b141b14cbaaec2d62" dependencies = [ "bumpalo", "lazy_static", "log", "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.18" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7866cab0aa01de1edf8b5d7936938a7e397ee50ce24119aef3e1eaa3b6171da" +checksum = "1fe9756085a84584ee9457a002b7cdfe0bfff169f45d2591d8be1345a6780e35" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "js-sys", "wasm-bindgen", "web-sys", @@ -3236,9 +3208,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.68" +version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b13312a745c08c469f0b292dd2fcd6411dba5f7160f593da6ef69b64e407038" +checksum = "7a6ac8995ead1f084a8dea1e65f194d0973800c7f571f6edd70adf06ecf77084" dependencies = [ "quote 1.0.7", "wasm-bindgen-macro-support", @@ -3246,28 +3218,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.68" +version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f249f06ef7ee334cc3b8ff031bfc11ec99d00f34d86da7498396dc1e3b1498fe" +checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.68" +version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307" +checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" [[package]] name = "wasm-bindgen-test" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34d1cdc8b98a557f24733d50a1199c4b0635e465eecba9c45b214544da197f64" +checksum = "0355fa0c1f9b792a09b6dcb6a8be24d51e71e6d74972f9eb4a44c4c004d24a25" dependencies = [ "console_error_panic_hook", "js-sys", @@ -3279,9 +3251,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8fb9c67be7439ee8ab1b7db502a49c05e51e2835b66796c705134d9b8e1a585" +checksum = "27e07b46b98024c2ba2f9e83a10c2ef0515f057f2da299c1762a2017de80438b" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", @@ -3289,9 +3261,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.45" +version = "0.3.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bf6ef87ad7ae8008e15a355ce696bed26012b7caa21605188cfd8214ab51e2d" +checksum = "222b1ef9334f92a21d3fb53dc3fd80f30836959a90f9274a626d7e06315ba3c3" dependencies = [ "js-sys", "wasm-bindgen", @@ -3370,9 +3342,9 @@ dependencies = [ [[package]] name = "zip" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "543adf038106b64cfca4711c82c917d785e3540e04f7996554488f988ec43124" +checksum = "cc2896475a242c41366941faa27264df2cb935185a92e059a004d0048feb2ac5" dependencies = [ "byteorder", "bzip2", From 8a44eff4a5e69513bd3fa2d50d99f332a4ee4ecb Mon Sep 17 00:00:00 2001 From: collin Date: Tue, 8 Dec 2020 16:00:12 -0500 Subject: [PATCH 27/41] fix nested mutable assignee bug, add swap test --- compiler/src/statement/assign/assignee.rs | 8 +++++++- compiler/tests/mutability/mod.rs | 8 ++++++++ compiler/tests/mutability/swap.leo | 20 ++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 compiler/tests/mutability/swap.leo diff --git a/compiler/src/statement/assign/assignee.rs b/compiler/src/statement/assign/assignee.rs index 3a0fe2641c..2bb37db9b8 100644 --- a/compiler/src/statement/assign/assignee.rs +++ b/compiler/src/statement/assign/assignee.rs @@ -34,7 +34,13 @@ impl> ConstrainedProgram { // Check that assignee exists and is mutable Ok(match self.get_mut(name) { Some(value) => match value { - ConstrainedValue::Mutable(mutable_value) => mutable_value, + ConstrainedValue::Mutable(mutable_value) => { + // Get the mutable value. + mutable_value.get_inner_mut(); + + // Return the mutable value. + mutable_value + } _ => return Err(StatementError::immutable_assign(name.to_owned(), span.to_owned())), }, None => return Err(StatementError::undefined_variable(name.to_owned(), span.to_owned())), diff --git a/compiler/tests/mutability/mod.rs b/compiler/tests/mutability/mod.rs index 8016bb5412..85d7b1fe8c 100644 --- a/compiler/tests/mutability/mod.rs +++ b/compiler/tests/mutability/mod.rs @@ -136,3 +136,11 @@ fn test_function_input_mut() { assert_satisfied(program); } + +#[test] +fn test_swap() { + let bytes = include_bytes!("swap.leo"); + let program = parse_program(bytes).unwrap(); + + assert_satisfied(program); +} diff --git a/compiler/tests/mutability/swap.leo b/compiler/tests/mutability/swap.leo new file mode 100644 index 0000000000..8234a3cfb7 --- /dev/null +++ b/compiler/tests/mutability/swap.leo @@ -0,0 +1,20 @@ +// Swap two elements of an array. +function swap(mut a: [u32; 2], i: u32, j: u32) -> [u32; 2] { + let t = a[i]; + a[i] = a[j]; + a[j] = t; + return a +} + +function main() { + let mut arr: [u32; 2] = [0, 1]; + let expected: [u32; 2] = [1, 0]; + + // Do swap. + let actual = swap(arr, 0, 1); + + // Check result. + for i in 0..2 { + console.assert(expected[i] == actual[i]); + } +} \ No newline at end of file From 31d065154aa0484fcdca0f5fd6b768238e0373bc Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 8 Dec 2020 22:05:22 +0000 Subject: [PATCH 28/41] Bump serde from 1.0.117 to 1.0.118 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.117 to 1.0.118. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.117...v1.0.118) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bab77ee4e2..fe0b8bf847 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2455,9 +2455,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.117" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" +checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" dependencies = [ "serde_derive", ] @@ -2474,9 +2474,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.117" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" +checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", From 7976650f1ef7e107685c6a75177d7a4572a2b6c3 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 9 Dec 2020 20:50:31 +0000 Subject: [PATCH 29/41] Bump zip from 0.5.8 to 0.5.9 Bumps [zip](https://github.com/mvdnes/zip-rs) from 0.5.8 to 0.5.9. - [Release notes](https://github.com/mvdnes/zip-rs/releases) - [Commits](https://github.com/mvdnes/zip-rs/compare/v0.5.8...v0.5.9) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bab77ee4e2..d6353a1e20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3377,9 +3377,9 @@ dependencies = [ [[package]] name = "zip" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "543adf038106b64cfca4711c82c917d785e3540e04f7996554488f988ec43124" +checksum = "cc2896475a242c41366941faa27264df2cb935185a92e059a004d0048feb2ac5" dependencies = [ "byteorder", "bzip2", From 79b42c168cd4bfbf69a76b6323f83a8cd5fe3f3a Mon Sep 17 00:00:00 2001 From: collin Date: Wed, 9 Dec 2020 17:00:06 -0500 Subject: [PATCH 30/41] update package name pest --- grammar/src/leo.pest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grammar/src/leo.pest b/grammar/src/leo.pest index 3fccb668eb..1addfba8ca 100644 --- a/grammar/src/leo.pest +++ b/grammar/src/leo.pest @@ -443,8 +443,8 @@ input_tuple = _{ "(" ~ NEWLINE* ~ (input ~ ("," ~ NEWLINE* ~ input)* ~ ","?)? ~ // Declared in imports/import.rs import = { "import " ~ package ~ LINE_END} - -package_name = @{ ((ASCII_ALPHA_LOWER | ASCII_DIGIT) ~ ( "-" ~ (ASCII_ALPHA_LOWER | ASCII_DIGIT))*)+ } +// Declared in imports/package_name.rs +package_name = @{ (ASCII_ALPHA_LOWER | ASCII_DIGIT)+ ~ ( "-" ~ (ASCII_ALPHA_LOWER | ASCII_DIGIT)+)* } // Declared in imports/package.rs package = { package_name ~ "." ~ package_access } From 40c816f921f6213a0192138a00939a1e6f372647 Mon Sep 17 00:00:00 2001 From: collin Date: Wed, 9 Dec 2020 17:08:22 -0500 Subject: [PATCH 31/41] update swap test --- compiler/tests/mutability/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/tests/mutability/mod.rs b/compiler/tests/mutability/mod.rs index 3a72173746..9c0dc5d122 100644 --- a/compiler/tests/mutability/mod.rs +++ b/compiler/tests/mutability/mod.rs @@ -139,8 +139,8 @@ fn test_function_input_mut() { #[test] fn test_swap() { - let bytes = include_bytes!("swap.leo"); - let program = parse_program(bytes).unwrap(); + let program_string = include_str!("swap.leo"); + let program = parse_program(program_string).unwrap(); assert_satisfied(program); } From e2406bec868ae1acb9d0d5fefb38819fc67d6a55 Mon Sep 17 00:00:00 2001 From: collin Date: Wed, 9 Dec 2020 17:42:15 -0500 Subject: [PATCH 32/41] fix lower array slice bug --- Cargo.lock | 238 ++++++++++++--------------- compiler/tests/array/mod.rs | 8 + compiler/tests/array/slice_lower.leo | 8 + grammar/src/common/range.rs | 5 + grammar/src/leo.pest | 3 +- 5 files changed, 128 insertions(+), 134 deletions(-) create mode 100644 compiler/tests/array/slice_lower.leo diff --git a/Cargo.lock b/Cargo.lock index 9dbcb1de6d..c936e0015c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.54" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2baad346b2d4e94a24347adeee9c7a93f412ee94b9cc26e5b59dea23848e9f28" +checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598" dependencies = [ "addr2line", "cfg-if 1.0.0", @@ -107,12 +107,6 @@ dependencies = [ "safemem", ] -[[package]] -name = "base64" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" - [[package]] name = "base64" version = "0.13.0" @@ -296,9 +290,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.62" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1770ced377336a88a67c473594ccc14eca6f4559217c34f64aac8f83d641b40" +checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" dependencies = [ "jobserver", ] @@ -373,15 +367,6 @@ dependencies = [ "vec_map", ] -[[package]] -name = "cloudabi" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4344512281c643ae7638bbabc3af17a11307803ec8f0fcad9fae512a8bf36467" -dependencies = [ - "bitflags", -] - [[package]] name = "colored" version = "2.0.0" @@ -421,9 +406,9 @@ dependencies = [ [[package]] name = "const_fn" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" +checksum = "cd51eab21ab4fd6a3bf889e2d0958c0a6e3a61ad04260325e919e652a2a62826" [[package]] name = "constant_time_eq" @@ -505,7 +490,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.0", + "crossbeam-utils", ] [[package]] @@ -516,18 +501,18 @@ checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" dependencies = [ "cfg-if 1.0.0", "crossbeam-epoch", - "crossbeam-utils 0.8.0", + "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f" +checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" dependencies = [ "cfg-if 1.0.0", "const_fn", - "crossbeam-utils 0.8.0", + "crossbeam-utils", "lazy_static", "memoffset", "scopeguard", @@ -535,24 +520,12 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.7.2" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -dependencies = [ - "autocfg", - "cfg-if 0.1.10", - "lazy_static", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec91540d98355f690a86367e566ecad2e9e579f230230eb7c21398372be73ea5" +checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d" dependencies = [ "autocfg", "cfg-if 1.0.0", - "const_fn", "lazy_static", ] @@ -568,9 +541,9 @@ dependencies = [ [[package]] name = "csv" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4666154fd004af3fd6f1da2e81a96fd5a81927fe8ddb6ecc79e2aa6e138b54" +checksum = "f9d58633299b24b515ac72a3f869f8b91306a3cec616a602843a383acd6f9e97" dependencies = [ "bstr", "csv-core", @@ -605,9 +578,9 @@ dependencies = [ [[package]] name = "curl-sys" -version = "0.4.38+curl-7.73.0" +version = "0.4.39+curl-7.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "498ecfb4f59997fd40023d62a9f1e506e768b2baeb59a1d311eb9751cdcd7e3f" +checksum = "07a8ce861e7b68a0b394e814d7ee9f1b2750ff8bd10372c6ad3bacc10e86f874" dependencies = [ "cc", "libc", @@ -626,7 +599,7 @@ checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", ] [[package]] @@ -748,7 +721,7 @@ checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", "synstructure", ] @@ -916,7 +889,7 @@ dependencies = [ "futures-io", "futures-task", "memchr", - "pin-project 1.0.1", + "pin-project 1.0.2", "pin-utils", "slab", ] @@ -1096,7 +1069,7 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project 1.0.1", + "pin-project 1.0.2", "socket2", "tokio", "tower-service", @@ -1190,9 +1163,9 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb1fc4429a33e1f80d41dc9fea4d108a88bec1de8053878898ae448a0b52f613" +checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" dependencies = [ "cfg-if 1.0.0", ] @@ -1247,9 +1220,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.45" +version = "0.3.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca059e81d9486668f12d455a4ea6daa600bd408134cd17e3d3fb5a32d1f016f8" +checksum = "cf3d7383929f7c9c7c2d0fa596f325832df98c3704f2c60553080f7127a58175" dependencies = [ "wasm-bindgen", ] @@ -1527,9 +1500,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.80" +version = "0.2.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" +checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" [[package]] name = "libloading" @@ -1567,9 +1540,9 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28247cc5a5be2f05fbcd76dd0cf2c7d3b5400cb978a28042abcd4fa0b3f8261c" +checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" dependencies = [ "scopeguard", ] @@ -1625,9 +1598,9 @@ checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" [[package]] name = "memoffset" -version = "0.5.6" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" dependencies = [ "autocfg", ] @@ -1669,9 +1642,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.6.22" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" dependencies = [ "cfg-if 0.1.10", "fuchsia-zircon", @@ -1700,9 +1673,9 @@ dependencies = [ [[package]] name = "miow" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" dependencies = [ "kernel32-sys", "net2", @@ -1730,9 +1703,9 @@ dependencies = [ [[package]] name = "net2" -version = "0.2.35" +version = "0.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853" +checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" dependencies = [ "cfg-if 0.1.10", "libc", @@ -1827,15 +1800,15 @@ checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" [[package]] name = "once_cell" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f53cef67919d7d247eb9a2f128ca9e522789967ef1eb4ccd8c71a95a8aedf596" +checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" [[package]] name = "oorandom" -version = "11.1.2" +version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a170cebd8021a008ea92e4db85a72f80b35df514ec664b296fdcbb654eac0b2c" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "opaque-debug" @@ -1871,9 +1844,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" [[package]] name = "openssl-sys" -version = "0.9.58" +version = "0.9.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de" +checksum = "de52d8eabd217311538a39bba130d7dea1f1e118010fee7a033d966845e7d5fe" dependencies = [ "autocfg", "cc", @@ -1884,9 +1857,9 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4893845fa2ca272e647da5d0e46660a314ead9c2fdd9a883aabc32e481a8733" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" dependencies = [ "instant", "lock_api", @@ -1895,12 +1868,11 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b" +checksum = "d7c6d9b8427445284a09c55be860a15855ab580a417ccad9da88f5a06787ced0" dependencies = [ - "cfg-if 0.1.10", - "cloudabi", + "cfg-if 1.0.0", "instant", "libc", "redox_syscall", @@ -1968,7 +1940,7 @@ dependencies = [ "pest_meta", "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", ] [[package]] @@ -1993,11 +1965,11 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee41d838744f60d959d7074e3afb6b35c7456d0f61cad38a24e35e6553f73841" +checksum = "9ccc2237c2c489783abd8c4c80e5450fc0e98644555b1364da68cc29aa151ca7" dependencies = [ - "pin-project-internal 1.0.1", + "pin-project-internal 1.0.2", ] [[package]] @@ -2008,18 +1980,18 @@ checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", ] [[package]] name = "pin-project-internal" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81a4ffa594b66bff340084d4081df649a7dc049ac8d7fc458d8e628bfbbb2f86" +checksum = "f8e8d2bf0b23038a4424865103a4df472855692821aab4e4f5c3312d461d9e5f" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", ] [[package]] @@ -2185,7 +2157,7 @@ checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" dependencies = [ "crossbeam-channel", "crossbeam-deque", - "crossbeam-utils 0.8.0", + "crossbeam-utils", "lazy_static", "num_cpus", ] @@ -2293,14 +2265,14 @@ dependencies = [ [[package]] name = "rust-argon2" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dab61250775933275e84053ac235621dfb739556d5c54a2f2e9313b7cf43a19" +checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" dependencies = [ - "base64 0.12.3", + "base64 0.13.0", "blake2b_simd", "constant_time_eq", - "crossbeam-utils 0.7.2", + "crossbeam-utils", ] [[package]] @@ -2480,7 +2452,7 @@ checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", ] [[package]] @@ -2564,9 +2536,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] name = "smallvec" -version = "1.4.2" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" +checksum = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75" [[package]] name = "snarkos-algorithms" @@ -2613,7 +2585,7 @@ checksum = "a8f6ce35f9f73c13e5381c6938747935ca105e22717998489c3e5ddb8c13120d" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", ] [[package]] @@ -2764,11 +2736,11 @@ dependencies = [ [[package]] name = "socket2" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fd8b795c389288baa5f355489c65e71fd48a02104600d15c4cfbc561e9e429d" +checksum = "2c29947abdee2a218277abeca306f25789c938e500ea5a9d4b12a5a504466902" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", "redox_syscall", "winapi 0.3.9", @@ -2799,9 +2771,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.48" +version = "1.0.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" +checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", @@ -2816,7 +2788,7 @@ checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", "unicode-xid 0.2.1", ] @@ -2836,18 +2808,18 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" dependencies = [ "winapi-util", ] [[package]] name = "terminal_size" -version = "0.1.13" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a14cd9f8c72704232f0bfc8455c0e861f0ad4eb60cc9ec8a170e231414c1e13" +checksum = "4bd2d183bd3fac5f5fe38ddbeb4dc9aec4a39a9d7d59e7491d900302da01cbe1" dependencies = [ "libc", "winapi 0.3.9", @@ -2879,7 +2851,7 @@ checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", ] [[package]] @@ -2914,9 +2886,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b78a366903f506d2ad52ca8dc552102ffdd3e937ba8a227f024dc1d1eae28575" +checksum = "ccf8dbc19eb42fba10e8feaaec282fb50e2c14b2726d6301dbfeed0f73306a6f" dependencies = [ "tinyvec_macros", ] @@ -2929,9 +2901,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "0.2.22" +version = "0.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" +checksum = "099837d3464c16a808060bb3f02263b412f6fafcb5d01c533d309985fbeebe48" dependencies = [ "bytes 0.5.6", "fnv", @@ -3005,7 +2977,7 @@ checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", ] [[package]] @@ -3108,9 +3080,9 @@ dependencies = [ [[package]] name = "unicode-normalization" -version = "0.1.14" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f98e67a4d84f730d343392f9bfff7d21e3fca562b9cb7a43b768350beeddc6" +checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606" dependencies = [ "tinyvec", ] @@ -3204,11 +3176,11 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] name = "wasm-bindgen" -version = "0.2.68" +version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42" +checksum = "3cd364751395ca0f68cafb17666eee36b63077fb5ecd972bbcd74c90c4bf736e" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "serde", "serde_json", "wasm-bindgen-macro", @@ -3216,26 +3188,26 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.68" +version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f22b422e2a757c35a73774860af8e112bff612ce6cb604224e8e47641a9e4f68" +checksum = "1114f89ab1f4106e5b55e688b828c0ab0ea593a1ea7c094b141b14cbaaec2d62" dependencies = [ "bumpalo", "lazy_static", "log", "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.18" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7866cab0aa01de1edf8b5d7936938a7e397ee50ce24119aef3e1eaa3b6171da" +checksum = "1fe9756085a84584ee9457a002b7cdfe0bfff169f45d2591d8be1345a6780e35" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "js-sys", "wasm-bindgen", "web-sys", @@ -3243,9 +3215,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.68" +version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b13312a745c08c469f0b292dd2fcd6411dba5f7160f593da6ef69b64e407038" +checksum = "7a6ac8995ead1f084a8dea1e65f194d0973800c7f571f6edd70adf06ecf77084" dependencies = [ "quote 1.0.7", "wasm-bindgen-macro-support", @@ -3253,28 +3225,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.68" +version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f249f06ef7ee334cc3b8ff031bfc11ec99d00f34d86da7498396dc1e3b1498fe" +checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.48", + "syn 1.0.54", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.68" +version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307" +checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" [[package]] name = "wasm-bindgen-test" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34d1cdc8b98a557f24733d50a1199c4b0635e465eecba9c45b214544da197f64" +checksum = "0355fa0c1f9b792a09b6dcb6a8be24d51e71e6d74972f9eb4a44c4c004d24a25" dependencies = [ "console_error_panic_hook", "js-sys", @@ -3286,9 +3258,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8fb9c67be7439ee8ab1b7db502a49c05e51e2835b66796c705134d9b8e1a585" +checksum = "27e07b46b98024c2ba2f9e83a10c2ef0515f057f2da299c1762a2017de80438b" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", @@ -3296,9 +3268,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.45" +version = "0.3.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bf6ef87ad7ae8008e15a355ce696bed26012b7caa21605188cfd8214ab51e2d" +checksum = "222b1ef9334f92a21d3fb53dc3fd80f30836959a90f9274a626d7e06315ba3c3" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/compiler/tests/array/mod.rs b/compiler/tests/array/mod.rs index 6d4684ad18..406047270c 100644 --- a/compiler/tests/array/mod.rs +++ b/compiler/tests/array/mod.rs @@ -229,6 +229,14 @@ fn test_slice() { assert_satisfied(program); } +#[test] +fn test_slice_lower() { + let program_string = include_str!("slice_lower.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + // Array type tests #[test] diff --git a/compiler/tests/array/slice_lower.leo b/compiler/tests/array/slice_lower.leo new file mode 100644 index 0000000000..dd669830ea --- /dev/null +++ b/compiler/tests/array/slice_lower.leo @@ -0,0 +1,8 @@ +function main() { + let arr: [u32; 9] = [0, 1, 2, 3, 4, 5, 6, 7, 8]; + let expected: [u32; 2] = [0, 1]; + + let actual = arr[..2]; // Should produce [0, 1] + + console.assert(expected == actual); +} \ No newline at end of file diff --git a/grammar/src/common/range.rs b/grammar/src/common/range.rs index 602f163964..2bf4de441a 100644 --- a/grammar/src/common/range.rs +++ b/grammar/src/common/range.rs @@ -20,10 +20,15 @@ use pest::Span; use pest_ast::FromPest; use serde::Serialize; +#[derive(Clone, Debug, FromPest, PartialEq, Serialize)] +#[pest_ast(rule(Rule::range_operator))] +pub struct RangeOperator {} + #[derive(Clone, Debug, FromPest, PartialEq, Serialize)] #[pest_ast(rule(Rule::range))] pub struct Range<'ast> { pub from: Option>, + pub operator: RangeOperator, pub to: Option>, #[pest_ast(outer())] #[serde(with = "SpanDef")] diff --git a/grammar/src/leo.pest b/grammar/src/leo.pest index 3fccb668eb..e418abb5ce 100644 --- a/grammar/src/leo.pest +++ b/grammar/src/leo.pest @@ -70,7 +70,8 @@ LINE_END = { ";" ~ NEWLINE* } mutable = { "mut " } // Declared in common/range.rs -range = { expression? ~ ".." ~ expression? } +range_operator = { ".." } +range = { expression? ~ range_operator ~ expression? } // Declared in common/range_or_expression.rs range_or_expression = { range | expression } From 08e90f5c59fb24416670ed36c6b075ddf58da53e Mon Sep 17 00:00:00 2001 From: collin Date: Thu, 10 Dec 2020 17:54:19 -0500 Subject: [PATCH 33/41] fix array spread type bug --- compiler/tests/array/spread.leo | 3 ++- type-inference/src/objects/frame.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/tests/array/spread.leo b/compiler/tests/array/spread.leo index 5370960c2d..962e92c923 100644 --- a/compiler/tests/array/spread.leo +++ b/compiler/tests/array/spread.leo @@ -1,6 +1,7 @@ // A spread operator `...` copies the elements of one array into another function main(a: [u8; 3]) { let b = [1u8, 1u8]; + let c = [1u8, ...b]; - console.assert(a == [1u8, ...b]); + console.assert(a == c); } \ No newline at end of file diff --git a/type-inference/src/objects/frame.rs b/type-inference/src/objects/frame.rs index e76702dddd..ca53c536b9 100644 --- a/type-inference/src/objects/frame.rs +++ b/type-inference/src/objects/frame.rs @@ -837,7 +837,7 @@ impl Frame { // Check that the type is an array. match array_type { - Type::Array(element_type) => Ok(Type::Array(element_type)), + Type::Array(element_type) => Ok(*element_type), type_ => Err(FrameError::invalid_spread(type_, span)), } } From 161fe2608cbf31183e1cbf440dbae0d0db474853 Mon Sep 17 00:00:00 2001 From: collin Date: Thu, 10 Dec 2020 18:02:25 -0500 Subject: [PATCH 34/41] fix accessing self variable inside nested scope bug --- compiler/src/statement/block/block.rs | 3 ++- compiler/src/statement/conditional/conditional.rs | 4 ++++ compiler/src/statement/iteration/iteration.rs | 2 ++ compiler/src/statement/statement.rs | 2 ++ compiler/tests/circuits/mod.rs | 8 ++++++++ .../circuits/mut_self_variable_conditional.leo | 15 +++++++++++++++ 6 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 compiler/tests/circuits/mut_self_variable_conditional.leo diff --git a/compiler/src/statement/block/block.rs b/compiler/src/statement/block/block.rs index b2633a0767..b4834494d3 100644 --- a/compiler/src/statement/block/block.rs +++ b/compiler/src/statement/block/block.rs @@ -36,6 +36,7 @@ impl> ConstrainedProgram { indicator: &Boolean, block: Block, return_type: Option, + declared_circuit_reference: &str, mut_self: bool, ) -> StatementResult>> { let mut results = Vec::with_capacity(block.statements.len()); @@ -48,7 +49,7 @@ impl> ConstrainedProgram { indicator, statement, return_type.clone(), - "", + declared_circuit_reference, mut_self, )?; diff --git a/compiler/src/statement/conditional/conditional.rs b/compiler/src/statement/conditional/conditional.rs index aebed7cc14..c5c07d84db 100644 --- a/compiler/src/statement/conditional/conditional.rs +++ b/compiler/src/statement/conditional/conditional.rs @@ -52,6 +52,7 @@ impl> ConstrainedProgram { indicator: &Boolean, statement: ConditionalStatement, return_type: Option, + declared_circuit_reference: &str, mut_self: bool, span: &Span, ) -> StatementResult>> { @@ -96,6 +97,7 @@ impl> ConstrainedProgram { &branch_1_indicator, statement.block, return_type.clone(), + declared_circuit_reference, mut_self, )?; @@ -125,6 +127,7 @@ impl> ConstrainedProgram { &branch_2_indicator, *nested, return_type, + declared_circuit_reference, mut_self, span, )?, @@ -135,6 +138,7 @@ impl> ConstrainedProgram { &branch_2_indicator, block, return_type, + declared_circuit_reference, mut_self, )?, }, diff --git a/compiler/src/statement/iteration/iteration.rs b/compiler/src/statement/iteration/iteration.rs index c7084143ff..fffc737ab5 100644 --- a/compiler/src/statement/iteration/iteration.rs +++ b/compiler/src/statement/iteration/iteration.rs @@ -48,6 +48,7 @@ impl> ConstrainedProgram { stop: Expression, block: Block, return_type: Option, + declared_circuit_reference: &str, mut_self: bool, span: &Span, ) -> StatementResult>> { @@ -75,6 +76,7 @@ impl> ConstrainedProgram { indicator, block.clone(), return_type.clone(), + declared_circuit_reference, mut_self, )?; diff --git a/compiler/src/statement/statement.rs b/compiler/src/statement/statement.rs index 9ca8a39562..81ef5702cb 100644 --- a/compiler/src/statement/statement.rs +++ b/compiler/src/statement/statement.rs @@ -90,6 +90,7 @@ impl> ConstrainedProgram { indicator, statement, return_type, + declared_circuit_reference, mut_self, &span, )?; @@ -107,6 +108,7 @@ impl> ConstrainedProgram { start_stop.1, block, return_type, + declared_circuit_reference, mut_self, &span, )?; diff --git a/compiler/tests/circuits/mod.rs b/compiler/tests/circuits/mod.rs index d3d31dc144..37c88ac7f9 100644 --- a/compiler/tests/circuits/mod.rs +++ b/compiler/tests/circuits/mod.rs @@ -150,6 +150,14 @@ fn test_mutate_self_variable() { assert_satisfied(program); } +#[test] +fn test_mutate_self_variable_conditional() { + let program_string = include_str!("mut_self_variable_conditional.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + #[test] fn test_mutate_self_variable_fail() { let program_string = include_str!("mut_self_variable_fail.leo"); diff --git a/compiler/tests/circuits/mut_self_variable_conditional.leo b/compiler/tests/circuits/mut_self_variable_conditional.leo new file mode 100644 index 0000000000..74345afcb4 --- /dev/null +++ b/compiler/tests/circuits/mut_self_variable_conditional.leo @@ -0,0 +1,15 @@ +function main() { + let mut f = Foo { a: 0u32 }; + + f.bar(); +} + +circuit Foo { + a: u32 + + function bar(mut self) { + if true { + self.a = 5u32; // Mutating a variable inside a conditional statement should work. + } + } +} \ No newline at end of file From ca36d0602257891e2e559bb5aa922537dc513175 Mon Sep 17 00:00:00 2001 From: collin Date: Fri, 11 Dec 2020 13:31:13 -0500 Subject: [PATCH 35/41] undeprecate parse_program_from_string and add test --- compiler/src/compiler.rs | 3 --- compiler/tests/compiler/main.leo | 3 +++ compiler/tests/compiler/mod.rs | 46 ++++++++++++++++++++++++++++++++ compiler/tests/mod.rs | 1 + 4 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 compiler/tests/compiler/main.leo create mode 100644 compiler/tests/compiler/mod.rs diff --git a/compiler/src/compiler.rs b/compiler/src/compiler.rs index 0726fc756b..51e85d1d0f 100644 --- a/compiler/src/compiler.rs +++ b/compiler/src/compiler.rs @@ -229,9 +229,6 @@ impl> Compiler { /// Equivalent to parse_and_check_program but uses the given program_string instead of a main /// file path. /// - /// Used for testing only. - /// - #[deprecated(note = "Please use the 'parse_program' method instead.")] pub fn parse_program_from_string(&mut self, program_string: &str) -> Result<(), CompilerError> { // Use the given bytes to construct the abstract syntax tree. let ast = Grammar::new(&self.main_file_path, &program_string).map_err(|mut e| { diff --git a/compiler/tests/compiler/main.leo b/compiler/tests/compiler/main.leo new file mode 100644 index 0000000000..f5ddfb4e7f --- /dev/null +++ b/compiler/tests/compiler/main.leo @@ -0,0 +1,3 @@ +function main() { + let a: u32 = 1 + 2; +} \ No newline at end of file diff --git a/compiler/tests/compiler/mod.rs b/compiler/tests/compiler/mod.rs new file mode 100644 index 0000000000..8daa6a9270 --- /dev/null +++ b/compiler/tests/compiler/mod.rs @@ -0,0 +1,46 @@ +// Copyright (C) 2019-2020 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{assert_satisfied, get_output, parse_program, EdwardsTestCompiler}; + +use std::{env::current_dir, path::PathBuf}; + +static MAIN_FILE_NAME: &str = "tests/compiler/main.leo"; + +// Compiler tests rely on knowledge of local directories. They should be run locally only. + +#[test] +#[ignore] +fn test_parse_program_from_string() { + // Parse program from string with compiler. + let program_string = include_str!("main.leo"); + let mut compiler_no_path = EdwardsTestCompiler::new("".to_string(), PathBuf::new(), PathBuf::new()); + + compiler_no_path.parse_program_from_string(program_string).unwrap(); + + // Parse program from file path with compiler. + let mut local = current_dir().unwrap(); + local.push(MAIN_FILE_NAME); + + let compiler_with_path = + EdwardsTestCompiler::parse_program_without_input("".to_string(), local, PathBuf::new()).unwrap(); + + // Compare output bytes. + let expected_output = get_output(compiler_no_path); + let actual_output = get_output(compiler_with_path); + + assert_eq!(expected_output, actual_output); +} diff --git a/compiler/tests/mod.rs b/compiler/tests/mod.rs index 434a19ff16..52e50e9188 100644 --- a/compiler/tests/mod.rs +++ b/compiler/tests/mod.rs @@ -21,6 +21,7 @@ pub mod address; pub mod array; pub mod boolean; pub mod circuits; +pub mod compiler; pub mod console; pub mod core; pub mod definition; From babb8ec1750e8e8fc92cded96b0b975f87282719 Mon Sep 17 00:00:00 2001 From: howardwu Date: Mon, 14 Dec 2020 13:54:46 -0400 Subject: [PATCH 36/41] Hotfix cargo fmt --- ast/src/circuits/circuit_member.rs | 8 ++------ compiler/src/function/main_function.rs | 4 +--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/ast/src/circuits/circuit_member.rs b/ast/src/circuits/circuit_member.rs index c86ae4156b..c63f3f0403 100644 --- a/ast/src/circuits/circuit_member.rs +++ b/ast/src/circuits/circuit_member.rs @@ -58,12 +58,8 @@ impl<'ast> From> for CircuitMember { impl fmt::Display for CircuitMember { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - CircuitMember::CircuitVariable(ref identifier, ref type_) => { - write!(f, "{}: {}", identifier, type_) - } - CircuitMember::CircuitFunction(ref function) => { - write!(f, "{}", function) - } + CircuitMember::CircuitVariable(ref identifier, ref type_) => write!(f, "{}: {}", identifier, type_), + CircuitMember::CircuitFunction(ref function) => write!(f, "{}", function), } } } diff --git a/compiler/src/function/main_function.rs b/compiler/src/function/main_function.rs index 1d3f5d1380..a229025fa0 100644 --- a/compiler/src/function/main_function.rs +++ b/compiler/src/function/main_function.rs @@ -52,9 +52,7 @@ impl> ConstrainedProgram { (input_id, value) } FunctionInput::SelfKeyword(_) => unimplemented!("cannot access self keyword in main function"), - FunctionInput::MutSelfKeyword(_) => { - unimplemented!("cannot access mut self keyword in main function") - } + FunctionInput::MutSelfKeyword(_) => unimplemented!("cannot access mut self keyword in main function"), FunctionInput::Variable(input_model) => { let name = input_model.identifier.name.clone(); let input_option = input From 9038c5a17af13fcfd5d4672ee634018a301f4d1c Mon Sep 17 00:00:00 2001 From: howardwu Date: Mon, 14 Dec 2020 13:57:01 -0400 Subject: [PATCH 37/41] chore(leo): bump version for new release --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 16 ++++++++-------- ast/Cargo.toml | 8 ++++---- compiler/Cargo.toml | 24 ++++++++++++------------ core/Cargo.toml | 6 +++--- gadgets/Cargo.toml | 2 +- grammar/Cargo.toml | 2 +- imports/Cargo.toml | 8 ++++---- input/Cargo.toml | 2 +- leo/leo-version | 2 +- linter/Cargo.toml | 2 +- package/Cargo.toml | 2 +- state/Cargo.toml | 8 ++++---- symbol-table/Cargo.toml | 12 ++++++------ type-inference/Cargo.toml | 12 ++++++------ 15 files changed, 66 insertions(+), 66 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a1ce27b338..47057963e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1270,7 +1270,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "leo-ast" -version = "1.0.6" +version = "1.0.7" dependencies = [ "criterion", "indexmap", @@ -1285,7 +1285,7 @@ dependencies = [ [[package]] name = "leo-compiler" -version = "1.0.6" +version = "1.0.7" dependencies = [ "bincode", "hex", @@ -1321,7 +1321,7 @@ dependencies = [ [[package]] name = "leo-core" -version = "1.0.6" +version = "1.0.7" dependencies = [ "leo-ast", "leo-gadgets", @@ -1337,7 +1337,7 @@ dependencies = [ [[package]] name = "leo-gadgets" -version = "1.0.6" +version = "1.0.7" dependencies = [ "criterion", "rand", @@ -1350,7 +1350,7 @@ dependencies = [ [[package]] name = "leo-grammar" -version = "1.0.6" +version = "1.0.7" dependencies = [ "criterion", "from-pest", @@ -1366,7 +1366,7 @@ dependencies = [ [[package]] name = "leo-imports" -version = "1.0.6" +version = "1.0.7" dependencies = [ "indexmap", "leo-ast", @@ -1377,7 +1377,7 @@ dependencies = [ [[package]] name = "leo-input" -version = "1.0.6" +version = "1.0.7" dependencies = [ "from-pest", "pest", @@ -1394,7 +1394,7 @@ dependencies = [ [[package]] name = "leo-lang" -version = "1.0.6" +version = "1.0.7" dependencies = [ "clap", "colored", @@ -1435,11 +1435,11 @@ dependencies = [ [[package]] name = "leo-linter" -version = "1.0.6" +version = "1.0.7" [[package]] name = "leo-package" -version = "1.0.6" +version = "1.0.7" dependencies = [ "lazy_static", "serde", @@ -1453,7 +1453,7 @@ dependencies = [ [[package]] name = "leo-state" -version = "1.0.6" +version = "1.0.7" dependencies = [ "indexmap", "leo-ast", @@ -1473,7 +1473,7 @@ dependencies = [ [[package]] name = "leo-symbol-table" -version = "1.0.6" +version = "1.0.7" dependencies = [ "indexmap", "leo-ast", @@ -1486,7 +1486,7 @@ dependencies = [ [[package]] name = "leo-type-inference" -version = "1.0.6" +version = "1.0.7" dependencies = [ "indexmap", "leo-ast", diff --git a/Cargo.toml b/Cargo.toml index 970e89f51e..2c9ccfff7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leo-lang" -version = "1.0.6" +version = "1.0.7" authors = [ "The Aleo Team " ] description = "The Leo programming language" homepage = "https://aleo.org" @@ -42,31 +42,31 @@ members = [ [dependencies.leo-ast] path = "./ast" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-compiler] path = "./compiler" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-gadgets] path = "./gadgets" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-imports] path = "./imports" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-input] path = "./input" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-package] path = "./package" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-state] path = "./state" -version = "1.0.6" +version = "1.0.7" [dependencies.snarkos-algorithms] version = "1.1.3" diff --git a/ast/Cargo.toml b/ast/Cargo.toml index 06c5d997ac..b0c4e0ede5 100644 --- a/ast/Cargo.toml +++ b/ast/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leo-ast" -version = "1.0.6" +version = "1.0.7" authors = [ "The Aleo Team " ] description = "Core AST of the Leo programming language" homepage = "https://aleo.org" @@ -28,11 +28,11 @@ harness = false [dependencies.leo-grammar] path = "../grammar" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-input] path = "../input" -version = "1.0.6" +version = "1.0.7" [dependencies.snarkos-errors] version = "1.1.3" @@ -44,7 +44,7 @@ default-features = false [dependencies.indexmap] version = "1.6.0" -features = ["serde-1"] +features = [ "serde-1" ] [dependencies.pest] version = "2.0" diff --git a/compiler/Cargo.toml b/compiler/Cargo.toml index fe242bf7d0..8d3efb213d 100644 --- a/compiler/Cargo.toml +++ b/compiler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leo-compiler" -version = "1.0.6" +version = "1.0.7" authors = [ "The Aleo Team " ] description = "Compiler of the Leo programming language" homepage = "https://aleo.org" @@ -19,43 +19,43 @@ edition = "2018" [dependencies.leo-ast] path = "../ast" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-core] path = "../core" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-gadgets] path = "../gadgets" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-grammar] path = "../grammar" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-imports] path = "../imports" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-input] path = "../input" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-package] path = "../package" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-state] path = "../state" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-symbol-table] path = "../symbol-table" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-type-inference] path = "../type-inference" -version = "1.0.6" +version = "1.0.7" [dependencies.snarkos-curves] version = "1.1.3" @@ -92,7 +92,7 @@ version = "0.4.2" [dependencies.indexmap] version = "1.6.0" -features = ["serde-1"] +features = [ "serde-1" ] [dependencies.pest] version = "2.0" diff --git a/core/Cargo.toml b/core/Cargo.toml index e864dfbb6c..caf4e91625 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leo-core" -version = "1.0.6" +version = "1.0.7" authors = [ "The Aleo Team " ] description = "Core package dependencies of the Leo programming language" homepage = "https://aleo.org" @@ -19,11 +19,11 @@ edition = "2018" [dependencies.leo-ast] path = "../ast" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-gadgets] path = "../gadgets" -version = "1.0.6" +version = "1.0.7" [dependencies.snarkos-errors] version = "1.1.3" diff --git a/gadgets/Cargo.toml b/gadgets/Cargo.toml index 650c5ee8ec..6a8fdd9d73 100644 --- a/gadgets/Cargo.toml +++ b/gadgets/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leo-gadgets" -version = "1.0.6" +version = "1.0.7" authors = [ "The Aleo Team " ] description = "Gadgets of the Leo programming language" homepage = "https://aleo.org" diff --git a/grammar/Cargo.toml b/grammar/Cargo.toml index 3dec5aa9ed..3c8308abf1 100644 --- a/grammar/Cargo.toml +++ b/grammar/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leo-grammar" -version = "1.0.6" +version = "1.0.7" authors = [ "The Aleo Team " ] description = "AST generated by pest from the Leo grammar rules" homepage = "https://aleo.org" diff --git a/imports/Cargo.toml b/imports/Cargo.toml index 909269250f..3c7c3e9b50 100644 --- a/imports/Cargo.toml +++ b/imports/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leo-imports" -version = "1.0.6" +version = "1.0.7" authors = [ "The Aleo Team " ] description = "Import parser for Leo program package dependencies" homepage = "https://aleo.org" @@ -19,15 +19,15 @@ edition = "2018" [dependencies.leo-ast] path = "../ast" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-grammar] path = "../grammar" -version = "1.0.6" +version = "1.0.7" [dependencies.indexmap] version = "1.6.0" -features = ["serde-1"] +features = [ "serde-1" ] [dependencies.thiserror] version = "1.0" diff --git a/input/Cargo.toml b/input/Cargo.toml index cb22145186..85c9dc196b 100644 --- a/input/Cargo.toml +++ b/input/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leo-input" -version = "1.0.6" +version = "1.0.7" authors = [ "The Aleo Team " ] description = "Input parser of the Leo programming language" homepage = "https://aleo.org" diff --git a/leo/leo-version b/leo/leo-version index 6df8b11430..ef6a92d304 100644 --- a/leo/leo-version +++ b/leo/leo-version @@ -1 +1 @@ -v1.0.6 \ No newline at end of file +v1.0.7 \ No newline at end of file diff --git a/linter/Cargo.toml b/linter/Cargo.toml index 502578d2dc..868aa6758c 100644 --- a/linter/Cargo.toml +++ b/linter/Cargo.toml @@ -2,7 +2,7 @@ dependencies = { } [package] name = "leo-linter" -version = "1.0.6" +version = "1.0.7" authors = [ "The Aleo Team " ] description = "Linter of the Leo programming language" homepage = "https://aleo.org" diff --git a/package/Cargo.toml b/package/Cargo.toml index f1a1befb49..edeaddf76a 100644 --- a/package/Cargo.toml +++ b/package/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leo-package" -version = "1.0.6" +version = "1.0.7" authors = [ "The Aleo Team " ] description = "Package parser of the Leo programming language" homepage = "https://aleo.org" diff --git a/state/Cargo.toml b/state/Cargo.toml index 5e08e52011..1b3ae625c0 100644 --- a/state/Cargo.toml +++ b/state/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leo-state" -version = "1.0.6" +version = "1.0.7" authors = [ "The Aleo Team " ] description = "State parser of the Leo programming language" homepage = "https://aleo.org" @@ -19,11 +19,11 @@ edition = "2018" [dependencies.leo-input] path = "../input" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-ast] path = "../ast" -version = "1.0.6" +version = "1.0.7" [dependencies.snarkos-algorithms] version = "1.1.3" @@ -54,7 +54,7 @@ version = "1.1.3" [dependencies.indexmap] version = "1.6.0" -features = ["serde-1"] +features = [ "serde-1" ] [dependencies.rand] version = "0.7" diff --git a/symbol-table/Cargo.toml b/symbol-table/Cargo.toml index aa9f5e1a50..e3cfdb0837 100644 --- a/symbol-table/Cargo.toml +++ b/symbol-table/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leo-symbol-table" -version = "1.0.6" +version = "1.0.7" authors = [ "The Aleo Team " ] description = "Stores user-defined variables during type resolution" homepage = "https://aleo.org" @@ -19,23 +19,23 @@ edition = "2018" [dependencies.leo-ast] path = "../ast" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-core] path = "../core" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-grammar] path = "../grammar" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-imports] path = "../imports" -version = "1.0.6" +version = "1.0.7" [dependencies.indexmap] version = "1.6.0" -features = ["serde-1"] +features = [ "serde-1" ] [dependencies.serde] version = "1.0" diff --git a/type-inference/Cargo.toml b/type-inference/Cargo.toml index 2841ba3f58..e3e522266d 100644 --- a/type-inference/Cargo.toml +++ b/type-inference/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leo-type-inference" -version = "1.0.6" +version = "1.0.7" authors = [ "The Aleo Team " ] description = "Checks that a program is correct using type inference" homepage = "https://aleo.org" @@ -19,23 +19,23 @@ edition = "2018" [dependencies.leo-ast] path = "../ast" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-imports] path = "../imports" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-grammar] path = "../grammar" -version = "1.0.6" +version = "1.0.7" [dependencies.leo-symbol-table] path = "../symbol-table" -version = "1.0.6" +version = "1.0.7" [dependencies.indexmap] version = "1.6.0" -features = ["serde-1"] +features = [ "serde-1" ] [dependencies.serde_json] version = "1.0" From 15592e8b1dee75cfbe622a76924664383907a571 Mon Sep 17 00:00:00 2001 From: howardwu Date: Mon, 14 Dec 2020 22:50:10 -0400 Subject: [PATCH 38/41] Fix typo in Cargo.toml category --- symbol-table/Cargo.toml | 2 +- type-inference/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/symbol-table/Cargo.toml b/symbol-table/Cargo.toml index e3cfdb0837..69947504af 100644 --- a/symbol-table/Cargo.toml +++ b/symbol-table/Cargo.toml @@ -12,7 +12,7 @@ keywords = [ "programming-language", "zero-knowledge" ] -categories = [ "cryptography::croptocurrencies", "web-programming" ] +categories = [ "cryptography::cryptocurrencies", "web-programming" ] include = [ "Cargo.toml", "src", "README.md", "LICENSE.md" ] license = "GPL-3.0" edition = "2018" diff --git a/type-inference/Cargo.toml b/type-inference/Cargo.toml index e3e522266d..6b10d25e47 100644 --- a/type-inference/Cargo.toml +++ b/type-inference/Cargo.toml @@ -12,7 +12,7 @@ keywords = [ "programming-language", "zero-knowledge" ] -categories = [ "cryptography::croptocurrencies", "web-programming" ] +categories = [ "cryptography::cryptocurrencies", "web-programming" ] include = [ "Cargo.toml", "src", "README.md", "LICENSE.md" ] license = "GPL-3.0" edition = "2018" From 9afdd17099cc7a2f31a9bee69ee45f2f9e475227 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 10:43:46 +0000 Subject: [PATCH 39/41] Bump reqwest from 0.10.9 to 0.10.10 Bumps [reqwest](https://github.com/seanmonstar/reqwest) from 0.10.9 to 0.10.10. - [Release notes](https://github.com/seanmonstar/reqwest/releases) - [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md) - [Commits](https://github.com/seanmonstar/reqwest/compare/v0.10.9...v0.10.10) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 39 ++------------------------------------- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 47057963e9..df485b0f3a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -394,16 +394,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "console_error_panic_hook" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211" -dependencies = [ - "cfg-if 0.1.10", - "wasm-bindgen", -] - [[package]] name = "const_fn" version = "0.4.4" @@ -2218,9 +2208,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.10.9" +version = "0.10.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb15d6255c792356a0f578d8a645c677904dc02e862bebe2ecc18e0c01b9a0ce" +checksum = "0718f81a8e14c4dbb3b34cf23dc6aaf9ab8a0dfec160c534b3dbca1aaa21f47c" dependencies = [ "base64 0.13.0", "bytes 0.5.6", @@ -2248,7 +2238,6 @@ dependencies = [ "url", "wasm-bindgen", "wasm-bindgen-futures", - "wasm-bindgen-test", "web-sys", "winreg", ] @@ -3242,30 +3231,6 @@ version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" -[[package]] -name = "wasm-bindgen-test" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0355fa0c1f9b792a09b6dcb6a8be24d51e71e6d74972f9eb4a44c4c004d24a25" -dependencies = [ - "console_error_panic_hook", - "js-sys", - "scoped-tls", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-bindgen-test-macro", -] - -[[package]] -name = "wasm-bindgen-test-macro" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27e07b46b98024c2ba2f9e83a10c2ef0515f057f2da299c1762a2017de80438b" -dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.7", -] - [[package]] name = "web-sys" version = "0.3.46" diff --git a/Cargo.toml b/Cargo.toml index 2c9ccfff7a..79576f45fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -128,7 +128,7 @@ version = "0.7" version = "0.5.1" [dependencies.reqwest] -version = "0.10.9" +version = "0.10.10" features = [ "blocking", "json" ] [dependencies.self_update] From 8894f10de73bdb34626364d4d6f3be7d27e4db93 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 10:44:12 +0000 Subject: [PATCH 40/41] Bump indexmap from 1.6.0 to 1.6.1 Bumps [indexmap](https://github.com/bluss/indexmap) from 1.6.0 to 1.6.1. - [Release notes](https://github.com/bluss/indexmap/releases) - [Commits](https://github.com/bluss/indexmap/compare/1.6.0...1.6.1) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 4 ++-- ast/Cargo.toml | 2 +- compiler/Cargo.toml | 2 +- imports/Cargo.toml | 2 +- state/Cargo.toml | 2 +- symbol-table/Cargo.toml | 2 +- type-inference/Cargo.toml | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 47057963e9..637f8912f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1120,9 +1120,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" +checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" dependencies = [ "autocfg", "hashbrown", diff --git a/ast/Cargo.toml b/ast/Cargo.toml index b0c4e0ede5..d5d5552a26 100644 --- a/ast/Cargo.toml +++ b/ast/Cargo.toml @@ -43,7 +43,7 @@ version = "1.1.3" default-features = false [dependencies.indexmap] -version = "1.6.0" +version = "1.6.1" features = [ "serde-1" ] [dependencies.pest] diff --git a/compiler/Cargo.toml b/compiler/Cargo.toml index 8d3efb213d..f05b375767 100644 --- a/compiler/Cargo.toml +++ b/compiler/Cargo.toml @@ -91,7 +91,7 @@ version = "1.0" version = "0.4.2" [dependencies.indexmap] -version = "1.6.0" +version = "1.6.1" features = [ "serde-1" ] [dependencies.pest] diff --git a/imports/Cargo.toml b/imports/Cargo.toml index 3c7c3e9b50..4542ad01a0 100644 --- a/imports/Cargo.toml +++ b/imports/Cargo.toml @@ -26,7 +26,7 @@ path = "../grammar" version = "1.0.7" [dependencies.indexmap] -version = "1.6.0" +version = "1.6.1" features = [ "serde-1" ] [dependencies.thiserror] diff --git a/state/Cargo.toml b/state/Cargo.toml index 1b3ae625c0..c3d5405f06 100644 --- a/state/Cargo.toml +++ b/state/Cargo.toml @@ -53,7 +53,7 @@ default-features = false version = "1.1.3" [dependencies.indexmap] -version = "1.6.0" +version = "1.6.1" features = [ "serde-1" ] [dependencies.rand] diff --git a/symbol-table/Cargo.toml b/symbol-table/Cargo.toml index e3cfdb0837..6a8c1c7301 100644 --- a/symbol-table/Cargo.toml +++ b/symbol-table/Cargo.toml @@ -34,7 +34,7 @@ path = "../imports" version = "1.0.7" [dependencies.indexmap] -version = "1.6.0" +version = "1.6.1" features = [ "serde-1" ] [dependencies.serde] diff --git a/type-inference/Cargo.toml b/type-inference/Cargo.toml index e3e522266d..648a52cb0b 100644 --- a/type-inference/Cargo.toml +++ b/type-inference/Cargo.toml @@ -34,7 +34,7 @@ path = "../symbol-table" version = "1.0.7" [dependencies.indexmap] -version = "1.6.0" +version = "1.6.1" features = [ "serde-1" ] [dependencies.serde_json] From a700e7bda4b69754107f9adcf8098f890b95370b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 10:44:35 +0000 Subject: [PATCH 41/41] Bump rand_core from 0.5.1 to 0.6.0 Bumps [rand_core](https://github.com/rust-random/rand) from 0.5.1 to 0.6.0. - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/rand/compare/rand_core-0.5.1...rand_core-0.6.0) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 16 +++++++++++----- Cargo.toml | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 47057963e9..276b3c2347 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1414,7 +1414,7 @@ dependencies = [ "notify", "num-bigint", "rand", - "rand_core", + "rand_core 0.6.0", "reqwest", "rusty-hook", "self_update", @@ -2096,7 +2096,7 @@ dependencies = [ "getrandom", "libc", "rand_chacha", - "rand_core", + "rand_core 0.5.1", "rand_hc", ] @@ -2107,7 +2107,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.5.1", ] [[package]] @@ -2119,13 +2119,19 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rand_core" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8b34ba8cfb21243bd8df91854c830ff0d785fff2e82ebd4434c2644cb9ada18" + [[package]] name = "rand_hc" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core", + "rand_core 0.5.1", ] [[package]] @@ -2134,7 +2140,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8" dependencies = [ - "rand_core", + "rand_core 0.5.1", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 2c9ccfff7a..0ad2e41531 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -125,7 +125,7 @@ version = "0.3" version = "0.7" [dependencies.rand_core] -version = "0.5.1" +version = "0.6.0" [dependencies.reqwest] version = "0.10.9"