Skip to content

Commit

Permalink
Refactor away from newer ES syntax in test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
kemitchell committed Sep 21, 2023
1 parent 58a802d commit 07d4686
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,46 @@ var failed = false

function write (string) { process.stdout.write(string) }

function label (expression, approved) {
write('satisfies(' + JSON.stringify(expression) + ', ' + JSON.stringify(approved) + ')')
function label (example) {
write('satisfies(' + JSON.stringify(example[0]) + ', ' + JSON.stringify(example[1]) + ')')
}

for (const [expression, approved] of examples.returnTrue) {
label(expression, approved)
examples.returnTrue.forEach(function (example) {
label(example)
try {
assert(satisfies(expression, approved) === true)
assert(satisfies(example[0], example[1]) === true)
} catch (error) {
failed = true
write(' did not return true\n')
continue
return
}
write(' returned true\n')
}
})

// False Examples
for (const [expression, approved] of examples.returnFalse) {
label(expression, approved)
examples.returnFalse.forEach(function (example) {
label(example)
try {
assert(satisfies(expression, approved) === false)
assert(satisfies(example[0], example[1]) === false)
} catch (error) {
failed = true
write(' did not return false\n')
continue
return
}
write(' returned false\n')
}
})

// Invalid License Arrays
for (const [expression, approved] of examples.throwErrors) {
label(expression, approved)
examples.throwErrors.forEach(function (example) {
label(example)
try {
satisfies(expression, approved)
satisfies(example[0], example[1])
} catch (error) {
write(' threw an exception\n')
continue
return
}
failed = true
write(' did not throw an exception\n')
}
})

process.exit(failed ? 1 : 0)

0 comments on commit 07d4686

Please sign in to comment.