michelson_or tests and changelog

This commit is contained in:
Lesenechal Remi 2020-03-30 13:20:14 +02:00
parent be5ad35fb9
commit f9d1928d8e
7 changed files with 82 additions and 2 deletions

View File

@ -2,6 +2,10 @@
## [Unreleased]
## [Michelson or type] (https://gitlab.com/ligolang/ligo/-/merge_requests/530)
### Added
- New type michelson_or, will give control over or types instead of relying on LIGO variants.
## [Support for self] (https://gitlab.com/ligolang/ligo/-/merge_requests/453)
### Added
- support for `Tezos.self(%Entrypoint)`

View File

@ -1117,7 +1117,7 @@ let%expect_test _ =
let%expect_test _ =
run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_toplevel.mligo" ; "main" ] ;
[%expect {|
ligo: in file "create_contract_toplevel.mligo", line 4, character 35 to line 8, character 8. No free variable allowed in this lambda: variable 'store' {"expression":"CREATE_CONTRACT(lambda (#P:Some(( nat * string ))) : None return\n let rhs#705 = #P in\n let p = rhs#705.0 in\n let s = rhs#705.1 in\n ( LIST_EMPTY() : (TO_list(operation)) , store ) ,\n NONE() : (TO_option(key_hash)) ,\n 300000000mutez ,\n \"un\")","location":"in file \"create_contract_toplevel.mligo\", line 4, character 35 to line 8, character 8"}
ligo: in file "create_contract_toplevel.mligo", line 4, character 35 to line 8, character 8. No free variable allowed in this lambda: variable 'store' {"expression":"CREATE_CONTRACT(lambda (#P:Some(( nat * string ))) : None return\n let rhs#712 = #P in\n let p = rhs#712.0 in\n let s = rhs#712.1 in\n ( LIST_EMPTY() : (TO_list(operation)) , store ) ,\n NONE() : (TO_option(key_hash)) ,\n 300000000mutez ,\n \"un\")","location":"in file \"create_contract_toplevel.mligo\", line 4, character 35 to line 8, character 8"}
If you're not sure how to fix this error, you can
@ -1130,7 +1130,7 @@ ligo: in file "create_contract_toplevel.mligo", line 4, character 35 to line 8,
run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_var.mligo" ; "main" ] ;
[%expect {|
ligo: in file "create_contract_var.mligo", line 6, character 35 to line 10, character 5. No free variable allowed in this lambda: variable 'a' {"expression":"CREATE_CONTRACT(lambda (#P:Some(( nat * int ))) : None return\n let rhs#708 = #P in\n let p = rhs#708.0 in\n let s = rhs#708.1 in\n ( LIST_EMPTY() : (TO_list(operation)) , a ) ,\n NONE() : (TO_option(key_hash)) ,\n 300000000mutez ,\n 1)","location":"in file \"create_contract_var.mligo\", line 6, character 35 to line 10, character 5"}
ligo: in file "create_contract_var.mligo", line 6, character 35 to line 10, character 5. No free variable allowed in this lambda: variable 'a' {"expression":"CREATE_CONTRACT(lambda (#P:Some(( nat * int ))) : None return\n let rhs#715 = #P in\n let p = rhs#715.0 in\n let s = rhs#715.1 in\n ( LIST_EMPTY() : (TO_list(operation)) , a ) ,\n NONE() : (TO_option(key_hash)) ,\n 300000000mutez ,\n 1)","location":"in file \"create_contract_var.mligo\", line 6, character 35 to line 10, character 5"}
If you're not sure how to fix this error, you can

View File

@ -0,0 +1,41 @@
open Cli_expect
let contract basename =
"../../test/contracts/" ^ basename
let bad_contract basename =
"../../test/contracts/negative/" ^ basename
let%expect_test _ =
run_ligo_good [ "dry-run" ; contract "double_michelson_or.mligo" ; "main" ; "unit" ; "(M_left (1) : storage)" ] ;
[%expect {| ( LIST_EMPTY() , M_right("one") ) |}];
run_ligo_good [ "dry-run" ; contract "double_michelson_or.ligo" ; "main" ; "unit" ; "(M_left (1) : storage)" ] ;
[%expect {| ( LIST_EMPTY() , M_right("one") ) |}]
let%expect_test _ =
run_ligo_good [ "compile-contract" ; contract "michelson_or_tree.mligo" ; "main" ] ;
[%expect {|
{ parameter unit ;
storage (or (int %m_left) (or %m_right (int %m_left) (nat %m_right))) ;
code { PUSH int 1 ;
LEFT nat ;
RIGHT int ;
DUP ;
NIL operation ;
PAIR ;
DIP { DROP 2 } } } |}]
let%expect_test _ =
run_ligo_bad [ "compile-contract" ; bad_contract "bad_michelson_or.mligo" ; "main" ] ;
[%expect {|
ligo: in file "bad_michelson_or.mligo", line 6, characters 12-27. michelson_or types must be annotated: {"constructor":"M_right","location":"in file \"bad_michelson_or.mligo\", line 6, characters 12-27"}
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog' |}]

View File

@ -0,0 +1,11 @@
type storage is michelson_or (int, string)
type foobar is michelson_or (int, int)
type return is list (operation) * storage
function main (const action : unit; const store : storage) : return is
block {
const foo : storage = (M_right ("one") : storage);
const bar : foobar = (M_right (1) : foobar)
} with
((nil : list (operation)), (foo : storage))

View File

@ -0,0 +1,9 @@
type storage = (int,string) michelson_or
type foobar = (int, int ) michelson_or
type return = operation list * storage
let main (action, store : unit * storage) : return =
let foo = (M_right ("one") : storage) in
let bar = (M_right 1 : foobar) in
(([] : operation list), (foo: storage))

View File

@ -0,0 +1,8 @@
type inner_storage = (int,nat) michelson_or
type storage = (int,inner_storage) michelson_or
type return = operation list * storage
let main (action, store : unit * storage) : return =
let foo = (M_right (M_left 1 : inner_storage) : storage) in
(([] : operation list), (foo: storage))

View File

@ -0,0 +1,7 @@
type storage = (int,string) michelson_or
type return = operation list * storage
let main (action, store : unit * storage) : return =
let foo = M_right ("one") in
(([] : operation list), (foo: storage))