Browse files

fixed some failing tests

  • Loading branch information...
1 parent de37e7b commit 581ae7e8d8732b77cc6db6004229f402c8968947 Jonah Fox committed Dec 12, 2010
Showing with 33 additions and 62 deletions.
  1. +5 −1 browser/kaffeine-browser.js
  2. +1 −2 expectations/bang
  3. +12 −30 expectations/extend_for
  4. +6 −12 expectations/implicit_vars
  5. +6 −17 expectations/stacks
  6. +3 −0 lib/plugins/bang.js
View
6 browser/kaffeine-browser.js
@@ -181,7 +181,11 @@ base.fn.addImpliedBraces = function() {
var indent = this.indent()
- pair.R.before(pair.L.next.newline ? "\n" + indent : " ")
+ if(pair.R.prev.newline) {
+ pair.R.prev.remove()
+ }
+ pair.R.before(" ") //pair.L.next.newline ? " " + indent :
+
pair.L.updateBlock()
pair.L.eatLeft()
pair.R.eatLeft()
View
3 expectations/bang
@@ -4,5 +4,4 @@ sum = add!(3, 4)
ok(sum == 7)
to:
add(3, 4, function(sum) {
- ok(sum == 7)
-})
+ ok(sum == 7) })
View
42 expectations/extend_for
@@ -20,9 +20,7 @@ for(x of [1,2,3,4]) {
}
to:
-var _a, x;
-for(_a = 0; _a < [1,2,3,4].length; _a++) {
- x = [1,2,3,4][_a];
+var _a, x; for(_a = 0; _a < [1,2,3,4].length; _a++) { x = [1,2,3,4][_a];
ok()
}
@@ -31,11 +29,8 @@ for(x of [1,2,3,4])
ok()
to:
-var _a, x;
-for(_a = 0; _a < [1,2,3,4].length; _a++) {
- x = [1,2,3,4][_a];
- ok()
-}
+var _a, x; for(_a = 0; _a < [1,2,3,4].length; _a++) { x = [1,2,3,4][_a];
+ ok() }
compiles:
for (var i = 0; i < nodes.length; i++) {
@@ -52,11 +47,8 @@ for(k, y in o)
x
i
to:
-var k, y;
-for(k in o) {
- y = o[k];
- x
-}
+var k, y; for(k in o) { y = o[k];
+ x }
i
compiles:
@@ -66,13 +58,10 @@ for(k, y in o)
}
to:
-var k, y;
-for(k in o) {
- y = o[k];
+var k, y; for(k in o) { y = o[k];
if(x) {
return true
- }
-}
+ } }
compiles:
for(k, y in o)
@@ -81,23 +70,16 @@ for(k, y in o)
to:
var k, y;
-for(k in o) {
- y = o[k];
+for(k in o) { y = o[k];
if(x)
- return true
-}
+ return true }
compiles:
for(i, x in a)
for(j, y in a)
x
to:
-var i, x, j, y;
-for(i in a) {
- x = a[i];
- for(j in a) {
- y = a[j];
- x
- }
-}
+var i, x, j, y; for(i in a) { x = a[i];
+ for(j in a) { y = a[j];
+ x } }
View
18 expectations/implicit_vars
@@ -3,8 +3,7 @@
compiles:
z = 0
to:
-var z;
-z = 0
+var z; z = 0
compiles:
@@ -14,8 +13,7 @@ function a() {
to:
function a() {
- var a;
- a = 2
+ var a; a = 2
}
compiles:
@@ -25,8 +23,7 @@ function(a) {
}
to:
-var z;
-z = 0
+var z; z = 0
function(a) {
z = 1
}
@@ -38,11 +35,9 @@ function(a) {
}
to:
-var z;
-z = 0
+var z; z = 0
function(a) {
- var y;
- y = 1, z = 1
+ var y; y = 1, z = 1
}
compiles:
@@ -52,8 +47,7 @@ function(a) {
}
to:
-var z;
-z = 0
+var z; z = 0
function(a) {
z = 1
}
View
23 expectations/stacks
@@ -42,13 +42,7 @@ exports.testAddEdge = function(is, done) {
User.client.get("User:jonah:love:n", function(err, data) {
is.equal(data, "1")
- return done()
- })
- })
- })
- })
- })
- })
+ return done() }) }) }) }) }) })
}
compiles:
@@ -58,9 +52,8 @@ compiles:
}
to:
-function() {
- var i;
- for(i=0; i < n; i++)
+function() {
+ var i; for(i=0; i < n; i++)
fn.call(this, i)
}
@@ -71,18 +64,14 @@ x = {
to:
-var x;
-x = function() {
+var x; x = function() {
return x = x || y
}
compiles:
for x of row.split ""
log letter
to:
-var _a, x;
-for(_a = 0; _a < row.split("").length; _a++) {
- x = row.split("")[_a];
- log(letter)
-}
+var _a, x; for(_a = 0; _a < row.split("").length; _a++) { x = row.split("")[_a];
+ log(letter) }
View
3 lib/plugins/bang.js
@@ -50,7 +50,10 @@ module.exports = function(stream) {
return "\n" + b;
})
+
+ body = body.replace(/\n$/, " ")
var text = "function(" + vars + ") {" + body + "}"
+
if(lbracket.next != rbracket)
text = ", " + text

0 comments on commit 581ae7e

Please sign in to comment.