From 273ec8c280cff3465c7859f9f7fd1a516f7bc2ff Mon Sep 17 00:00:00 2001 From: John David Pressman Date: Tue, 12 Nov 2019 08:01:18 -0800 Subject: [PATCH] Add ability to access balance to PascaLIGO --- src/passes/operators/operators.ml | 1 + src/test/contracts/balance_constant.ligo | 11 +++++++++++ src/test/integration_tests.ml | 10 +++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/test/contracts/balance_constant.ligo diff --git a/src/passes/operators/operators.ml b/src/passes/operators/operators.ml index ac4d68bfc..2546357cb 100644 --- a/src/passes/operators/operators.ml +++ b/src/passes/operators/operators.ml @@ -64,6 +64,7 @@ module Simplify = struct ("int" , "INT") ; ("abs" , "ABS") ; ("amount" , "AMOUNT") ; + ("balance", "BALANCE") ; ("now" , "NOW") ; ("unit" , "UNIT") ; ("source" , "SOURCE") ; diff --git a/src/test/contracts/balance_constant.ligo b/src/test/contracts/balance_constant.ligo new file mode 100644 index 000000000..6f78d339a --- /dev/null +++ b/src/test/contracts/balance_constant.ligo @@ -0,0 +1,11 @@ +(** + +This test makes sure that the balance is accessible in PascaLIGO. +It's there to detect a regression of: https://gitlab.com/ligolang/ligo/issues/68 + +*) + +type storage is tez + +function main (const p : unit; const s: int) : list(operation) * storage is + ((nil : list(operation)), balance) diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index a971527aa..77bcc74a9 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -1151,6 +1151,13 @@ let website2_mligo () : unit result = expect_eq_n program "main" make_input make_expected let balance_constant () : unit result = + let%bind program = type_file "./contracts/balance_constant.ligo" in + let input = e_tuple [e_unit () ; e_mutez 0] in + let expected = e_tuple [e_list []; e_mutez 4000000000000] in + expect_eq program "main" input expected + + +let balance_constant_mligo () : unit result = let%bind program = mtype_file "./contracts/balance_constant.mligo" in let input = e_tuple [e_unit () ; e_mutez 0] in let expected = e_tuple [e_list []; e_mutez 4000000000000] in @@ -1236,5 +1243,6 @@ let main = test_suite "Integration (End to End)" [ test "website1 ligo" website1_ligo ; test "website2 ligo" website2_ligo ; test "website2 (mligo)" website2_mligo ; - test "balance constant (mligo)" balance_constant ; + test "balance constant" balance_constant ; + test "balance constant (mligo)" balance_constant_mligo ; ]