Skip to content
This repository was archived by the owner on Apr 25, 2024. It is now read-only.

Commit 8bec235

Browse files
Add test for KProduction.label (#880)
~Blocked on #860~ --------- Co-authored-by: devops <[email protected]>
1 parent f94ac0c commit 8bec235

File tree

5 files changed

+38
-4
lines changed

5 files changed

+38
-4
lines changed

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
project = 'pyk'
1010
author = 'Runtime Verification, Inc'
1111
copyright = '2024, Runtime Verification, Inc'
12-
version = '0.1.628'
13-
release = '0.1.628'
12+
version = '0.1.629'
13+
release = '0.1.629'
1414

1515
# -- General configuration ---------------------------------------------------
1616
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

package/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.628
1+
0.1.629

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "pyk"
7-
version = "0.1.628"
7+
version = "0.1.629"
88
description = ""
99
authors = [
1010
"Runtime Verification, Inc. <[email protected]>",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module KLABEL
2+
syntax Foo ::= "foo" [symbol(foo)]
3+
| "bar" [klabel(bar), symbol]
4+
| "baz" [klabel(baz)]
5+
| "qux"
6+
endmodule

src/tests/integration/test_kompile.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44

55
import pytest
66

7+
from pyk.kast import KAtt
78
from pyk.ktool.kompile import KompileBackend, KompileNotFoundError, kompile
89
from pyk.testing import KompiledTest
910

1011
from .utils import K_FILES
1112

1213
if TYPE_CHECKING:
14+
from pyk.kast.inner import KLabel
15+
from pyk.kast.outer import KDefinition
1316
from pyk.ktool.kompile import DefinitionInfo
1417

1518

@@ -42,3 +45,28 @@ def test_kompile_not_found(monkeypatch: pytest.MonkeyPatch) -> None:
4245

4346
with pytest.raises(KompileNotFoundError):
4447
kompile(k_file, command=[bad_kompile])
48+
49+
50+
class TestKLabel(KompiledTest):
51+
KOMPILE_MAIN_FILE = K_FILES / 'klabel.k'
52+
53+
def test(self, definition: KDefinition) -> None:
54+
# Given
55+
module = definition.module('KLABEL')
56+
57+
def klabel_defined_at_line(line: int) -> KLabel:
58+
(prod,) = (prod for prod in module.productions if prod.att.get(KAtt.LOCATION, [None])[0] == line)
59+
res = prod.klabel
60+
assert res is not None
61+
return res
62+
63+
foo = klabel_defined_at_line(2)
64+
bar = klabel_defined_at_line(3)
65+
baz = klabel_defined_at_line(4)
66+
qux = klabel_defined_at_line(5)
67+
68+
# Then
69+
assert foo.name == 'foo'
70+
assert bar.name == 'bar'
71+
assert baz.name == 'baz_KLABEL_Foo'
72+
assert qux.name == 'qux_KLABEL_Foo'

0 commit comments

Comments
 (0)