Michelson: test compare on bytes and concat on 2 strings

This commit is contained in:
Pierre Chambart 2018-07-19 02:00:06 +02:00 committed by Grégoire Henry
parent 46f9f65b6a
commit 09592a6eeb
3 changed files with 16 additions and 4 deletions

View File

@ -0,0 +1,9 @@
parameter (pair bytes bytes);
storage (list bool);
code {CAR; DUP; DUP; DUP; DUP; DIIIIIP {NIL bool};
DIIIIP {DUP; CAR; DIP {CDR}; COMPARE; LE; CONS};
DIIIP {DUP; CAR; DIP {CDR}; COMPARE; GE; CONS};
DIIP{DUP; CAR; DIP {CDR}; COMPARE; LT; CONS};
DIP {DUP; CAR; DIP {CDR}; COMPARE; GT; CONS};
DUP; CAR; DIP {CDR}; COMPARE; EQ; CONS;
NIL operation; PAIR};

View File

@ -1,7 +1,4 @@
parameter (list string); parameter (list string);
storage (list string); storage (list string);
code{ CAR; code{ CAR;
MAP { NIL string ; SWAP ; CONS ; MAP { PUSH @hello string "Hello "; CONCAT }; NIL operation; PAIR};
PUSH @hello string "Hello "; CONS ;
CONCAT };
NIL operation; PAIR};

View File

@ -465,6 +465,12 @@ assert_success $client transfer 0 from bootstrap1 to reveal_signed_preimage -arg
'(Pair 0x050100000027566f756c657a2d766f757320636f75636865722061766563206d6f692c20636520736f6972203f "p2sigsceCzcDw2AeYDzUonj4JT341WC9Px4wdhHBxbZcG1FhfqFVuG7f2fGCzrEHSAZgrsrQWpxduDPk9qZRgrpzwJnSHC3gZJ")' '(Pair 0x050100000027566f756c657a2d766f757320636f75636865722061766563206d6f692c20636520736f6972203f "p2sigsceCzcDw2AeYDzUonj4JT341WC9Px4wdhHBxbZcG1FhfqFVuG7f2fGCzrEHSAZgrsrQWpxduDPk9qZRgrpzwJnSHC3gZJ")'
bake bake
# Test comparisons on bytes { EQ ; GT ; LT ; GE ; LE }
assert_storage $contract_dir/compare_bytes.tz '{}' '(Pair 0x33 0x34)' '{ False ; False ; True ; False ; True }'
assert_storage $contract_dir/compare_bytes.tz '{}' '(Pair 0x33 0x33aa)' '{ False ; False ; True ; False ; True }'
assert_storage $contract_dir/compare_bytes.tz '{}' '(Pair 0x33 0x33)' '{ True ; False ; False ; True ; True }'
assert_storage $contract_dir/compare_bytes.tz '{}' '(Pair 0x34 0x33)' '{ False ; True ; False ; True ; False }'
# Test SLICE and SIZE on bytes # Test SLICE and SIZE on bytes
init_with_transfer $contract_dir/slices.tz bootstrap1 \ init_with_transfer $contract_dir/slices.tz bootstrap1 \
'"sppk7dBPqMPjDjXgKbb5f7V3PuKUrA4Zuwc3c3H7XqQerqPUWbK7Hna"' 1,000 bootstrap1 '"sppk7dBPqMPjDjXgKbb5f7V3PuKUrA4Zuwc3c3H7XqQerqPUWbK7Hna"' 1,000 bootstrap1