First set of unit tests

This commit is contained in:
Jonathan Turner 2009-07-08 18:59:10 +00:00
parent 3d75f17d21
commit e7d63b1536
132 changed files with 194 additions and 1 deletions

View File

@ -3,7 +3,6 @@
#include "chaiscript.hpp"
int main(int argc, char *argv[]) {
std::string input;
chaiscript::ChaiScript_Engine chai;

1
unittests/bool_not.chai Normal file
View File

@ -0,0 +1 @@
print(!true)

1
unittests/bool_not.txt Normal file
View File

@ -0,0 +1 @@
false

View File

@ -0,0 +1,7 @@
var i = 0
while (i < 10) {
if (++i == 5) {
break
}
}
print(i)

View File

@ -0,0 +1 @@
5

1
unittests/char_init.chai Normal file
View File

@ -0,0 +1 @@
print('b')

1
unittests/char_init.txt Normal file
View File

@ -0,0 +1 @@
b

1
unittests/collate.chai Normal file
View File

@ -0,0 +1 @@
print(collate(1, 2))

1
unittests/collate.txt Normal file
View File

@ -0,0 +1 @@
[1, 2]

View File

@ -0,0 +1 @@
print(1 > 2)

1
unittests/compare_gt.txt Normal file
View File

@ -0,0 +1 @@
false

View File

@ -0,0 +1 @@
print(1 < 2)

1
unittests/compare_lt.txt Normal file
View File

@ -0,0 +1 @@
true

1
unittests/concat.chai Normal file
View File

@ -0,0 +1 @@
print(concat([1, 2], [3, 4]))

1
unittests/concat.txt Normal file
View File

@ -0,0 +1 @@
[1, 2, 3, 4]

View File

@ -0,0 +1 @@
print(3.5.to_string() + "bob")

View File

@ -0,0 +1 @@
3.5bob

View File

@ -0,0 +1 @@
print(3.to_string + "bob")

View File

@ -0,0 +1 @@
3bob

View File

@ -0,0 +1 @@
print("3.5".to_double() + 3.3)

View File

@ -0,0 +1 @@
6.7999999999999998

View File

@ -0,0 +1 @@
print("4".to_int() + 4)

View File

@ -0,0 +1 @@
8

1
unittests/drop.chai Normal file
View File

@ -0,0 +1 @@
print(drop([1, 2, 3, 4], 2))

1
unittests/drop.txt Normal file
View File

@ -0,0 +1 @@
[3, 4]

View File

@ -0,0 +1 @@
print(drop_while([1, 2, 3], odd))

1
unittests/drop_while.txt Normal file
View File

@ -0,0 +1 @@
[2, 3]

1
unittests/even.chai Normal file
View File

@ -0,0 +1 @@
print(even(4))

1
unittests/even.txt Normal file
View File

@ -0,0 +1 @@
true

1
unittests/filter.chai Normal file
View File

@ -0,0 +1 @@
print(filter([1, 2, 3, 4], odd))

1
unittests/filter.txt Normal file
View File

@ -0,0 +1 @@
[1, 3]

1
unittests/foldl.chai Normal file
View File

@ -0,0 +1 @@
print(foldl([1, 2, 3, 4], `+`, 0))

1
unittests/foldl.txt Normal file
View File

@ -0,0 +1 @@
10

3
unittests/for.chai Normal file
View File

@ -0,0 +1,3 @@
for (var i = 0; i < 5; ++i) {
print(i)
}

5
unittests/for.txt Normal file
View File

@ -0,0 +1,5 @@
0
1
2
3
4

1
unittests/for_each.chai Normal file
View File

@ -0,0 +1 @@
for_each([1, 2, 3], print)

3
unittests/for_each.txt Normal file
View File

@ -0,0 +1,3 @@
1
2
3

View File

@ -0,0 +1 @@
print(generate_range(1, 10))

View File

@ -0,0 +1 @@
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

4
unittests/if.chai Normal file
View File

@ -0,0 +1,4 @@
if (true) {
print("true")
}
print("done")

2
unittests/if.txt Normal file
View File

@ -0,0 +1,2 @@
true
done

8
unittests/if_else.chai Normal file
View File

@ -0,0 +1,8 @@
var i = 3
if (i == 2) {
print("2")
}
else {
print("other")
}
print("done")

2
unittests/if_else.txt Normal file
View File

@ -0,0 +1,2 @@
other
done

12
unittests/if_elseif.chai Normal file
View File

@ -0,0 +1,12 @@
var i = 3
if (i == 2) {
print("2")
}
elseif (i == 4) {
print("4")
}
elseif (i == 3) {
print("3")
}
print("done")

2
unittests/if_elseif.txt Normal file
View File

@ -0,0 +1,2 @@
3
done

View File

@ -0,0 +1,12 @@
var i = 3
if (i == 2) {
print("2")
}
elseif (i == 4) {
print("4")
}
else {
print("3")
}
print("done")

View File

@ -0,0 +1,2 @@
3
done

1
unittests/join.chai Normal file
View File

@ -0,0 +1 @@
print(join([1, 2, 3], "*"))

1
unittests/join.txt Normal file
View File

@ -0,0 +1 @@
1*2*3

2
unittests/lambda.chai Normal file
View File

@ -0,0 +1,2 @@
var bob = fun(x) { x + 1 }
print(bob(3))

1
unittests/lambda.txt Normal file
View File

@ -0,0 +1 @@
4

1
unittests/map.chai Normal file
View File

@ -0,0 +1 @@
print(map([1, 2, 3], odd))

1
unittests/map.txt Normal file
View File

@ -0,0 +1 @@
[true, false, true]

View File

@ -0,0 +1,2 @@
var x = ["bob":2, "fred":3]
print(x["fred"])

1
unittests/map_access.txt Normal file
View File

@ -0,0 +1 @@
3

View File

@ -0,0 +1,2 @@
var x = ["bob":1, "fred":2]
print(x)

View File

@ -0,0 +1 @@
[<bob, 1>, <fred, 2>]

1
unittests/math_add.chai Normal file
View File

@ -0,0 +1 @@
print(1 + 2)

1
unittests/math_add.txt Normal file
View File

@ -0,0 +1 @@
3

View File

@ -0,0 +1 @@
print(1.5 + 2)

1
unittests/math_dec.chai Normal file
View File

@ -0,0 +1 @@
print(--3)

1
unittests/math_dec.txt Normal file
View File

@ -0,0 +1 @@
2

1
unittests/math_div.chai Normal file
View File

@ -0,0 +1 @@
print(10 / 5)

1
unittests/math_div.txt Normal file
View File

@ -0,0 +1 @@
2

1
unittests/math_inc.chai Normal file
View File

@ -0,0 +1 @@
print(++3)

1
unittests/math_inc.txt Normal file
View File

@ -0,0 +1 @@
4

1
unittests/math_mod.chai Normal file
View File

@ -0,0 +1 @@
print(11 % 3)

1
unittests/math_mod.txt Normal file
View File

@ -0,0 +1 @@
2

1
unittests/math_mult.chai Normal file
View File

@ -0,0 +1 @@
print(3 * 4)

1
unittests/math_mult.txt Normal file
View File

@ -0,0 +1 @@
12

View File

@ -0,0 +1 @@
print(-(3 + 4))

View File

@ -0,0 +1 @@
-7

View File

@ -0,0 +1 @@
print(3*(4+5))

1
unittests/math_paren.txt Normal file
View File

@ -0,0 +1 @@
27

1
unittests/math_sub.chai Normal file
View File

@ -0,0 +1 @@
print(5 - 3)

1
unittests/math_sub.txt Normal file
View File

@ -0,0 +1 @@
2

1
unittests/max.chai Normal file
View File

@ -0,0 +1 @@
print(max(3, 5))

1
unittests/max.txt Normal file
View File

@ -0,0 +1 @@
5

View File

@ -0,0 +1 @@
print([1, 2, 3].sum())

View File

@ -0,0 +1 @@
6

1
unittests/min.chai Normal file
View File

@ -0,0 +1 @@
print(min(3, 5))

1
unittests/min.txt Normal file
View File

@ -0,0 +1 @@
3

1
unittests/odd.chai Normal file
View File

@ -0,0 +1 @@
print(odd(4))

1
unittests/odd.txt Normal file
View File

@ -0,0 +1 @@
false

View File

@ -0,0 +1 @@
print(2 + 3 * 4)

View File

@ -0,0 +1 @@
14

View File

@ -0,0 +1 @@
print(5 - 4 - 3)

View File

@ -0,0 +1 @@
-2

View File

@ -0,0 +1 @@
print(10 / 5 % 2)

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,2 @@
var x = var y = 4
print(x); print(y)

View File

@ -0,0 +1,2 @@
4
4

1
unittests/product.chai Normal file
View File

@ -0,0 +1 @@
print(product([1, 2, 3, 4]))

1
unittests/product.txt Normal file
View File

@ -0,0 +1 @@
24

View File

@ -0,0 +1 @@
print([3..6])

View File

@ -0,0 +1 @@
[3, 4, 5, 6]

1
unittests/reduce.chai Normal file
View File

@ -0,0 +1 @@
print(reduce([1, 2, 3, 4], `+`))

1
unittests/reduce.txt Normal file
View File

@ -0,0 +1 @@
10

5
unittests/return.chai Normal file
View File

@ -0,0 +1,5 @@
def bob() {
return 5
}
print(bob())

1
unittests/return.txt Normal file
View File

@ -0,0 +1 @@
5

Some files were not shown because too many files have changed in this diff Show More