mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-23 18:21:38 +03:00
merge testnet3
This commit is contained in:
commit
bfd3a37a42
18
Cargo.lock
generated
18
Cargo.lock
generated
@ -145,9 +145,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.57"
|
||||
version = "1.0.58"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc"
|
||||
checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704"
|
||||
|
||||
[[package]]
|
||||
name = "arrayref"
|
||||
@ -897,12 +897,6 @@ version = "1.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.1"
|
||||
@ -1026,12 +1020,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.8.2"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a"
|
||||
checksum = "6c6392766afd7964e2531940894cffe4bd8d7d17dbc3c1c4857040fd4b33bdb3"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown 0.11.2",
|
||||
"hashbrown",
|
||||
"serde",
|
||||
]
|
||||
|
||||
@ -2148,7 +2142,7 @@ dependencies = [
|
||||
"curl",
|
||||
"derivative",
|
||||
"digest",
|
||||
"hashbrown 0.12.1",
|
||||
"hashbrown",
|
||||
"hex",
|
||||
"itertools",
|
||||
"lazy_static",
|
||||
|
@ -74,7 +74,7 @@ version = "0.15.0"
|
||||
version = "4.0.0"
|
||||
|
||||
[dependencies.indexmap]
|
||||
version = "1.8"
|
||||
version = "1.9"
|
||||
features = ["serde"]
|
||||
|
||||
[dependencies.lazy_static]
|
||||
|
@ -97,7 +97,7 @@ impl BinaryOperation {
|
||||
sym::nand => Self::Nand,
|
||||
sym::neq => Self::Neq,
|
||||
sym::nor => Self::Nor,
|
||||
sym::or => Self::Or,
|
||||
sym::or => Self::BitwiseOr,
|
||||
sym::pow => Self::Pow,
|
||||
sym::pow_wrapped => Self::PowWrapped,
|
||||
sym::shl => Self::Shl,
|
||||
|
@ -57,16 +57,16 @@ impl ParserContext<'_> {
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent
|
||||
/// a ternary expression. May or may not include circuit init expressions.
|
||||
///
|
||||
/// Otherwise, tries to parse the next token using [`parse_disjunctive_expression`].
|
||||
/// Otherwise, tries to parse the next token using [`parse_boolean_or_expression`].
|
||||
pub(super) fn parse_conditional_expression(&mut self) -> Result<Expression> {
|
||||
// Try to parse the next expression. Try BinaryOperation::Or.
|
||||
let mut expr = self.parse_disjunctive_expression()?;
|
||||
let mut expr = self.parse_boolean_or_expression()?;
|
||||
|
||||
// Parse the rest of the ternary expression.
|
||||
if self.eat(&Token::Question) {
|
||||
let if_true = self.parse_expression()?;
|
||||
self.expect(&Token::Colon)?;
|
||||
let if_false = self.parse_conditional_expression()?;
|
||||
let if_false = self.parse_expression()?;
|
||||
expr = Expression::Ternary(TernaryExpression {
|
||||
span: expr.span() + if_false.span(),
|
||||
condition: Box::new(expr),
|
||||
@ -101,28 +101,20 @@ impl ParserContext<'_> {
|
||||
Ok(expr)
|
||||
}
|
||||
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent
|
||||
/// a binary OR expression.
|
||||
///
|
||||
/// Otherwise, tries to parse the next token using [`parse_conjunctive_expression`].
|
||||
fn parse_disjunctive_expression(&mut self) -> Result<Expression> {
|
||||
self.parse_bin_expr(&[Token::Or], Self::parse_conjunctive_expression)
|
||||
}
|
||||
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// binary AND expression.
|
||||
///
|
||||
/// Otherwise, tries to parse the next token using [`parse_equality_expression`].
|
||||
fn parse_conjunctive_expression(&mut self) -> Result<Expression> {
|
||||
self.parse_bin_expr(&[Token::And], Self::parse_shift_expression)
|
||||
fn parse_boolean_and_expression(&mut self) -> Result<Expression> {
|
||||
self.parse_bin_expr(&[Token::And], Self::parse_equality_expression)
|
||||
}
|
||||
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// shift left or a shift right expression.
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent
|
||||
/// a binary OR expression.
|
||||
///
|
||||
/// Otherwise, tries to parse the next token using [`parse_equality_expression`].
|
||||
fn parse_shift_expression(&mut self) -> Result<Expression> {
|
||||
self.parse_bin_expr(&[Token::Shl, Token::Shr], Self::parse_equality_expression)
|
||||
/// Otherwise, tries to parse the next token using [`parse_boolean_and_expression`].
|
||||
fn parse_boolean_or_expression(&mut self) -> Result<Expression> {
|
||||
self.parse_bin_expr(&[Token::Or], Self::parse_boolean_and_expression)
|
||||
}
|
||||
|
||||
/// Eats one of binary operators matching any in `tokens`.
|
||||
@ -145,10 +137,24 @@ impl ParserContext<'_> {
|
||||
Token::Exp => BinaryOperation::Pow,
|
||||
Token::Shl => BinaryOperation::Shl,
|
||||
Token::Shr => BinaryOperation::Shr,
|
||||
Token::Xor => BinaryOperation::Xor,
|
||||
_ => unreachable!("`eat_bin_op` shouldn't produce this"),
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// binary relational expression: less than, less than or equals, greater than, greater than or equals.
|
||||
///
|
||||
/// Otherwise, tries to parse the next token using [`parse_additive_expression`].
|
||||
fn parse_ordering_expression(&mut self) -> Result<Expression> {
|
||||
let mut expr = self.parse_bitwise_exclusive_or_expression()?;
|
||||
if let Some(op) = self.eat_bin_op(&[Token::Lt, Token::LtEq, Token::Gt, Token::GtEq]) {
|
||||
let right = self.parse_bitwise_exclusive_or_expression()?;
|
||||
expr = Self::bin_expr(expr, right, op);
|
||||
}
|
||||
Ok(expr)
|
||||
}
|
||||
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// binary equals or not equals expression.
|
||||
///
|
||||
@ -163,16 +169,35 @@ impl ParserContext<'_> {
|
||||
}
|
||||
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// binary relational expression: less than, less than or equals, greater than, greater than or equals.
|
||||
/// bitwise exclusive or expression.
|
||||
///
|
||||
/// Otherwise, tries to parse the next token using [`parse_bitwise_inclusive_or_expression`].
|
||||
fn parse_bitwise_exclusive_or_expression(&mut self) -> Result<Expression> {
|
||||
self.parse_bin_expr(&[Token::Xor], Self::parse_bitwise_inclusive_or_expression)
|
||||
}
|
||||
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// bitwise inclusive or expression.
|
||||
///
|
||||
/// Otherwise, tries to parse the next token using [`parse_bitwise_and_expression`].
|
||||
fn parse_bitwise_inclusive_or_expression(&mut self) -> Result<Expression> {
|
||||
self.parse_bin_expr(&[Token::BitwiseOr], Self::parse_bitwise_and_expression)
|
||||
}
|
||||
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// bitwise and expression.
|
||||
///
|
||||
/// Otherwise, tries to parse the next token using [`parse_shift_expression`].
|
||||
fn parse_bitwise_and_expression(&mut self) -> Result<Expression> {
|
||||
self.parse_bin_expr(&[Token::BitwiseAnd], Self::parse_shift_expression)
|
||||
}
|
||||
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// shift left or a shift right expression.
|
||||
///
|
||||
/// Otherwise, tries to parse the next token using [`parse_additive_expression`].
|
||||
fn parse_ordering_expression(&mut self) -> Result<Expression> {
|
||||
let mut expr = self.parse_additive_expression()?;
|
||||
if let Some(op) = self.eat_bin_op(&[Token::Lt, Token::LtEq, Token::Gt, Token::GtEq]) {
|
||||
let right = self.parse_additive_expression()?;
|
||||
expr = Self::bin_expr(expr, right, op);
|
||||
}
|
||||
Ok(expr)
|
||||
fn parse_shift_expression(&mut self) -> Result<Expression> {
|
||||
self.parse_bin_expr(&[Token::Shl, Token::Shr], Self::parse_additive_expression)
|
||||
}
|
||||
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
@ -241,18 +266,18 @@ impl ParserContext<'_> {
|
||||
let (mut args, _, span) = self.parse_expr_tuple()?;
|
||||
let span = receiver.span() + span;
|
||||
|
||||
if let ([], Some(operator)) = (&*args, UnaryOperation::from_symbol(method.name)) {
|
||||
if let (true, Some(op)) = (args.is_empty(), UnaryOperation::from_symbol(method.name)) {
|
||||
// Found an unary operator and the argument list is empty.
|
||||
Ok(Expression::Unary(UnaryExpression {
|
||||
span,
|
||||
op: operator,
|
||||
op,
|
||||
receiver: Box::new(receiver),
|
||||
}))
|
||||
} else if let (true, Some(operator)) = (args.len() == 1, BinaryOperation::from_symbol(method.name)) {
|
||||
} else if let (1, Some(op)) = (args.len(), BinaryOperation::from_symbol(method.name)) {
|
||||
// Found a binary operator and the argument list contains a single argument.
|
||||
Ok(Expression::Binary(BinaryExpression {
|
||||
span,
|
||||
op: operator,
|
||||
op,
|
||||
left: Box::new(receiver),
|
||||
right: Box::new(args.swap_remove(0)),
|
||||
}))
|
||||
@ -308,20 +333,23 @@ impl ParserContext<'_> {
|
||||
let mut expr = self.parse_primary_expression()?;
|
||||
loop {
|
||||
if self.eat(&Token::Dot) {
|
||||
// Eat a method call on a type
|
||||
expr = self.parse_method_call_expression(expr)?
|
||||
} else if self.eat(&Token::DoubleColon) {
|
||||
expr = self.parse_static_access_expression(expr)?;
|
||||
} else if self.check(&Token::LeftParen) {
|
||||
// Parse a function call that's by itself.
|
||||
let (arguments, _, span) = self.parse_paren_comma_list(|p| p.parse_expression().map(Some))?;
|
||||
expr = Expression::Call(CallExpression {
|
||||
span: expr.span() + span,
|
||||
function: Box::new(expr),
|
||||
arguments,
|
||||
});
|
||||
}
|
||||
if !self.check(&Token::LeftParen) {
|
||||
// Check if next token is a dot to see if we are calling recursive method.
|
||||
if !self.check(&Token::Dot) {
|
||||
break;
|
||||
}
|
||||
|
||||
let (arguments, _, span) = self.parse_expr_tuple()?;
|
||||
expr = Expression::Call(CallExpression {
|
||||
span: expr.span() + span,
|
||||
function: Box::new(expr),
|
||||
arguments,
|
||||
});
|
||||
}
|
||||
Ok(expr)
|
||||
}
|
||||
@ -422,7 +450,9 @@ impl ParserContext<'_> {
|
||||
/// circuit initialization expression.
|
||||
/// let foo = Foo { x: 1u8 };
|
||||
pub fn parse_circuit_expression(&mut self, identifier: Identifier) -> Result<Expression> {
|
||||
let (members, _, end) = self.parse_list(Delimiter::Brace, Some(Token::Comma), |p| p.parse_circuit_member().map(Some))?;
|
||||
let (members, _, end) = self.parse_list(Delimiter::Brace, Some(Token::Comma), |p| {
|
||||
p.parse_circuit_member().map(Some)
|
||||
})?;
|
||||
|
||||
Ok(Expression::CircuitInit(CircuitInitExpression {
|
||||
span: identifier.span + end,
|
||||
|
@ -166,7 +166,7 @@ impl ParserContext<'_> {
|
||||
// CAUTION: function members are unstable for testnet3.
|
||||
let function = self.parse_function()?;
|
||||
|
||||
return Err(ParserError::circuit_functions_unstable(function.1.span()).into())
|
||||
return Err(ParserError::circuit_functions_unstable(function.1.span()).into());
|
||||
// Ok(CircuitMember::CircuitFunction(Box::new(function.1)))
|
||||
} else {
|
||||
return Err(Self::unexpected_item(&self.token).into());
|
||||
|
@ -300,6 +300,7 @@ impl Token {
|
||||
'{' => return single(&mut input, Token::LeftCurly),
|
||||
'}' => return single(&mut input, Token::RightCurly),
|
||||
'|' => return followed_by(&mut input, '|', Token::Or, Token::BitwiseOr),
|
||||
'^' => return single(&mut input, Token::Xor),
|
||||
_ => (),
|
||||
}
|
||||
if let Some(ident) = eat_identifier(&mut input) {
|
||||
|
@ -69,6 +69,7 @@ pub enum Token {
|
||||
Shl,
|
||||
Shr,
|
||||
Underscore,
|
||||
Xor,
|
||||
|
||||
// Syntactic Grammar
|
||||
// Types
|
||||
@ -248,6 +249,7 @@ impl fmt::Display for Token {
|
||||
Shl => write!(f, "<<"),
|
||||
Shr => write!(f, ">>"),
|
||||
Underscore => write!(f, "_"),
|
||||
Xor => write!(f, "^"),
|
||||
|
||||
Address => write!(f, "address"),
|
||||
Bool => write!(f, "bool"),
|
||||
|
@ -60,7 +60,7 @@ impl<'a> SymbolTable<'a> {
|
||||
pub fn insert_circuit(&mut self, symbol: Symbol, insert: &'a Circuit) -> Result<()> {
|
||||
if self.circuits.contains_key(&symbol) {
|
||||
// Return an error if the circuit name has already been inserted.
|
||||
return Err(AstError::shadowed_circuit(symbol, insert.span).into())
|
||||
return Err(AstError::shadowed_circuit(symbol, insert.span).into());
|
||||
}
|
||||
self.circuits.insert(symbol, insert);
|
||||
Ok(())
|
||||
|
@ -66,7 +66,11 @@ impl<'a> ExpressionVisitorDirector<'a> for Director<'a> {
|
||||
fn visit_identifier(&mut self, input: &'a Identifier, expected: &Self::AdditionalInput) -> Option<Self::Output> {
|
||||
if let VisitResult::VisitChildren = self.visitor.visit_identifier(input) {
|
||||
return if let Some(circuit) = self.visitor.symbol_table.clone().lookup_circuit(&input.name) {
|
||||
Some(self.visitor.assert_expected_option(Type::Identifier(circuit.identifier.clone()), expected, circuit.span()))
|
||||
Some(self.visitor.assert_expected_option(
|
||||
Type::Identifier(circuit.identifier.clone()),
|
||||
expected,
|
||||
circuit.span(),
|
||||
))
|
||||
} else if let Some(var) = self.visitor.symbol_table.clone().lookup_variable(&input.name) {
|
||||
Some(self.visitor.assert_expected_option(*var.type_, expected, var.span))
|
||||
} else {
|
||||
@ -463,7 +467,7 @@ impl<'a> ExpressionVisitorDirector<'a> for Director<'a> {
|
||||
let t1 = self.visit_expression(&input.left, destination);
|
||||
|
||||
// Assert right type is a magnitude (u8, u16, u32).
|
||||
let t2 = self.visit_expression(&input.left, &None);
|
||||
let t2 = self.visit_expression(&input.right, &None);
|
||||
self.visitor.assert_magnitude_type(&t2, input.right.span());
|
||||
|
||||
return_incorrect_type(t1, t2, destination)
|
||||
@ -606,7 +610,9 @@ impl<'a> ExpressionVisitorDirector<'a> for Director<'a> {
|
||||
) -> Option<Self::Output> {
|
||||
if let Some(circ) = self.visitor.symbol_table.clone().lookup_circuit(&input.name.name) {
|
||||
// Check circuit type name.
|
||||
let ret = self.visitor.assert_expected_circuit(circ.identifier, additional, input.name.span());
|
||||
let ret = self
|
||||
.visitor
|
||||
.assert_expected_circuit(circ.identifier, additional, input.name.span());
|
||||
|
||||
// Check number of circuit members.
|
||||
if circ.members.len() != input.members.len() {
|
||||
@ -616,7 +622,7 @@ impl<'a> ExpressionVisitorDirector<'a> for Director<'a> {
|
||||
input.members.len(),
|
||||
input.span(),
|
||||
)
|
||||
.into(),
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
// Check circuit member types
|
||||
@ -630,7 +636,7 @@ impl<'a> ExpressionVisitorDirector<'a> for Director<'a> {
|
||||
self.visit_expression(expr, &Some(*type_));
|
||||
}
|
||||
}
|
||||
_ => {/* Circuit functions cannot be inside circuit init expressions */}
|
||||
_ => { /* Circuit functions cannot be inside circuit init expressions */ }
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -248,7 +248,17 @@ function-call = identifier function-arguments
|
||||
|
||||
function-arguments = "(" [ expression *( "," expression ) [ "," ] ] ")"
|
||||
|
||||
unary-expression = primary-expression
|
||||
postfix-expression = primary-expression
|
||||
/ operator-call
|
||||
|
||||
operator-call = unary-operator-call / binary-operator-call
|
||||
|
||||
unary-operator-call = postfix-expression "." identifier "(" ")"
|
||||
|
||||
binary-operator-call =
|
||||
postfix-expression "." identifier "(" expression [ "," ] ")"
|
||||
|
||||
unary-expression = postfix-expression
|
||||
/ "!" unary-expression
|
||||
/ "-" unary-expression
|
||||
|
||||
@ -263,23 +273,39 @@ additive-expression = multiplicative-expression
|
||||
/ additive-expression "+" multiplicative-expression
|
||||
/ additive-expression "-" multiplicative-expression
|
||||
|
||||
ordering-expression = additive-expression
|
||||
/ additive-expression "<" additive-expression
|
||||
/ additive-expression ">" additive-expression
|
||||
/ additive-expression "<=" additive-expression
|
||||
/ additive-expression ">=" additive-expression
|
||||
shift-expression = additive-expression
|
||||
/ shift-expression "<<" additive-expression
|
||||
/ shift-expression ">>" additive-expression
|
||||
|
||||
bitwise-and-expression = shift-expression
|
||||
/ bitwise-and-expression "&" shift-expression
|
||||
|
||||
bitwise-inclusive-or-expression =
|
||||
bitwise-and-expression
|
||||
/ bitwise-inclusive-or-expression "|" bitwise-and-expression
|
||||
|
||||
bitwise-exclusive-or-expression =
|
||||
bitwise-inclusive-or-expression
|
||||
/ bitwise-exclusive-or-expression "^" bitwise-inclusive-or-expression
|
||||
|
||||
ordering-expression =
|
||||
bitwise-exclusive-or-expression
|
||||
/ bitwise-exclusive-or-expression "<" bitwise-exclusive-or-expression
|
||||
/ bitwise-exclusive-or-expression ">" bitwise-exclusive-or-expression
|
||||
/ bitwise-exclusive-or-expression "<=" bitwise-exclusive-or-expression
|
||||
/ bitwise-exclusive-or-expression ">=" bitwise-exclusive-or-expression
|
||||
|
||||
equality-expression = ordering-expression
|
||||
/ ordering-expression "==" ordering-expression
|
||||
/ ordering-expression "!=" ordering-expression
|
||||
|
||||
conjunctive-expression = equality-expression
|
||||
/ conjunctive-expression "&&" equality-expression
|
||||
boolean-and-expression = equality-expression
|
||||
/ boolean-and-expression "&&" equality-expression
|
||||
|
||||
disjunctive-expression = conjunctive-expression
|
||||
/ disjunctive-expression "||" conjunctive-expression
|
||||
boolean-or-expression = boolean-and-expression
|
||||
/ boolean-or-expression "||" boolean-and-expression
|
||||
|
||||
binary-expression = disjunctive-expression
|
||||
binary-expression = boolean-or-expression
|
||||
|
||||
conditional-expression = binary-expression
|
||||
/ binary-expression "?" expression ":" expression
|
||||
|
@ -23,7 +23,7 @@ path = "../errors"
|
||||
version = "1.5.3"
|
||||
|
||||
[dependencies.indexmap]
|
||||
version = "1.8"
|
||||
version = "1.9"
|
||||
features = ["serde"]
|
||||
|
||||
[dependencies.serde]
|
||||
|
13
tests/compiler/address/binary.leo
Normal file
13
tests/compiler/address/binary.leo
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/address1.in
|
||||
*/
|
||||
|
||||
|
||||
function main (x: address) -> bool {
|
||||
let a: address = aleo1fj982yqchhy973kz7e9jk6er7t6qd6jm9anplnlprem507w6lv9spwvfxx;
|
||||
let b: bool = x.eq(a);
|
||||
let c: bool = x.neq(a);
|
||||
return c;
|
||||
}
|
25
tests/compiler/boolean/operator_methods.leo
Normal file
25
tests/compiler/boolean/operator_methods.leo
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file:
|
||||
- inputs/false_false.in
|
||||
- inputs/false_true.in
|
||||
- inputs/true_false.in
|
||||
- inputs/true_true.in
|
||||
*/
|
||||
|
||||
function main(a: bool, b: bool) -> bool {
|
||||
// unary
|
||||
let h: bool = a.not();
|
||||
|
||||
// binary
|
||||
let l: bool = a.and(b);
|
||||
let o: bool = a.eq(b);
|
||||
let v: bool = a.nand(b);
|
||||
let w: bool = a.neq(b);
|
||||
let x: bool = a.nor(b);
|
||||
let y: bool = a.or(b);
|
||||
let ar: bool = a.xor(b);
|
||||
|
||||
return h;
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
|
||||
// todo: rewrite this test so it properly tests a compute key.
|
||||
function main(public compute_key: ComputeKey, a: bool) -> bool {
|
||||
return a;
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
// todo: rewrite this test so it properly tests a private key.
|
||||
function main(public private_key: PrivateKey, a: bool) -> bool {
|
||||
return a;
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
|
||||
// todo: rewrite this test so it properly tests a record type.
|
||||
function main(public record: Record, a: bool) -> bool {
|
||||
return a;
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
// todo: rewrite this test so it properly tests a signature.
|
||||
function main(public signature: Signature, a: bool) -> bool {
|
||||
return a;
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
// todo: rewrite this test so it properly tests a view key.
|
||||
function main(public view_key: ViewKey, a: bool) -> bool {
|
||||
return a;
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
// todo: rewrite this test so it properly tests poseidon hash functions.
|
||||
function main(public poseidon: Poseidon, a: bool) -> bool {
|
||||
return a;
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
|
||||
function main(public dne: DNE, a: bool) -> bool {
|
||||
return a;
|
||||
}
|
28
tests/compiler/field/operator_methods.leo
Normal file
28
tests/compiler/field/operator_methods.leo
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file:
|
||||
- inputs/fields.in
|
||||
*/
|
||||
|
||||
function main(a: field, b: field) -> bool {
|
||||
// unary
|
||||
let f: field = a.inv();
|
||||
let g: field = a.neg();
|
||||
let i: field = a.square();
|
||||
let j: field = a.sqrt();
|
||||
|
||||
// binary
|
||||
let k: field = a.add(b);
|
||||
let m: field = a.div(b);
|
||||
let o: bool = a.eq(b);
|
||||
let p: bool = a.ge(b);
|
||||
let q: bool = a.gt(b);
|
||||
let r: bool = a.le(b);
|
||||
let s: bool = a.lt(b);
|
||||
let t: field = a.mul(b);
|
||||
let w: bool = a.neq(b);
|
||||
let z: field = a.pow(b);
|
||||
|
||||
return w;
|
||||
}
|
20
tests/compiler/group/operator_methods.leo
Normal file
20
tests/compiler/group/operator_methods.leo
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/three.in
|
||||
*/
|
||||
|
||||
function main(a: group, b: group) -> bool {
|
||||
// unary
|
||||
let e: group = a.double();
|
||||
let g: group = a.neg();
|
||||
|
||||
// binary
|
||||
let j: group = a.add(b);
|
||||
let o: bool = a.eq(b);
|
||||
let t: group = a.mul(2scalar);
|
||||
let q: group = 2scalar.mul(a);
|
||||
let w: bool = a.neq(b);
|
||||
|
||||
return a == b;
|
||||
}
|
9
tests/compiler/integers/i128/and.leo
Normal file
9
tests/compiler/integers/i128/and.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128, c: i128) -> bool {
|
||||
return a & b == c;
|
||||
}
|
50
tests/compiler/integers/i128/operator_methods.leo
Normal file
50
tests/compiler/integers/i128/operator_methods.leo
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128) -> bool {
|
||||
// unary
|
||||
let c: i128 = a.abs();
|
||||
let d: i128 = a.abs_wrapped();
|
||||
let g: i128 = a.neg();
|
||||
let h: i128 = a.not();
|
||||
|
||||
// binary
|
||||
let j: i128 = a.add(b);
|
||||
let k: i128 = a.add_wrapped(b);
|
||||
let l: i128 = a.and(b);
|
||||
let m: i128 = a.div(b);
|
||||
let n: i128 = a.div_wrapped(b);
|
||||
let o: bool = a.eq(b);
|
||||
let p: bool = a.ge(b);
|
||||
let q: bool = a.gt(b);
|
||||
let r: bool = a.le(b);
|
||||
let s: bool = a.lt(b);
|
||||
let t: i128 = a.mul(b);
|
||||
let u: i128 = a.mul_wrapped(b);
|
||||
let w: bool = a.neq(b);
|
||||
let y: i128 = a.or(b);
|
||||
let z: i128 = a.pow(2u8);
|
||||
let aa: i128 = a.pow(2u16);
|
||||
let ab: i128 = a.pow(2u32);
|
||||
let ac: i128 = a.pow_wrapped(2u8);
|
||||
let ad: i128 = a.pow_wrapped(2u16);
|
||||
let ae: i128 = a.pow_wrapped(2u32);
|
||||
let af: i128 = a.shl(2u8);
|
||||
let ag: i128 = a.shl(2u16);
|
||||
let ah: i128 = a.shl(2u32);
|
||||
let ai: i128 = a.shl_wrapped(2u8);
|
||||
let aj: i128 = a.shl_wrapped(2u16);
|
||||
let ak: i128 = a.shl_wrapped(2u32);
|
||||
let al: i128 = a.shr(2u8);
|
||||
let am: i128 = a.shr(2u16);
|
||||
let an: i128 = a.shr(2u32);
|
||||
let ao: i128 = a.shr_wrapped(2u8);
|
||||
let ap: i128 = a.shr_wrapped(2u16);
|
||||
let aq: i128 = a.shr_wrapped(2u32);
|
||||
let ar: i128 = a.xor(b);
|
||||
|
||||
return a == b;
|
||||
}
|
9
tests/compiler/integers/i128/or.leo
Normal file
9
tests/compiler/integers/i128/or.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128, c: i128) -> bool {
|
||||
return a | b == c;
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
expectation: Pass
|
||||
input_file: inputs/pow.in
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128, c: i128) -> bool {
|
||||
return a ** b == c;
|
||||
return a ** 2u8 == a ** 2u16 && a ** 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i128/shl.leo
Normal file
9
tests/compiler/integers/i128/shl.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128, c: i128) -> bool {
|
||||
return a << 2u8 == a << 2u16 && a << 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i128/shr.leo
Normal file
9
tests/compiler/integers/i128/shr.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128, c: i128) -> bool {
|
||||
return a >> 2u8 == a >> 2u16 && a >> 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i128/xor.leo
Normal file
9
tests/compiler/integers/i128/xor.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128, c: i128) -> bool {
|
||||
return a ^ 2u8 == a ^ 2u16 && a ^ 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i16/and.leo
Normal file
9
tests/compiler/integers/i16/and.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i16, b: i16, c: i16) -> bool {
|
||||
return a & b == c;
|
||||
}
|
50
tests/compiler/integers/i16/operator_methods.leo
Normal file
50
tests/compiler/integers/i16/operator_methods.leo
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i16, b: i16) -> bool {
|
||||
// unary
|
||||
let c: i16 = a.abs();
|
||||
let d: i16 = a.abs_wrapped();
|
||||
let g: i16 = a.neg();
|
||||
let h: i16 = a.not();
|
||||
|
||||
// binary
|
||||
let j: i16 = a.add(b);
|
||||
let k: i16 = a.add_wrapped(b);
|
||||
let l: i16 = a.and(b);
|
||||
let m: i16 = a.div(b);
|
||||
let n: i16 = a.div_wrapped(b);
|
||||
let o: bool = a.eq(b);
|
||||
let p: bool = a.ge(b);
|
||||
let q: bool = a.gt(b);
|
||||
let r: bool = a.le(b);
|
||||
let s: bool = a.lt(b);
|
||||
let t: i16 = a.mul(b);
|
||||
let u: i16 = a.mul_wrapped(b);
|
||||
let w: bool = a.neq(b);
|
||||
let y: i16 = a.or(b);
|
||||
let z: i16 = a.pow(2u8);
|
||||
let aa: i16 = a.pow(2u16);
|
||||
let ab: i16 = a.pow(2u32);
|
||||
let ac: i16 = a.pow_wrapped(2u8);
|
||||
let ad: i16 = a.pow_wrapped(2u16);
|
||||
let ae: i16 = a.pow_wrapped(2u32);
|
||||
let af: i16 = a.shl(2u8);
|
||||
let ag: i16 = a.shl(2u16);
|
||||
let ah: i16 = a.shl(2u32);
|
||||
let ai: i16 = a.shl_wrapped(2u8);
|
||||
let aj: i16 = a.shl_wrapped(2u16);
|
||||
let ak: i16 = a.shl_wrapped(2u32);
|
||||
let al: i16 = a.shr(2u8);
|
||||
let am: i16 = a.shr(2u16);
|
||||
let an: i16 = a.shr(2u32);
|
||||
let ao: i16 = a.shr_wrapped(2u8);
|
||||
let ap: i16 = a.shr_wrapped(2u16);
|
||||
let aq: i16 = a.shr_wrapped(2u32);
|
||||
let ar: i16 = a.xor(b);
|
||||
|
||||
return a == b;
|
||||
}
|
9
tests/compiler/integers/i16/or.leo
Normal file
9
tests/compiler/integers/i16/or.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i16, b: i16, c: i16) -> bool {
|
||||
return a | b == c;
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
expectation: Pass
|
||||
input_file: inputs/pow.in
|
||||
*/
|
||||
|
||||
function main(a: i16, b: i16, c: i16) -> bool {
|
||||
return a ** b == c;
|
||||
return a ** 2u8 == a ** 2u16 && a ** 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i16/shl.leo
Normal file
9
tests/compiler/integers/i16/shl.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i16, b: i16, c: i16) -> bool {
|
||||
return a << 2u8 == a << 2u16 && a << 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i16/shr.leo
Normal file
9
tests/compiler/integers/i16/shr.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i16, b: i16, c: i16) -> bool {
|
||||
return a >> 2u8 == a >> 2u16 && a >> 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i16/xor.leo
Normal file
9
tests/compiler/integers/i16/xor.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i16, b: i16, c: i16) -> bool {
|
||||
return a ^ 2u8 == a ^ 2u16 && a ^ 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i32/and.leo
Normal file
9
tests/compiler/integers/i32/and.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i32, b: i32, c: i32) -> bool {
|
||||
return a & b == c;
|
||||
}
|
50
tests/compiler/integers/i32/operator_methods.leo
Normal file
50
tests/compiler/integers/i32/operator_methods.leo
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i32, b: i32) -> bool {
|
||||
// unary
|
||||
let c: i32 = a.abs();
|
||||
let d: i32 = a.abs_wrapped();
|
||||
let g: i32 = a.neg();
|
||||
let h: i32 = a.not();
|
||||
|
||||
// binary
|
||||
let j: i32 = a.add(b);
|
||||
let k: i32 = a.add_wrapped(b);
|
||||
let l: i32 = a.and(b);
|
||||
let m: i32 = a.div(b);
|
||||
let n: i32 = a.div_wrapped(b);
|
||||
let o: bool = a.eq(b);
|
||||
let p: bool = a.ge(b);
|
||||
let q: bool = a.gt(b);
|
||||
let r: bool = a.le(b);
|
||||
let s: bool = a.lt(b);
|
||||
let t: i32 = a.mul(b);
|
||||
let u: i32 = a.mul_wrapped(b);
|
||||
let w: bool = a.neq(b);
|
||||
let y: i32 = a.or(b);
|
||||
let z: i32 = a.pow(2u8);
|
||||
let aa: i32 = a.pow(2u16);
|
||||
let ab: i32 = a.pow(2u32);
|
||||
let ac: i32 = a.pow_wrapped(2u8);
|
||||
let ad: i32 = a.pow_wrapped(2u16);
|
||||
let ae: i32 = a.pow_wrapped(2u32);
|
||||
let af: i32 = a.shl(2u8);
|
||||
let ag: i32 = a.shl(2u16);
|
||||
let ah: i32 = a.shl(2u32);
|
||||
let ai: i32 = a.shl_wrapped(2u8);
|
||||
let aj: i32 = a.shl_wrapped(2u16);
|
||||
let ak: i32 = a.shl_wrapped(2u32);
|
||||
let al: i32 = a.shr(2u8);
|
||||
let am: i32 = a.shr(2u16);
|
||||
let an: i32 = a.shr(2u32);
|
||||
let ao: i32 = a.shr_wrapped(2u8);
|
||||
let ap: i32 = a.shr_wrapped(2u16);
|
||||
let aq: i32 = a.shr_wrapped(2u32);
|
||||
let ar: i32 = a.xor(b);
|
||||
|
||||
return a == b;
|
||||
}
|
9
tests/compiler/integers/i32/or.leo
Normal file
9
tests/compiler/integers/i32/or.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i32, b: i32, c: i32) -> bool {
|
||||
return a | b == c;
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
expectation: Pass
|
||||
input_file: inputs/pow.in
|
||||
*/
|
||||
|
||||
function main(a: i32, b: i32, c: i32) -> bool {
|
||||
return a ** b == c;
|
||||
return a ** 2u8 == a ** 2u16 && a ** 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i32/shl.leo
Normal file
9
tests/compiler/integers/i32/shl.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i32, b: i32, c: i32) -> bool {
|
||||
return a << 2u8 == a << 2u16 && a << 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i32/shr.leo
Normal file
9
tests/compiler/integers/i32/shr.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i32, b: i32, c: i32) -> bool {
|
||||
return a >> 2u8 == a >> 2u16 && a >> 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i32/xor.leo
Normal file
9
tests/compiler/integers/i32/xor.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i32, b: i32, c: i32) -> bool {
|
||||
return a ^ 2u8 == a ^ 2u16 && a ^ 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i64/and.leo
Normal file
9
tests/compiler/integers/i64/and.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i64, b: i64, c: i64) -> bool {
|
||||
return a & b == c;
|
||||
}
|
50
tests/compiler/integers/i64/operator_methods.leo
Normal file
50
tests/compiler/integers/i64/operator_methods.leo
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i64, b: i64) -> bool {
|
||||
// unary
|
||||
let c: i64 = a.abs();
|
||||
let d: i64 = a.abs_wrapped();
|
||||
let g: i64 = a.neg();
|
||||
let h: i64 = a.not();
|
||||
|
||||
// binary
|
||||
let j: i64 = a.add(b);
|
||||
let k: i64 = a.add_wrapped(b);
|
||||
let l: i64 = a.and(b);
|
||||
let m: i64 = a.div(b);
|
||||
let n: i64 = a.div_wrapped(b);
|
||||
let o: bool = a.eq(b);
|
||||
let p: bool = a.ge(b);
|
||||
let q: bool = a.gt(b);
|
||||
let r: bool = a.le(b);
|
||||
let s: bool = a.lt(b);
|
||||
let t: i64 = a.mul(b);
|
||||
let u: i64 = a.mul_wrapped(b);
|
||||
let w: bool = a.neq(b);
|
||||
let y: i64 = a.or(b);
|
||||
let z: i64 = a.pow(2u8);
|
||||
let aa: i64 = a.pow(2u16);
|
||||
let ab: i64 = a.pow(2u32);
|
||||
let ac: i64 = a.pow_wrapped(2u8);
|
||||
let ad: i64 = a.pow_wrapped(2u16);
|
||||
let ae: i64 = a.pow_wrapped(2u32);
|
||||
let af: i64 = a.shl(2u8);
|
||||
let ag: i64 = a.shl(2u16);
|
||||
let ah: i64 = a.shl(2u32);
|
||||
let ai: i64 = a.shl_wrapped(2u8);
|
||||
let aj: i64 = a.shl_wrapped(2u16);
|
||||
let ak: i64 = a.shl_wrapped(2u32);
|
||||
let al: i64 = a.shr(2u8);
|
||||
let am: i64 = a.shr(2u16);
|
||||
let an: i64 = a.shr(2u32);
|
||||
let ao: i64 = a.shr_wrapped(2u8);
|
||||
let ap: i64 = a.shr_wrapped(2u16);
|
||||
let aq: i64 = a.shr_wrapped(2u32);
|
||||
let ar: i64 = a.xor(b);
|
||||
|
||||
return a == b;
|
||||
}
|
9
tests/compiler/integers/i64/or.leo
Normal file
9
tests/compiler/integers/i64/or.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i64, b: i64, c: i64) -> bool {
|
||||
return a | b == c;
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
expectation: Pass
|
||||
input_file: inputs/pow.in
|
||||
*/
|
||||
|
||||
function main(a: i64, b: i64, c: i64) -> bool {
|
||||
return a ** b == c;
|
||||
return a ** 2u8 == a ** 2u16 && a ** 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i64/shl.leo
Normal file
9
tests/compiler/integers/i64/shl.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i64, b: i64, c: i64) -> bool {
|
||||
return a << 2u8 == a << 2u16 && a << 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i64/shr.leo
Normal file
9
tests/compiler/integers/i64/shr.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i64, b: i64, c: i64) -> bool {
|
||||
return a >> 2u8 == a >> 2u16 && a >> 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i64/xor.leo
Normal file
9
tests/compiler/integers/i64/xor.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i64, b: i64, c: i64) -> bool {
|
||||
return a ^ 2u8 == a ^ 2u16 && a ^ 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i8/and.leo
Normal file
9
tests/compiler/integers/i8/and.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i8, b: i8, c: i8) -> bool {
|
||||
return a & b == c;
|
||||
}
|
50
tests/compiler/integers/i8/operator_methods.leo
Normal file
50
tests/compiler/integers/i8/operator_methods.leo
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i8, b: i8) -> bool {
|
||||
// unary
|
||||
let c: i8 = a.abs();
|
||||
let d: i8 = a.abs_wrapped();
|
||||
let g: i8 = a.neg();
|
||||
let h: i8 = a.not();
|
||||
|
||||
// binary
|
||||
let j: i8 = a.add(b);
|
||||
let k: i8 = a.add_wrapped(b);
|
||||
let l: i8 = a.and(b);
|
||||
let m: i8 = a.div(b);
|
||||
let n: i8 = a.div_wrapped(b);
|
||||
let o: bool = a.eq(b);
|
||||
let p: bool = a.ge(b);
|
||||
let q: bool = a.gt(b);
|
||||
let r: bool = a.le(b);
|
||||
let s: bool = a.lt(b);
|
||||
let t: i8 = a.mul(b);
|
||||
let u: i8 = a.mul_wrapped(b);
|
||||
let w: bool = a.neq(b);
|
||||
let y: i8 = a.or(b);
|
||||
let z: i8 = a.pow(2u8);
|
||||
let aa: i8 = a.pow(2u16);
|
||||
let ab: i8 = a.pow(2u32);
|
||||
let ac: i8 = a.pow_wrapped(2u8);
|
||||
let ad: i8 = a.pow_wrapped(2u16);
|
||||
let ae: i8 = a.pow_wrapped(2u32);
|
||||
let af: i8 = a.shl(2u8);
|
||||
let ag: i8 = a.shl(2u16);
|
||||
let ah: i8 = a.shl(2u32);
|
||||
let ai: i8 = a.shl_wrapped(2u8);
|
||||
let aj: i8 = a.shl_wrapped(2u16);
|
||||
let ak: i8 = a.shl_wrapped(2u32);
|
||||
let al: i8 = a.shr(2u8);
|
||||
let am: i8 = a.shr(2u16);
|
||||
let an: i8 = a.shr(2u32);
|
||||
let ao: i8 = a.shr_wrapped(2u8);
|
||||
let ap: i8 = a.shr_wrapped(2u16);
|
||||
let aq: i8 = a.shr_wrapped(2u32);
|
||||
let ar: i8 = a.xor(b);
|
||||
|
||||
return a == b;
|
||||
}
|
9
tests/compiler/integers/i8/or.leo
Normal file
9
tests/compiler/integers/i8/or.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i8, b: i8, c: i8) -> bool {
|
||||
return a | b == c;
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
expectation: Pass
|
||||
input_file: inputs/pow.in
|
||||
*/
|
||||
|
||||
function main(a: i8, b: i8, c: i8) -> bool {
|
||||
return a ** b == c;
|
||||
return a ** 2u8 == a ** 2u16 && a ** 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i8/shl.leo
Normal file
9
tests/compiler/integers/i8/shl.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i8, b: i8, c: i8) -> bool {
|
||||
return a << 2u8 == a << 2u16 && a << 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i8/shr.leo
Normal file
9
tests/compiler/integers/i8/shr.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i8, b: i8, c: i8) -> bool {
|
||||
return a >> 2u8 == a >> 2u16 && a >> 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/i8/xor.leo
Normal file
9
tests/compiler/integers/i8/xor.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i8, b: i8, c: i8) -> bool {
|
||||
return a ^ 2u8 == a ^ 2u16 && a ^ 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/u128/and.leo
Normal file
9
tests/compiler/integers/u128/and.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u128, b: u128, c: u128) -> bool {
|
||||
return a & b == c;
|
||||
}
|
49
tests/compiler/integers/u128/operator_methods.leo
Normal file
49
tests/compiler/integers/u128/operator_methods.leo
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u128, b: u128) -> bool {
|
||||
// unary
|
||||
let c: u128 = a.abs();
|
||||
let d: u128 = a.abs_wrapped();
|
||||
let h: u128 = a.not();
|
||||
|
||||
// binary
|
||||
let j: u128 = a.add(b);
|
||||
let k: u128 = a.add_wrapped(b);
|
||||
let l: u128 = a.and(b);
|
||||
let m: u128 = a.div(b);
|
||||
let n: u128 = a.div_wrapped(b);
|
||||
let o: bool = a.eq(b);
|
||||
let p: bool = a.ge(b);
|
||||
let q: bool = a.gt(b);
|
||||
let r: bool = a.le(b);
|
||||
let s: bool = a.lt(b);
|
||||
let t: u128 = a.mul(b);
|
||||
let u: u128 = a.mul_wrapped(b);
|
||||
let w: bool = a.neq(b);
|
||||
let y: u128 = a.or(b);
|
||||
let z: u128 = a.pow(2u8);
|
||||
let aa: u128 = a.pow(2u16);
|
||||
let ab: u128 = a.pow(2u32);
|
||||
let ac: u128 = a.pow_wrapped(2u8);
|
||||
let ad: u128 = a.pow_wrapped(2u16);
|
||||
let ae: u128 = a.pow_wrapped(2u32);
|
||||
let af: u128 = a.shl(2u8);
|
||||
let ag: u128 = a.shl(2u16);
|
||||
let ah: u128 = a.shl(2u32);
|
||||
let ai: u128 = a.shl_wrapped(2u8);
|
||||
let aj: u128 = a.shl_wrapped(2u16);
|
||||
let ak: u128 = a.shl_wrapped(2u32);
|
||||
let al: u128 = a.shr(2u8);
|
||||
let am: u128 = a.shr(2u16);
|
||||
let an: u128 = a.shr(2u32);
|
||||
let ao: u128 = a.shr_wrapped(2u8);
|
||||
let ap: u128 = a.shr_wrapped(2u16);
|
||||
let aq: u128 = a.shr_wrapped(2u32);
|
||||
let ar: u128 = a.xor(b);
|
||||
|
||||
return a == b;
|
||||
}
|
9
tests/compiler/integers/u128/or.leo
Normal file
9
tests/compiler/integers/u128/or.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u128, b: u128, c: u128) -> bool {
|
||||
return a | b == c;
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
expectation: Pass
|
||||
|
||||
# The exponent must be u8, u16, or u32
|
||||
*/
|
||||
|
||||
function main(a: u128, b: u128, c: u128) -> bool {
|
||||
return a ** b == c;
|
||||
return a ** 2u8 == a ** 2u16 && a ** 2u32 == c;
|
||||
}
|
||||
|
9
tests/compiler/integers/u128/shl.leo
Normal file
9
tests/compiler/integers/u128/shl.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u128, b: u128, c: u128) -> bool {
|
||||
return a << 2u8 == a << 2u16 && a << 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/u128/shr.leo
Normal file
9
tests/compiler/integers/u128/shr.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u128, b: u128, c: u128) -> bool {
|
||||
return a >> 2u8 == a >> 2u16 && a >> 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/u128/xor.leo
Normal file
9
tests/compiler/integers/u128/xor.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u128, b: u128, c: u128) -> bool {
|
||||
return a ^ 2u8 == a ^ 2u16 && a ^ 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/u16/and.leo
Normal file
9
tests/compiler/integers/u16/and.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u16, b: u16, c: u16) -> bool {
|
||||
return a & b == c;
|
||||
}
|
55
tests/compiler/integers/u16/operator_methods.leo
Normal file
55
tests/compiler/integers/u16/operator_methods.leo
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u16, b: u16) -> bool {
|
||||
// unary
|
||||
let c: u16 = a.abs();
|
||||
let d: u16 = a.abs_wrapped();
|
||||
let h: u16 = a.not();
|
||||
|
||||
// binary
|
||||
let j: u16 = a.add(b);
|
||||
let k: u16 = a.add_wrapped(b);
|
||||
let l: u16 = a.and(b);
|
||||
let m: u16 = a.div(b);
|
||||
let n: u16 = a.div_wrapped(b);
|
||||
let o: bool = a.eq(b);
|
||||
let p: bool = a.ge(b);
|
||||
let q: bool = a.gt(b);
|
||||
let r: bool = a.le(b);
|
||||
let s: bool = a.lt(b);
|
||||
let t: u16 = a.mul(b);
|
||||
let u: u16 = a.mul_wrapped(b);
|
||||
let w: bool = a.neq(b);
|
||||
let y: u16 = a.or(b);
|
||||
let z: u16 = a.pow(2u8);
|
||||
let aa: u16 = a.pow(b);
|
||||
let ab: u16 = a.pow(2u32);
|
||||
let ac: u16 = a.pow_wrapped(2u8);
|
||||
let ad: u16 = a.pow_wrapped(b);
|
||||
let ae: u16 = a.pow_wrapped(2u32);
|
||||
let af: u16 = a.shl(2u8);
|
||||
let ag: u16 = a.shl(b);
|
||||
let ah: u16 = a.shl(2u32);
|
||||
let ai: u16 = a.shl_wrapped(2u8);
|
||||
let aj: u16 = a.shl_wrapped(b);
|
||||
let ak: u16 = a.shl_wrapped(2u32);
|
||||
let al: u16 = a.shr(2u8);
|
||||
let am: u16 = a.shr(b);
|
||||
let an: u16 = a.shr(2u32);
|
||||
let ao: u16 = a.shr_wrapped(2u8);
|
||||
let ap: u16 = a.shr_wrapped(b);
|
||||
let aq: u16 = a.shr_wrapped(2u32);
|
||||
let ar: u16 = a.xor(b);
|
||||
|
||||
return a == b;
|
||||
}
|
9
tests/compiler/integers/u16/or.leo
Normal file
9
tests/compiler/integers/u16/or.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u16, b: u16, c: u16) -> bool {
|
||||
return a | b == c;
|
||||
}
|
@ -5,5 +5,5 @@ input_file: inputs/pow.in
|
||||
*/
|
||||
|
||||
function main(a: u16, b: u16, c: u16) -> bool {
|
||||
return a ** b == c;
|
||||
return a ** 2u8 == a ** b && a ** 2u32 == c;
|
||||
}
|
||||
|
9
tests/compiler/integers/u16/shl.leo
Normal file
9
tests/compiler/integers/u16/shl.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u16, b: u16, c: u16) -> bool {
|
||||
return a << 2u8 == a << b && a << 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/u16/shr.leo
Normal file
9
tests/compiler/integers/u16/shr.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u16, b: u16, c: u16) -> bool {
|
||||
return a >> 2u8 == a >> b && a >> 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/u16/xor.leo
Normal file
9
tests/compiler/integers/u16/xor.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u16, b: u16, c: u16) -> bool {
|
||||
return a ^ 2u8 == a ^ b && a ^ 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/u32/and.leo
Normal file
9
tests/compiler/integers/u32/and.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u32, b: u32, c: u32) -> bool {
|
||||
return a & b == c;
|
||||
}
|
55
tests/compiler/integers/u32/operator_methods.leo
Normal file
55
tests/compiler/integers/u32/operator_methods.leo
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u32, b: u32) -> bool {
|
||||
// unary
|
||||
let c: u32 = a.abs();
|
||||
let d: u32 = a.abs_wrapped();
|
||||
let h: u32 = a.not();
|
||||
|
||||
// binary
|
||||
let j: u32 = a.add(b);
|
||||
let k: u32 = a.add_wrapped(b);
|
||||
let l: u32 = a.and(b);
|
||||
let m: u32 = a.div(b);
|
||||
let n: u32 = a.div_wrapped(b);
|
||||
let o: bool = a.eq(b);
|
||||
let p: bool = a.ge(b);
|
||||
let q: bool = a.gt(b);
|
||||
let r: bool = a.le(b);
|
||||
let s: bool = a.lt(b);
|
||||
let t: u32 = a.mul(b);
|
||||
let u: u32 = a.mul_wrapped(b);
|
||||
let w: bool = a.neq(b);
|
||||
let y: u32 = a.or(b);
|
||||
let z: u32 = a.pow(2u8);
|
||||
let aa: u32 = a.pow(2u16);
|
||||
let ab: u32 = a.pow(b);
|
||||
let ac: u32 = a.pow_wrapped(2u8);
|
||||
let ad: u32 = a.pow_wrapped(2u16);
|
||||
let ae: u32 = a.pow_wrapped(b);
|
||||
let af: u32 = a.shl(2u8);
|
||||
let ag: u32 = a.shl(2u16);
|
||||
let ah: u32 = a.shl(b);
|
||||
let ai: u32 = a.shl_wrapped(2u8);
|
||||
let aj: u32 = a.shl_wrapped(2u16);
|
||||
let ak: u32 = a.shl_wrapped(b);
|
||||
let al: u32 = a.shr(2u8);
|
||||
let am: u32 = a.shr(2u16);
|
||||
let an: u32 = a.shr(b);
|
||||
let ao: u32 = a.shr_wrapped(2u8);
|
||||
let ap: u32 = a.shr_wrapped(2u16);
|
||||
let aq: u32 = a.shr_wrapped(b);
|
||||
let ar: u32 = a.xor(b);
|
||||
|
||||
return a == b;
|
||||
}
|
9
tests/compiler/integers/u32/or.leo
Normal file
9
tests/compiler/integers/u32/or.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u32, b: u32, c: u32) -> bool {
|
||||
return a | b == c;
|
||||
}
|
@ -8,5 +8,5 @@ input_file: inputs/pow.in
|
||||
*/
|
||||
|
||||
function main(a: u32, b: u32, c: u32) -> bool {
|
||||
return a ** b == c;
|
||||
return a ** 2u8 == a ** 2u16 && a ** b == c;
|
||||
}
|
||||
|
9
tests/compiler/integers/u32/shl.leo
Normal file
9
tests/compiler/integers/u32/shl.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u32, b: u32, c: u32) -> bool {
|
||||
return a << 2u8 == a << 2u16 && a << b == c;
|
||||
}
|
9
tests/compiler/integers/u32/shr.leo
Normal file
9
tests/compiler/integers/u32/shr.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u32, b: u32, c: u32) -> bool {
|
||||
return a >> 2u8 == a >> 2u16 && a >> b == c;
|
||||
}
|
9
tests/compiler/integers/u32/xor.leo
Normal file
9
tests/compiler/integers/u32/xor.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u32, b: u32, c: u32) -> bool {
|
||||
return a ^ 2u8 == a ^ 2u16 && a ^ b == c;
|
||||
}
|
9
tests/compiler/integers/u64/and.leo
Normal file
9
tests/compiler/integers/u64/and.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u64, b: u64, c: u64) -> bool {
|
||||
return a & b == c;
|
||||
}
|
49
tests/compiler/integers/u64/operator_methods.leo
Normal file
49
tests/compiler/integers/u64/operator_methods.leo
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u64, b: u64) -> bool {
|
||||
// unary
|
||||
let c: u64 = a.abs();
|
||||
let d: u64 = a.abs_wrapped();
|
||||
let h: u64 = a.not();
|
||||
|
||||
// binary
|
||||
let j: u64 = a.add(b);
|
||||
let k: u64 = a.add_wrapped(b);
|
||||
let l: u64 = a.and(b);
|
||||
let m: u64 = a.div(b);
|
||||
let n: u64 = a.div_wrapped(b);
|
||||
let o: bool = a.eq(b);
|
||||
let p: bool = a.ge(b);
|
||||
let q: bool = a.gt(b);
|
||||
let r: bool = a.le(b);
|
||||
let s: bool = a.lt(b);
|
||||
let t: u64 = a.mul(b);
|
||||
let u: u64 = a.mul_wrapped(b);
|
||||
let w: bool = a.neq(b);
|
||||
let y: u64 = a.or(b);
|
||||
let z: u64 = a.pow(2u8);
|
||||
let aa: u64 = a.pow(2u16);
|
||||
let ab: u64 = a.pow(2u32);
|
||||
let ac: u64 = a.pow_wrapped(2u8);
|
||||
let ad: u64 = a.pow_wrapped(2u16);
|
||||
let ae: u64 = a.pow_wrapped(2u32);
|
||||
let af: u64 = a.shl(2u8);
|
||||
let ag: u64 = a.shl(2u16);
|
||||
let ah: u64 = a.shl(2u32);
|
||||
let ai: u64 = a.shl_wrapped(2u8);
|
||||
let aj: u64 = a.shl_wrapped(2u16);
|
||||
let ak: u64 = a.shl_wrapped(2u32);
|
||||
let al: u64 = a.shr(2u8);
|
||||
let am: u64 = a.shr(2u16);
|
||||
let an: u64 = a.shr(2u32);
|
||||
let ao: u64 = a.shr_wrapped(2u8);
|
||||
let ap: u64 = a.shr_wrapped(2u16);
|
||||
let aq: u64 = a.shr_wrapped(2u32);
|
||||
let ar: u64 = a.xor(b);
|
||||
|
||||
return a == b;
|
||||
}
|
9
tests/compiler/integers/u64/or.leo
Normal file
9
tests/compiler/integers/u64/or.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u64, b: u64, c: u64) -> bool {
|
||||
return a | b == c;
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
expectation: Pass
|
||||
input_file: inputs/pow.in
|
||||
|
||||
# The exponent must be u8, u16, or u32
|
||||
*/
|
||||
|
||||
function main(a: u64, b: u64, c: u64) -> bool {
|
||||
return a ** b == c;
|
||||
return a ** 2u8 == a ** 2u16 && a ** 2u32 == c;
|
||||
}
|
||||
|
9
tests/compiler/integers/u64/shl.leo
Normal file
9
tests/compiler/integers/u64/shl.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u64, b: u64, c: u64) -> bool {
|
||||
return a << 2u8 == a << 2u16 && a << 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/u64/shr.leo
Normal file
9
tests/compiler/integers/u64/shr.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u64, b: u64, c: u64) -> bool {
|
||||
return a >> 2u8 == a >> 2u16 && a >> 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/u64/xor.leo
Normal file
9
tests/compiler/integers/u64/xor.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u64, b: u64, c: u64) -> bool {
|
||||
return a ^ 2u8 == a ^ 2u16 && a ^ 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/u8/and.leo
Normal file
9
tests/compiler/integers/u8/and.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u8, b: u8, c: u8) -> bool {
|
||||
return a & b == c;
|
||||
}
|
49
tests/compiler/integers/u8/operator_methods.leo
Normal file
49
tests/compiler/integers/u8/operator_methods.leo
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u8, b: u8) -> bool {
|
||||
// unary
|
||||
let c: u8 = a.abs();
|
||||
let d: u8 = a.abs_wrapped();
|
||||
let h: u8 = a.not();
|
||||
|
||||
// binary
|
||||
let j: u8 = a.add(b);
|
||||
let k: u8 = a.add_wrapped(b);
|
||||
let l: u8 = a.and(b);
|
||||
let m: u8 = a.div(b);
|
||||
let n: u8 = a.div_wrapped(b);
|
||||
let o: bool = a.eq(b);
|
||||
let p: bool = a.ge(b);
|
||||
let q: bool = a.gt(b);
|
||||
let r: bool = a.le(b);
|
||||
let s: bool = a.lt(b);
|
||||
let t: u8 = a.mul(b);
|
||||
let u: u8 = a.mul_wrapped(b);
|
||||
let w: bool = a.neq(b);
|
||||
let y: u8 = a.or(b);
|
||||
let z: u8 = a.pow(b);
|
||||
let aa: u8 = a.pow(2u16);
|
||||
let ab: u8 = a.pow(2u32);
|
||||
let ac: u8 = a.pow_wrapped(b);
|
||||
let ad: u8 = a.pow_wrapped(2u16);
|
||||
let ae: u8 = a.pow_wrapped(2u32);
|
||||
let af: u8 = a.shl(b);
|
||||
let ag: u8 = a.shl(2u16);
|
||||
let ah: u8 = a.shl(2u32);
|
||||
let ai: u8 = a.shl_wrapped(b);
|
||||
let aj: u8 = a.shl_wrapped(2u16);
|
||||
let ak: u8 = a.shl_wrapped(2u32);
|
||||
let al: u8 = a.shr(b);
|
||||
let am: u8 = a.shr(2u16);
|
||||
let an: u8 = a.shr(2u32);
|
||||
let ao: u8 = a.shr_wrapped(b);
|
||||
let ap: u8 = a.shr_wrapped(2u16);
|
||||
let aq: u8 = a.shr_wrapped(2u32);
|
||||
let ar: u8 = a.xor(b);
|
||||
|
||||
return a == b;
|
||||
}
|
9
tests/compiler/integers/u8/or.leo
Normal file
9
tests/compiler/integers/u8/or.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u8, b: u8, c: u8) -> bool {
|
||||
return a | b == c;
|
||||
}
|
@ -5,5 +5,5 @@ input_file: inputs/pow.in
|
||||
*/
|
||||
|
||||
function main(a: u8, b: u8, c: u8) -> bool {
|
||||
return a ** b == c;
|
||||
return a ** b == a ** 2u16 && a ** 2u32 == c;
|
||||
}
|
||||
|
9
tests/compiler/integers/u8/shl.leo
Normal file
9
tests/compiler/integers/u8/shl.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u8, b: u8, c: u8) -> bool {
|
||||
return a << b == a << 2u16 && a << 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/u8/shr.leo
Normal file
9
tests/compiler/integers/u8/shr.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u8, b: u8, c: u8) -> bool {
|
||||
return a >> b == a >> 2u16 && a >> 2u32 == c;
|
||||
}
|
9
tests/compiler/integers/u8/xor.leo
Normal file
9
tests/compiler/integers/u8/xor.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: u8, b: u8, c: u8) -> bool {
|
||||
return a ^ b == a ^ 2u16 && a ^ 2u32 == c;
|
||||
}
|
24
tests/compiler/scalar/operator_methods.leo
Normal file
24
tests/compiler/scalar/operator_methods.leo
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file:
|
||||
- inputs/scalars.in
|
||||
*/
|
||||
|
||||
function main(a: scalar, b: scalar) -> bool {
|
||||
// unary
|
||||
let i: scalar = a.sqrt();
|
||||
|
||||
// binary
|
||||
let j: scalar = a.add(b);
|
||||
let o: bool = a.eq(b);
|
||||
let p: bool = a.ge(b);
|
||||
let q: bool = a.gt(b);
|
||||
let r: bool = a.le(b);
|
||||
let s: bool = a.lt(b);
|
||||
let t: group = 2group.mul(b);
|
||||
let u: group = a.mul(2group);
|
||||
let w: bool = a.neq(b);
|
||||
|
||||
return a == b;
|
||||
}
|
8
tests/expectations/compiler/compiler/address/binary.out
Normal file
8
tests/expectations/compiler/compiler/address/binary.out
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: ed65ff9337fc5a00cd28d780a985bcb05de7d0e5fe02b555774984552f0c14e8
|
||||
initial_ast: c920b653c76c858673ef791ad9f7b42bd8b70e9ddc2c9bd80c48c531f654334f
|
||||
symbol_table: b736692dc7bdc91c5a808a20a3965f4c8ed2c46c212696d33fc6dd4cfc9a5844
|
@ -0,0 +1,11 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: b60204e9191bfb24680632af160fc62316e8b8043c0e3908c157855cc5547eb3
|
||||
- initial_input_ast: 023263dbb2c455cbc5507aa39f8de80d8d1dbdce22e979302f29046261206ee4
|
||||
- initial_input_ast: a4ec20e71f9401cb0f085770a98cbafb7ca39b4606215cd044ab413790653294
|
||||
- initial_input_ast: a90726f08c89ae8eeb4becffd30d13acaa925902d2a29b59842dfc9ee8dc2e3a
|
||||
initial_ast: b8707d1d3f6c111db2515d4093d15b4739765bfb9e114ed345ebedce0c04024d
|
||||
symbol_table: e6f7abfd330837d1c643b6b7465c02333b1c895e3e6f624085e8e956ab6e5fe5
|
@ -1,8 +1,5 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: no input
|
||||
initial_ast: 0d3f6d046e06638ff0a22e142982cc29c349117dcbd722cb6334cd66c2be3219
|
||||
symbol_table: 533169a9c16acf0947feb73f24400d339173893e0691d7d6bc262f9a3cc6dcce
|
||||
- "Error [ETYC0372013]: The type ComputeKey is a reserved core type name.\n --> compiler-test:4:35\n |\n 4 | function main(public compute_key: ComputeKey, a: bool) -> bool {\n | ^^^^^^^^^^\n"
|
||||
|
@ -1,8 +1,5 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: no input
|
||||
initial_ast: c4b937afc608d8a4aeab6a0daba79a66e651237ca6268d0fc4a183092ee8908b
|
||||
symbol_table: d2e68d11f0c2bacb8e8dc3e2131c8ce8ed3246b2f2798d24666080ae1c8de2bb
|
||||
- "Error [ETYC0372013]: The type PrivateKey is a reserved core type name.\n --> compiler-test:4:35\n |\n 4 | function main(public private_key: PrivateKey, a: bool) -> bool {\n | ^^^^^^^^^^\n"
|
||||
|
@ -1,8 +1,5 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: no input
|
||||
initial_ast: bc3f30018bab5d022864d1e9224600af6a1601e362392831f2df670d28757626
|
||||
symbol_table: c97101911c52e7e13511a056edbbfbb45a7460b70d9eb40787790d96e9759881
|
||||
- "Error [ETYC0372013]: The type Record is a reserved core type name.\n --> compiler-test:4:30\n |\n 4 | function main(public record: Record, a: bool) -> bool {\n | ^^^^^^\n"
|
||||
|
@ -1,8 +1,5 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: no input
|
||||
initial_ast: 7e9b3271337d1985002f48c9f6798650414b5bbd2a3f3b3fb6af450568c3261e
|
||||
symbol_table: 951448c8c85b3ea9013ca01d10acf398b733c871e0283af29493620db422c83e
|
||||
- "Error [ETYC0372013]: The type Signature is a reserved core type name.\n --> compiler-test:4:33\n |\n 4 | function main(public signature: Signature, a: bool) -> bool {\n | ^^^^^^^^^\n"
|
||||
|
@ -1,8 +1,5 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: no input
|
||||
initial_ast: ccfb34b6626d3a257fdd09a912ee7ac12550e75f7a14950cc9e1ae3867bc1b12
|
||||
symbol_table: 6a2947d1d7af5c250ea9e5f02c70b08143d840377d3f4794bb6e605236d477e5
|
||||
- "Error [ETYC0372013]: The type ViewKey is a reserved core type name.\n --> compiler-test:4:32\n |\n 4 | function main(public view_key: ViewKey, a: bool) -> bool {\n | ^^^^^^^\n"
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user