forked from skandhas/mrubybind
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·59 lines (50 loc) · 1.27 KB
/
test.sh
File metadata and controls
executable file
·59 lines (50 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
################################################################
# Test framework.
function error_exit() {
echo -n -e "\033[1;31m[ERROR]\033[0;39m "
echo "$1"
exit 1
}
function run() {
echo -n "Testing $1 ... "
result=$(./$1)
code=$?
if [ $code -ne 0 ]; then
error_exit "exit status is not 0 [$code]"
fi
if [ "$result" != "$2" ]; then
error_exit "$2 expected, but got '$result'"
fi
echo ok
}
function fail() {
echo -n "Testing $1 ... "
result=$(./$1)
code=$?
if [ $code -eq 0 ]; then
error_exit "Failure expected, but succeeded!"
fi
if [ "$result" != "$2" ]; then
error_exit "$2 expected, but got '$result'"
fi
echo ok
}
################################################################
# Test cases.
run void 'dummy called'
run int '1234321'
run float '408.0'
run string '* Hello, mruby! *'
run cptr 'cptr test'
run class 'Foo::ctor(123)
690
99980001
Foo::dtor()'
run module 'modfunc called: 1234'
# Failure cases
fail wrong_type "#<TypeError: can't convert String into Fixnum, argument 1(1111)>"
fail wrong_arg_num "#<ArgumentError: 'square': wrong number of arguments (2 for 1)>"
################################################################
# All tests succeeded.
echo -n -e "\033[1;32mTEST ALL SUCCEEDED!\033[0;39m\n"