Permalink
Browse files

new tests using mocha diffs

still need more coverage for include, extend etc
  • Loading branch information...
1 parent 7063e38 commit cb16e62c4f5d62f5caa0089f56c7b899add23147 @tj tj committed Mar 10, 2012
Showing with 533 additions and 11 deletions.
  1. +2 −5 Makefile
  2. +4 −0 Readme.md
  3. +1 −1 lib/parser.js
  4. +6 −5 package.json
  5. +7 −0 test/cases/attrs.html
  6. +1 −0 test/cases/attrs.interpolation.html
  7. +2 −0 test/cases/attrs.interpolation.jade
  8. +8 −0 test/cases/attrs.jade
  9. +1 −0 test/cases/attrs.js.html
  10. +3 −0 test/cases/attrs.js.jade
  11. +3 −0 test/cases/aux/mixins.jade
  12. +1 −0 test/cases/aux/smile.html
  13. +6 −0 test/cases/basic.html
  14. +3 −0 test/cases/basic.jade
  15. +8 −0 test/cases/blanks.html
  16. +8 −0 test/cases/blanks.jade
  17. +8 −0 test/cases/block-expansion.html
  18. +5 −0 test/cases/block-expansion.jade
  19. +8 −0 test/cases/block-expansion.shorthands.html
  20. +2 −0 test/cases/block-expansion.shorthands.jade
  21. +1 −0 test/cases/classes.html
  22. +3 −0 test/cases/classes.jade
  23. +14 −0 test/cases/code.conditionals.html
  24. +27 −0 test/cases/code.conditionals.jade
  25. +4 −0 test/cases/code.escape.html
  26. +2 −0 test/cases/code.escape.jade
  27. +20 −0 test/cases/code.html
  28. +44 −0 test/cases/code.iteration.html
  29. +25 −0 test/cases/code.iteration.jade
  30. +10 −0 test/cases/code.jade
  31. +2 −0 test/cases/comments.conditional.html
  32. +3 −0 test/cases/comments.conditional.jade
  33. +13 −0 test/cases/comments.html
  34. +12 −0 test/cases/comments.jade
  35. +1 −0 test/cases/doctype.custom.html
  36. +1 −0 test/cases/doctype.custom.jade
  37. +7 −0 test/cases/doctype.default.html
  38. +4 −0 test/cases/doctype.default.jade
  39. +1 −0 test/cases/doctype.keyword.html
  40. +1 −0 test/cases/doctype.keyword.jade
  41. +8 −0 test/cases/html.html
  42. +8 −0 test/cases/html.jade
  43. +4 −0 test/cases/html5.html
  44. +4 −0 test/cases/html5.jade
  45. +4 −0 test/cases/includes.html
  46. +7 −0 test/cases/includes.jade
  47. +22 −0 test/cases/mixins.html
  48. +25 −0 test/cases/mixins.jade
  49. +4 −0 test/cases/namespaces.html
  50. +2 −0 test/cases/namespaces.jade
  51. +16 −0 test/cases/nesting.html
  52. +8 −0 test/cases/nesting.jade
  53. +4 −0 test/cases/quotes.html
  54. +2 −0 test/cases/quotes.jade
  55. +4 −0 test/cases/scripts.html
  56. +4 −0 test/cases/scripts.jade
  57. +12 −0 test/cases/scripts.non-js.html
  58. +9 −0 test/cases/scripts.non-js.jade
  59. +8 −0 test/cases/styles.html
  60. +6 −0 test/cases/styles.jade
  61. +6 −0 test/cases/text-block.html
  62. +6 −0 test/cases/text-block.jade
  63. +24 −0 test/cases/text.html
  64. +23 −0 test/cases/text.jade
  65. +1 −0 test/cases/vars.html
  66. +3 −0 test/cases/vars.jade
  67. +27 −0 test/run.js
View
@@ -1,5 +1,4 @@
-TESTS = test/*.js
SRC = $(shell find lib -name "*.js" -type f)
UGLIFY = $(shell find node_modules -name "uglifyjs" -type f)
UGLIFY_FLAGS = --no-mangle
@@ -9,10 +8,8 @@ all: jade.min.js runtime.min.js
test:
@./node_modules/.bin/mocha \
- --ui exports \
- --globals name \
- --reporter $(REPORTER) \
- $(TESTS)
+ --reporter $(REPORTER) \
+ --require should
test-cov: lib-cov
JADE_COV=1 $(MAKE) test REPORTER=html-cov > coverage.html
View
@@ -1046,6 +1046,10 @@ Examples:
```
+## Tutorials
+
+ - in [Japanese](http://blog.craftgear.net/4f501e97c1347ec934000001/title/10%E5%88%86%E3%81%A7%E3%82%8F%E3%81%8B%E3%82%8Bjade%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%A8%E3%83%B3%E3%82%B8%E3%83%B3)
+
## License
(The MIT License)
View
@@ -611,7 +611,7 @@ Parser.prototype = {
case ':':
this.advance();
tag.block = new nodes.Block;
- tag.block.push(this.parseTag());
+ tag.block.push(this.parseExpr());
break;
}
View
@@ -12,11 +12,12 @@
},
"devDependencies": {
"mocha": "*",
- "coffee-script": ">= 0.0.1",
- "markdown": ">= 0.0.1",
- "stylus": ">= 0.0.1",
- "uubench": "0.0.1",
- "uglify-js": ">= 1.0.7"
+ "coffee-script": "*",
+ "markdown": "*",
+ "stylus": "*",
+ "uubench": "*",
+ "should": "*",
+ "uglify-js": "*"
},
"scripts" : { "prepublish" : "npm prune" },
"engines": { "node": ">= 0.1.98" }
View
@@ -0,0 +1,7 @@
+<a href="/contact">contact</a><a href="/save" class="button">save</a><a foo="foo" bar="bar" baz="baz"></a><a foo="foo, bar, baz" bar="1"></a><a foo="((foo))" bar="1"></a>
+<select>
+ <option value="foo" selected="selected">Foo
+ </option>
+ <option selected="selected" value="bar">Bar
+ </option>
+</select>
@@ -0,0 +1 @@
+<a href="/user/5"></a>
@@ -0,0 +1,2 @@
+- var id = 5
+a(href='/user/#{id}')
View
@@ -0,0 +1,8 @@
+a(href='/contact') contact
+a(href='/save').button save
+a(foo, bar, baz)
+a(foo='foo, bar, baz', bar=1)
+a(foo='((foo))', bar= (1) ? 1 : 0 )
+select
+ option(value='foo', selected) Foo
+ option(selected, value='bar') Bar
View
@@ -0,0 +1 @@
+<a href="/user/5" class="button"></a><a href="/user/5" class="button"></a>
View
@@ -0,0 +1,3 @@
+- var id = 5
+a(href='/user/' + id, class='button')
+a(href = '/user/' + id, class = 'button')
@@ -0,0 +1,3 @@
+
+mixin foo()
+ p bar
@@ -0,0 +1 @@
+<p>:)</p>
View
@@ -0,0 +1,6 @@
+<html>
+ <body>
+ <h1>Title
+ </h1>
+ </body>
+</html>
View
@@ -0,0 +1,3 @@
+html
+ body
+ h1 Title
View
@@ -0,0 +1,8 @@
+<ul>
+ <li>foo
+ </li>
+ <li>bar
+ </li>
+ <li>baz
+ </li>
+</ul>
View
@@ -0,0 +1,8 @@
+
+
+ul
+ li foo
+
+ li bar
+
+ li baz
@@ -0,0 +1,8 @@
+<ul>
+ <li><a href="#">foo</a>
+ </li>
+ <li><a href="#">bar</a>
+ </li>
+</ul>
+<p>baz
+</p>
@@ -0,0 +1,5 @@
+ul
+ li: a(href='#') foo
+ li: a(href='#') bar
+
+p baz
@@ -0,0 +1,8 @@
+<ul>
+ <li class="list-item">
+ <div class="foo">
+ <div id="bar">baz
+ </div>
+ </div>
+ </li>
+</ul>
@@ -0,0 +1,2 @@
+ul
+ li.list-item: .foo: #bar baz
View
@@ -0,0 +1 @@
+<a class="foo bar baz"></a><a class="foo bar baz"></a><a class="foo-bar_baz"></a>
View
@@ -0,0 +1,3 @@
+a(class=['foo', 'bar', 'baz'])
+a.foo(class='bar').baz
+a.foo-bar_baz
@@ -0,0 +1,14 @@
+<p>foo
+</p>
+<p>foo
+</p>
+<p>foo
+</p>
+<p>bar
+</p>
+<p>baz
+</p>
+<p>bar
+</p>
+<p>yay
+</p>
@@ -0,0 +1,27 @@
+
+- if (true)
+ p foo
+- else
+ p bar
+
+- if (true) {
+ p foo
+- } else {
+ p bar
+- }
+
+if true
+ p foo
+ p bar
+ p baz
+else
+ p bar
+
+unless true
+ p foo
+else
+ p bar
+
+if 'nested'
+ if 'works'
+ p yay
@@ -0,0 +1,4 @@
+<p>&lt;script&gt;
+</p>
+<p><script>
+</p>
@@ -0,0 +1,2 @@
+p= '<script>'
+p!= '<script>'
View
@@ -0,0 +1,20 @@
+<p>
+</p>
+<p>
+</p>
+<p>
+</p>
+<p>0
+</p>
+<p>false
+</p>
+<p>
+</p>
+<p>
+</p>
+<p foo="">
+</p>
+<p foo="0">
+</p>
+<p>
+</p>
@@ -0,0 +1,44 @@
+<ul>
+ <li>1
+ </li>
+ <li>2
+ </li>
+ <li>3
+ </li>
+</ul>
+<ul>
+ <li class="item-0">1
+ </li>
+ <li class="item-1">2
+ </li>
+ <li class="item-2">3
+ </li>
+</ul>
+<ul>
+ <li>1
+ </li>
+ <li>2
+ </li>
+ <li>3
+ </li>
+</ul>
+<ul>
+ <li>1: a
+ </li>
+ <li>2: a
+ </li>
+ <li>3: a
+ </li>
+ <li>1: b
+ </li>
+ <li>2: b
+ </li>
+ <li>3: b
+ </li>
+ <li>1: c
+ </li>
+ <li>2: c
+ </li>
+ <li>3: c
+ </li>
+</ul>
@@ -0,0 +1,25 @@
+
+- var items = [1,2,3]
+
+ul
+ - items.forEach(function(item){
+ li= item
+ - })
+
+items = [1,2,3]
+
+ul
+ for item, i in items
+ li(class='item-#{i}')= item
+
+ul
+ each item, i in items
+ li= item
+
+nums = [1, 2, 3]
+letters = ['a', 'b', 'c']
+
+ul
+ for l in letters
+ for n in nums
+ li #{n}: #{l}
View
@@ -0,0 +1,10 @@
+p= null
+p= undefined
+p= ''
+p= 0
+p= false
+p(foo=null)
+p(foo=undefined)
+p(foo='')
+p(foo=0)
+p(foo=false)
@@ -0,0 +1,2 @@
+<!--[if IE lt 9]>
+<script src="/lame.js"></script><![endif]-->
@@ -0,0 +1,3 @@
+
+//if IE lt 9
+ script(src='/lame.js')
View
@@ -0,0 +1,13 @@
+<!-- foo-->
+<ul>
+ <!-- bar-->
+ <li>one
+ </li>
+</ul><!-- asdf
+<!-- baz-->
+<li>two
+</li>--><!--
+<ul>
+ <li>foo
+ </li>
+</ul>-->
View
@@ -0,0 +1,12 @@
+
+// foo
+ul
+ // bar
+ li one
+// asdf
+ // baz
+ li two
+
+//
+ ul
+ li foo
@@ -0,0 +1 @@
+<!DOCTYPE custom stuff>
@@ -0,0 +1 @@
+doctype custom stuff
@@ -0,0 +1,7 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <body>
+ <h1>Title
+ </h1>
+ </body>
+</html>
@@ -0,0 +1,4 @@
+!!!
+html
+ body
+ h1 Title
@@ -0,0 +1 @@
+<!DOCTYPE html>
@@ -0,0 +1 @@
+doctype html
Oops, something went wrong.

0 comments on commit cb16e62

Please sign in to comment.