From 8cfa583d556f73f0cd1702028ba82ddc83902b1e Mon Sep 17 00:00:00 2001 From: John David Pressman Date: Fri, 25 Oct 2019 16:33:31 -0700 Subject: [PATCH] Add more string tests to CameLIGO --- src/test/contracts/string_arithmetic.mligo | 6 ++++++ src/test/integration_tests.ml | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/test/contracts/string_arithmetic.mligo b/src/test/contracts/string_arithmetic.mligo index 89d77ff60..1e1db9750 100644 --- a/src/test/contracts/string_arithmetic.mligo +++ b/src/test/contracts/string_arithmetic.mligo @@ -1,4 +1,10 @@ (* Test that the string concatenation syntax in CameLIGO works *) +let size_op (s : string) : nat = + String.size s + +let slice_op (s : string) : string = + String.slice 1p 2p s + let concat_syntax (s: string) = s ^ "test_literal" diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index ba12aed84..509b1f0d6 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -239,6 +239,9 @@ let string_arithmetic () : unit result = let string_arithmetic_mligo () : unit result = let%bind program = mtype_file "./contracts/string_arithmetic.mligo" in + let%bind () = expect_eq program "size_op" (e_string "tata") (e_nat 4) in + let%bind () = expect_eq program "slice_op" (e_string "tata") (e_string "at") in + let%bind () = expect_eq program "slice_op" (e_string "foo") (e_string "oo") in let%bind () = expect_eq program "concat_syntax" (e_string "string_") (e_string "string_test_literal") in ok ()