Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 75 lines (60 sloc) 1.912 kb
75ee63a @mauricemach Initial import.
authored
1 exec = require('child_process').exec
2 coffeekup = require 'coffeekup'
3 render = coffeekup.render
9b2b6e5 @mauricemach Benchmark refactoring.
authored
4 benchmark = require './benchmark'
75ee63a @mauricemach Initial import.
authored
5
6 task 'build', ->
7 exec 'coffee -c lib/coffeekup.coffee', (err) ->
8 puts err if err
9 exec 'cp lib/coffeekup.js examples/browser', (err) ->
10 puts err if err
11
12 task 'test', ->
13 [tests, passed, failed, errors] = [[], [], [], []]
14
15 test = (name, code) ->
16 tests.push name
17 print "Testing \"#{name}\"... "
18 try
19 if code()
20 passed.push name
21 puts "[OK]"
22 else
23 failed.push name
24 puts "[Failed]"
25 catch ex
26 errors.push name
27 puts "[Error] (#{ex.message})"
28
29 test 'Literal text', ->
30 'Just text' is render ->
31 text 'Just text'
32
33 test 'Default DOCTYPE', ->
34 '<!DOCTYPE html>' is render ->
35 doctype()
36
37 test 'DOCTYPE', ->
38 '<?xml version="1.0" encoding="utf-8" ?>' is render ->
39 doctype 'xml'
40
41 test 'Self-closing tags', ->
42 '<br />' is (render -> br()) and
43 '<img src="icon.png" alt="Icon" />' is render -> img src: 'icon.png', alt: 'Icon'
44
45 test 'Normal tags', ->
46 '<h1>hi</h1>' is render ->
47 h1 'hi'
48
49 test 'Attributes', ->
50 '<a href="/" title="Home"></a>' is render ->
51 a href: '/', title: 'Home'
52
53 test 'HereDocs', ->
54 "<script>$(document).ready(function(){\n alert('test');\n});</script>" is render ->
55 script """
56 $(document).ready(function(){
57 alert('test');
58 });
59 """
60
61 test 'CoffeeScript', ->
62 "<script>$(document).ready(function() {\n return alert('hi!');\n });</script>" is render ->
63 coffeescript ->
64 $(document).ready ->
65 alert 'hi!'
66
67 test 'Comments', ->
68 '<!--Comment-->' is render ->
69 comment 'Comment'
70
71 puts "\nTests: #{tests.length} | Passed: #{passed.length} | Failed: #{failed.length} | Errors: #{errors.length}"
9b2b6e5 @mauricemach Benchmark refactoring.
authored
72
73 task 'benchmark', ->
74 benchmark.run()
Something went wrong with that request. Please try again.