keys 2.5 KB

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