1+ from __future__ import annotations
2+
3+ from typing import TYPE_CHECKING
4+
15import pytest
26
37import pyk .kllvm .load # noqa: F401
8+ from pyk .kllvm import parser
49from pyk .kllvm .ast import Pattern
510from pyk .kllvm .convert import pattern_to_llvm
611from 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
720
821TEST_DATA = (
922 '"foo"' ,
@@ -30,3 +43,23 @@ def test_serialize(kore_text: str) -> None:
3043 # Then
3144 assert actual is not None
3245 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