create_contract: add some tests

This commit is contained in:
Lesenechal Remi 2020-02-28 19:49:51 +01:00
parent ffd792e2f8
commit 9a30eb67c1
4 changed files with 80 additions and 1 deletions

View File

@ -1145,3 +1145,50 @@ let%expect_test _ =
* 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' |}]
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: store {"expression":"CREATE_CONTRACT(lambda (#P : ( nat * string ):Some(( nat * string ))) : None return let rhs#752 = #P in let p = rhs#752.0 in let s = rhs#752.1 in ( list[] : (TO_list(operation)) , store ) , NONE() : (TO_option(key_hash)) , 300000000mutez , \"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
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' |}] ;
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: a {"expression":"CREATE_CONTRACT(lambda (#P : ( nat * int ):Some(( nat * int ))) : None return let rhs#755 = #P in let p = rhs#755.0 in let s = rhs#755.1 in ( list[] : (TO_list(operation)) , a ) , NONE() : (TO_option(key_hash)) , 300000000mutez , 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
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' |}] ;
run_ligo_good [ "compile-contract" ; contract "create_contract.mligo" ; "main" ] ;
[%expect {|
{ parameter string ;
storage string ;
code { PUSH string "un" ;
PUSH mutez 300000000 ;
NONE key_hash ;
CREATE_CONTRACT
{ parameter nat ;
storage string ;
code { PUSH string "one" ; NIL operation ; PAIR ; DIP { DROP } } } ;
PAIR ;
DUP ;
CAR ;
NIL operation ;
SWAP ;
CONS ;
DIP { DIP { DUP } ; SWAP ; CDR } ;
PAIR ;
DIP { DROP 2 } } } |}]

View File

@ -0,0 +1,10 @@
type return = operation list * string
let main (action, store : string * string) : return =
let toto : operation * address = Tezos.create_contract
(fun (p, s : nat * string) -> (([] : operation list), "one"))
(None: key_hash option)
300tz
"un"
in
([toto.0], store)

View File

@ -0,0 +1,10 @@
type return = operation list * string
let main (action, store : string * string) : return =
let toto : operation * address = Tezos.create_contract
(fun (p, s : nat * string) -> (([] : operation list), store))
(None: key_hash option)
300tz
"un"
in
([toto.0], store)

View File

@ -0,0 +1,12 @@
type return = operation list * string
let a : int = 2
let main (action, store : string * string) : return =
let toto : operation * address = Tezos.create_contract
(fun (p, s : nat * int) -> (([] : operation list), a))
(None: key_hash option)
300tz
1
in
([toto.0], store)