blob: e59c2934ed68ef9e37b585d4a74d7c68da7a37c5 (
plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
linkname "";
import int printf(char+> s, ...*);
var bool error = :false;
bool fail(int testnum)
{
printf("failure at test #%d\n", testnum);
error = :true;
return :true;
}
uint8 u80 = 80;
uint8 u100 = 100;
uint8 u120 = 120;
var int state = 0;
int8 runonce()
{
if state != 0 return 120;
state = 1;
return -128;
}
int main()
{
int8 s8n = -128;
int8 s8p = 100;
int16 s16n = -32768;
int16 s16p = 10000;
int32 s32n = -2147483648;
int32 s32p = 1000000000;
int64 s64n = -9223372036854775808;
int64 s64p = 1000000000000000000;
//s8n < 120 or error = fail(1); // TODO improve error message. should be "expression cannot be assigned to"
s8n < u120 or fail(11);
s8n <= u120 or fail(12);
not s8n > u80 or fail(13);
not s8n >= u80 or fail(14);
not s8n == u80 or fail(15);
s8n != u100 or fail(16);
u120 > s8n or fail(21);
u120 >= s8n or fail(22);
not u80 < s8n or fail(23);
not u80 <= s8n or fail(24);
not u80 == s8n or fail(25);
u100 != s8n or fail(26);
s8p < u120 or fail(31);
s8p <= u120 or fail(32);
s8p > u80 or fail(33);
s8p >= u80 or fail(34);
s8p == u100 or fail(35);
s8p != u80 or fail(36);
u120 > s8p or fail(41);
u120 >= s8p or fail(42);
u80 < s8p or fail(43);
u80 <= s8p or fail(44);
u100 == s8p or fail(45);
u80 != s8p or fail(46);
runonce() < u120 or fail(51);
// TODO test with int16, int32 and int64
// TODO test with differing sizes (e.g. int8 and uint64)
return (error then 1 else 0);
}
|