Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
first input line error is propagated as result
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrolistical committed Jun 1, 2018
1 parent 9cb0548 commit 81f45c8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
7.0.0 (May 31, 2018)
* first input line error is propagated as result

6.0.0 (May 4, 2018)
* change continuations to collapse down to newline instead of space

Expand Down
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,21 @@ function SpecCheck ({requires, errors}) {
const rawLines = node.value.split('\n')
let input
let result
let inputFailed
let expected
try {
const lines = parser(rawLines)
for (let i = 0; i < lines.length; i++) {
if (lines[i].type === 'input') {
if (inputFailed) {
continue
}
input = lines[i].code
try {
result = scopedEval(input)
} catch (error) {
result = error
inputFailed = true
}
} else {
if (i === 0) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spec-check",
"version": "6.0.0",
"version": "7.0.0",
"description": "Executable specification in Markdown for Javascript",
"main": "index.js",
"bin": {
Expand Down
8 changes: 4 additions & 4 deletions specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ throw new Error('oops')

[`spec-check`](https://github.com/concept-not-found/spec-check)ed

### multiple input lines swallow earlier errors
### input errors fail first

```js
> throw new Error('oops')
> 'Everything is fine.'
'Everything is fine.'
> throw new Error('first')
> throw new Error('second')
Error: first
```

[`spec-check`](https://github.com/concept-not-found/spec-check)ed
Expand Down

0 comments on commit 81f45c8

Please sign in to comment.