-
Notifications
You must be signed in to change notification settings - Fork 11
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
adds tracing for names #66
Conversation
2691b50
to
1dc2bf3
Compare
type T { | ||
a String | ||
b String | ||
c Integer |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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}$")
de8d123
to
2914b42
Compare
b22befc
into
bmw-software-engineering:main
adds tracing for chapter 11 ("Names")