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

Added test for strange exception swallowing origamitower/folktale#163 #164

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jmatsushita
Copy link

@jmatsushita jmatsushita commented Nov 12, 2017

The first test correctly throws a TypeError. But the second test doesn't, it in fact throws an AssertionError meaning the TypeErrorexception has been swallowed.

// Should have thrown by then
$ASSERT(false)
} catch (e) {
if (e.message != 'false') $ASSERT(e instanceof TypeError)
Copy link
Member

Choose a reason for hiding this comment

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

This should be testing if the error is an instance of AssertionError, so:

const { AssertionError } = require('assert');
if (!(e instanceof AssertionError)) {
  $ASSERT(e instanceof TypeError);
}

Copy link
Author

Choose a reason for hiding this comment

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

Hi! I tried to use assert.throws() which would have been clearer, but it wouldn't compile. I simplified the test though now. Hopefully it is clearer.

.map((() => false ? Result.a : Result.b))
.run()
.promise();
// Should have thrown a TypeError by then
Copy link
Member

Choose a reason for hiding this comment

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

Why is this one expected to throw a TypeError here?

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