Merge branch '127-unsupported-bytes_unpack-in-pascaligo' into 'dev'
Resolve "unsupported `bytes_unpack` in pascaligo" Closes #127 See merge request ligolang/ligo!295
This commit is contained in:
commit
280c6fc3c4
@ -92,6 +92,7 @@ module Simplify = struct
|
|||||||
| "bytes_concat" -> ok C_CONCAT
|
| "bytes_concat" -> ok C_CONCAT
|
||||||
| "bytes_slice" -> ok C_SLICE
|
| "bytes_slice" -> ok C_SLICE
|
||||||
| "bytes_pack" -> ok C_BYTES_PACK
|
| "bytes_pack" -> ok C_BYTES_PACK
|
||||||
|
| "bytes_unpack" -> ok C_BYTES_UNPACK
|
||||||
| "set_empty" -> ok C_SET_EMPTY
|
| "set_empty" -> ok C_SET_EMPTY
|
||||||
| "set_mem" -> ok C_SET_MEM
|
| "set_mem" -> ok C_SET_MEM
|
||||||
| "set_add" -> ok C_SET_ADD
|
| "set_add" -> ok C_SET_ADD
|
||||||
|
11
src/test/contracts/bytes_unpack.ligo
Normal file
11
src/test/contracts/bytes_unpack.ligo
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
function id_string (const p : string) : option(string) is block {
|
||||||
|
const packed : bytes = bytes_pack(p) ;
|
||||||
|
} with (bytes_unpack(packed): option(string))
|
||||||
|
|
||||||
|
function id_int (const p : int) : option(int) is block {
|
||||||
|
const packed : bytes = bytes_pack(p) ;
|
||||||
|
} with (bytes_unpack(packed): option(int))
|
||||||
|
|
||||||
|
function id_address (const p : address) : option(address) is block {
|
||||||
|
const packed : bytes = bytes_pack(p) ;
|
||||||
|
} with (bytes_unpack(packed): option(address))
|
@ -1812,7 +1812,18 @@ let let_in_multi_bind () : unit result =
|
|||||||
(e_string "mynameisbob")
|
(e_string "mynameisbob")
|
||||||
in ok ()
|
in ok ()
|
||||||
|
|
||||||
|
let bytes_unpack () : unit result =
|
||||||
|
let%bind program = type_file "./contracts/bytes_unpack.ligo" in
|
||||||
|
let%bind () = expect_eq program "id_string" (e_string "teststring") (e_some (e_string "teststring")) in
|
||||||
|
let%bind () = expect_eq program "id_int" (e_int 42) (e_some (e_int 42)) in
|
||||||
|
let open Proto_alpha_utils.Memory_proto_alpha in
|
||||||
|
let addr = Protocol.Alpha_context.Contract.to_b58check @@
|
||||||
|
(List.nth dummy_environment.identities 0).implicit_contract in
|
||||||
|
let%bind () = expect_eq program "id_address" (e_address addr) (e_some (e_address addr)) in
|
||||||
|
ok ()
|
||||||
|
|
||||||
let main = test_suite "Integration (End to End)" [
|
let main = test_suite "Integration (End to End)" [
|
||||||
|
test "bytes unpack" bytes_unpack ;
|
||||||
test "key hash" key_hash ;
|
test "key hash" key_hash ;
|
||||||
test "chain id" chain_id ;
|
test "chain id" chain_id ;
|
||||||
test "type alias" type_alias ;
|
test "type alias" type_alias ;
|
||||||
|
Loading…
Reference in New Issue
Block a user