src/HOL/Codegenerator_Test/Code_Test_OCaml.thy
author wenzelm
Sat, 01 Jun 2019 11:29:59 +0200
changeset 70299 83774d669b51
parent 69597 ff784d5a5bfb
child 81642 e77e8ef5bf9b
permissions -rw-r--r--
Added tag Isabelle2019-RC4 for changeset ad2d84c42380

(*  Title:      HOL/Codegenerator_Test/Code_Test_OCaml.thy
    Author:     Andreas Lochbihler, ETH Zurich

Test case for test_code on OCaml
*)

theory Code_Test_OCaml imports  "HOL-Library.Code_Test" Code_Lazy_Test begin

test_code "14 + 7 * -12 = (140 div -2 :: integer)" in OCaml

value [OCaml] "14 + 7 * -12 :: integer"

test_code \<comment> \<open>Tests for the serialisation of \<^const>\<open>gcd\<close> on \<^typ>\<open>integer\<close>\<close>
  "gcd 15 10 = (5 :: integer)"
  "gcd 15 (- 10) = (5 :: integer)"
  "gcd (- 10) 15 = (5 :: integer)"
  "gcd (- 10) (- 15) = (5 :: integer)"
  "gcd 0 (- 10) = (10 :: integer)"
  "gcd (- 10) 0 = (10 :: integer)"
  "gcd 0 0 = (0 :: integer)"
in OCaml

test_code "stake 10 (cycle ''ab'') = ''ababababab''" in OCaml

end