ReasonLIGO pretty printing testing.
This commit is contained in:
parent
e9f5c3e1ae
commit
c8ed8c38cc
@ -317,7 +317,7 @@ and pp_projection {value; _} =
|
|||||||
let fields = Utils.nsepseq_to_list field_path
|
let fields = Utils.nsepseq_to_list field_path
|
||||||
and sep = string "." ^^ break 0 in
|
and sep = string "." ^^ break 0 in
|
||||||
let fields = separate_map sep pp_selection fields in
|
let fields = separate_map sep pp_selection fields in
|
||||||
group (pp_ident struct_name ^^ string "." ^^ break 0 ^^ fields)
|
group (pp_ident struct_name ^^ break 0 ^^ string "[" ^^ fields ^^ string "]")
|
||||||
|
|
||||||
and pp_selection = function
|
and pp_selection = function
|
||||||
FieldName v -> string v.value
|
FieldName v -> string v.value
|
||||||
|
165
src/test/contracts/dune
Normal file
165
src/test/contracts/dune
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
(rule (targets address.output) (action (with-stdout-to address.output (run ligo "pretty-print" "address.religo"))))
|
||||||
|
(rule (targets amount.output) (action (with-stdout-to amount.output (run ligo "pretty-print" "amount.religo"))))
|
||||||
|
(rule (targets arithmetic.output) (action (with-stdout-to arithmetic.output (run ligo "pretty-print" "arithmetic.religo"))))
|
||||||
|
(rule (targets bad_address_format.output) (action (with-stdout-to bad_address_format.output (run ligo "pretty-print" "bad_address_format.religo"))))
|
||||||
|
(rule (targets balance_constant.output) (action (with-stdout-to balance_constant.output (run ligo "pretty-print" "balance_constant.religo"))))
|
||||||
|
(rule (targets bitwise_arithmetic.output) (action (with-stdout-to bitwise_arithmetic.output (run ligo "pretty-print" "bitwise_arithmetic.religo"))))
|
||||||
|
(rule (targets boolean_operators.output) (action (with-stdout-to boolean_operators.output (run ligo "pretty-print" "boolean_operators.religo"))))
|
||||||
|
(rule (targets bytes_arithmetic.output) (action (with-stdout-to bytes_arithmetic.output (run ligo "pretty-print" "bytes_arithmetic.religo"))))
|
||||||
|
(rule (targets bytes_unpack.output) (action (with-stdout-to bytes_unpack.output (run ligo "pretty-print" "bytes_unpack.religo"))))
|
||||||
|
(rule (targets check_signature.output) (action (with-stdout-to check_signature.output (run ligo "pretty-print" "check_signature.religo"))))
|
||||||
|
(rule (targets closure.output) (action (with-stdout-to closure.output (run ligo "pretty-print" "closure.religo"))))
|
||||||
|
(rule (targets condition-shadowing.output) (action (with-stdout-to condition-shadowing.output (run ligo "pretty-print" "condition-shadowing.religo"))))
|
||||||
|
(rule (targets condition.output) (action (with-stdout-to condition.output (run ligo "pretty-print" "condition.religo"))))
|
||||||
|
(rule (targets counter.output) (action (with-stdout-to counter.output (run ligo "pretty-print" "counter.religo"))))
|
||||||
|
(rule (targets crypto.output) (action (with-stdout-to crypto.output (run ligo "pretty-print" "crypto.religo"))))
|
||||||
|
(rule (targets empty_case.output) (action (with-stdout-to empty_case.output (run ligo "pretty-print" "empty_case.religo"))))
|
||||||
|
(rule (targets eq_bool.output) (action (with-stdout-to eq_bool.output (run ligo "pretty-print" "eq_bool.religo"))))
|
||||||
|
(rule (targets failwith.output) (action (with-stdout-to failwith.output (run ligo "pretty-print" "failwith.religo"))))
|
||||||
|
(rule (targets function-shared.output) (action (with-stdout-to function-shared.output (run ligo "pretty-print" "function-shared.religo"))))
|
||||||
|
(rule (targets high-order.output) (action (with-stdout-to high-order.output (run ligo "pretty-print" "high-order.religo"))))
|
||||||
|
(rule (targets implicit_account.output) (action (with-stdout-to implicit_account.output (run ligo "pretty-print" "implicit_account.religo"))))
|
||||||
|
(rule (targets included.output) (action (with-stdout-to included.output (run ligo "pretty-print" "included.religo"))))
|
||||||
|
(rule (targets includer.output) (action (with-stdout-to includer.output (run ligo "pretty-print" "includer.religo"))))
|
||||||
|
(rule (targets key_hash.output) (action (with-stdout-to key_hash.output (run ligo "pretty-print" "key_hash.religo"))))
|
||||||
|
(rule (targets lambda.output) (action (with-stdout-to lambda.output (run ligo "pretty-print" "lambda.religo"))))
|
||||||
|
(rule (targets lambda2.output) (action (with-stdout-to lambda2.output (run ligo "pretty-print" "lambda2.religo"))))
|
||||||
|
(rule (targets let_multiple.output) (action (with-stdout-to let_multiple.output (run ligo "pretty-print" "let_multiple.religo"))))
|
||||||
|
(rule (targets letin.output) (action (with-stdout-to letin.output (run ligo "pretty-print" "letin.religo"))))
|
||||||
|
(rule (targets list.output) (action (with-stdout-to list.output (run ligo "pretty-print" "list.religo"))))
|
||||||
|
(rule (targets loop.output) (action (with-stdout-to loop.output (run ligo "pretty-print" "loop.religo"))))
|
||||||
|
(rule (targets map.output) (action (with-stdout-to map.output (run ligo "pretty-print" "map.religo"))))
|
||||||
|
(rule (targets match_bis.output) (action (with-stdout-to match_bis.output (run ligo "pretty-print" "match_bis.religo"))))
|
||||||
|
(rule (targets match.output) (action (with-stdout-to match.output (run ligo "pretty-print" "match.religo"))))
|
||||||
|
(rule (targets michelson_pair_tree.output) (action (with-stdout-to michelson_pair_tree.output (run ligo "pretty-print" "michelson_pair_tree.religo"))))
|
||||||
|
(rule (targets multiple-parameters.output) (action (with-stdout-to multiple-parameters.output (run ligo "pretty-print" "multiple-parameters.religo"))))
|
||||||
|
(rule (targets multisig.output) (action (with-stdout-to multisig.output (run ligo "pretty-print" "multisig.religo"))))
|
||||||
|
(rule (targets no_semicolon.output) (action (with-stdout-to no_semicolon.output (run ligo "pretty-print" "no_semicolon.religo"))))
|
||||||
|
(rule (targets pledge.output) (action (with-stdout-to pledge.output (run ligo "pretty-print" "pledge.religo"))))
|
||||||
|
(rule (targets record.output) (action (with-stdout-to record.output (run ligo "pretty-print" "record.religo"))))
|
||||||
|
(rule (targets recursion.output) (action (with-stdout-to recursion.output (run ligo "pretty-print" "recursion.religo"))))
|
||||||
|
(rule (targets self_address.output) (action (with-stdout-to self_address.output (run ligo "pretty-print" "self_address.religo"))))
|
||||||
|
(rule (targets set_arithmetic.output) (action (with-stdout-to set_arithmetic.output (run ligo "pretty-print" "set_arithmetic.religo"))))
|
||||||
|
(rule (targets set_delegate.output) (action (with-stdout-to set_delegate.output (run ligo "pretty-print" "set_delegate.religo"))))
|
||||||
|
(rule (targets single_record_item.output) (action (with-stdout-to single_record_item.output (run ligo "pretty-print" "single_record_item.religo"))))
|
||||||
|
(rule (targets string_arithmetic.output) (action (with-stdout-to string_arithmetic.output (run ligo "pretty-print" "string_arithmetic.religo"))))
|
||||||
|
(rule (targets super-counter.output) (action (with-stdout-to super-counter.output (run ligo "pretty-print" "super-counter.religo"))))
|
||||||
|
(rule (targets tuple_list.output) (action (with-stdout-to tuple_list.output (run ligo "pretty-print" "tuple_list.religo"))))
|
||||||
|
(rule (targets tuple_param_destruct.output) (action (with-stdout-to tuple_param_destruct.output (run ligo "pretty-print" "tuple_param_destruct.religo"))))
|
||||||
|
(rule (targets tuple_type.output) (action (with-stdout-to tuple_type.output (run ligo "pretty-print" "tuple_type.religo"))))
|
||||||
|
(rule (targets tuple.output) (action (with-stdout-to tuple.output (run ligo "pretty-print" "tuple.religo"))))
|
||||||
|
(rule (targets tuples_no_annotation.output) (action (with-stdout-to tuples_no_annotation.output (run ligo "pretty-print" "tuples_no_annotation.religo"))))
|
||||||
|
(rule (targets tuples_sequences_functions.output) (action (with-stdout-to tuples_sequences_functions.output (run ligo "pretty-print" "tuples_sequences_functions.religo"))))
|
||||||
|
(rule (targets variant.output) (action (with-stdout-to variant.output (run ligo "pretty-print" "variant.religo"))))
|
||||||
|
(rule (targets website2.output) (action (with-stdout-to website2.output (run ligo "pretty-print" "website2.religo"))))
|
||||||
|
|
||||||
|
|
||||||
|
(alias (name runtest) (action (diff expected/address.religo address.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/amount.religo amount.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/arithmetic.religo arithmetic.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/bad_address_format.religo bad_address_format.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/balance_constant.religo balance_constant.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/bitwise_arithmetic.religo bitwise_arithmetic.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/boolean_operators.religo boolean_operators.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/bytes_arithmetic.religo bytes_arithmetic.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/bytes_unpack.religo bytes_unpack.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/check_signature.religo check_signature.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/closure.religo closure.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/condition-shadowing.religo condition-shadowing.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/condition.religo condition.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/counter.religo counter.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/crypto.religo crypto.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/empty_case.religo empty_case.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/eq_bool.religo eq_bool.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/failwith.religo failwith.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/function-shared.religo function-shared.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/high-order.religo high-order.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/implicit_account.religo implicit_account.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/included.religo included.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/includer.religo includer.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/key_hash.religo key_hash.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/lambda.religo lambda.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/lambda2.religo lambda2.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/let_multiple.religo let_multiple.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/letin.religo letin.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/list.religo list.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/loop.religo loop.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/map.religo map.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/match_bis.religo match_bis.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/match.religo match.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/michelson_pair_tree.religo michelson_pair_tree.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/multiple-parameters.religo multiple-parameters.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/multisig.religo multisig.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/no_semicolon.religo no_semicolon.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/pledge.religo pledge.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/record.religo record.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/recursion.religo recursion.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/self_address.religo self_address.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/set_arithmetic.religo set_arithmetic.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/set_delegate.religo set_delegate.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/single_record_item.religo single_record_item.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/string_arithmetic.religo string_arithmetic.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/super-counter.religo super-counter.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/tuple_list.religo tuple_list.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/tuple_param_destruct.religo tuple_param_destruct.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/tuple_type.religo tuple_type.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/tuple.religo tuple.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/tuples_no_annotation.religo tuples_no_annotation.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/tuples_sequences_functions.religo tuples_sequences_functions.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/variant.religo variant.output)))
|
||||||
|
(alias (name runtest) (action (diff expected/website2.religo website2.output)))
|
||||||
|
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst address.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst amount.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst arithmetic.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst bad_address_format.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst balance_constant.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst bitwise_arithmetic.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst boolean_operators.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst bytes_arithmetic.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst bytes_unpack.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst check_signature.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst closure.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst condition-shadowing.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst condition.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst counter.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst crypto.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst empty_case.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst eq_bool.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst failwith.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst function-shared.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst high-order.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst implicit_account.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst included.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst includer.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst key_hash.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst lambda.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst lambda2.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst let_multiple.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst letin.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst list.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst loop.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst map.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst match_bis.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst match.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst michelson_pair_tree.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst multiple-parameters.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst multisig.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst no_semicolon.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst pledge.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst record.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst recursion.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst self_address.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst set_arithmetic.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst set_delegate.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst single_record_item.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst string_arithmetic.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst super-counter.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst tuple_list.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst tuple_param_destruct.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst tuple_type.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst tuple.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst tuples_no_annotation.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst tuples_sequences_functions.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst variant.output -s reasonligo))))
|
||||||
|
(alias (name runtest) (action (ignore-stdout (run ligo print-cst website2.output -s reasonligo))))
|
6
src/test/contracts/expected/address.religo
Normal file
6
src/test/contracts/expected/address.religo
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
let main =
|
||||||
|
(p: key_hash): address =>
|
||||||
|
{
|
||||||
|
let c: contract(unit) = Tezos.implicit_account(p);
|
||||||
|
Tezos.address(c)
|
||||||
|
};
|
8
src/test/contracts/expected/amount.religo
Normal file
8
src/test/contracts/expected/amount.religo
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
let check_ =
|
||||||
|
(p: unit): int =>
|
||||||
|
if(Tezos.amount
|
||||||
|
== 100000000mutez) {
|
||||||
|
42
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
};
|
17
src/test/contracts/expected/arithmetic.religo
Normal file
17
src/test/contracts/expected/arithmetic.religo
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
let mod_op = (n: int): nat => n mod 42;
|
||||||
|
|
||||||
|
let plus_op = (n: int): int => n + 42;
|
||||||
|
|
||||||
|
let minus_op = (n: int): int => n - 42;
|
||||||
|
|
||||||
|
let times_op = (n: int): int => n * 42;
|
||||||
|
|
||||||
|
let div_op = (n: int): int => n / 2;
|
||||||
|
|
||||||
|
let neg_op = (n: int): int => -n;
|
||||||
|
|
||||||
|
let foo = (n: int): int => n + 10;
|
||||||
|
|
||||||
|
let neg_op_2 = (b: int): int => -foo(b);
|
||||||
|
|
||||||
|
let ediv_op = (n: int): option((int, nat)) => ediv(n 2);
|
3
src/test/contracts/expected/bad_address_format.religo
Normal file
3
src/test/contracts/expected/bad_address_format.religo
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
let main =
|
||||||
|
(parameter: int, storage: address) =>
|
||||||
|
([] : list(operation), "KT1badaddr" : address);
|
7
src/test/contracts/expected/balance_constant.religo
Normal file
7
src/test/contracts/expected/balance_constant.religo
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
type storage = tez;
|
||||||
|
|
||||||
|
let main2 =
|
||||||
|
(p: unit, s: storage) =>
|
||||||
|
([] : list(operation), Tezos.balance);
|
||||||
|
|
||||||
|
let main = (x: (unit, storage)) => main2(x[0] x[1]);
|
9
src/test/contracts/expected/bitwise_arithmetic.religo
Normal file
9
src/test/contracts/expected/bitwise_arithmetic.religo
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
let or_op = (n: nat): nat => Bitwise.or(n 4n);
|
||||||
|
|
||||||
|
let and_op = (n: nat): nat => Bitwise.and(n 7n);
|
||||||
|
|
||||||
|
let xor_op = (n: nat): nat => Bitwise.xor(n 7n);
|
||||||
|
|
||||||
|
let lsl_op = (n: nat): nat => Bitwise.shift_left(n 7n);
|
||||||
|
|
||||||
|
let lsr_op = (n: nat): nat => Bitwise.shift_right(n 7n);
|
9
src/test/contracts/expected/boolean_operators.religo
Normal file
9
src/test/contracts/expected/boolean_operators.religo
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
let or_true = (b: bool): bool => b || true;
|
||||||
|
|
||||||
|
let or_false = (b: bool): bool => b || false;
|
||||||
|
|
||||||
|
let and_true = (b: bool): bool => b && true;
|
||||||
|
|
||||||
|
let and_false = (b: bool): bool => b && false;
|
||||||
|
|
||||||
|
let not_bool = (b: bool): bool => ! b;
|
5
src/test/contracts/expected/bytes_arithmetic.religo
Normal file
5
src/test/contracts/expected/bytes_arithmetic.religo
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
let concat_op = (s: bytes): bytes => Bytes.concat(s 0x7070);
|
||||||
|
|
||||||
|
let slice_op = (s: bytes): bytes => Bytes.slice(1n 2n s);
|
||||||
|
|
||||||
|
let hasherman = (s: bytes): bytes => Crypto.sha256(s);
|
20
src/test/contracts/expected/bytes_unpack.religo
Normal file
20
src/test/contracts/expected/bytes_unpack.religo
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
let id_string =
|
||||||
|
(p: string): option(string) =>
|
||||||
|
{
|
||||||
|
let packed: bytes = Bytes.pack(p);
|
||||||
|
((Bytes.unpack(packed)) : option(string))
|
||||||
|
};
|
||||||
|
|
||||||
|
let id_int =
|
||||||
|
(p: int): option(int) =>
|
||||||
|
{
|
||||||
|
let packed: bytes = Bytes.pack(p);
|
||||||
|
((Bytes.unpack(packed)) : option(int))
|
||||||
|
};
|
||||||
|
|
||||||
|
let id_address =
|
||||||
|
(p: address): option(address) =>
|
||||||
|
{
|
||||||
|
let packed: bytes = Bytes.pack(p);
|
||||||
|
((Bytes.unpack(packed)) : option(address))
|
||||||
|
};
|
6
src/test/contracts/expected/check_signature.religo
Normal file
6
src/test/contracts/expected/check_signature.religo
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
let check_signature =
|
||||||
|
(param: (key, signature, bytes)): bool =>
|
||||||
|
{
|
||||||
|
let (pk, signed, msg) = param;
|
||||||
|
Crypto.check(pk signed msg)
|
||||||
|
};
|
8
src/test/contracts/expected/closure.religo
Normal file
8
src/test/contracts/expected/closure.religo
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
let test =
|
||||||
|
(k: int): int =>
|
||||||
|
{
|
||||||
|
let j: int = k + 5;
|
||||||
|
let close: (int) => int) = (i: int) => i + j;
|
||||||
|
let j: int = 20;
|
||||||
|
close(20)
|
||||||
|
};
|
15
src/test/contracts/expected/condition-shadowing.religo
Normal file
15
src/test/contracts/expected/condition-shadowing.religo
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
let main =
|
||||||
|
(i: int) =>
|
||||||
|
{
|
||||||
|
let result = 0;
|
||||||
|
if(i
|
||||||
|
== 2) {
|
||||||
|
|
||||||
|
let result = 42;
|
||||||
|
result
|
||||||
|
} else {
|
||||||
|
|
||||||
|
let result = 0;
|
||||||
|
result
|
||||||
|
}
|
||||||
|
};
|
8
src/test/contracts/expected/condition.religo
Normal file
8
src/test/contracts/expected/condition.religo
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
let main =
|
||||||
|
(i: int) =>
|
||||||
|
if(i
|
||||||
|
== 2) {
|
||||||
|
42
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
};
|
5
src/test/contracts/expected/counter.religo
Normal file
5
src/test/contracts/expected/counter.religo
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
type storage = int;
|
||||||
|
|
||||||
|
let main =
|
||||||
|
((p, s): (int, storage)): (list(operation), storage) =>
|
||||||
|
([] : list(operation), p + s);
|
3
src/test/contracts/expected/crypto.religo
Normal file
3
src/test/contracts/expected/crypto.religo
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
let hasherman512 = (s: bytes) => Crypto.sha512(s);
|
||||||
|
|
||||||
|
let hasherman_blake = (s: bytes) => Crypto.blake2b(s);
|
8
src/test/contracts/expected/empty_case.religo
Normal file
8
src/test/contracts/expected/empty_case.religo
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
type foo = Bar(int) | Baz;
|
||||||
|
|
||||||
|
let main =
|
||||||
|
(f: foo): int =>
|
||||||
|
switch(f) {
|
||||||
|
| Bari => i
|
||||||
|
| Baz => (-1)
|
||||||
|
};
|
8
src/test/contracts/expected/eq_bool.religo
Normal file
8
src/test/contracts/expected/eq_bool.religo
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
let main =
|
||||||
|
((a, b): (bool, bool)) =>
|
||||||
|
if(a
|
||||||
|
== b) {
|
||||||
|
999
|
||||||
|
} else {
|
||||||
|
1
|
||||||
|
};
|
7
src/test/contracts/expected/failwith.religo
Normal file
7
src/test/contracts/expected/failwith.religo
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
type storage = unit;
|
||||||
|
|
||||||
|
let main =
|
||||||
|
(p: unit, storage) =>
|
||||||
|
if(true) {
|
||||||
|
failwith("This contract always fails")
|
||||||
|
};
|
5
src/test/contracts/expected/function-shared.religo
Normal file
5
src/test/contracts/expected/function-shared.religo
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
let foo = (i: int): int => i + 20;
|
||||||
|
|
||||||
|
let bar = (i: int): int => i + 50;
|
||||||
|
|
||||||
|
let foobar = (i: int): int => foo(i) + bar(i);
|
53
src/test/contracts/expected/high-order.religo
Normal file
53
src/test/contracts/expected/high-order.religo
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
let foobar =
|
||||||
|
(i: int): int =>
|
||||||
|
{
|
||||||
|
let foo: int) => int = (i: int) => i;
|
||||||
|
let bar: (int) => int) => int) =
|
||||||
|
(f: int) => int) => f(i);
|
||||||
|
bar(foo)
|
||||||
|
};
|
||||||
|
|
||||||
|
let higher2 =
|
||||||
|
(i: int, f: int) => int): int =>
|
||||||
|
{
|
||||||
|
let ii: int = f(i);
|
||||||
|
ii
|
||||||
|
};
|
||||||
|
|
||||||
|
let foobar2 =
|
||||||
|
(i: int): int =>
|
||||||
|
{
|
||||||
|
let foo2: int) => int = (i: int) => i;
|
||||||
|
higher2(i foo2)
|
||||||
|
};
|
||||||
|
|
||||||
|
let a: int = 0;
|
||||||
|
|
||||||
|
let foobar3 =
|
||||||
|
(i: int): int =>
|
||||||
|
{
|
||||||
|
let foo2: int) => int = (i: int) => a + i;
|
||||||
|
higher2(i foo2)
|
||||||
|
};
|
||||||
|
|
||||||
|
let f = (i: int): int => i;
|
||||||
|
|
||||||
|
let g = (i: int): int => f(i);
|
||||||
|
|
||||||
|
let foobar4 = (i: int): int => g(g(i));
|
||||||
|
|
||||||
|
let higher3 =
|
||||||
|
(i: int, f: int) => int, g: int) => int): int =>
|
||||||
|
{
|
||||||
|
let ii: int = f(g(i));
|
||||||
|
ii
|
||||||
|
};
|
||||||
|
|
||||||
|
let foobar5 =
|
||||||
|
(i: int): int =>
|
||||||
|
{
|
||||||
|
let a: int = 0;
|
||||||
|
let foo: int) => int = (i: int) => a + i;
|
||||||
|
let goo: int) => int = (i: int) => foo(i);
|
||||||
|
higher3(i foo goo)
|
||||||
|
};
|
3
src/test/contracts/expected/implicit_account.religo
Normal file
3
src/test/contracts/expected/implicit_account.religo
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
let main =
|
||||||
|
(kh: key_hash): contract(unit) =>
|
||||||
|
Tezos.implicit_account(kh);
|
1
src/test/contracts/expected/included.religo
Normal file
1
src/test/contracts/expected/included.religo
Normal file
@ -0,0 +1 @@
|
|||||||
|
let foo: int = 144;
|
3
src/test/contracts/expected/includer.religo
Normal file
3
src/test/contracts/expected/includer.religo
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
let foo: int = 144;
|
||||||
|
|
||||||
|
let bar: int = foo;
|
8
src/test/contracts/expected/key_hash.religo
Normal file
8
src/test/contracts/expected/key_hash.religo
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
let check_hash_key =
|
||||||
|
(kh1_k2: (key_hash, key)): (bool, key_hash) =>
|
||||||
|
{
|
||||||
|
let (kh1, k2) = kh1_k2;
|
||||||
|
let kh2: key_hash = Crypto.hash_key(k2);
|
||||||
|
((kh1
|
||||||
|
== kh2), kh2)
|
||||||
|
};
|
5
src/test/contracts/expected/lambda.religo
Normal file
5
src/test/contracts/expected/lambda.religo
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
type storage = unit;
|
||||||
|
|
||||||
|
let main =
|
||||||
|
((p, s): (unit, storage)): unit =>
|
||||||
|
((useless: unit) => ())(());
|
5
src/test/contracts/expected/lambda2.religo
Normal file
5
src/test/contracts/expected/lambda2.religo
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
type storage = unit;
|
||||||
|
|
||||||
|
let main =
|
||||||
|
((a, s): (unit, storage)): unit =>
|
||||||
|
((f: unit) => unit) => f(()))((useless: unit) => unit);
|
13
src/test/contracts/expected/let_multiple.religo
Normal file
13
src/test/contracts/expected/let_multiple.religo
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
let (x: int, y: int) = (1, 2);
|
||||||
|
|
||||||
|
let main = (p: unit): int => x + y;
|
||||||
|
|
||||||
|
let (x: int, y: int) = (3, 3);
|
||||||
|
|
||||||
|
let main_paren = (p: unit): int => x + y;
|
||||||
|
|
||||||
|
let foobar: (int, int) = (23, 42);
|
||||||
|
|
||||||
|
let (foo: int, bar: int) = foobar;
|
||||||
|
|
||||||
|
let non_tuple_rhs = (p: unit): int => foo + bar;
|
39
src/test/contracts/expected/letin.religo
Normal file
39
src/test/contracts/expected/letin.religo
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
type storage = (int, int);
|
||||||
|
|
||||||
|
let main =
|
||||||
|
(n: (int, storage)): (list(operation), storage) =>
|
||||||
|
{
|
||||||
|
let x: (int, int) =
|
||||||
|
{
|
||||||
|
let x: int = 7;
|
||||||
|
(x + n[0], n[1.0] + n[1.1])
|
||||||
|
};
|
||||||
|
([] : list(operation), x)
|
||||||
|
};
|
||||||
|
|
||||||
|
let f0 = (a: string) => true;
|
||||||
|
|
||||||
|
let f1 = (a: string) => true;
|
||||||
|
|
||||||
|
let f2 = (a: string) => true;
|
||||||
|
|
||||||
|
let letin_nesting =
|
||||||
|
(_: unit) =>
|
||||||
|
{
|
||||||
|
let s = "test";
|
||||||
|
let p0 = f0(s);
|
||||||
|
assert(p0);
|
||||||
|
let p1 = f1(s);
|
||||||
|
assert(p1);
|
||||||
|
let p2 = f2(s);
|
||||||
|
assert(p2);
|
||||||
|
s
|
||||||
|
};
|
||||||
|
|
||||||
|
let letin_nesting2 =
|
||||||
|
(x: int) =>
|
||||||
|
{
|
||||||
|
let y = 2;
|
||||||
|
let z = 3;
|
||||||
|
x + y + z
|
||||||
|
};
|
42
src/test/contracts/expected/list.religo
Normal file
42
src/test/contracts/expected/list.religo
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
type storage = (int, list(int));
|
||||||
|
|
||||||
|
type parameter = list(int);
|
||||||
|
|
||||||
|
type return = (list(operation), storage);
|
||||||
|
|
||||||
|
let x: list(int) = [];
|
||||||
|
|
||||||
|
let y: list(int) = [3, 4, 5];
|
||||||
|
|
||||||
|
let z: list(int) = [2, ...y];
|
||||||
|
|
||||||
|
let main =
|
||||||
|
((action, s): (parameter, storage)): return =>
|
||||||
|
{
|
||||||
|
let storage =
|
||||||
|
switch(action) {
|
||||||
|
| [] => s
|
||||||
|
| [hd, ...tl] => (s[0] + hd, tl)
|
||||||
|
};
|
||||||
|
([] : list(operation), storage)
|
||||||
|
};
|
||||||
|
|
||||||
|
let size_ = (s: list(int)): nat => List.length(s);
|
||||||
|
|
||||||
|
let fold_op =
|
||||||
|
(s: list(int)): int =>
|
||||||
|
{
|
||||||
|
let aggregate = (t: (int, int)) => t[0] + t[1];
|
||||||
|
List.fold(aggregate s 10)
|
||||||
|
};
|
||||||
|
|
||||||
|
let map_op =
|
||||||
|
(s: list(int)): list(int) =>
|
||||||
|
List.map((cur: int) => cur + 1 s);
|
||||||
|
|
||||||
|
let iter_op =
|
||||||
|
(s: list(int)): unit =>
|
||||||
|
{
|
||||||
|
let do_nothing = (useless: int) => unit;
|
||||||
|
List.iter(do_nothing s)
|
||||||
|
};
|
51
src/test/contracts/expected/loop.religo
Normal file
51
src/test/contracts/expected/loop.religo
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
let rec aux_simple =
|
||||||
|
(i: int): int =>
|
||||||
|
if(i
|
||||||
|
< 100) {
|
||||||
|
aux_simple(i + 1)
|
||||||
|
} else {
|
||||||
|
i
|
||||||
|
};
|
||||||
|
|
||||||
|
let counter_simple = (n: int): int => aux_simple(n);
|
||||||
|
|
||||||
|
type sum_aggregator = {counter: int, sum: int };
|
||||||
|
|
||||||
|
let counter =
|
||||||
|
(n: int): int =>
|
||||||
|
{
|
||||||
|
let initial: sum_aggregator = {counter = 0, sum = 0 };
|
||||||
|
let rec aggregate =
|
||||||
|
(prev: sum_aggregator): int =>
|
||||||
|
if(prev[counter]
|
||||||
|
<= n) {
|
||||||
|
|
||||||
|
|
||||||
|
aggregate({
|
||||||
|
counter = prev[counter] + 1,
|
||||||
|
sum = prev[counter] + prev[sum]
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
prev[sum]
|
||||||
|
};
|
||||||
|
aggregate(initial)
|
||||||
|
};
|
||||||
|
|
||||||
|
let rec aux_nest =
|
||||||
|
(prev: sum_aggregator): sum_aggregator =>
|
||||||
|
if(prev[counter]
|
||||||
|
< 100) {
|
||||||
|
|
||||||
|
let sum: int = prev[sum] + aux_simple(prev[counter]);
|
||||||
|
aux_nest({counter = prev[counter] + 1, sum = sum })
|
||||||
|
} else {
|
||||||
|
({counter = prev[counter], sum = prev[sum] })
|
||||||
|
};
|
||||||
|
|
||||||
|
let counter_nest =
|
||||||
|
(n: int): int =>
|
||||||
|
{
|
||||||
|
let initial: sum_aggregator = {counter = 0, sum = 0 };
|
||||||
|
let out: sum_aggregator = aux_nest(initial);
|
||||||
|
out[sum]
|
||||||
|
};
|
71
src/test/contracts/expected/map.religo
Normal file
71
src/test/contracts/expected/map.religo
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
type foobar = map(int, int);
|
||||||
|
|
||||||
|
let empty_map: foobar = Map.empty;
|
||||||
|
|
||||||
|
let map1: foobar =
|
||||||
|
|
||||||
|
Map.literal([(144, 23),
|
||||||
|
(51, 23),
|
||||||
|
(42, 23),
|
||||||
|
(120, 23),
|
||||||
|
(421, 23)]);
|
||||||
|
|
||||||
|
let map2: foobar = Map.literal([(23, 0), (42, 0)]);
|
||||||
|
|
||||||
|
let set_ =
|
||||||
|
(n: int, m: foobar): foobar => Map.update(23 Some (n) m);
|
||||||
|
|
||||||
|
let add = (n: int, m: foobar): foobar => Map.add(23 n m);
|
||||||
|
|
||||||
|
let rm = (m: foobar): foobar => Map.remove(42 m);
|
||||||
|
|
||||||
|
let patch_ =
|
||||||
|
(m: foobar): foobar =>
|
||||||
|
Map.literal([(0, 5), (1, 6), (2, 7)]);
|
||||||
|
|
||||||
|
let patch_empty =
|
||||||
|
(m: foobar): foobar =>
|
||||||
|
Map.literal([(0, 0), (1, 1), (2, 2)]);
|
||||||
|
|
||||||
|
let patch_deep =
|
||||||
|
(m: (foobar, nat)): (foobar, nat) =>
|
||||||
|
(Map.literal([(0, 0), (1, 9), (2, 2)]), 10n);
|
||||||
|
|
||||||
|
let size_ = (m: foobar): nat => Map.size(m);
|
||||||
|
|
||||||
|
let get = (m: foobar): option(int) => Map.find_opt(42 m);
|
||||||
|
|
||||||
|
let get_ = (m: foobar): option(int) => Map.find_opt(42 m);
|
||||||
|
|
||||||
|
let mem = (km: (int, foobar)): bool => Map.mem(km[0] km[1]);
|
||||||
|
|
||||||
|
let iter_op =
|
||||||
|
(m: foobar): unit =>
|
||||||
|
{
|
||||||
|
let assert_eq = (i: int, j: int) => assert(i == j);
|
||||||
|
Map.iter(assert_eq m)
|
||||||
|
};
|
||||||
|
|
||||||
|
let map_op =
|
||||||
|
(m: foobar): foobar =>
|
||||||
|
{
|
||||||
|
let increment = (z: int, j: int) => j + 1;
|
||||||
|
Map.map(increment m)
|
||||||
|
};
|
||||||
|
|
||||||
|
let fold_op =
|
||||||
|
(m: foobar): foobar =>
|
||||||
|
{
|
||||||
|
let aggregate =
|
||||||
|
(i: int, j: (int, int)) => i + j[0] + j[1];
|
||||||
|
Map.fold(aggregate m 10)
|
||||||
|
};
|
||||||
|
|
||||||
|
let deep_op =
|
||||||
|
(m: foobar): foobar =>
|
||||||
|
{
|
||||||
|
let coco = (0, m);
|
||||||
|
let coco = (0, Map.remove(42 coco[1]));
|
||||||
|
let coco = (0, Map.update(32 Some (16) coco[1]));
|
||||||
|
coco[1]
|
||||||
|
};
|
17
src/test/contracts/expected/match.religo
Normal file
17
src/test/contracts/expected/match.religo
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
type storage = int;
|
||||||
|
|
||||||
|
type parameter = Add(int) | Sub(int);
|
||||||
|
|
||||||
|
type return = (list(operation), storage);
|
||||||
|
|
||||||
|
let main =
|
||||||
|
((action, store): (parameter, storage)) =>
|
||||||
|
{
|
||||||
|
let store =
|
||||||
|
store
|
||||||
|
+ (switch(action) {
|
||||||
|
| Addn => n
|
||||||
|
| Subn => -n
|
||||||
|
});
|
||||||
|
(([] : list(operation)), store)
|
||||||
|
};
|
18
src/test/contracts/expected/match_bis.religo
Normal file
18
src/test/contracts/expected/match_bis.religo
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
type storage = int;
|
||||||
|
|
||||||
|
type parameter = Increment(int) | Decrement(int);
|
||||||
|
|
||||||
|
let add = (a: int, b: int) => a + b;
|
||||||
|
|
||||||
|
let sub = (a: int, b: int) => a - b;
|
||||||
|
|
||||||
|
let main =
|
||||||
|
((action, store): (parameter, storage)) =>
|
||||||
|
{
|
||||||
|
let store =
|
||||||
|
switch(action) {
|
||||||
|
| Incrementn => add(store n)
|
||||||
|
| Decrementn => sub(store n)
|
||||||
|
};
|
||||||
|
(([] : list(operation)), store)
|
||||||
|
};
|
13
src/test/contracts/expected/michelson_pair_tree.religo
Normal file
13
src/test/contracts/expected/michelson_pair_tree.religo
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
type inner_storage = michelson_pair(int, "one", nat, "two");
|
||||||
|
|
||||||
|
type storage = michelson_pair
|
||||||
|
(int, "three", inner_storage, "four");
|
||||||
|
|
||||||
|
type return = (list(operation), storage);
|
||||||
|
|
||||||
|
let main =
|
||||||
|
((action, store): (unit, storage)): return =>
|
||||||
|
{
|
||||||
|
let foo = (3, (1, 2n));
|
||||||
|
(([] : list(operation)), (foo : storage))
|
||||||
|
};
|
6
src/test/contracts/expected/multiple-parameters.religo
Normal file
6
src/test/contracts/expected/multiple-parameters.religo
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
let abcde_curried =
|
||||||
|
(a: int, b: int, c: int, d: int, e: int): int => c + e + 3;
|
||||||
|
|
||||||
|
let abcde =
|
||||||
|
(x: (int, int, int, int, int)): int =>
|
||||||
|
abcde_curried(x[0] x[1] x[2] x[3] x[4]);
|
97
src/test/contracts/expected/multisig.religo
Normal file
97
src/test/contracts/expected/multisig.religo
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
type counter = nat;
|
||||||
|
|
||||||
|
type threshold = nat;
|
||||||
|
|
||||||
|
type authorized_keys = list(key);
|
||||||
|
|
||||||
|
type id = string;
|
||||||
|
|
||||||
|
type storage = {
|
||||||
|
id: id,
|
||||||
|
counter: counter,
|
||||||
|
threshold: threshold,
|
||||||
|
auth: authorized_keys
|
||||||
|
};
|
||||||
|
|
||||||
|
type message = unit) => list(operation);
|
||||||
|
|
||||||
|
type dummy = (key_hash, signature);
|
||||||
|
|
||||||
|
type signatures = list(dummy);
|
||||||
|
|
||||||
|
type check_message_pt = {
|
||||||
|
counter: counter,
|
||||||
|
message: message,
|
||||||
|
signatures: signatures
|
||||||
|
};
|
||||||
|
|
||||||
|
type return = (list(operation), storage);
|
||||||
|
|
||||||
|
type parameter = CheckMessage(check_message_pt);
|
||||||
|
|
||||||
|
let check_message =
|
||||||
|
((param, s): (check_message_pt, storage)): return =>
|
||||||
|
{
|
||||||
|
let message: message = param[message];
|
||||||
|
let s =
|
||||||
|
if(param[counter]
|
||||||
|
!= s[counter]) {
|
||||||
|
(failwith("Counters does not match") : storage)
|
||||||
|
} else {
|
||||||
|
|
||||||
|
let packed_payload: bytes =
|
||||||
|
|
||||||
|
Bytes.pack((message, param[counter], s[id],
|
||||||
|
chain_id));
|
||||||
|
let valid: nat = 0n;
|
||||||
|
let keys: authorized_keys = s[auth];
|
||||||
|
let aux =
|
||||||
|
((vk, pkh_sig):
|
||||||
|
((nat, authorized_keys), (key_hash, signature)))
|
||||||
|
:
|
||||||
|
(nat, authorized_keys) =>
|
||||||
|
{
|
||||||
|
let (valid, keys) = vk;
|
||||||
|
switch(keys) {
|
||||||
|
| [] => vk
|
||||||
|
| [key, ...keys] =>
|
||||||
|
if(pkh_sig[0]
|
||||||
|
== Crypto.hash_key(key)) {
|
||||||
|
|
||||||
|
let valid =
|
||||||
|
if(
|
||||||
|
Crypto.check(key
|
||||||
|
pkh_sig[1]
|
||||||
|
packed_payload)) {
|
||||||
|
valid + 1n
|
||||||
|
} else {
|
||||||
|
|
||||||
|
(failwith("Invalid signature")
|
||||||
|
: nat)
|
||||||
|
};
|
||||||
|
(valid, keys)
|
||||||
|
} else {
|
||||||
|
(valid, keys)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let (valid, keys) =
|
||||||
|
List.fold(aux param[signatures] (valid, keys));
|
||||||
|
if(valid
|
||||||
|
< s[threshold]) {
|
||||||
|
|
||||||
|
(
|
||||||
|
failwith("Not enough signatures passed the check")
|
||||||
|
: storage)
|
||||||
|
} else {
|
||||||
|
{...s, counter: s[counter] + 1n}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
(message(unit), s)
|
||||||
|
};
|
||||||
|
|
||||||
|
let main =
|
||||||
|
((action, store): (parameter, storage)): return =>
|
||||||
|
switch(action) {
|
||||||
|
| CheckMessagep => check_message((p, store))
|
||||||
|
};
|
18
src/test/contracts/expected/no_semicolon.religo
Normal file
18
src/test/contracts/expected/no_semicolon.religo
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
type f = int;
|
||||||
|
|
||||||
|
let a =
|
||||||
|
(b: f) =>
|
||||||
|
{
|
||||||
|
if(b
|
||||||
|
== 2) {
|
||||||
|
3
|
||||||
|
} else {
|
||||||
|
4
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let c =
|
||||||
|
(c: f) =>
|
||||||
|
{
|
||||||
|
3
|
||||||
|
};
|
35
src/test/contracts/expected/pledge.religo
Normal file
35
src/test/contracts/expected/pledge.religo
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
type storage = address;
|
||||||
|
|
||||||
|
type parameter = Donate(unit)
|
||||||
|
| Distribute((unit) => list(operation)));
|
||||||
|
|
||||||
|
let donate =
|
||||||
|
((p, s): (unit, storage)): (list(operation), storage) =>
|
||||||
|
{
|
||||||
|
(([] : list(operation)), s)
|
||||||
|
};
|
||||||
|
|
||||||
|
let distribute =
|
||||||
|
((p, s): (unit) => list(operation), storage))
|
||||||
|
:
|
||||||
|
(list(operation), storage) =>
|
||||||
|
{
|
||||||
|
if(Tezos.sender
|
||||||
|
== s) {
|
||||||
|
(p(()), s)
|
||||||
|
} else {
|
||||||
|
|
||||||
|
(
|
||||||
|
failwith("You're not the oracle for this distribution.")
|
||||||
|
: (list(operation), storage))
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let main =
|
||||||
|
((p, s): (parameter, storage)): (list(operation), storage) =>
|
||||||
|
{
|
||||||
|
switch(p) {
|
||||||
|
| Donate => donate(((), s))
|
||||||
|
| Distributemsg => distribute((msg, s))
|
||||||
|
}
|
||||||
|
};
|
36
src/test/contracts/expected/record.religo
Normal file
36
src/test/contracts/expected/record.religo
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
type foobar = {foo: int, bar: int };
|
||||||
|
|
||||||
|
let fb: foobar = {foo = 0, bar = 0 };
|
||||||
|
|
||||||
|
type abc = {a: int, b: int, c: int };
|
||||||
|
|
||||||
|
let abc: abc = {a = 42, b = 142, c = 242 };
|
||||||
|
|
||||||
|
let a: int = abc[a];
|
||||||
|
|
||||||
|
let b: int = abc[b];
|
||||||
|
|
||||||
|
let c: int = abc[c];
|
||||||
|
|
||||||
|
let projection = (r: foobar): int => r[foo] + r[bar];
|
||||||
|
|
||||||
|
let modify =
|
||||||
|
(r: foobar): foobar => {foo = 256, bar = r[bar] };
|
||||||
|
|
||||||
|
let modify_abc = (r: abc): abc => {...r, b: 2048, c: 42};
|
||||||
|
|
||||||
|
type big_record = {a: int, b: int, c: int, d: int, e: int };
|
||||||
|
|
||||||
|
let br: big_record =
|
||||||
|
{
|
||||||
|
a = 23,
|
||||||
|
b = 23,
|
||||||
|
c = 23,
|
||||||
|
d = 23,
|
||||||
|
e = 23
|
||||||
|
};
|
||||||
|
|
||||||
|
type double_record = {inner: abc };
|
||||||
|
|
||||||
|
let modify_inner =
|
||||||
|
(r: double_record): double_record => {...r, inner.b: 2048};
|
17
src/test/contracts/expected/recursion.religo
Normal file
17
src/test/contracts/expected/recursion.religo
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
let rec sum =
|
||||||
|
((n, acc): (int, int)): int =>
|
||||||
|
if(n
|
||||||
|
< 1) {
|
||||||
|
acc
|
||||||
|
} else {
|
||||||
|
sum((n - 1, acc + n))
|
||||||
|
};
|
||||||
|
|
||||||
|
let rec fibo =
|
||||||
|
((n, n_1, n_0): (int, int, int)): int =>
|
||||||
|
if(n
|
||||||
|
< 2) {
|
||||||
|
n_1
|
||||||
|
} else {
|
||||||
|
fibo((n - 1, n_1 + n_0, n_1))
|
||||||
|
};
|
1
src/test/contracts/expected/self_address.religo
Normal file
1
src/test/contracts/expected/self_address.religo
Normal file
@ -0,0 +1 @@
|
|||||||
|
let main = (p: unit): address => Tezos.self_address;
|
17
src/test/contracts/expected/set_arithmetic.religo
Normal file
17
src/test/contracts/expected/set_arithmetic.religo
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
let literal_op =
|
||||||
|
(p: unit): set(string) =>
|
||||||
|
Set.literal(["foo", "bar", "foobar"]);
|
||||||
|
|
||||||
|
let add_op =
|
||||||
|
(s: set(string)): set(string) => Set.add("foobar" s);
|
||||||
|
|
||||||
|
let remove_op =
|
||||||
|
(s: set(string)): set(string) => Set.remove("foobar" s);
|
||||||
|
|
||||||
|
let remove_deep =
|
||||||
|
(s: (set(string), nat)): set(string) =>
|
||||||
|
Set.remove("foobar" s[0]);
|
||||||
|
|
||||||
|
let mem_op = (s: set(string)): bool => Set.mem("foobar" s);
|
||||||
|
|
||||||
|
let size_op = (s: set(string)): nat => Set.cardinal(s);
|
6
src/test/contracts/expected/set_delegate.religo
Normal file
6
src/test/contracts/expected/set_delegate.religo
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
let main =
|
||||||
|
(p: key_hash): list(operation) =>
|
||||||
|
{
|
||||||
|
let unused: operation = (Tezos.set_delegate(Some (p)));
|
||||||
|
([] : list(operation))
|
||||||
|
};
|
3
src/test/contracts/expected/single_record_item.religo
Normal file
3
src/test/contracts/expected/single_record_item.religo
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
type p = {x: int };
|
||||||
|
|
||||||
|
let o = (p: int): p => {x = p };
|
5
src/test/contracts/expected/string_arithmetic.religo
Normal file
5
src/test/contracts/expected/string_arithmetic.religo
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
let size_op = (s: string): nat => String.length(s);
|
||||||
|
|
||||||
|
let slice_op = (s: string): string => String.sub(1n 2n s);
|
||||||
|
|
||||||
|
let concat_syntax = (s: string) => s ++ "test_literal";
|
16
src/test/contracts/expected/super-counter.religo
Normal file
16
src/test/contracts/expected/super-counter.religo
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
type parameter = Increment(int) | Decrement(int);
|
||||||
|
|
||||||
|
type storage = int;
|
||||||
|
|
||||||
|
type return = (list(operation), storage);
|
||||||
|
|
||||||
|
let main =
|
||||||
|
((action, store): (parameter, storage)): return =>
|
||||||
|
{
|
||||||
|
let store =
|
||||||
|
switch(action) {
|
||||||
|
| Incrementn => store + n
|
||||||
|
| Decrementn => store - n
|
||||||
|
};
|
||||||
|
([] : list(operation), store)
|
||||||
|
};
|
13
src/test/contracts/expected/tuple.religo
Normal file
13
src/test/contracts/expected/tuple.religo
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
type abc = (int, int, int);
|
||||||
|
|
||||||
|
let projection_abc = (tpl: abc): int => tpl[1];
|
||||||
|
|
||||||
|
type foobar = (int, int);
|
||||||
|
|
||||||
|
let fb: foobar = (0, 0);
|
||||||
|
|
||||||
|
let projection = (tpl: foobar): int => tpl[0] + tpl[1];
|
||||||
|
|
||||||
|
type big_tuple = (int, int, int, int, int);
|
||||||
|
|
||||||
|
let br: big_tuple = (23, 23, 23, 23, 23);
|
3
src/test/contracts/expected/tuple_list.religo
Normal file
3
src/test/contracts/expected/tuple_list.religo
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
type z = list((int, int));
|
||||||
|
|
||||||
|
let o: z = [(2, 4), (4, 6)];
|
4
src/test/contracts/expected/tuple_param_destruct.religo
Normal file
4
src/test/contracts/expected/tuple_param_destruct.religo
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
let sum = ((result, i): (int, int)): int => result - i;
|
||||||
|
|
||||||
|
let parentheses =
|
||||||
|
((result, i): (((int, int),),)): int => result - i;
|
48
src/test/contracts/expected/tuple_type.religo
Normal file
48
src/test/contracts/expected/tuple_type.religo
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
type fun_type = (int, int) => int;
|
||||||
|
|
||||||
|
let arguments =
|
||||||
|
(b: int, c: int) =>
|
||||||
|
{
|
||||||
|
b + c
|
||||||
|
};
|
||||||
|
|
||||||
|
let arguments_type_def = (b: fun_type) => b(5 3);
|
||||||
|
|
||||||
|
let arguments_test =
|
||||||
|
(_: int) => arguments_type_def(arguments);
|
||||||
|
|
||||||
|
type tuple_type = (int, int)) => int;
|
||||||
|
|
||||||
|
let tuple =
|
||||||
|
((a, b): (int, int)) =>
|
||||||
|
{
|
||||||
|
a + b
|
||||||
|
};
|
||||||
|
|
||||||
|
let tuple_type_def = (b: tuple_type) => b((5, 3));
|
||||||
|
|
||||||
|
let tuple_test = (_: int) => tuple_type_def(tuple);
|
||||||
|
|
||||||
|
let arguments_inline =
|
||||||
|
(b: int, c: int) =>
|
||||||
|
{
|
||||||
|
b + c
|
||||||
|
};
|
||||||
|
|
||||||
|
let arguments_type_def_inline =
|
||||||
|
(b: (int, int) => int) => b(5 3);
|
||||||
|
|
||||||
|
let arguments_test_inline =
|
||||||
|
(_: int) => arguments_type_def_inline(arguments_inline);
|
||||||
|
|
||||||
|
let tuple_inline =
|
||||||
|
((a, b): (int, int)) =>
|
||||||
|
{
|
||||||
|
a + b
|
||||||
|
};
|
||||||
|
|
||||||
|
let tuple_type_def_inline =
|
||||||
|
(b: (int, int)) => int) => b((5, 3));
|
||||||
|
|
||||||
|
let tuple_test_inline =
|
||||||
|
(_: int) => tuple_type_def_inline(tuple_inline);
|
9
src/test/contracts/expected/tuples_no_annotation.religo
Normal file
9
src/test/contracts/expected/tuples_no_annotation.religo
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
type storage = (int, string, nat, bool);
|
||||||
|
|
||||||
|
type parameter = int;
|
||||||
|
|
||||||
|
let main =
|
||||||
|
((p, storage): (parameter, storage)) =>
|
||||||
|
{
|
||||||
|
([] : list(operation), (2, "2", 2n, false))
|
||||||
|
};
|
@ -0,0 +1,65 @@
|
|||||||
|
let a = 1;
|
||||||
|
|
||||||
|
let b = 1n;
|
||||||
|
|
||||||
|
let c = 2mutez;
|
||||||
|
|
||||||
|
let d = 1n + 2n;
|
||||||
|
|
||||||
|
let e = 1mutez + 3mutez;
|
||||||
|
|
||||||
|
let f = (a, c);
|
||||||
|
|
||||||
|
let g = (a + 1, c);
|
||||||
|
|
||||||
|
let h = ("a" ++ "2", d);
|
||||||
|
|
||||||
|
let i = (a: int, b: int) => a + b;
|
||||||
|
|
||||||
|
let j = (a: int, b: int) => a - b;
|
||||||
|
|
||||||
|
let m =
|
||||||
|
{
|
||||||
|
let z = 3;
|
||||||
|
z
|
||||||
|
};
|
||||||
|
|
||||||
|
let n = (a: int): int => a + 1;
|
||||||
|
|
||||||
|
let o = (a: int): int => a + 1;
|
||||||
|
|
||||||
|
let n = (a: int, b: int): int => a + 1;
|
||||||
|
|
||||||
|
let o = (a: int, b: int): int => a + 1;
|
||||||
|
|
||||||
|
let p =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
3
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let q =
|
||||||
|
{
|
||||||
|
f = 3,
|
||||||
|
g = 6,
|
||||||
|
h = {i = "bla", j = 1 + 2, k = {l = 1, z = 2 } }
|
||||||
|
};
|
||||||
|
|
||||||
|
let s =
|
||||||
|
{
|
||||||
|
let a = 2;
|
||||||
|
{
|
||||||
|
z = a,
|
||||||
|
a = a
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let t = (((((((2)))))));
|
||||||
|
|
||||||
|
let u =
|
||||||
|
if(true) {
|
||||||
|
1
|
||||||
|
} else {
|
||||||
|
2
|
||||||
|
};
|
7
src/test/contracts/expected/variant.religo
Normal file
7
src/test/contracts/expected/variant.religo
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
type foobar = Foo(int) | Bar(bool) | Kee(nat);
|
||||||
|
|
||||||
|
let foo: foobar = Foo (42);
|
||||||
|
|
||||||
|
let bar: foobar = Bar (true);
|
||||||
|
|
||||||
|
let kee: foobar = Kee (23n);
|
18
src/test/contracts/expected/website2.religo
Normal file
18
src/test/contracts/expected/website2.religo
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
type storage = int;
|
||||||
|
|
||||||
|
type parameter = Increment(int) | Decrement(int);
|
||||||
|
|
||||||
|
let add = ((a, b): (int, int)): int => a + b;
|
||||||
|
|
||||||
|
let sub = ((a, b): (int, int)): int => a - b;
|
||||||
|
|
||||||
|
let main =
|
||||||
|
((p, storage): (parameter, storage)) =>
|
||||||
|
{
|
||||||
|
let storage =
|
||||||
|
switch(p) {
|
||||||
|
| Incrementn => add((storage, n))
|
||||||
|
| Decrementn => sub((storage, n))
|
||||||
|
};
|
||||||
|
([] : list(operation), storage)
|
||||||
|
};
|
@ -6,7 +6,7 @@ type storage = int;
|
|||||||
|
|
||||||
type return = (list (operation), storage);
|
type return = (list (operation), storage);
|
||||||
|
|
||||||
let main = ((action, store): (parameter, storage) : return => {
|
let main = ((action, store): (parameter, storage)) : return => {
|
||||||
let store =
|
let store =
|
||||||
switch (action) {
|
switch (action) {
|
||||||
| Increment (n) => store + n
|
| Increment (n) => store + n
|
||||||
|
@ -2492,6 +2492,7 @@ let main = test_suite "Integration (End to End)" [
|
|||||||
test "counter contract" counter_contract ;
|
test "counter contract" counter_contract ;
|
||||||
test "super counter contract" super_counter_contract ;
|
test "super counter contract" super_counter_contract ;
|
||||||
test "super counter contract" super_counter_contract_mligo ;
|
test "super counter contract" super_counter_contract_mligo ;
|
||||||
|
test "super counter contract (reasonligo)" super_counter_contract_religo ;
|
||||||
test "dispatch counter contract" dispatch_counter_contract ;
|
test "dispatch counter contract" dispatch_counter_contract ;
|
||||||
test "basic (mligo)" basic_mligo ;
|
test "basic (mligo)" basic_mligo ;
|
||||||
test "basic (religo)" basic_religo ;
|
test "basic (religo)" basic_religo ;
|
||||||
|
Loading…
Reference in New Issue
Block a user