node conversion finished, narwhal removed.

This commit is contained in:
Jeremy Ashkenas
2010-01-29 23:30:54 -05:00
parent e08e99a403
commit f5a37035cf
48 changed files with 208 additions and 357 deletions

View File

@@ -2,11 +2,11 @@ x: 1
y: {}
y.x: -> 3
print x is 1
print typeof(y.x) is 'function'
print y.x instanceof Function
print y.x() is 3
print y.x.name is 'x'
puts x is 1
puts typeof(y.x) is 'function'
puts y.x instanceof Function
puts y.x() is 3
puts y.x.name is 'x'
# The empty function should not cause a syntax error.
@@ -17,10 +17,10 @@ obj: {
name: "Fred"
bound: ->
(=> print(this.name is "Fred"))()
(=> puts(this.name is "Fred"))()
unbound: ->
(-> print(!this.name?))()
(-> puts(!this.name?))()
}
obj.unbound()
@@ -44,18 +44,18 @@ Math: {
FastAdd: memoize (a, b) -> a + b
}
print Math.Add(5, 5) is 10
print Math.AnonymousAdd(10, 10) is 20
print Math.FastAdd(20, 20) is 40
puts Math.Add(5, 5) is 10
puts Math.AnonymousAdd(10, 10) is 20
puts Math.FastAdd(20, 20) is 40
# Parens are optional on simple function calls.
print 100 > 1 if 1 > 0
print true unless false
print true for i in [1..3]
puts 100 > 1 if 1 > 0
puts true unless false
puts true for i in [1..3]
print_func: (f) -> print(f())
print_func -> true
puts_func: (f) -> puts(f())
puts_func -> true
# Optional parens can be used in a nested fashion.
call: (func) -> func()
@@ -64,7 +64,7 @@ result: call ->
inner: call ->
Math.Add(5, 5)
print result is 10
puts result is 10
# And even with strange things like this:
@@ -72,8 +72,8 @@ print result is 10
funcs: [(x) -> x, (x) -> x * x]
result: funcs[1] 5
print result is 25
puts result is 25
result: ("hello".slice) 3
print result is 'lo'
puts result is 'lo'