Skip to content

Commit

Permalink
Better t.throws example, fixes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
finnp committed Apr 9, 2015
1 parent 7c54629 commit ae4b9b8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions exercises/to-err-is-human/instruction.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ try {
petDog('bordercollie')
}
catch(err) {
console.error("It seems like he doesn't like that.")
console.error('It seems like it doesn\'t like that.')
}
```

Expand All @@ -41,8 +41,17 @@ So maybe we know that a dachshund does not like to be petted. Well we could test
this behavior like this:

```js
t.throws(petDog('dachshund'))
t.throws(function () {
petDog('dachshund')
})
```

Now the tests expects an error and throws an error if there is no error.
Mind boggling, right?
Mind boggling, right?

By the way, if you are familiar with functional javascript, you might already know,
that you could also write it in one line:
```js
t.throws(petDog.bind(null, 'dachhund'))
```

0 comments on commit ae4b9b8

Please sign in to comment.