Add tests in the language
This commit is contained in:
parent
74bd9c9582
commit
e8d8731922
6 changed files with 102 additions and 0 deletions
24
tests/list.ang
Normal file
24
tests/list.ang
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
list := []
|
||||
|
||||
x := 1
|
||||
while x <= 1000 {
|
||||
list = list.append(x)
|
||||
assert(list.reduce(func(tot, a){
|
||||
return tot + a
|
||||
}, 0) == x*(x + 1)/2)
|
||||
|
||||
x = x + 1
|
||||
}
|
||||
|
||||
func sum(a, b) {
|
||||
return a + b
|
||||
}
|
||||
|
||||
list = []
|
||||
x = 1
|
||||
while x <= 100 {
|
||||
list = list.append(2*x - 1)
|
||||
assert(list.reduce(sum, 0) == x*x)
|
||||
|
||||
x = x + 1
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue