-
Notifications
You must be signed in to change notification settings - Fork 77
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
The extract_keys method may fail if the token has three or more words #172
Comments
a failing test case would be nice |
tried this; it("multiple section modifiers #only", function()
assert.is_not_is_not_equal(1, 1)
assert.not_is_not_is_equal(1, 1)
assert.not_not_is_is_equal(1, 1)
assert.is_is_not_not_equal(1, 1)
assert.is_not_is_not_is_not_equal(1, 2)
assert.not_is_not_is_not_is_equal(1, 2)
assert.not_not_not_is_is_is_equal(1, 2)
assert.is_is_is_not_not_not_equal(1, 2)
end) But that passes nicely, so cannot reproduce this. Am I missing something @Triple-Z ? |
@Tieske Sorry, I consider this issue is created by assertions but no modifiers. Here is my test for this: it("three words token #only", function()
assert:register("assertion", "three_words_token", function() print("can you see me?") return false end, "assertion.same.positive", "assertion.same.negative")
assert:register("assertion", "more_three_words_token", function() print("can you see me now?") return false end, "assertion.same.positive", "assertion.same.negative")
assert.is_not_more_three_words_token()
end) The With the change which I proposed before, Like this test: it("three words token #only", function()
assert:register("assertion", "three_words_token", function() print("you can't see me") return false end, "assertion.same.positive", "assertion.same.negative")
assert:register("assertion", "than_three_words_token", function() print("you can't see me") return false end, "assertion.same.positive", "assertion.same.negative")
assert:register("assertion", "more_than_three_words_token", function() print("you can see me") return false end, "assertion.same.positive", "assertion.same.negative")
assert.is_not_more_than_three_words_token()
end) However, I find there is another bug, the Like this: it("three words token #only", function()
assert:register("assertion", "three_words_token", function() print("you can't see me") return false end, "assertion.same.positive", "assertion.same.negative")
-- assert:register("assertion", "than_three_words_token", function() print("you can't see me") return false end, "assertion.same.positive", "assertion.same.negative")
assert:register("assertion", "more_than_three_words_token", function() print("you can see me") return false end, "assertion.same.positive", "assertion.same.negative")
assert.is_not_more_than_three_words_token()
end) It would raise an error: "luassert: unknown modifier/assertion: 'is_not_more_than'" . |
tbh, I think the best route would be to document that tokens can have a maximum of 3 words. That is fair enough imo, and prevents us from going down a rabbit hole with this one. wdyt @ajacksified @DorianGray ? |
I just ran into the same problem, but in a little bit more surprising setup. Executing a spec with |
https://github.com/Olivine-Labs/luassert/blob/36fc3af9621696a9dfcf71c0bcd25cdbc9475cf8/src/util.lua#L322-L329
At line 328, the
longkey
maybe wrong in further iterations.For example: if the
tokens
is{'is', 'match', 'error'}
, thelongkey
variable will bematch_match_error
at the second iteration in the inner while loop. So it may fail to get the longest matching key when the key has three or more words.Here is the potential fix which I brought up:
The text was updated successfully, but these errors were encountered: