|
81761
|
1 |
(* Author: Florian Haftmann, TU Muenchen *)
|
|
|
2 |
|
|
|
3 |
section \<open>Test of target-language string literal operations\<close>
|
|
|
4 |
|
|
|
5 |
theory Generate_Target_String_Literals
|
|
|
6 |
imports
|
|
|
7 |
"HOL-Library.Code_Test"
|
|
|
8 |
begin
|
|
|
9 |
|
|
|
10 |
definition computations where
|
|
|
11 |
\<open>computations = (
|
|
|
12 |
STR ''abc'' + STR 0x20 + STR ''def'',
|
|
|
13 |
String.implode ''abc'',
|
|
|
14 |
String.explode STR ''abc'',
|
|
|
15 |
String.literal_of_asciis [10, 20, 30, 40, 1111, 2222, 3333],
|
|
|
16 |
size (STR ''abc''),
|
|
|
17 |
STR ''def'' \<le> STR ''abc'',
|
|
|
18 |
STR ''abc'' < STR ''def''
|
|
|
19 |
)\<close>
|
|
|
20 |
|
|
|
21 |
definition results where
|
|
|
22 |
\<open>results = (
|
|
|
23 |
STR ''abc def'',
|
|
|
24 |
STR ''abc'',
|
|
|
25 |
''abc'',
|
|
|
26 |
STR ''\<newline>'' + STR 0x14 + STR 0x1E + STR ''(W.'' + STR 0x05,
|
|
|
27 |
3,
|
|
|
28 |
False,
|
|
|
29 |
True
|
|
|
30 |
)\<close>
|
|
|
31 |
|
|
|
32 |
definition check where
|
|
|
33 |
\<open>check \<longleftrightarrow> computations = results\<close>
|
|
|
34 |
|
|
|
35 |
lemma check
|
|
|
36 |
by code_simp
|
|
|
37 |
|
|
|
38 |
lemma check
|
|
|
39 |
by normalization
|
|
|
40 |
|
|
|
41 |
lemma check
|
|
|
42 |
by eval
|
|
|
43 |
|
|
|
44 |
test_code check in OCaml
|
|
|
45 |
test_code check in GHC
|
|
|
46 |
test_code check in Scala
|
|
|
47 |
|
|
|
48 |
end
|