File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed
Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1818desc "run JavaScriptLint on the source"
1919task :lint do
2020 system "jsl -nofilelisting -nologo -conf docs/jsl.conf -process backbone.js"
21+ end
22+
23+ desc "test the CoffeeScript integration"
24+ task :test do
25+ system "coffee test/*.coffee"
2126end
Original file line number Diff line number Diff line change 695695 _ . extend ( child . prototype , protoProps ) ;
696696 if ( classProps ) _ . extend ( child , classProps ) ;
697697 child . prototype . constructor = child ;
698+ child . __super__ = parent . prototype ;
698699 return child ;
699700 } ;
700701
Original file line number Diff line number Diff line change 1+ # Quick Backbone/CoffeeScript tests to make sure that inheritance
2+ # works correctly.
3+
4+ {ok , equal , deepEqual } = require ' assert'
5+ {Model , Collection , Events } = require ' ../backbone'
6+
7+
8+ # Patch `ok` to store a count of passed tests...
9+ count = 0
10+ oldOk = ok
11+ ok = ->
12+ oldOk arguments ...
13+ count++
14+
15+
16+ class Document extends Model
17+
18+ fullName : ->
19+ @ get (' name' ) + ' ' + @ get (' surname' )
20+
21+ tempest = new Document
22+ id : ' 1-the-tempest' ,
23+ title : " The Tempest" ,
24+ name : " William"
25+ surname : " Shakespeare"
26+ length : 123
27+
28+ ok tempest .fullName () is " William Shakespeare"
29+ ok tempest .get (' length' ) is 123
30+
31+
32+ class ProperDocument extends Document
33+
34+ fullName : ->
35+ " Mr. " + super
36+
37+ properTempest = new ProperDocument tempest .attributes
38+
39+ ok properTempest .fullName () is " Mr. William Shakespeare"
40+ ok properTempest .get (' length' ) is 123
41+
42+
43+ console .log " passed #{ count} tests"
You can’t perform that action at this time.
0 commit comments