src/HOL/Codegenerator_Test/Code_Test_OCaml.thy
author haftmann
Mon, 23 Dec 2024 21:22:10 +0100
changeset 81642 e77e8ef5bf9b
parent 69597 ff784d5a5bfb
child 81713 378b9d6c52b2
permissions -rw-r--r--
explicit tests for target-language bit operations
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
59720
f893472fff31 proper headers;
wenzelm
parents: 58626
diff changeset
     1
(*  Title:      HOL/Codegenerator_Test/Code_Test_OCaml.thy
58039
469a375212c1 add testing framework for generated code
Andreas Lochbihler
parents:
diff changeset
     2
    Author:     Andreas Lochbihler, ETH Zurich
81642
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
     3
    Author:     Florian Haftmann, TU Muenchen
58039
469a375212c1 add testing framework for generated code
Andreas Lochbihler
parents:
diff changeset
     4
*)
469a375212c1 add testing framework for generated code
Andreas Lochbihler
parents:
diff changeset
     5
81642
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
     6
theory Code_Test_OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
     7
imports
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
     8
  "HOL-Library.Code_Test"
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
     9
  Code_Lazy_Test
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    10
begin
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    11
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    12
text \<open>Test cases for \<^text>\<open>test_code\<close>\<close>
58039
469a375212c1 add testing framework for generated code
Andreas Lochbihler
parents:
diff changeset
    13
469a375212c1 add testing framework for generated code
Andreas Lochbihler
parents:
diff changeset
    14
test_code "14 + 7 * -12 = (140 div -2 :: integer)" in OCaml
469a375212c1 add testing framework for generated code
Andreas Lochbihler
parents:
diff changeset
    15
58348
2d47c7d10b62 add target language evaluators for the value command;
Andreas Lochbihler
parents: 58039
diff changeset
    16
value [OCaml] "14 + 7 * -12 :: integer"
58039
469a375212c1 add testing framework for generated code
Andreas Lochbihler
parents:
diff changeset
    17
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68155
diff changeset
    18
test_code \<comment> \<open>Tests for the serialisation of \<^const>\<open>gcd\<close> on \<^typ>\<open>integer\<close>\<close>
61856
4b1b85f38944 add gcd instance for integer and serialisation to target language operations
Andreas Lochbihler
parents: 59720
diff changeset
    19
  "gcd 15 10 = (5 :: integer)"
4b1b85f38944 add gcd instance for integer and serialisation to target language operations
Andreas Lochbihler
parents: 59720
diff changeset
    20
  "gcd 15 (- 10) = (5 :: integer)"
4b1b85f38944 add gcd instance for integer and serialisation to target language operations
Andreas Lochbihler
parents: 59720
diff changeset
    21
  "gcd (- 10) 15 = (5 :: integer)"
4b1b85f38944 add gcd instance for integer and serialisation to target language operations
Andreas Lochbihler
parents: 59720
diff changeset
    22
  "gcd (- 10) (- 15) = (5 :: integer)"
4b1b85f38944 add gcd instance for integer and serialisation to target language operations
Andreas Lochbihler
parents: 59720
diff changeset
    23
  "gcd 0 (- 10) = (10 :: integer)"
4b1b85f38944 add gcd instance for integer and serialisation to target language operations
Andreas Lochbihler
parents: 59720
diff changeset
    24
  "gcd (- 10) 0 = (10 :: integer)"
4b1b85f38944 add gcd instance for integer and serialisation to target language operations
Andreas Lochbihler
parents: 59720
diff changeset
    25
  "gcd 0 0 = (0 :: integer)"
4b1b85f38944 add gcd instance for integer and serialisation to target language operations
Andreas Lochbihler
parents: 59720
diff changeset
    26
in OCaml
4b1b85f38944 add gcd instance for integer and serialisation to target language operations
Andreas Lochbihler
parents: 59720
diff changeset
    27
68155
8b50f29a1992 new tool Code_Lazy
Andreas Lochbihler
parents: 66453
diff changeset
    28
test_code "stake 10 (cycle ''ab'') = ''ababababab''" in OCaml
8b50f29a1992 new tool Code_Lazy
Andreas Lochbihler
parents: 66453
diff changeset
    29
81642
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    30
text \<open>Test cases for bit operations on target language numerals\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    31
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    32
unbundle bit_operations_syntax
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    33
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    34
lemma \<open>bit (473514 :: integer) 5\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    35
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    36
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    37
test_code \<open>bit (473514 :: integer) 5\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    38
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    39
lemma \<open>bit (- 805167 :: integer) 7\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    40
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    41
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    42
test_code \<open>bit (- 805167 :: integer) 7\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    43
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    44
lemma \<open>473514 AND (767063 :: integer) = 208898\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    45
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    46
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    47
test_code \<open>473514 AND (767063 :: integer) = 208898\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    48
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    49
lemma \<open>- 805167 AND (767063 :: integer) = 242769\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    50
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    51
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    52
test_code \<open>- 805167 AND (767063 :: integer) = 242769\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    53
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    54
lemma \<open>473514 AND (- 314527 :: integer) = 209184\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    55
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    56
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    57
test_code \<open>473514 AND (- 314527 :: integer) = 209184\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    58
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    59
lemma \<open>- 805167 AND (- 314527 :: integer) = - 839103\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    60
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    61
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    62
test_code \<open>- 805167 AND (- 314527 :: integer) = - 839103\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    63
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    64
lemma \<open>473514 OR (767063 :: integer) = 1031679\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    65
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    66
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    67
test_code \<open>473514 OR (767063 :: integer) = 1031679\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    68
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    69
lemma \<open>- 805167 OR (767063 :: integer) = - 280873\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    70
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    71
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    72
test_code \<open>- 805167 OR (767063 :: integer) = - 280873\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    73
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    74
lemma \<open>473514 OR (- 314527 :: integer) = - 50197\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    75
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    76
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    77
test_code \<open>473514 OR (- 314527 :: integer) = - 50197\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    78
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    79
lemma \<open>- 805167 OR (- 314527 :: integer) = - 280591\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    80
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    81
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    82
test_code \<open>- 805167 OR (- 314527 :: integer) = - 280591\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    83
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    84
lemma \<open>473514 XOR (767063 :: integer) = 822781\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    85
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    86
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    87
test_code \<open>473514 XOR (767063 :: integer) = 822781\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    88
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    89
lemma \<open>- 805167 XOR (767063 :: integer) = - 523642\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    90
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    91
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    92
test_code \<open>- 805167 XOR (767063 :: integer) = - 523642\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    93
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    94
lemma \<open>473514 XOR (- 314527 :: integer) = - 259381\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    95
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    96
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    97
test_code \<open>473514 XOR (- 314527 :: integer) = - 259381\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    98
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
    99
lemma \<open>- 805167 XOR (- 314527 :: integer) = 558512\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   100
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   101
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   102
test_code \<open>- 805167 XOR (- 314527 :: integer) = 558512\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   103
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   104
lemma \<open>NOT (473513 :: integer) = - 473514\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   105
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   106
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   107
test_code \<open>NOT (473513 :: integer) = - 473514\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   108
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   109
lemma \<open>NOT (- 805167 :: integer) = 805166\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   110
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   111
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   112
test_code \<open>NOT (- 805167 :: integer) = 805166\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   113
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   114
lemma \<open>(mask 39 :: integer) = 549755813887\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   115
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   116
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   117
test_code \<open>(mask 39 :: integer) = 549755813887\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   118
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   119
lemma \<open>set_bit 15 (473514 :: integer) = 506282\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   120
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   121
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   122
test_code \<open>set_bit 15 (473514 :: integer) = 506282\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   123
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   124
lemma \<open>set_bit 11 (- 805167 :: integer) = - 803119\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   125
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   126
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   127
test_code \<open>set_bit 11 (- 805167 :: integer) = - 803119\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   128
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   129
lemma \<open>unset_bit 13 (473514 :: integer) = 465322\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   130
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   131
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   132
test_code \<open>unset_bit 13 (473514 :: integer) = 465322\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   133
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   134
lemma \<open>unset_bit 12 (- 805167 :: integer) = - 809263\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   135
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   136
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   137
test_code \<open>unset_bit 12 (- 805167 :: integer) = - 809263\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   138
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   139
lemma \<open>flip_bit 15 (473514 :: integer) = 506282\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   140
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   141
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   142
test_code \<open>flip_bit 15 (473514 :: integer) = 506282\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   143
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   144
lemma \<open>flip_bit 12 (- 805167 :: integer) = - 809263\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   145
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   146
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   147
test_code \<open>flip_bit 12 (- 805167 :: integer) = - 809263\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   148
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   149
lemma \<open>push_bit 12 (473514 :: integer) = 1939513344\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   150
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   151
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   152
test_code \<open>push_bit 12 (473514 :: integer) = 1939513344\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   153
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   154
lemma \<open>push_bit 12 (- 805167 :: integer) = - 3297964032\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   155
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   156
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   157
test_code \<open>push_bit 12 (- 805167 :: integer) = - 3297964032\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   158
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   159
lemma \<open>drop_bit 12 (473514 :: integer) = 115\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   160
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   161
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   162
test_code \<open>drop_bit 12 (473514 :: integer) = 115\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   163
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   164
lemma \<open>drop_bit 12 (- 805167 :: integer) = - 197\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   165
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   166
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   167
test_code \<open>drop_bit 12 (- 805167 :: integer) = - 197\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   168
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   169
lemma \<open>take_bit 12 (473514 :: integer) = 2474\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   170
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   171
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   172
test_code \<open>take_bit 12 (473514 :: integer) = 2474\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   173
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   174
lemma \<open>take_bit 12 (- 805167 :: integer) = 1745\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   175
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   176
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   177
test_code \<open>take_bit 12 (- 805167 :: integer) = 1745\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   178
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   179
lemma \<open>signed_take_bit 12 (473514 :: integer) = - 1622\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   180
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   181
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   182
test_code \<open>signed_take_bit 12 (473514 :: integer) = - 1622\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   183
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   184
lemma \<open>signed_take_bit 12 (- 805167 :: integer) = - 2351\<close>
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   185
  by normalization
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   186
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   187
test_code \<open>signed_take_bit 12 (- 805167 :: integer) = - 2351\<close> in OCaml
e77e8ef5bf9b explicit tests for target-language bit operations
haftmann
parents: 69597
diff changeset
   188
58039
469a375212c1 add testing framework for generated code
Andreas Lochbihler
parents:
diff changeset
   189
end