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

new string equality tests? #207

Closed
marcinruszkiewicz opened this issue Mar 15, 2019 · 3 comments
Closed

new string equality tests? #207

marcinruszkiewicz opened this issue Mar 15, 2019 · 3 comments

Comments

@marcinruszkiewicz
Copy link
Contributor

Are they correct?

I was updating the Kaiser-Ruby implementation with the new test suite and encountered this.

Spec says String <op> Boolean => Convert the string to a boolean using all defined aliases., however the new test suite has tests like these:

say "lies" is false => false
say "lies" is true => true

Which treat every string as truthy no matter what it contains.

Both my implementation and Maiden's online version convert the aliases, so the string can actually have a value and still be falsy for comparisons.

So, which behaviour is correct here?

@gaborsch
Copy link

Yeah, I've also hit this issue when implementing my Java interpreter. I've decided to comply with the tests, but the spec needs to be updated, if the tests are correct.

@dylanbeattie
Copy link
Collaborator

Yes, the tests are correct, the spec is out of date (and the older version of the test suite reflected the old behaviour)

The thinking behind this is that a string such as "lies" evaluating as false could lead to some weird behaviour when support is implemented for string manipulation. For example - popping the leading character off a string until the string is false; if you started with "assemblies" or "multiplies" you'd get the false condition when the string wasn't actually empty.

"lies" > false would be better support by explicit parsing than implicit type coercion.

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

No branches or pull requests

3 participants