src/HOL/Codegenerator_Test/Code_Test_OCaml.thy
author haftmann
Mon, 16 Jun 2025 15:25:38 +0200
changeset 82730 3b98b1b57435
parent 81815 0b31f0909060
permissions -rw-r--r--
more explicit theorem names for list quantifiers

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

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

text \<open>Test cases for \<^text>\<open>test_code\<close>\<close>

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