summaryrefslogtreecommitdiff
path: root/tests/test/trecreg.pp
blob: a22b6093ee4b7f1ebd8bbc634d0f80c3ff1cc178 (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
type
  u_char = byte;
  u_short = word;
  u_long = cardinal;

  wrec = record
    w: word;
  end;

  wrec2 = record
    b1,b2: byte;
  end;

  SunB = record
    s_b1,
    s_b2,
    s_b3,
    s_b4: u_char;
  end;

  SunW = record
    s_w1: wrec;
    s_w2: wrec2;
  end;

  in_addr =  record
    case Integer of
      0: (S_un_b: SunB);
      1: (S_un_w: SunW);
      2: (S_addr: u_long);
  end;

procedure t(i: in_addr);
begin
  if (i.s_un_b.s_b1 <> $de) or
     (i.s_un_b.s_b2 <> $ad) or
     (i.s_un_b.s_b3 <> $be) or
     (i.s_un_b.s_b4 <> $ef) then
    begin
      writeln('error1');
      halt(1);
    end;
end;

procedure t2(i: in_addr);
begin
  if (i.s_un_w.s_w1.w <> $cafe) or
     (i.s_un_w.s_w2.b1 <> $ba) or
     (i.s_un_w.s_w2.b2 <> $be) then
    begin
      writeln('error2');
      halt(2);
    end;
end;


var
  i: in_addr;
begin
  i.s_un_b.s_b1 := $de;
  i.s_un_b.s_b2 := $ad;
  i.s_un_b.s_b3 := $be;
  i.s_un_b.s_b4 := $ef;
  t(i);
  i.s_un_w.s_w1.w := $cafe;
  i.s_un_w.s_w2.b1 := $ba;
  i.s_un_w.s_w2.b2 := $be;
  t2(i);
end.