File: tst_IO.gri

package info (click to toggle)
gri 2.12.26-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 5,952 kB
  • ctags: 2,396
  • sloc: cpp: 36,598; sh: 4,196; lisp: 3,764; perl: 1,362; ansic: 1,046; makefile: 606
file content (66 lines) | stat: -rw-r--r-- 2,467 bytes parent folder | download | duplicates (8)
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
show "doc/tst_suite/tst_IO.gri      ..." ...
# Test some I/O features.  NOTE: this will make _no_ sense
# to you unless you have a look at the test files!
# Read columns from file with newline at the end ...
open tst_IO_1.dat
read columns x y
close
assert {rpn ..num_col_data.. 2 ==}      " failed test 1-a"
assert {rpn x 0 @  1 ==}                " failed test 1-b"
assert {rpn x 1 @  2 ==}                " failed test 1-c"
assert {rpn y 0 @ 11 ==}                " failed test 1-d"
assert {rpn y 1 @ 22 ==}                " failed test 1-e"
# ... as above, but from a file without newline at the end.
open tst_IO_2.dat
read columns x y
close
assert {rpn ..num_col_data.. 2 ==}      " failed test 2-a"
assert {rpn x 0 @  1 ==}                " failed test 2-b"
assert {rpn x 1 @  2 ==}                " failed test 2-c"
assert {rpn y 0 @ 11 ==}                " failed test 2-d"
assert {rpn y 1 @ 22 ==}                " failed test 2-e"
# Read a line into a synonym.
open tst_IO_1.dat
read line \s
assert {rpn "\s" "1 11" ==}             " failed test 3-a"
read line \s
assert {rpn "\s" "2 22" ==}             " failed test 3-b"
close
open tst_IO_2.dat
read line \s
assert {rpn "\s" "1 11" ==}             " failed test 3-c"
read line \s
assert {rpn "\s" "2 22" ==}             " failed test 3-d"
close
# Read variable/synonym, in various orders.
open tst_IO_1.dat
read .a. .b.
assert {rpn .a.  1 ==}                  " failed test 4-a"
assert {rpn .b. 11 ==}                  " failed test 4-b"
read \a \b
assert {rpn "\a"  "2" ==}               " failed test 4-c"
assert {rpn "\b" "22" ==}               " failed test 4-d"
rewind
read .a. \b
assert {rpn .a.  1 ==}                  " failed test 4-e"
assert {rpn "\b" "11" ==}               " failed test 4-f"
read \a .b.
assert {rpn "\a" "2" ==}                " failed test 4-g"
assert {rpn .b.  22  ==}                " failed test 4-h"
close
open tst_IO_2.dat
read .a. .b.
assert {rpn .a.  1 ==}                  " failed test 4-i"
assert {rpn .b. 11 ==}                  " failed test 4-j"
read \a \b
assert {rpn "\a"  "2" ==}               " failed test 4-k"
assert {rpn "\b" "22" ==}               " failed test 4-l"
rewind
read .a. \b
assert {rpn .a.  1 ==}                  " failed test 4-m"
assert {rpn "\b" "11" ==}               " failed test 4-n"
read \a .b.
assert {rpn "\a" "2" ==}                " failed test 4-o"
assert {rpn .b.  22  ==}                " failed test 4-p"
close
show " passed"