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