summaryrefslogtreecommitdiff
path: root/fpcsrc/tests/tbs/tb0531.pp
blob: 691b94a5d61464a4e61f36bdc6db3da9aaca65bc (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
procedure testshort;
var
  s1,s2: shortint;
  l: longint;
begin
  s1 := -1;
  s1 := s1 xor -1;
  l := -65536;
  l := l + s1;
  if (l <> -65536) then
    halt(1);

  s1 := 127;
  s1 := s1 or -128;
  l := -65536;
  l := l + s1;
  if (l <> -65536-1) then
    halt(2);


  s1 := -1;
  s1 := s1 xor -128;
  l := -65536;
  l := l + s1;
  if (l <> -65536+127) then
    halt(3);

  s1 := 127;
  s1 := s1 or -128;
  l := -65536;
  l := l + s1;
  if (l <> -65536-1) then
    halt(4);


  s1 := -1;
  s2 := -128;
  s1 := s1 xor s2;
  l := 0;
  l := l + s1;
  if l <> 127 then
    halt(5);
  
  s1 := 126;
  s2 := -128;
  s1 := s1 or s2;
  l := 0;
  l := l + s1;
  if l <> -2 then
    halt(6);
end;


procedure testsmall;
var
  s1,s2: smallint;
  l: longint;
begin
  s1 := -1;
  s1 := s1 xor -1;
  l := -65536;
  l := l + s1;
  if (l <> -65536) then
    halt(1+6);

  s1 := 32767;
  s1 := s1 or -32678;
  l := -65536;
  l := l + s1;
  if (l <> -65536-1) then
    halt(2+6);


  s1 := -1;
  s1 := s1 xor -32768;
  l := -65536;
  l := l + s1;
  if (l <> -65536+32767) then
    halt(3+6);

  s1 := 32767;
  s1 := s1 or -32768;
  l := -65536;
  l := l + s1;
  if (l <> -65536-1) then
    halt(4+6);


  s1 := -1;
  s2 := -32768;
  s1 := s1 xor s2;
  l := 0;
  l := l + s1;
  if l <> 32767 then
    halt(5+6);
  
  s1 := 32766;
  s2 := -32768;
  s1 := s1 or s2;
  l := 0;
  l := l + s1;
  if l <> -2 then
    halt(6+6);
end;

begin
  testshort;
  testsmall;
end.