2010-01-16 16:37:49 -05:00
|
|
|
# CoffeeScript's operations should be chainable, like Python's.
|
2010-02-16 19:45:25 -05:00
|
|
|
ok 500 > 50 > 5 > -5
|
2010-01-16 16:37:49 -05:00
|
|
|
|
2010-02-16 19:45:25 -05:00
|
|
|
ok true is not false is true is not false
|
2010-01-16 16:37:49 -05:00
|
|
|
|
2010-03-06 23:48:06 -05:00
|
|
|
ok 0 is 0 isnt 50 is 50
|
|
|
|
|
2010-02-16 19:45:25 -05:00
|
|
|
ok 10 < 20 > 10
|
2010-01-16 16:37:49 -05:00
|
|
|
|
2010-02-16 19:45:25 -05:00
|
|
|
ok 50 > 10 > 5 is parseInt('5', 10)
|
2010-01-16 22:04:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
# Make sure that each argument is only evaluated once, even if used
|
|
|
|
# more than once.
|
|
|
|
i: 0
|
2010-01-26 10:52:05 -05:00
|
|
|
func: -> i++
|
2010-01-16 22:04:08 -05:00
|
|
|
|
2010-02-16 19:45:25 -05:00
|
|
|
ok 1 > func() < 1
|
2010-03-21 21:07:32 -04:00
|
|
|
|
|
|
|
|
|
|
|
# `:` and `=` should be interchangeable, as should be `==` and `is`.
|
|
|
|
a: 1
|
|
|
|
b: 1
|
|
|
|
|
|
|
|
ok a is 1 and b is 1
|
|
|
|
ok a == b
|
|
|
|
ok a is b
|
2010-03-31 22:48:47 -04:00
|
|
|
|
|
|
|
|
|
|
|
# Ensure that chained operations don't cause functions to be evaluated more
|
|
|
|
# than once.
|
|
|
|
val: 0
|
|
|
|
func: -> val: + 1
|
|
|
|
|
|
|
|
ok 2 > (func null) < 2
|
|
|
|
ok val is 1
|
2010-06-21 22:25:28 -04:00
|
|
|
|
|
|
|
|
|
|
|
# Allow "if x not in y"
|
|
|
|
obj: {a: true}
|
2010-06-21 23:51:12 -04:00
|
|
|
ok 'a' of obj
|
|
|
|
ok 'b' not of obj
|
|
|
|
|
|
|
|
# And for "a in b" with array presence.
|
|
|
|
ok 100 in [100, 200, 300]
|
|
|
|
array: [100, 200, 300]
|
|
|
|
ok 100 in array
|
|
|
|
ok 1 not in array
|