Root/test/keys

1#!/bin/sh
2. ./Common
3
4###############################################################################
5
6fped "keys: tables, master before slave" <<EOF
7table { a, eng } { 1, "one" } { 2, "two" }
8table { ?a, ger } { 1, "eins" } { 2, "zwei" }
9
10%iprint eng
11%iprint ger
12EOF
13expect <<EOF
14one
15eins
16two
17zwei
18EOF
19
20#------------------------------------------------------------------------------
21
22fped "keys: tables, master after slave" <<EOF
23table { ?a, eng } { 1, "one" } { 2, "two" }
24table { a, spa } { 1, "uno" } { 2, "dos" }
25
26%iprint eng
27%iprint spa
28EOF
29expect <<EOF
30one
31uno
32two
33dos
34EOF
35
36#------------------------------------------------------------------------------
37
38fped_fail "keys: tables, slaves without master" <<EOF
39table { ?a, eng } { 1, "one" } { 2, "two" }
40table { ?a, lat } { 1, "unum" } { 2, "duo" }
41
42%iprint eng
43%iprint lat
44EOF
45expect <<EOF
46undefined variable "a"
47EOF
48
49#------------------------------------------------------------------------------
50
51fped_fail "keys: tables, both masters" <<EOF
52table { a, eng } { 1, "one" } { 2, "two" }
53table { a, lat } { 1, "unum" } { 2, "duo" }
54
55%iprint eng
56%iprint lat
57EOF
58expect <<EOF
592: duplicate variable "a" near "a"
60EOF
61
62#------------------------------------------------------------------------------
63
64fped "keys: master is single variable, slave is table" <<EOF
65set n = 2
66table { ?n, square } { 1, 1 } { 2, 4 } { 3, 9 } { 4, 16 }
67
68%iprint square
69EOF
70expect <<EOF
714
72EOF
73
74#------------------------------------------------------------------------------
75
76fped "keys: master is table, slave is single variable" <<EOF
77table { n, cube } { 1, 1 } { 2, 8 } { 3, 27 } { 4, 64 }
78set ?n = 3
79
80%iprint cube
81EOF
82expect <<EOF
8327
84EOF
85
86#------------------------------------------------------------------------------
87
88fped "keys: master is loop, slave is table" <<EOF
89loop n = 1, 3
90table { ?n, sqr } { 1, 1 } { 2, 4 } { 3, 9 } { 4, 16 }
91
92%iprint sqr
93EOF
94expect <<EOF
951
964
979
98EOF
99
100#------------------------------------------------------------------------------
101
102fped "keys: two keys" <<EOF
103table { a, an } { 1, "one" } { 2, "two" }
104table { b, bn } { 3, "three" } { 4, "four" } { 5, "five" }
105table { ?a, ?b, sum }
106  { 1, 3, "four" }
107  { 2, 4, "six" }
108  { 3, 4, "seven" }
109
110%iprint sum
111EOF
112expect <<EOF
113four
114six
115EOF
116
117#------------------------------------------------------------------------------
118
119fped "keys: key set by outer frame" <<EOF
120frame tab {
121    table { sqrt, ?n } { 1, 1 } { 2, 4 } { 3, 9 } { 4, 16 } { 5, 25 }
122    %iprint sqrt
123}
124
125table { n } { 25 } { 9 }
126
127frame tab @
128EOF
129expect <<EOF
1305
1313
132EOF
133
134###############################################################################
135

Archive Download this file

Branches:
master



interactive