Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions bin/run.moon
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#! /usr/bin/env moon

-- Implements test-runner interface version 2

require 'moonscript'
lfs = require 'lfs'
json = (require 'dkjson').use_lpeg!
Expand Down Expand Up @@ -92,6 +94,13 @@ run_tests = (slug, dir) ->
message: test.trace.message,
}

for test in *data.errors
results[test.element.name] = {
status: 'error',
name: test.element.name,
message: test.trace.message,
}

results


Expand Down
5 changes: 5 additions & 0 deletions tests/example-partial-error/.busted
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
return {
default = {
ROOT = { '.' }
}
}
12 changes: 12 additions & 0 deletions tests/example-partial-error/example_partial_error.moon
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- hamming
distance = (left, right) ->
assert #left == #right, 'strands must be of equal length'

dist = 0
-- below should be `=` not `in`
for i in 1,#left
dist += 1 if left\sub(i) ~= right\sub(i)
dist

{ :distance }

39 changes: 39 additions & 0 deletions tests/example-partial-error/example_partial_error_spec.moon
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
hamming = require 'example_partial_error'

describe 'hamming', ->
it 'empty strands', ->
result = hamming.distance '', ''
assert.are.equal 0, result

it 'single letter identical strands', ->
result = hamming.distance 'A', 'A'
assert.are.equal 0, result

it 'single letter different strands', ->
result = hamming.distance 'G', 'T'
assert.are.equal 1, result

it 'long identical strands', ->
result = hamming.distance 'GGACTGAAATCTG', 'GGACTGAAATCTG'
assert.are.equal 0, result

it 'long different strands', ->
result = hamming.distance 'GGACGGATTCTG', 'AGGACGGATTCT'
assert.are.equal 9, result

it 'disallow first strand longer', ->
f = -> hamming.distance 'AATG', 'AAA'
assert.has.error f, 'strands must be of equal length'

it 'disallow second strand longer', ->
f = -> hamming.distance 'ATA', 'AGTG'
assert.has.error f, 'strands must be of equal length'

it 'disallow empty first strand', ->
f = -> hamming.distance '', 'G'
assert.has.error f, 'strands must be of equal length'

it 'disallow empty second strand', ->
f = -> hamming.distance 'G', ''
assert.has.error f, 'strands must be of equal length'

1 change: 1 addition & 0 deletions tests/example-partial-error/expected_results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"tests":[{"message":"./example_partial_error.moon:5: attempt to call a number value (for iterator 'for iterator')","status":"error","test_code":" result = hamming.distance '', ''\n assert.are.equal 0, result\n","name":"empty strands"},{"message":"./example_partial_error.moon:5: attempt to call a number value (for iterator 'for iterator')","status":"error","test_code":" result = hamming.distance 'A', 'A'\n assert.are.equal 0, result\n","name":"single letter identical strands"},{"message":"./example_partial_error.moon:5: attempt to call a number value (for iterator 'for iterator')","status":"error","test_code":" result = hamming.distance 'G', 'T'\n assert.are.equal 1, result\n","name":"single letter different strands"},{"message":"./example_partial_error.moon:5: attempt to call a number value (for iterator 'for iterator')","status":"error","test_code":" result = hamming.distance 'GGACTGAAATCTG', 'GGACTGAAATCTG'\n assert.are.equal 0, result\n","name":"long identical strands"},{"message":"./example_partial_error.moon:5: attempt to call a number value (for iterator 'for iterator')","status":"error","test_code":" result = hamming.distance 'GGACGGATTCTG', 'AGGACGGATTCT'\n assert.are.equal 9, result\n","name":"long different strands"},{"status":"pass","test_code":" f = -> hamming.distance 'AATG', 'AAA'\n assert.has.error f, 'strands must be of equal length'\n","name":"disallow first strand longer"},{"status":"pass","test_code":" f = -> hamming.distance 'ATA', 'AGTG'\n assert.has.error f, 'strands must be of equal length'\n","name":"disallow second strand longer"},{"status":"pass","test_code":" f = -> hamming.distance '', 'G'\n assert.has.error f, 'strands must be of equal length'\n","name":"disallow empty first strand"},{"status":"pass","test_code":" f = -> hamming.distance 'G', ''\n assert.has.error f, 'strands must be of equal length'\n","name":"disallow empty second strand"}],"status":"pass","version":2}
Loading