This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var check_later, debug, delay, return_arg, return_call; | |
var __slice = Array.prototype.slice, __hasProp = Object.prototype.hasOwnProperty; | |
require('/home/tim/dev/web/coffee-spec/lib/coffee-spec').autorun(global, 2); | |
debug = require("sys").debug; | |
delay = function(func) { | |
return process.nextTick(func); | |
}; | |
return_arg = function(x, cb) { | |
return delay(function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# defer can be placed in front of any function call that takes | |
# a callback as its last paramater. | |
# instead of this: | |
myFunc: (callback) -> | |
someFunction 1, 2, 3, (result) -> | |
doSomeThingWith(result) | |
callback(true) | |
# you will write this: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Sync | |
constructor: (reader, store) -> | |
@reader = reader | |
@store = store | |
pull_tags: (cb) -> | |
@reader.get_user_tags (tags) -> | |
@store.set_valid_tags(tags, cb) | |
pull_items: (tag_name, cb) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var _a, _b, _c, _d, evens, num; | |
evens = (function() { | |
_a = []; _c = [1, 2, 3, 4, 5, 6]; | |
for (_b = 0, _d = _c.length; _b < _d; _b++) { | |
num = _c[_b]; | |
num % 2 === 0 ? _a.push((function() { | |
num *= -1; | |
num -= 2; | |
return num * -1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/grammar.coffee b/src/grammar.coffee | |
index 0a8d950..219911d 100644 | |
--- a/src/grammar.coffee | |
+++ b/src/grammar.coffee | |
@@ -457,8 +457,8 @@ grammar: { | |
# The CoffeeScript switch/when/else block replaces the JavaScript | |
# switch/case/default by compiling into an if-else chain. | |
Switch: [ | |
- o "SWITCH Expression INDENT Whens OUTDENT", -> $4.rewrite_condition $2 | |
- o "SWITCH Expression INDENT Whens ELSE Block OUTDENT", -> $4.rewrite_condition($2).add_else $6, true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.run_tests: run_tests: (cb) -> | |
remaining: (test for test in tests when test.success is null) | |
iterate: -> | |
if remaining.length == 0 | |
cb() | |
return | |
test: remaining.shift() | |
test.run(iterate) | |
iterate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bin/cake test -f operations | |
passed 3 tests in 0.01 seconds | |
# verbose test listing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# basically, you just have nested "describe" blocks, with one "it" block per test. | |
describe 'deferred', -> | |
it 'should deal with a single defer', -> | |
single_def: (x) -> defer return_arg(x) | |
equal single_def.length, 2 | |
callback_called: false | |
single_def "a", (result) -> |
NewerOlder