1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
1
5
import pytest
2
6
3
7
import pyk .kllvm .load # noqa: F401
8
+ from pyk .kllvm import parser
4
9
from pyk .kllvm .ast import Pattern
5
10
from pyk .kllvm .convert import pattern_to_llvm
6
11
from pyk .kore .parser import KoreParser
12
+ from pyk .testing import RuntimeTest
13
+
14
+ from ..utils import K_FILES
15
+
16
+ if TYPE_CHECKING :
17
+ from pathlib import Path
18
+
19
+ from pyk .kllvm .runtime import Runtime
7
20
8
21
TEST_DATA = (
9
22
'"foo"' ,
@@ -30,3 +43,23 @@ def test_serialize(kore_text: str) -> None:
30
43
# Then
31
44
assert actual is not None
32
45
assert str (actual ) == str (pattern )
46
+
47
+
48
+ class TestSerializeRaw (RuntimeTest ):
49
+ KOMPILE_MAIN_FILE = K_FILES / 'imp.k'
50
+
51
+ def test_serialize_raw (self , runtime : Runtime , tmp_path : Path ) -> None :
52
+ # Given
53
+ kore_text = r"""Lbl'UndsPlus'Int'Unds'{}(\dv{SortInt{}}("1"),\dv{SortInt{}}("2"))"""
54
+ pattern = parser .parse_pattern (kore_text )
55
+ term = runtime .term (pattern )
56
+ kore_file = tmp_path / 'kore'
57
+
58
+ # When
59
+ term ._block ._serialize_raw (str (kore_file ), 'SortInt{}' )
60
+ pattern = Pattern .deserialize (kore_file .read_bytes ())
61
+ pattern_with_raw = Pattern .deserialize (kore_file .read_bytes (), strip_raw_term = False )
62
+
63
+ # Then
64
+ assert str (pattern ) == r'\dv{SortInt{}}("3")'
65
+ assert str (pattern_with_raw ) == r'rawTerm{}(inj{SortInt{}, SortKItem{}}(\dv{SortInt{}}("3")))'
0 commit comments