Skip to content
Merged
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
11 changes: 9 additions & 2 deletions scripts/gen_conformance_corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

from liminate.analyzer import analyze # noqa: E402
from liminate.lexer import LexError, tokenize # noqa: E402
from liminate.parser import parse # noqa: E402
from liminate.parser import ASTNode, parse # noqa: E402
from liminate.renderer import render # noqa: E402
from liminate.reorderer import reorder # noqa: E402
from liminate.result import LiminateResult, ResultStatus # noqa: E402
Expand Down Expand Up @@ -120,12 +120,19 @@ def node_kinds(node: object) -> list[str]:

Kind names are the class name here and the `kind` field in TypeScript, and
they already agree — `RequireNode` is `RequireNode` on both sides.

An `ASTNode` subclass is a node; another dataclass is a container. The walk
recurses through both and counts only the first. `ChooseBranch` is the case
that made the distinction necessary: it is a plain dataclass here and an
interface with no `kind` field in TypeScript, so both implementations
already agree it is not a node — and counting it made them disagree.
"""
found: list[str] = []

def walk(value: object) -> None:
if dataclasses.is_dataclass(value) and not isinstance(value, type):
found.append(type(value).__name__)
if isinstance(value, ASTNode):
found.append(type(value).__name__)
for f in dataclasses.fields(value):
walk(getattr(value, f.name))
elif isinstance(value, (list, tuple)):
Expand Down
4 changes: 0 additions & 4 deletions tests/fixtures/conformance-0.18.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@
{
"canonical": "choose if tags includes urgent: show yes otherwise show no",
"nodes": [
"ChooseBranch",
"ChooseBranch",
"ChooseNode",
"ConditionNode",
"NameRef",
Expand Down Expand Up @@ -218,8 +216,6 @@
{
"canonical": "choose if tags not includes urgent: show ok otherwise show skip",
"nodes": [
"ChooseBranch",
"ChooseBranch",
"ChooseNode",
"ConditionNode",
"NameRef",
Expand Down