finished converting the test suite, to run it, do: bin/node_coffee -r tasks.coffee -- test
This commit is contained in:
parent
b41afe79b4
commit
a8a46257ae
|
@ -1,5 +1,3 @@
|
||||||
# Assign to try/catch.
|
|
||||||
|
|
||||||
result: try
|
result: try
|
||||||
nonexistent * missing
|
nonexistent * missing
|
||||||
catch error
|
catch error
|
||||||
|
@ -7,17 +5,15 @@ catch error
|
||||||
|
|
||||||
result2: try nonexistent * missing catch error then true
|
result2: try nonexistent * missing catch error then true
|
||||||
|
|
||||||
puts result is true and result2 is true
|
ok result is true and result2 is true, 'can assign the result of a try/catch block'
|
||||||
|
|
||||||
|
|
||||||
# Assign to conditional.
|
|
||||||
|
|
||||||
get_x: -> 10
|
get_x: -> 10
|
||||||
|
|
||||||
if x: get_x() then 100
|
if x: get_x() then 100
|
||||||
|
|
||||||
puts x is 10
|
ok x is 10, 'can assign a conditional statement'
|
||||||
|
|
||||||
x: if get_x() then 100
|
x: if get_x() then 100
|
||||||
|
|
||||||
puts x is 100
|
ok x is 100, 'can assign a conditional statement'
|
|
@ -1,4 +1,4 @@
|
||||||
results: [1, 2, 3].map (x) ->
|
results: [1, 2, 3].map (x) ->
|
||||||
x * x
|
x * x
|
||||||
|
|
||||||
puts results.join(' ') is '1 4 9'
|
ok results.join(' ') is '1 4 9', 'basic block syntax'
|
|
@ -21,7 +21,7 @@ ThirdChild::func: (string) ->
|
||||||
|
|
||||||
result: (new ThirdChild()).func 'four'
|
result: (new ThirdChild()).func 'four'
|
||||||
|
|
||||||
puts result is 'zero/one/two/three/four'
|
ok result is 'zero/one/two/three/four', 'successfully set up and called a four-level inheritance chain'
|
||||||
|
|
||||||
|
|
||||||
TopClass: (arg) ->
|
TopClass: (arg) ->
|
||||||
|
@ -39,4 +39,4 @@ SubClass: ->
|
||||||
SuperClass extends TopClass
|
SuperClass extends TopClass
|
||||||
SubClass extends SuperClass
|
SubClass extends SuperClass
|
||||||
|
|
||||||
puts((new SubClass()).prop is 'top-super-sub')
|
ok (new SubClass()).prop is 'top-super-sub', 'inheritance'
|
|
@ -3,7 +3,7 @@ identity_wrap: (x) ->
|
||||||
|
|
||||||
result: identity_wrap(identity_wrap(true))()()
|
result: identity_wrap(identity_wrap(true))()()
|
||||||
|
|
||||||
puts result
|
ok result, 'basic chained function calls'
|
||||||
|
|
||||||
|
|
||||||
str: 'god'
|
str: 'god'
|
||||||
|
@ -14,7 +14,7 @@ result: str.
|
||||||
reverse().
|
reverse().
|
||||||
reverse()
|
reverse()
|
||||||
|
|
||||||
puts result.join('') is 'dog'
|
ok result.join('') is 'dog', 'chained accesses split on period/newline'
|
||||||
|
|
||||||
result: str
|
result: str
|
||||||
.split('')
|
.split('')
|
||||||
|
@ -22,4 +22,4 @@ result: str
|
||||||
.reverse()
|
.reverse()
|
||||||
.reverse()
|
.reverse()
|
||||||
|
|
||||||
puts result.join('') is 'dog'
|
ok result.join('') is 'dog', 'chained accesses split on newline/period'
|
|
@ -3,26 +3,26 @@ b: -2
|
||||||
|
|
||||||
[a, b]: [b, a]
|
[a, b]: [b, a]
|
||||||
|
|
||||||
puts a is -2
|
ok a is -2
|
||||||
puts b is -1
|
ok b is -1
|
||||||
|
|
||||||
|
|
||||||
arr: [1, 2, 3]
|
arr: [1, 2, 3]
|
||||||
|
|
||||||
[a, b, c]: arr
|
[a, b, c]: arr
|
||||||
|
|
||||||
puts a is 1
|
ok a is 1
|
||||||
puts b is 2
|
ok b is 2
|
||||||
puts c is 3
|
ok c is 3
|
||||||
|
|
||||||
|
|
||||||
obj: {x: 10, y: 20, z: 30}
|
obj: {x: 10, y: 20, z: 30}
|
||||||
|
|
||||||
{x: a, y: b, z: c}: obj
|
{x: a, y: b, z: c}: obj
|
||||||
|
|
||||||
puts a is 10
|
ok a is 10
|
||||||
puts b is 20
|
ok b is 20
|
||||||
puts c is 30
|
ok c is 30
|
||||||
|
|
||||||
|
|
||||||
person: {
|
person: {
|
||||||
|
@ -42,8 +42,8 @@ person: {
|
||||||
|
|
||||||
{name: a, family: {brother: {addresses: [one, {city: b}]}}}: person
|
{name: a, family: {brother: {addresses: [one, {city: b}]}}}: person
|
||||||
|
|
||||||
puts a is "Bob"
|
ok a is "Bob"
|
||||||
puts b is "Moquasset NY, 10021"
|
ok b is "Moquasset NY, 10021"
|
||||||
|
|
||||||
|
|
||||||
test: {
|
test: {
|
||||||
|
@ -59,4 +59,4 @@ test: {
|
||||||
|
|
||||||
{person: {address: [ignore, addr...]}}: test
|
{person: {address: [ignore, addr...]}}: test
|
||||||
|
|
||||||
puts addr.join(', ') is "Street 101, Apt 101, City 101"
|
ok addr.join(', ') is "Street 101, Apt 101, City 101"
|
|
@ -26,4 +26,4 @@ func: ->
|
||||||
|
|
||||||
c.single: c.list[1..1][0]
|
c.single: c.list[1..1][0]
|
||||||
|
|
||||||
puts func() is '-'
|
ok func() is '-'
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
puts(if my_special_variable? then false else true)
|
ok(if my_special_variable? then false else true)
|
||||||
|
|
||||||
my_special_variable: false
|
my_special_variable: false
|
||||||
|
|
||||||
puts(if my_special_variable? then true else false)
|
ok(if my_special_variable? then true else false)
|
||||||
|
|
||||||
|
|
||||||
# Existential assignment.
|
# Existential assignment.
|
||||||
|
@ -12,7 +12,7 @@ a: null
|
||||||
a ?= 10
|
a ?= 10
|
||||||
b ?= 10
|
b ?= 10
|
||||||
|
|
||||||
puts a is 10 and b is 10
|
ok a is 10 and b is 10
|
||||||
|
|
||||||
|
|
||||||
# The existential operator.
|
# The existential operator.
|
||||||
|
@ -20,7 +20,7 @@ puts a is 10 and b is 10
|
||||||
z: null
|
z: null
|
||||||
x: z ? "EX"
|
x: z ? "EX"
|
||||||
|
|
||||||
puts z is null and x is "EX"
|
ok z is null and x is "EX"
|
||||||
|
|
||||||
|
|
||||||
# Only evaluate once.
|
# Only evaluate once.
|
||||||
|
@ -30,7 +30,7 @@ get_next_node: ->
|
||||||
throw "up" if counter
|
throw "up" if counter
|
||||||
counter++
|
counter++
|
||||||
|
|
||||||
puts(if get_next_node()? then true else false)
|
ok(if get_next_node()? then true else false)
|
||||||
|
|
||||||
|
|
||||||
# Existence chains, soaking up undefined properties:
|
# Existence chains, soaking up undefined properties:
|
||||||
|
@ -39,19 +39,19 @@ obj: {
|
||||||
prop: "hello"
|
prop: "hello"
|
||||||
}
|
}
|
||||||
|
|
||||||
puts obj?.prop is "hello"
|
ok obj?.prop is "hello"
|
||||||
|
|
||||||
puts obj.prop?.length is 5
|
ok obj.prop?.length is 5
|
||||||
|
|
||||||
puts obj?.prop?.non?.existent?.property is undefined
|
ok obj?.prop?.non?.existent?.property is undefined
|
||||||
|
|
||||||
|
|
||||||
# Soaks and caches method calls as well.
|
# Soaks and caches method calls as well.
|
||||||
|
|
||||||
arr: ["--", "----"]
|
arr: ["--", "----"]
|
||||||
|
|
||||||
puts arr.pop()?.length is 4
|
ok arr.pop()?.length is 4
|
||||||
puts arr.pop()?.length is 2
|
ok arr.pop()?.length is 2
|
||||||
puts arr.pop()?.length is undefined
|
ok arr.pop()?.length is undefined
|
||||||
puts arr[0]?.length is undefined
|
ok arr[0]?.length is undefined
|
||||||
puts arr.pop()?.length?.non?.existent()?.property is undefined
|
ok arr.pop()?.length?.non?.existent()?.property is undefined
|
||||||
|
|
|
@ -9,7 +9,7 @@ findit: (items) ->
|
||||||
for item in items
|
for item in items
|
||||||
return item if item is "bacon"
|
return item if item is "bacon"
|
||||||
|
|
||||||
puts findit(items) is "bacon"
|
ok findit(items) is "bacon"
|
||||||
|
|
||||||
|
|
||||||
# When when a closure wrapper is generated for expression conversion, make sure
|
# When when a closure wrapper is generated for expression conversion, make sure
|
||||||
|
@ -26,5 +26,5 @@ obj: {
|
||||||
this.num
|
this.num
|
||||||
}
|
}
|
||||||
|
|
||||||
puts obj.num is obj.func()
|
ok obj.num is obj.func()
|
||||||
puts obj.num is obj.result
|
ok obj.num is obj.result
|
|
@ -7,13 +7,13 @@ result: if a
|
||||||
if d
|
if d
|
||||||
true
|
true
|
||||||
|
|
||||||
puts result
|
ok result
|
||||||
|
|
||||||
|
|
||||||
first: if false then false else second: if false then false else true
|
first: if false then false else second: if false then false else true
|
||||||
|
|
||||||
puts first
|
ok first
|
||||||
puts second
|
ok second
|
||||||
|
|
||||||
|
|
||||||
result: if false
|
result: if false
|
||||||
|
@ -23,4 +23,4 @@ else if NaN
|
||||||
else
|
else
|
||||||
true
|
true
|
||||||
|
|
||||||
puts result
|
ok result
|
|
@ -2,11 +2,11 @@ x: 1
|
||||||
y: {}
|
y: {}
|
||||||
y.x: -> 3
|
y.x: -> 3
|
||||||
|
|
||||||
puts x is 1
|
ok x is 1
|
||||||
puts typeof(y.x) is 'function'
|
ok typeof(y.x) is 'function'
|
||||||
puts y.x instanceof Function
|
ok y.x instanceof Function
|
||||||
puts y.x() is 3
|
ok y.x() is 3
|
||||||
puts y.x.name is 'x'
|
ok y.x.name is 'x'
|
||||||
|
|
||||||
|
|
||||||
# The empty function should not cause a syntax error.
|
# The empty function should not cause a syntax error.
|
||||||
|
@ -18,10 +18,10 @@ obj: {
|
||||||
name: "Fred"
|
name: "Fred"
|
||||||
|
|
||||||
bound: ->
|
bound: ->
|
||||||
(=> puts(this.name is "Fred"))()
|
(=> ok(this.name is "Fred"))()
|
||||||
|
|
||||||
unbound: ->
|
unbound: ->
|
||||||
(-> puts(!this.name?))()
|
(-> ok(!this.name?))()
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.unbound()
|
obj.unbound()
|
||||||
|
@ -45,18 +45,18 @@ Math: {
|
||||||
FastAdd: memoize (a, b) -> a + b
|
FastAdd: memoize (a, b) -> a + b
|
||||||
}
|
}
|
||||||
|
|
||||||
puts Math.Add(5, 5) is 10
|
ok Math.Add(5, 5) is 10
|
||||||
puts Math.AnonymousAdd(10, 10) is 20
|
ok Math.AnonymousAdd(10, 10) is 20
|
||||||
puts Math.FastAdd(20, 20) is 40
|
ok Math.FastAdd(20, 20) is 40
|
||||||
|
|
||||||
|
|
||||||
# Parens are optional on simple function calls.
|
# Parens are optional on simple function calls.
|
||||||
puts 100 > 1 if 1 > 0
|
ok 100 > 1 if 1 > 0
|
||||||
puts true unless false
|
ok true unless false
|
||||||
puts true for i in [1..3]
|
ok true for i in [1..3]
|
||||||
|
|
||||||
puts_func: (f) -> puts(f())
|
ok_func: (f) -> ok(f())
|
||||||
puts_func -> true
|
ok_func -> true
|
||||||
|
|
||||||
# Optional parens can be used in a nested fashion.
|
# Optional parens can be used in a nested fashion.
|
||||||
call: (func) -> func()
|
call: (func) -> func()
|
||||||
|
@ -65,7 +65,7 @@ result: call ->
|
||||||
inner: call ->
|
inner: call ->
|
||||||
Math.Add(5, 5)
|
Math.Add(5, 5)
|
||||||
|
|
||||||
puts result is 10
|
ok result is 10
|
||||||
|
|
||||||
|
|
||||||
# And even with strange things like this:
|
# And even with strange things like this:
|
||||||
|
@ -73,8 +73,8 @@ puts result is 10
|
||||||
funcs: [(x) -> x, (x) -> x * x]
|
funcs: [(x) -> x, (x) -> x * x]
|
||||||
result: funcs[1] 5
|
result: funcs[1] 5
|
||||||
|
|
||||||
puts result is 25
|
ok result is 25
|
||||||
|
|
||||||
result: ("hello".slice) 3
|
result: ("hello".slice) 3
|
||||||
|
|
||||||
puts result is 'lo'
|
ok result is 'lo'
|
|
@ -18,7 +18,7 @@ switch 'string'
|
||||||
code()
|
code()
|
||||||
# comment
|
# comment
|
||||||
|
|
||||||
puts func()
|
ok func()
|
||||||
|
|
||||||
func
|
func
|
||||||
func
|
func
|
||||||
|
|
|
@ -3,7 +3,7 @@ a: """
|
||||||
on two lines
|
on two lines
|
||||||
"""
|
"""
|
||||||
|
|
||||||
puts a is "basic heredoc\non two lines"
|
ok a is "basic heredoc\non two lines"
|
||||||
|
|
||||||
|
|
||||||
a: '''
|
a: '''
|
||||||
|
@ -12,12 +12,12 @@ a: '''
|
||||||
c
|
c
|
||||||
'''
|
'''
|
||||||
|
|
||||||
puts a is "a\n \"b\nc"
|
ok a is "a\n \"b\nc"
|
||||||
|
|
||||||
|
|
||||||
a: '''one-liner'''
|
a: '''one-liner'''
|
||||||
|
|
||||||
puts a is 'one-liner'
|
ok a is 'one-liner'
|
||||||
|
|
||||||
|
|
||||||
a: """
|
a: """
|
||||||
|
@ -25,7 +25,7 @@ a: """
|
||||||
here
|
here
|
||||||
"""
|
"""
|
||||||
|
|
||||||
puts a is "out\nhere"
|
ok a is "out\nhere"
|
||||||
|
|
||||||
|
|
||||||
a: '''
|
a: '''
|
||||||
|
@ -34,7 +34,7 @@ a: '''
|
||||||
c
|
c
|
||||||
'''
|
'''
|
||||||
|
|
||||||
puts a is " a\n b\nc"
|
ok a is " a\n b\nc"
|
||||||
|
|
||||||
a: '''
|
a: '''
|
||||||
a
|
a
|
||||||
|
@ -43,4 +43,4 @@ a
|
||||||
b c
|
b c
|
||||||
'''
|
'''
|
||||||
|
|
||||||
puts a is "a\n\n\nb c"
|
ok a is "a\n\n\nb c"
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
num: 1 + 2 + (a: 3)
|
num: 1 + 2 + (a: 3)
|
||||||
|
|
||||||
puts num is 6
|
ok num is 6
|
||||||
|
|
||||||
|
|
||||||
result: if true
|
result: if true
|
||||||
false
|
false
|
||||||
other: "result"
|
other: "result"
|
||||||
|
|
||||||
puts result is "result" and other is "result"
|
ok result is "result" and other is "result"
|
|
@ -1,43 +1,43 @@
|
||||||
a: [(x) -> x, (x) -> x * x]
|
a: [(x) -> x, (x) -> x * x]
|
||||||
|
|
||||||
puts a.length is 2
|
ok a.length is 2
|
||||||
|
|
||||||
|
|
||||||
regex: /match/i
|
regex: /match/i
|
||||||
words: "I think there is a match in here."
|
words: "I think there is a match in here."
|
||||||
|
|
||||||
puts !!words.match(regex)
|
ok !!words.match(regex)
|
||||||
|
|
||||||
|
|
||||||
neg: (3 -4)
|
neg: (3 -4)
|
||||||
|
|
||||||
puts neg is -1
|
ok neg is -1
|
||||||
|
|
||||||
|
|
||||||
func: ->
|
func: ->
|
||||||
return if true
|
return if true
|
||||||
|
|
||||||
puts func() is null
|
ok func() is null
|
||||||
|
|
||||||
|
|
||||||
str: "\\"
|
str: "\\"
|
||||||
reg: /\\/
|
reg: /\\/
|
||||||
|
|
||||||
puts reg(str) and str is '\\'
|
ok reg(str) and str is '\\'
|
||||||
|
|
||||||
|
|
||||||
i: 10
|
i: 10
|
||||||
while i -= 1
|
while i -= 1
|
||||||
|
|
||||||
puts i is 0
|
ok i is 0
|
||||||
|
|
||||||
|
|
||||||
money$: 'dollars'
|
money$: 'dollars'
|
||||||
|
|
||||||
puts money$ is 'dollars'
|
ok money$ is 'dollars'
|
||||||
|
|
||||||
|
|
||||||
puts {a: (num) -> num is 10 }.a 10
|
ok {a: (num) -> num is 10 }.a 10
|
||||||
|
|
||||||
|
|
||||||
bob: {
|
bob: {
|
||||||
|
@ -49,8 +49,8 @@ bob: {
|
||||||
10: 'number'
|
10: 'number'
|
||||||
}
|
}
|
||||||
|
|
||||||
puts bob.hello() is "Hello Bob"
|
ok bob.hello() is "Hello Bob"
|
||||||
puts bob[10] is 'number'
|
ok bob[10] is 'number'
|
||||||
|
|
||||||
|
|
||||||
obj: {
|
obj: {
|
||||||
|
@ -58,5 +58,5 @@ obj: {
|
||||||
'not': -> no
|
'not': -> no
|
||||||
}
|
}
|
||||||
|
|
||||||
puts obj.is()
|
ok obj.is()
|
||||||
puts not obj.not()
|
ok not obj.not()
|
||||||
|
|
|
@ -6,6 +6,6 @@ multi_liner:
|
||||||
single_liner:
|
single_liner:
|
||||||
[x, y] for y in [3..5] for x in [3..5]
|
[x, y] for y in [3..5] for x in [3..5]
|
||||||
|
|
||||||
puts multi_liner.length is single_liner.length
|
ok multi_liner.length is single_liner.length
|
||||||
puts 5 is multi_liner[2][2][1]
|
ok 5 is multi_liner[2][2][1]
|
||||||
puts 5 is single_liner[2][2][1]
|
ok 5 is single_liner[2][2][1]
|
||||||
|
|
|
@ -3,4 +3,4 @@ six:
|
||||||
2 +
|
2 +
|
||||||
3
|
3
|
||||||
|
|
||||||
puts six is 6
|
ok six is 6
|
|
@ -1,12 +1,12 @@
|
||||||
# CoffeeScript's operations should be chainable, like Python's.
|
# CoffeeScript's operations should be chainable, like Python's.
|
||||||
|
|
||||||
puts 500 > 50 > 5 > -5
|
ok 500 > 50 > 5 > -5
|
||||||
|
|
||||||
puts true is not false is true is not false
|
ok true is not false is true is not false
|
||||||
|
|
||||||
puts 10 < 20 > 10
|
ok 10 < 20 > 10
|
||||||
|
|
||||||
puts 50 > 10 > 5 is parseInt('5', 10)
|
ok 50 > 10 > 5 is parseInt('5', 10)
|
||||||
|
|
||||||
|
|
||||||
# Make sure that each argument is only evaluated once, even if used
|
# Make sure that each argument is only evaluated once, even if used
|
||||||
|
@ -15,4 +15,4 @@ puts 50 > 10 > 5 is parseInt('5', 10)
|
||||||
i: 0
|
i: 0
|
||||||
func: -> i++
|
func: -> i++
|
||||||
|
|
||||||
puts 1 > func() < 1
|
ok 1 > func() < 1
|
||||||
|
|
|
@ -5,16 +5,16 @@ negs: negs[0..2]
|
||||||
|
|
||||||
result: nums.concat(negs).join(', ')
|
result: nums.concat(negs).join(', ')
|
||||||
|
|
||||||
puts result is '3, 6, 9, -20, -19, -18'
|
ok result is '3, 6, 9, -20, -19, -18'
|
||||||
|
|
||||||
# Ensure that ranges are safe. This used to infinite loop:
|
# Ensure that ranges are safe. This used to infinite loop:
|
||||||
j = 5
|
j = 5
|
||||||
result: for j in [j..(j+3)]
|
result: for j in [j..(j+3)]
|
||||||
j
|
j
|
||||||
|
|
||||||
puts result.join(' ') is '5 6 7 8'
|
ok result.join(' ') is '5 6 7 8'
|
||||||
|
|
||||||
# With range comprehensions, you can loop in steps.
|
# With range comprehensions, you can loop in steps.
|
||||||
results: x for x in [0..25] by 5
|
results: x for x in [0..25] by 5
|
||||||
|
|
||||||
puts results.join(' ') is '0 5 10 15 20 25'
|
ok results.join(' ') is '0 5 10 15 20 25'
|
|
@ -5,12 +5,12 @@ b: array[2...4]
|
||||||
|
|
||||||
result: a.concat(b).join(' ')
|
result: a.concat(b).join(' ')
|
||||||
|
|
||||||
puts result is "7 8 9 2 3"
|
ok result is "7 8 9 2 3"
|
||||||
|
|
||||||
|
|
||||||
countdown: [10..1].join(' ')
|
countdown: [10..1].join(' ')
|
||||||
puts countdown is "10 9 8 7 6 5 4 3 2 1"
|
ok countdown is "10 9 8 7 6 5 4 3 2 1"
|
||||||
|
|
||||||
|
|
||||||
array: [(1+5)..1+9]
|
array: [(1+5)..1+9]
|
||||||
puts array.join(' ') is "6 7 8 9 10"
|
ok array.join(' ') is "6 7 8 9 10"
|
|
@ -3,7 +3,7 @@ func: (first, second, rest...) ->
|
||||||
|
|
||||||
result: func 1, 2, 3, 4, 5
|
result: func 1, 2, 3, 4, 5
|
||||||
|
|
||||||
puts result is "3 4 5"
|
ok result is "3 4 5"
|
||||||
|
|
||||||
|
|
||||||
gold: silver: bronze: the_field: null
|
gold: silver: bronze: the_field: null
|
||||||
|
@ -29,7 +29,7 @@ contenders: [
|
||||||
|
|
||||||
medalists "Mighty Mouse", contenders...
|
medalists "Mighty Mouse", contenders...
|
||||||
|
|
||||||
puts gold is "Mighty Mouse"
|
ok gold is "Mighty Mouse"
|
||||||
puts silver is "Michael Phelps"
|
ok silver is "Michael Phelps"
|
||||||
puts bronze is "Liu Xiang"
|
ok bronze is "Liu Xiang"
|
||||||
puts the_field.length is 8
|
ok the_field.length is 8
|
|
@ -2,4 +2,4 @@ array: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||||
|
|
||||||
array[5..10]: [0, 0, 0]
|
array[5..10]: [0, 0, 0]
|
||||||
|
|
||||||
puts array.join(' ') is '0 1 2 3 4 0 0 0'
|
ok array.join(' ') is '0 1 2 3 4 0 0 0'
|
|
@ -14,7 +14,7 @@ result: switch num
|
||||||
when 11 then false
|
when 11 then false
|
||||||
else false
|
else false
|
||||||
|
|
||||||
puts result
|
ok result
|
||||||
|
|
||||||
|
|
||||||
func: (num) ->
|
func: (num) ->
|
||||||
|
@ -25,7 +25,7 @@ func: (num) ->
|
||||||
false
|
false
|
||||||
else false
|
else false
|
||||||
|
|
||||||
puts func(2)
|
ok func(2)
|
||||||
puts func(6)
|
ok func(6)
|
||||||
puts !func(3)
|
ok !func(3)
|
||||||
puts !func(8)
|
ok !func(8)
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
i: 100
|
i: 100
|
||||||
while i -= 1
|
while i -= 1
|
||||||
|
|
||||||
puts i is 0
|
ok i is 0
|
||||||
|
|
||||||
|
|
||||||
i: 5
|
i: 5
|
||||||
list: while i -= 1
|
list: while i -= 1
|
||||||
i * 2
|
i * 2
|
||||||
|
|
||||||
puts list.join(' ') is "8 6 4 2"
|
ok list.join(' ') is "8 6 4 2"
|
||||||
|
|
||||||
|
|
||||||
i: 5
|
i: 5
|
||||||
list: (i * 3 while i -= 1)
|
list: (i * 3 while i -= 1)
|
||||||
|
|
||||||
puts list.join(' ') is "12 9 6 3"
|
ok list.join(' ') is "12 9 6 3"
|
||||||
|
|
||||||
|
|
||||||
i: 5
|
i: 5
|
||||||
func: (num) -> i -= num
|
func: (num) -> i -= num
|
||||||
assert: -> puts i < 5 > 0
|
assert: -> ok i < 5 > 0
|
||||||
|
|
||||||
results: while func 1
|
results: while func 1
|
||||||
assert()
|
assert()
|
||||||
i
|
i
|
||||||
|
|
||||||
puts results.join(' ') is '4 3 2 1'
|
ok results.join(' ') is '4 3 2 1'
|
Loading…
Reference in New Issue