From 855232f8f463e567e075d2919578374fa8bc32d3 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 28 Aug 2026 20:37:47 -0700 Subject: [PATCH 1/3] fix typoed test name --- tests/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests.py b/tests/tests.py index d616ecbd..adaaf101 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -1074,7 +1074,7 @@ def test_murphi_format_not_unicode(): assert ":= ¬y" in stdout, "`¬` spaced incorrectly" -def test_muprhi_format_smart_quotes(): +def test_murphi_format_smart_quotes(): """murphi-format should handle smart quotes (“”) correctly""" model = "rule begin assert “foo bar” x; end" From 8c45c9fea66046c9797606468416081db2c3ecd8 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 28 Aug 2026 20:37:47 -0700 Subject: [PATCH 2/3] add a test case for bad 'muphi-format' indentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Github: #339 “missing dedent in murphi-format” --- tests/tests.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/tests.py b/tests/tests.py index adaaf101..fc46995f 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -1216,6 +1216,30 @@ def test_murphi_format_end_newline(): assert stdout.endswith("\n"), "incorrect file ending" +@pytest.mark.xfail(raises=AssertionError, reason="FIXME", strict=True) +def test_murphi_format_arrow_break_dedent(): + """ + is murphi-format’s indenting confused by `==>\n\n`? + + https://github.com/Smattr/rumur/issues/339 + """ + + # a rule that has a paragraph break after `==>` + src = 'rule"foo"==>\n\nvar x:boolean;begin x:=false;end;' + + # run this through `murphi-format` + ret, stdout, stderr = run(["murphi-format"], src) + if ret != 0: + sys.stdout.write(stdout) + sys.stderr.write(stderr) + assert ret == 0, "failed to reflow Murphi snippet" + assert stderr == "", "murphi-format printed errors/warnings" + + # if indentation was not mismanaged, ending indentation should be 0 + # did we get the expected reflowing? + assert stdout.endswith("\nend;\n"), "incorrect handling of `==>`" + + @pytest.mark.parametrize("component", ("list", "set")) @pytest.mark.skipif(shutil.which("m4") is None, reason="m4 not available") def test_stdlib(component, tmp_path): From fdeab2f1837a5819db04739ecd178d578a9582e8 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 28 Aug 2026 20:37:47 -0700 Subject: [PATCH 3/3] murphi-format: fix incorrect indentation handling of '==>\n\nbegin' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Github: fixes #339 “missing dedent in murphi-format” --- murphi-format/src/format.c | 11 ++++++++++- tests/tests.py | 1 - 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/murphi-format/src/format.c b/murphi-format/src/format.c index e3524b17..10b9b79e 100644 --- a/murphi-format/src/format.c +++ b/murphi-format/src/format.c @@ -54,6 +54,9 @@ typedef struct state { /// have we output anything to `dst` yet? bool started; + + /// have we seen `==>` and are thus anticipating `begin`? + bool arrow_expecting_begin; } state_t; /// are two strings equal? @@ -135,8 +138,13 @@ static int pend_newline(state_t *st, token_t token) { if (token.type == TOKEN_EOF) goto done; size_t indentation = st->indentation; - if (token.type != TOKEN_ID || !streq(token.text, "begin")) + if (token.type != TOKEN_ID || !streq(token.text, "begin")) { indentation += st->soft_indentation; + } else if (st->arrow_expecting_begin) { + st->indentation--; + --indentation; + st->arrow_expecting_begin = false; + } for (size_t i = 0; i < indentation; ++i) { if (fputs(tab, st->dst) < 0) { rc = EIO; @@ -165,6 +173,7 @@ static int arrow_lookahead(state_t *st, token_t token) { // otherwise infer a newline and indent ++st->indentation; + st->arrow_expecting_begin = true; rc = pend_newline(st, token); done: diff --git a/tests/tests.py b/tests/tests.py index fc46995f..91ed99dd 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -1216,7 +1216,6 @@ def test_murphi_format_end_newline(): assert stdout.endswith("\n"), "incorrect file ending" -@pytest.mark.xfail(raises=AssertionError, reason="FIXME", strict=True) def test_murphi_format_arrow_break_dedent(): """ is murphi-format’s indenting confused by `==>\n\n`?