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

adds tracing for names #66

Conversation

christophkloeffel
Copy link
Contributor

@christophkloeffel christophkloeffel commented Jan 16, 2024

adds tracing for chapter 11 ("Names")

@phiwuu phiwuu requested a review from florianschanda January 30, 2024 15:20
@christophkloeffel christophkloeffel requested a review from a team as a code owner June 10, 2024 15:09
@christophkloeffel christophkloeffel enabled auto-merge (squash) September 2, 2024 12:03
@phiwuu phiwuu requested review from phiwuu and removed request for florianschanda September 2, 2024 12:40
@phiwuu phiwuu self-assigned this Sep 2, 2024
language-reference-manual/lrm.trlc Outdated Show resolved Hide resolved
language-reference-manual/lrm.trlc Show resolved Hide resolved
tests-system/rbt-endswith-semantics/foo.trlc Show resolved Hide resolved
tests-system/rbt-endswith-semantics/output Show resolved Hide resolved
tests-system/rbt-len-semantics/foo.rsl Show resolved Hide resolved
type T {
a String
b String
c Integer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c is not needed

}

checks T {
matches(a, "potato"), warning "a should match with potato", a
Copy link
Member

@phiwuu phiwuu Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: The matches function uses a regex. Here the regex is potato, which is equal to startswith(a, "potato").
In order to make this clear (for any future developer looking at the tests), and to make sure the matches function really uses a regex implementation (and not just redirects to startswith), I recommend to refactor the test like this:

package Foo

type T {
    a String
    b String
    c String
    d String
}

checks T {
    matches(a, "/^[a-zA-Z0-9]{6,12}$/"), warning "a should match with 6 to 12 letters or digits", a
    matches(b, "\w+"), warning "b should match only letters, digits, or underscores.", b
    matches(c, "potato"), warning "b should start with 'potato'.", c
    matches(d, "^D.*"), warning "d should start with D", d
}

Then please update the foo.trlc as follows:

package Foo

T No_Regex_Matches {
    a = "123456789 abcdefghijklmn"
    b = "??...kitten_...??"
    c = "not potato"
    d = "not Diego"
}

T All_Regex_Matches {
    a = "123abc"
    b = "3_kitten_"
    c = "potato and tomato sauce"
    d = "Diego"
}

Expected output:

a = "123456789 abcdefghijklmn"
    ^^^^^^^^^^^^^^^^^^^^^^^^^^ .\test.trlc:4: check warning: a should match with 6 to 12 letters or digits
b = "??...kitten_...??"
    ^^^^^^^^^^^^^^^^^^^ .\test.trlc:5: check warning: b should match only letters, digits, or underscores.
c = "not potato"
    ^^^^^^^^^^^^ .\test.trlc:6: check warning: b should start with 'potato'.
d = "not Diego"
    ^^^^^^^^^^^ .\test.trlc:7: check warning: d should start with D
Processed 1 model(s), 0 check(s) and 1 requirement file(s) and found 6 warning(s)

As we will then see, the test is failing. The reason could be a parsing issue of the regex. Maybe the slashes are not escaped well.

Copy link
Contributor Author

@christophkloeffel christophkloeffel Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not reproduce this with the given samples, so I removed the "/" delimiter in your matches(a, "/^[a-zA-Z0-9]{6,12}$/") check to matches(a, "^[a-zA-Z0-9]{6,12}$")

@phiwuu phiwuu force-pushed the tracing/chapter-12 branch from de8d123 to 2914b42 Compare October 15, 2024 11:25
@christophkloeffel christophkloeffel merged commit b22befc into bmw-software-engineering:main Oct 15, 2024
21 checks passed
christophkloeffel pushed a commit to christophkloeffel/trlc that referenced this pull request Oct 17, 2024
christophkloeffel pushed a commit to christophkloeffel/trlc that referenced this pull request Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants