-
Notifications
You must be signed in to change notification settings - Fork 141
Coffeescript: Tests not executed #406
Comments
I just tested the Kata Check and Mate as a guest and confirmed that this hack works for CoffeeScript but not JavaScript. UPDATE: I also tested this with the other ( |
I think this is caused by tests written as embedded JavaScript in the form: `
test();
` # CoffeeScript test from "Number-like counter" kata (simplified)
`
var c = new Counter();
Test.expect(c == 0, "c == 0 was false");
` Reproducible with add = (a, b) -> a + b `
Test.assertEquals(add(1, 1), 2);
` add = (a, b) -> a + b
# adding
Test.expect true
# makes this pass I'm guessing having no test at all is considered a failure and adding one passing test works around it. This issue only happens when the first backtick is followed by LF. `Test.assertEquals(add(1, 1), 2);` # ok
`Test.assertEquals(add(1, 1),
2);` # ok
`
Test.assertEquals(add(1, 1), 2);
` # not ok
`
Test.assertEquals(add(1, 1), 2);` # not ok This is because CoffeeScript runner combines the code like the following: Test.handleError ->
# setup
# solution
do ->
# tests and `
Test.assertEquals(add(1, 1), 2);` is return
Test.assertEquals(add(1, 1), 2);; inside Also, more than one statement won't work. You can work around with `(function() {
Test.assertEquals(add(1, 1), 2);
Test.assertEquals(add(1, 2), 3);
// ...
})()` Maybe this used to work on older version of CoffeeScript, but I don't know the language enough to tell. By the way, is this common on Codewars? Just wrapping the original JavaScript tests with backticks to have CoffeeScript translation? |
Closing this because I'm not sure how to fix this from our end and workarounds are available. |
I was able to solve https://www.codewars.com/kata/check-and-mate and
https://www.codewars.com/kata/5313b713bb244a0eb20001fe by just executing a successful test:
A solution of just
results in
Time: 311ms Passed: 0 Failed: 1 Errors: 1
.This might be because both use embedded Javascript (with `) for their tests and it looks like that code is not executed.
The text was updated successfully, but these errors were encountered: