Skip to content

Commit

Permalink
Add test for detection of references to optional fields
Browse files Browse the repository at this point in the history
Ref. #413
  • Loading branch information
treiher committed Oct 13, 2020
1 parent 85e9a75 commit f17f20d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/unit/model/message_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from rflx.error import Location, RecordFluxError
from rflx.expression import (
FALSE,
TRUE,
Add,
Aggregate,
Expand Down Expand Up @@ -660,6 +661,31 @@ def test_subsequent_variable() -> None:
)


def test_reference_to_optional_field() -> None:
structure = [
Link(INITIAL, Field("F1")),
Link(Field("F1"), Field("F2"), Equal(Variable("F1"), TRUE)),
Link(Field("F1"), Field("F3"), Equal(Variable("F1"), FALSE)),
Link(Field("F2"), Field("F3")),
Link(
Field("F3"),
FINAL,
Equal(Variable("F2", location=Location((10, 30))), TRUE, location=Location((10, 20))),
),
]

types = {Field("F1"): BOOLEAN, Field("F2"): BOOLEAN, Field("F3"): BOOLEAN}

assert_message_model_error(
structure,
types,
r"^"
r'<stdin>:10:30: model: error: undefined variable "F2"\n'
r"<stdin>:10:20: model: info: on path F1 -> F3 -> Final"
r"$",
)


def test_invalid_use_of_length_attribute() -> None:
structure = [
Link(INITIAL, Field("F1")),
Expand Down

0 comments on commit f17f20d

Please sign in to comment.