Skip to content
This repository was archived by the owner on Jul 12, 2025. It is now read-only.

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

Open
jmatsushita wants to merge 3 commits intoorigamitower:masterfrom
iilab:master
Open

Added test for strange exception swallowing origamitower/folktale#163#164
jmatsushita wants to merge 3 commits intoorigamitower:masterfrom
iilab:master

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants