1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

helpers: added test

This commit is contained in:
satyr 2010-09-25 09:15:47 +09:00
parent a04e17c4ea
commit 3df82a757d

40
test/test_helpers.coffee Normal file
View file

@ -0,0 +1,40 @@
{ indexOf, include, starts, ends, compact, count, merge, extend, flatten, del
} = require('../lib/helpers').helpers
array = [0..4]
ok indexOf(array, 0) is 0
ok indexOf(array, 2) is 2
ok indexOf(array, 4) is 4
ok indexOf(array, 6) is -1
ok include array, 0
ok include array, 2
ok include array, 4
ok not include array, 6
string = array.join ''
ok starts string, '012'
ok starts string, '34', 3
ok not starts string, '42'
ok not starts string, '42', 6
ok ends string, '234'
ok ends string, '01', 3
ok not ends string, '42'
ok not ends string, '42', 6
object = {}
merged = merge object, array
ok merged isnt object
ok merged[3] is 3
ok object is extend object, array
ok object[3] is 3
ok "#{ flatten [0, [1, 2], 3, [4]] }" is "#{ array }"
ok 1 is del object, 1
ok 1 not of object