| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- MODULE TermCfgTest ;
- (* Read a terminal config and print it as hex, so the loader and the escape
- decoder are asserted byte for byte (tests/term_config.sh compares this with
- an expected file). The path is fixed because this is a harness program, not
- a configurable tool: the script copies the fixture there. *)
- FROM TermCfg IMPORT Cfg, Load ;
- FROM Posix IMPORT write ;
- FROM SYSTEM IMPORT ADR ;
- VAR
- c : Cfg ;
- ok : BOOLEAN ;
- n : LONGINT ;
- ch : CHAR ;
- PROCEDURE Out (s : ARRAY OF CHAR) ;
- VAR i : CARDINAL ;
- BEGIN
- i := 0 ;
- WHILE (i <= HIGH (s)) AND (s [i] # 0C) DO
- ch := s [i] ;
- n := write (1, ADR (ch), 1) ;
- INC (i)
- END
- END Out ;
- PROCEDURE NL ;
- BEGIN
- ch := CHR (10) ;
- n := write (1, ADR (ch), 1)
- END NL ;
- PROCEDURE HexDig (d : CARDINAL) ;
- BEGIN
- IF d < 10 THEN
- ch := CHR (ORD ('0') + d)
- ELSE
- ch := CHR (ORD ('A') + d - 10)
- END ;
- n := write (1, ADR (ch), 1)
- END HexDig ;
- PROCEDURE Hex (label : ARRAY OF CHAR ; s : ARRAY OF CHAR) ;
- VAR i, o : CARDINAL ;
- BEGIN
- Out (label) ;
- Out ("=") ;
- i := 0 ;
- WHILE (i <= HIGH (s)) AND (s [i] # 0C) DO
- o := ORD (s [i]) ;
- HexDig (o DIV 16) ;
- HexDig (o MOD 16) ;
- Out (" ") ;
- INC (i)
- END ;
- NL
- END Hex ;
- BEGIN
- Load ("../tmp/term_test.trm", c, ok) ;
- IF ok THEN Out ("ok=1") ELSE Out ("ok=0") END ;
- NL ;
- Out ("NAME=") ; Out (c.name) ; NL ;
- Hex ("CLEAR", c.clear) ;
- Hex ("HOME", c.home) ;
- Hex ("GOTO", c.moveTo) ;
- Hex ("NORMAL", c.normal) ;
- Hex ("MARKED", c.marked) ;
- Hex ("BEEP", c.beep)
- END TermCfgTest.
|