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

Update README to note that or, and and xor **do** short-circuit #143

Closed
boris-petrov opened this issue Jan 18, 2022 · 2 comments · Fixed by #184
Closed

Update README to note that or, and and xor **do** short-circuit #143

boris-petrov opened this issue Jan 18, 2022 · 2 comments · Fixed by #184

Comments

@boris-petrov
Copy link

{{or true (throw "asd")}}

This, as of Ember 3.28, shows true. {{or false (throw "asd")}} throws an exception. So the section in the README which says that they do not short-circuit should be updated. It was true before, I remember, but it is no longer so.

@Techn1x
Copy link
Contributor

Techn1x commented Jul 21, 2023

😮 I see! I'm running Ember 4.12 (with ember-truth-helpers 3.1.1) and can confirm the now-short-circuiting behaviour

A more straightforward way to test this without needing the "throw" helper implemented

{{or true (log "OR - NOT CALLED")}}
{{or false (log "OR - CALLED")}}
{{and true (log "AND - CALLED")}}
{{and false (log "AND - NOT CALLED")}}

output

OR - CALLED
AND - CALLED

XOR still seems to call both though

{{xor true (log "XOR - TEST1")}}
{{xor false (log "XOR - TEST2")}}

output

XOR - TEST1
XOR - TEST2

makes sense, looking at the helper code
https://github.com/jmurphyau/ember-truth-helpers/blob/f28ae790f68e8899d5da7a6c0199162282049d2a/packages/ember-truth-helpers/src/helpers/xor.ts#L12C10-L12C62

@Techn1x
Copy link
Contributor

Techn1x commented Jul 21, 2023

I've updated the readme here
#184

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 a pull request may close this issue.

2 participants