Debian Codegraph @

scripts/tests/sanity.fim

raw
1 #!/usr/local/bin/fim -E
2
3 # $Id: sanity.fim 203 2009-01-10 11:13:17Z dezperado $
4
5 # this script is going to be replaced, or regenerated, from the tests contained in src/testdir.
6
7 #!/usr/local/bin/fim -t -E
8 #!/usr/local/bin/fim --no-framebuffer -E
9 #!/usr/bin/env fim -E
10
11 #
12 # This script tests the Fim language correctness.
13 # It is used during Fim maintenance, debugging, and developement.
14 #
15 # Fim should execute this script and return 0 if all tests pass.
16 #
17
18 if ( 1 ) { echo "if construct seems working"; }
19 else { echo "if construct seems not working"; }
20
21 if ( 0 ) { echo "if construct seems not working"; }
22 else { echo "if construct seems working"; }
23
24 if ( 0 == 0 ) { echo "equality works"; }
25 else { echo "equality does not work"; return -1; }
26
27 if ( 0 != 1 ) { echo "disequality works"; }
28 else { echo "disequality does not work"; return -1; }
29
30 if ( 40 == 50-10 ) { echo "basic integer arithmetics works"; }
31 else { echo "basic integer arithmetics does not work"; return -1; }
32
33 if ( 41 != 50-10 ) { echo "basic integer arithmetics works"; }
34 else { echo "basic integer arithmetics does not work"; return -1; }
35
36 iv=1;
37
38 if ( iv ) { echo "integer variables work"; }
39 else { echo "integer variables don't work"; return -1; }
40
41 iv=0;
42
43 if ( !iv ) { echo "integer variables work"; }
44 else { echo "integer variables don't work"; return -1; }
45
46 if ( !!iv ) { echo "integer variables don't work"; return -1; }
47 else { echo "integer variables work"; }
48
49 if ( !!!iv ) { echo "integer variables work"; }
50 else { echo "integer variables don't work"; return -1; }
51
52 if ( iv == 0 ) { echo "integer variables work"; }
53 else { echo "integer variables don't work"; return -1; }
54
55 if ( iv == 3*iv-2*iv ) { echo "integer variables work"; }
56 else { echo "integer variables don't work"; return -1; }
57
58 if ( iv != 3*iv-2*iv ) { echo "integer variables don't work"; return -1; }
59 else { echo "integer variables work"; }
60
61 if ( iv != iv ) { echo "integer variables don't work"; return -1; }
62 else { echo "integer variables work"; }
63
64 # Like in Vim, the following form is not correct for an arithmetic assignment:
65 # fv=2.0;
66 # The next one is the correct one:
67 fv="2.0";
68
69 if ( fv ) { echo "float variables work"; }
70 else { echo "float variables don't work"; return -1; }
71
72 if ( !fv ) { echo "float variables don't work"; return -1; }
73 else { echo "float variables work"; }
74
75 if ( !!fv ) { echo "float variables work"; }
76 else { echo "float variables don't work"; return -1; }
77
78 if ( !!!fv ) { echo "float variables don't work"; return -1; }
79 else { echo "float variables work"; }
80
81 if ( fv == "0.0" ) { echo "float variables don't work"; return -1; }
82 else { echo "float variables work"; }
83
84 if ( ! ( fv != "0.0" ) ) { echo "float variables don't work"; return -1; }
85 else { echo "float variables work"; }
86
87 if ( !!! ( fv != "0.0" ) ) { echo "float variables don't work"; return -1; }
88 else { echo "float variables work"; }
89
90 if ( !! ( fv == "0.0" ) ) { echo "float variables don't work"; return -1; }
91 else { echo "float variables work"; }
92
93 if ( fv == "2.0" ) { echo "float variables work"; }
94 else { echo "float variables don't work"; return -1; }
95
96 if ( fv != "3.0" ) { echo "float variables work"; }
97 else { echo "float variables don't work"; return -1; }
98
99 echo "tab works";
100 echo
101 "newline works";
102
103 if
104 ( 1==1 )
105 {
106 echo "multiline" " and multiarg constructs ".
107 "work"
108 }
109 else { return -1; }
110
111 if( "aba"."a"=="a"."ba"."a" ){echo "string collation works";}
112 else {echo "string collation does not work"; return -1;}
113
114 if( "aba"!="a"."sba"."a" ){echo "string collation works";}
115 else {echo "string collation does not work"; return -1;}
116
117 if( "aba"=~"a.*a" ){echo "regular expressions work";}
118 else {echo "regular expressions does not work"; return -1;}
119
120 if( !("aba"=~"a.*a") ) {echo "single negations on regular expressions does not work"; return -1;}
121 else {echo "single negations on regular expressions work";}
122
123 # the following doesn't work in fim 0.3.
124 if( !(!("aba"=~"a.*a")) ){echo "double negations on regular expressions work";}
125 else {echo "double negations on regular expressions does not work"; }
126
127 a=1;
128 {a=5}
129 if( a==5 ){echo "{command} constructs work";}
130 else {echo "{command} constructs don't work";}
131
132 {a=10;}
133 if( a==10 ){echo "{command;} constructs work";}
134 else {echo "{command;} constructs don't work";}
135
136 #the following does not work
137 #{a=20;;}
138
139 if( a==20 ){echo "{command;;} constructs work";}
140 else {echo "{command;;} constructs don't work";}
141
142
143 rc=0;
144 return rc;
145