Debian Codegraph @

debian/tests/ngraph-test

raw
1 #!/usr/bin/ngraph -i
2 ERROR=0
3 show_result() {
4 if [ "$2" = "$3" ]
5 then
6 echo "OK. ($1)"
7 else
8 echo "error. ($1) '$2' '$3'"
9 ERROR=1
10 fi
11 }
12
13 new string
14
15 string::@=" a b b b c d e f BCD"
16
17 show_result "strip" "${string::strip}" "a b b b c d e f BCD"
18 show_result "upcase" "${string::upcase}" " A B B B C D E F BCD"
19 show_result "downcase" "${string::downcase}" " a b b b c d e f bcd"
20 show_result "reverse" "${string::reverse}" "DCB f e d c b b b a "
21 show_result "slice" "${string::slice:'6 9'}" "b b c"
22 show_result "slice" "${string::slice:'21 4'}" "f BC"
23 show_result "index" "${string::index:'D 25'}" "25"
24 show_result "index" "${string::index:'a 1'}" "1"
25 show_result "rindex" "${string::rindex:'a 1'}" "1"
26 show_result "rindex" "${string::rindex:'b 20'}" "10"
27 show_result "match" "${string::match:'f.B'}" "true"
28 show_result "match" "${string::match:'a[^b]+c'}" "false"
29 exit $ERROR