2010-07-25 05:23:37 +00:00
|
|
|
area = (x, y, x1, y1) ->
|
2010-02-17 00:38:52 +00:00
|
|
|
(x - x1) * (x - y1)
|
|
|
|
|
2010-07-25 05:23:37 +00:00
|
|
|
x = y = 10
|
|
|
|
x1 = y1 = 20
|
2010-02-17 00:38:52 +00:00
|
|
|
|
2010-04-03 14:39:32 +00:00
|
|
|
ok area(x, y, x1, y1) is 100
|
2010-02-17 00:38:52 +00:00
|
|
|
|
|
|
|
ok(area(x, y,
|
2010-04-03 14:39:32 +00:00
|
|
|
x1, y1) is 100)
|
2010-02-17 00:38:52 +00:00
|
|
|
|
|
|
|
ok(area(
|
|
|
|
x
|
|
|
|
y
|
|
|
|
x1
|
|
|
|
y1
|
2010-04-03 14:39:32 +00:00
|
|
|
) is 100)
|
2010-02-17 00:38:52 +00:00
|
|
|
|
|
|
|
|
2010-07-25 05:23:37 +00:00
|
|
|
sumOfArgs = ->
|
|
|
|
sum = 0
|
|
|
|
sum += val for val in arguments
|
2010-03-16 03:46:14 +00:00
|
|
|
sum
|
|
|
|
|
2010-07-28 05:54:36 +00:00
|
|
|
ok sumOfArgs(1, 2, 3, 4, 5) is 15
|
|
|
|
|
|
|
|
|
|
|
|
((@arg) ->).call context = {}, 1
|
|
|
|
ok context.arg is 1
|
|
|
|
|
|
|
|
((splat..., @arg) ->).call context, 1, 2, 3
|
|
|
|
ok context.arg is 3
|