Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle KLLVM.StringBuffer.contents as bytes and enable unicode tests in String contructors #4567

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyk/src/pyk/kllvm/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def sentence_to_llvm(sentence: Sentence) -> kllvm.Declaration:
def pattern_to_llvm(pattern: Pattern) -> kllvm.Pattern:
match pattern:
case String(value):
return kllvm.StringPattern(value)
return kllvm.StringPattern(value.encode('latin-1'))
case VarPattern(name, sort):
return kllvm.VariablePattern(name, sort_to_llvm(sort))
case App(symbol, sorts, args):
Expand Down Expand Up @@ -201,7 +201,7 @@ def llvm_to_sentence(decl: kllvm.Declaration) -> Sentence:
def llvm_to_pattern(pattern: kllvm.Pattern) -> Pattern:
match pattern:
case kllvm.StringPattern(): # type: ignore
return String(pattern.contents)
return String(pattern.contents.decode('latin-1'))
case kllvm.VariablePattern(): # type: ignore
if pattern.name and pattern.name[0] == '@':
return SVar(pattern.name, llvm_to_sort(pattern.sort))
Expand Down
2 changes: 1 addition & 1 deletion pyk/src/tests/integration/kllvm/test_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_string() -> None:

# Then
assert str(pattern) == '"abc"'
assert pattern.contents == 'abc'
assert pattern.contents.decode('latin-1') == 'abc'


def test_variable() -> None:
Expand Down
9 changes: 9 additions & 0 deletions pyk/src/tests/integration/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
'🙂',
)

SKIPPED_BINDINGS_TESTS: Final = {
'𐍈',
'武天老師',
'🙂',
}

KOMPILE_DEFINITION = """
module STRING-REWRITE
imports STRING-SYNTAX
Expand Down Expand Up @@ -217,6 +223,9 @@ def test_krun(backend: str, definition_dir: Path, text: str) -> None:
def test_bindings(runtime: Runtime, text: str) -> None:
from pyk.kllvm.convert import llvm_to_pattern, pattern_to_llvm

if text in SKIPPED_BINDINGS_TESTS:
pytest.skip()

# Given
kore = kore_config(text, '')
expected = kore_config(None, text)
Expand Down
Loading