home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / euphoria / sanity.ex < prev    next >
Text File  |  1994-03-05  |  17KB  |  841 lines

  1.         ------------------------------------------
  2.         -- AUTOMATIC SELF-CHECKING SANITY TEST  --
  3.         -- for Euphoria                         --
  4.         -- A quick test of most of the features --
  5.         ------------------------------------------
  6. with type_check
  7.  
  8. include get.e
  9. include graphics.e
  10. include sort.e
  11. include machine.e
  12. include file.e
  13.  
  14. trace(0)
  15.  
  16. constant msg = 1 -- place to send messages
  17.  
  18. global object y, i, r
  19.  
  20. procedure the_end()
  21.     abort(1)
  22. end procedure
  23.  
  24. procedure make_sound()
  25. -- test sound() built-in
  26.     for i = 500 to 5000 by 500 do
  27.     sound(i)
  28.     for j = 1 to 100000 do
  29.     end for
  30.     sound(0)
  31.     end for
  32. end procedure
  33.  
  34. without warning
  35. procedure abort()
  36. -- force abort with trace back
  37.     puts(msg, "\ndivide by 0 to get trace back...Press Enter\n")
  38.     if sequence(gets(0)) then
  39.     end if
  40.     ? 1/0
  41. end procedure
  42. with warning
  43.  
  44. procedure show(object x, object y)
  45. -- show the mismatched values
  46.     puts(msg, "\n   ---MISMATCH--- \n   x is ")
  47.     ? x
  48.     puts(msg, "   y is ")
  49.     ? y
  50.     abort()
  51. end procedure
  52.  
  53. constant epsilon = 1e-10 -- allow for small floating point inaccuracy
  54.  
  55. procedure same(object x, object y)
  56. -- object x must be identical to object y else abort program
  57.     atom ratio
  58.  
  59.     if atom(x) and atom(y) then
  60.     if x = y then
  61.         return
  62.     else
  63.         if y = 0 then
  64.         show(x, y)
  65.         else
  66.         ratio = x / y
  67.         if ratio < 1 - epsilon or ratio > 1 + epsilon then
  68.             show(x, y)
  69.         end if
  70.         end if
  71.     end if
  72.     elsif length(x) = length(y) then
  73.     for i = 1 to length(x) do
  74.         same(x[i], y[i])
  75.     end for
  76.     else
  77.     show(x, y)
  78.     end if
  79. end procedure
  80.  
  81. function abs(atom x)
  82. -- absolute value
  83.     if x < 0 then
  84.     return -x
  85.     else
  86.     return x
  87.     end if
  88. end function
  89.  
  90. function built_in()
  91. -- built-in tests
  92.     sequence d
  93.  
  94.     d = date()
  95.     if d[1] < 93 or d[2] > 12 or d[3] < 1 or d[4] > 23 or d[5] > 59 or
  96.     d[6] >59 or d[7] > 7  or d[8] > 366 then
  97.     abort()
  98.     end if
  99.     d = power({-5, -4.5, -1,  0, 1,  2,  3.5, 4, 6},
  100.           { 3,    2, -1,0.5, 0, 29, -2.5, 5, 8})
  101.     if d[1] != -125 or d[2] != 20.25 or d[3] != -1 or d[4] != 0 then
  102.     abort()
  103.     end if 
  104.     if d[5] != 1 or d[6] != 536870912 or d[7] <.043 or d[7] > .044 then
  105.     abort()
  106.     end if
  107.     if d[8] != 1024 or d[9] != 1679616 or power(2,3) != 8 then
  108.     abort()
  109.     end if
  110.     same(power(16, 0.5), 4)
  111.     d = remainder({5, 9, 15, -27}, {3, 4, 5, 6})
  112.     if d[1] != 2 or d[2] != 1 or d[3] != 0 or d[4] != -3 then
  113.     abort()
  114.     end if
  115.     d = remainder({11.5, -8.8, 3.5, 5.0}, {2, 3.5, -1.5, -100.0})
  116.     if d[1] != 1.5 or d[2] < -1.81 or d[2] > -1.79 or d[3] != 0.5 or d[4] != 5 then
  117.     abort()
  118.     end if
  119.     same(4, sqrt(16))
  120.     same(3, length("ABC"))
  121.     same({1, 1, 1, 1}, repeat(1, 4))
  122.     if rand(10) > 10 or rand(20) < 1 or not find(rand(5.5), {1,2,3,4,5}) then
  123.     abort()
  124.     end if
  125.     if time() < 0 then
  126.     abort()
  127.     end if
  128.     if abs(sin(3.1415)) > 0.02 then
  129.     abort()
  130.     end if
  131.     if cos(0) < .98 then
  132.     abort()
  133.     end if
  134.     if abs(tan(3.14/4) - 1) > .02 then
  135.     abort()
  136.     end if
  137.     if log(2.7) < 0.8 or log(2.7) > 1.2 then
  138.     abort()
  139.     end if
  140.     if floor(-3.3) != -4 then
  141.     abort()
  142.     end if
  143.     if floor(-999/3.000000001) != -333 then
  144.     abort()
  145.     end if
  146.     if floor(9.99/1) != 9 then
  147.     abort()
  148.     end if
  149.     for i = -9 to 2 do
  150.     if i = 1 then
  151.         return i
  152.     end if
  153.     end for
  154. end function
  155.  
  156. procedure sub()
  157.     y = 200
  158. end procedure
  159.  
  160. procedure overflow()
  161. -- test overflows from integer into floating point
  162.     object two29, two30, maxint, prev_i
  163.     integer two30i, mtwo30i
  164.     sequence s
  165.  
  166.     two30 = 1
  167.     for i = 1 to 30 do
  168.     two30 = two30 * 2
  169.     end for
  170.     s = {two30, two30+1, two30+2}
  171.     s = s + s
  172.     if compare(s, {two30*2, two30*2+2, two30*2+4}) then
  173.     abort()
  174.     end if
  175.     mtwo30i = -1
  176.     for i = 1 to 29 do
  177.     mtwo30i = mtwo30i * 2
  178.     end for
  179.     two30i = 1
  180.     for i = 1 to 29 do
  181.     two30i = two30i * 2
  182.     end for
  183.     if 2 * two30i != -2 * mtwo30i then
  184.     abort()
  185.     end if
  186.     if two30i*2 != two30 then
  187.     abort()
  188.     end if
  189.     two29 = floor(two30 / 2)
  190.     if two29 + two29 != two30 then
  191.        abort()
  192.     end if
  193.  
  194.     maxint = floor(two30 - 1)
  195.     if maxint + 1 != two30 then
  196.     abort()
  197.     end if
  198.  
  199.     if 2 + maxint != two30 + 1 then
  200.     abort()
  201.     end if
  202.  
  203.     if (-maxint - 1) * -1 != two30 then
  204.     abort()
  205.     end if
  206.  
  207.     prev_i = -maxint + 1
  208.     for i = -maxint to -maxint -5 by -1 do
  209.     if i != prev_i - 1 then
  210.         abort()
  211.     end if
  212.     prev_i = i
  213.     end for
  214.  
  215.     prev_i = maxint - 5
  216.     for i = maxint - 3 to maxint + 3 by 2 do
  217.     if i != prev_i + 2 then
  218.         abort()
  219.     end if
  220.     prev_i = i
  221.     end for
  222.  
  223.     if floor(two30) != two30 then
  224.     abort()
  225.     end if
  226.  
  227.     if floor(two30 + two30 - 1) != two30 * 2 - 1 then
  228.     abort()
  229.     end if
  230. end procedure
  231.  
  232. type natural(integer x)
  233.     return x >= 0
  234. end type
  235.  
  236. procedure atomic_ops()
  237. -- test operations on atoms
  238.     object a, x, z
  239.     integer n, m
  240.     natural p
  241.  
  242.     p = 0
  243.     p = 0.000
  244.     p = 4.0/2.0
  245.     if p != 2.0 then
  246.     abort()
  247.     end if    
  248.     n = 1
  249.     m = 1
  250.     if n and m then
  251.     else
  252.     abort()  
  253.     end if
  254.  
  255.     x = 100
  256.     sub() -- y = 200
  257.     z = 300
  258.  
  259.     if x + y != z then
  260.     abort()
  261.     end if
  262.  
  263.     if x != 100 then
  264.     abort()
  265.     end if
  266.  
  267.     if 3 * 3 != 9 or
  268.        3 * 900000000 != 2700000000 or
  269.        15000 * 32000 != 480000000 or
  270.        32000 * 15000 != 480000000 or
  271.        1000 * 13000 != 13000000 or
  272.        13000 * 1000 != 13000000 then
  273.     abort()
  274.     end if
  275.     while x != 100 do
  276.     abort()
  277.     end while
  278.  
  279.     if not (z - y = 100) then
  280.     abort()
  281.     end if
  282.  
  283.     if #FFFFFFFF != 4294967295 then
  284.     abort()
  285.     end if
  286.    
  287.     p = 20
  288.     while not (p < 10) do
  289.     p = p - 2    
  290.     end while
  291.     if p != 8 then
  292.     abort()
  293.     end if
  294.  
  295.     if x * 1000.5 != 100050 or x * y != 20000 or x / y != 0.5 then
  296.     abort()
  297.     end if
  298.  
  299.     if y < x then
  300.     abort()
  301.     end if
  302.  
  303.     if y <= x then
  304.     abort()
  305.     end if
  306.  
  307.     if x > y then
  308.     abort()
  309.     end if
  310.  
  311.     if x >= y then
  312.     abort()
  313.     end if
  314.  
  315.     if -x != -100 then
  316.     abort()
  317.     end if
  318.  
  319.     if x = x and y > z then
  320.     abort()
  321.     end if
  322.  
  323.     x = 0
  324.  
  325.     y = {"ten", "one", "two", "three", "four", "five", "six", "seven", "eight",
  326.      "nine", "ten", "ten"}
  327.  
  328.     while x <= 11 do
  329.     if x = 1 then a = "one"
  330.     elsif x = 2 then a = "two"
  331.     elsif x = 3 then a = "three"
  332.     elsif x = 4 then a = "four"
  333.     elsif x = 5 then a = "five"
  334.     elsif x = 6 then a = "six"
  335.     elsif x = 7 then a = "seven"
  336.              if 1 + 1 = 2 then
  337.                  same(a, "seven")
  338.              elsif 1 + 1 = 3 then
  339.                  abort()
  340.              else
  341.                  abort()
  342.              end if
  343.     elsif x = 8 then a = "eight"
  344.     elsif x = 9 then a = "nine"
  345.     else a = "ten"
  346.     end if
  347.     same(a, y[1+x])
  348.     x = x + 1
  349.     end while
  350.  
  351.     y = 0
  352.     for xx = 100 to 0 by -2 do
  353.     y = y + xx
  354.     end for
  355.     same(y, 50 * 51)
  356.  
  357.     for xx = 1 to 10 do
  358.     if xx = 6 then
  359.         x = 6
  360.         exit
  361.     end if
  362.     y = 1
  363.     while y < 25 do
  364.         y = y + 1
  365.         if y = 18 then
  366.         exit
  367.         end if
  368.     end while
  369.     same(y, 18)
  370.     end for
  371.     y = repeat(-99, 7)
  372.     for xx = +3 to -3 by -1 do
  373.     y[xx+4] = xx
  374.     end for
  375.     same(y, {-3, -2, -1, 0, +1, +2, +3})
  376.  
  377.     y = {1,2,3}
  378.     for xx = 1.5 to +3.0 by .5 do
  379.       y[xx] = xx
  380.     end for
  381.     same(y, {1.5, 2.5, 3.0})
  382.     y = {}
  383.     for xx = -9.0 to -9.5 by -.25 do
  384.       y = y & xx
  385.     end for
  386.     same(y, {-9, -9.25, -9.5})
  387.     y = {}
  388.     for i = 800000000 to 900000000 by 800000000 do
  389.     y = append(y, i)    
  390.     end for
  391.     if compare(y, {800000000}) then
  392.     abort()
  393.     end if
  394.     y = 5
  395.     n = 3
  396.     a = 2
  397.     for i = 1 to y by a do
  398.     n = n - 1
  399.     y = 155
  400.     a = 1
  401.     end for
  402.     same(n, 0)
  403. end procedure
  404.  
  405. procedure floating_pt()
  406. -- test floating-point operations
  407.     sequence x
  408.  
  409.     x = {1.5, -3.5, 1e10, -1e20, 0.0, 0.0001}
  410.     y = repeat(x, 10)
  411.     if x[1]/x[2] > -0.42 or x[1]/x[2] < -0.43 then
  412.     abort()
  413.     end if
  414.     if find(1e10, x) != 3 then
  415.     abort()
  416.     end if
  417. end procedure
  418.  
  419. function one()
  420.     return 1
  421. end function
  422.  
  423. function two()
  424.     return 2.000
  425. end function
  426.  
  427. function sequence_ops()
  428. -- test operations on sequences
  429.     object i, w, x, y, z
  430.     sequence s
  431.     integer j
  432.  
  433.     x = "Hello "
  434.     y = "World"
  435.  
  436.     if find(0, x = x) then
  437.     abort()
  438.     end if
  439.     if x[two()*two() - two()] != 'e' then
  440.     abort()
  441.     end if
  442.     if x[one()+one()] != x[two()] then
  443.     abort()
  444.     end if
  445.  
  446.     j = x[1]
  447.     if j != 'H' then
  448.     abort()
  449.     end if
  450.     s = {3.0}
  451.     s[1] = 1.0000
  452.     j = s[1]
  453.     if j != 1 then
  454.     abort()
  455.     end if
  456.     i = 1
  457.     if not atom(i) or not integer(i) then 
  458.     abort()
  459.     end if
  460.     if length(y) != 5 then 
  461.     abort()
  462.     end if
  463.     while i <= 5 do
  464.     x = append(x, y[i])
  465.     i = i + 1
  466.     end while
  467.     i = 1
  468.     while i <= 3 do
  469.     x = append(x, '.')
  470.     x = append(x, '\'')
  471.     i = i + 1
  472.     end while
  473.     same(x, "Hello World.'.'.'")
  474.     x = repeat(5, 19)
  475.     x = append(x, 20)
  476.     x[7] = 9
  477.     y = {9, 9, {9}}
  478.     y = prepend(y, 8)
  479.     y = prepend(y, {9, 9})
  480.     same(y, {{9, 9}, 8, 9, 9, {9}})
  481.     y = x
  482.     z = y * x + x + 1000
  483.     w = z > 1030 or x = 9
  484.     same(z, {1030, 1030, 1030, 1030, 1030, 1030, 1090, 1030, 1030, 1030,
  485.          1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1420})
  486.     same(w, {0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
  487.          0, 0, 0, 0, 0, 0, 0, 0, 0, 1})
  488.     x = {100, 200, {1, 2, {0, 0, 0}}, 300}
  489.     x[3][3][3] = 25
  490.     x = x * x
  491.     same(x, {10000, 40000, {1, 4, {0, 0, 625}}, 90000})
  492.     y = x / {1, 2, 3, 4}
  493.     same(y, {10000, 20000, {1/3, 4/3, {0, 0, 625/3}}, 22500})
  494.     -- & tests
  495.  
  496.     same(2 & {5, 6,7}, {2, 5, 6, 7})
  497.     same({} & 3, {3})
  498.     same("ABC" & "DEF" & "GHIJ" & {}, "ABCDEFGHIJ")
  499.     same('A' & 'B' & 'C', "ABC")
  500.  
  501.     -- slice tests
  502.     x = "ABCDEFGHIJKLMNOP"
  503.     same(x[1..4], "ABCD")
  504.     y = x[2..5]
  505.     same(y, "BCDE")
  506.     same(x[4..3], {})
  507.     same(x[4..4], "D")
  508.     x[3..5] = "000"
  509.     same(x, "AB000FGHIJKLMNOP")
  510.     x[6..9] = '8'
  511.     same(x, "AB0008888JKLMNOP")
  512.  
  513.     same(floor({1, 2, -3, 4, -5} / 3), {0, 0, -1, 1, -2})
  514.  
  515.     return y
  516. end function
  517.  
  518.  
  519. procedure sequence_ops2()
  520. -- more tests of sequence operations
  521. object x, y
  522.  
  523.     x = "ABCDEFGHIJKLMNOP"
  524.     if find('D', x) != 4 then
  525.     abort()
  526.     end if
  527.     if match("EFGH", x) != 5 then
  528.     abort()
  529.     end if
  530.     if match({"AB", "CD"}, {0, 1, 3, {}, {"AB", "C"}, "AB", "CD", "EF"}) != 6 then
  531.     abort()
  532.     end if
  533.     if compare(x,x) != 0 then
  534.     abort()
  535.     end if
  536.     if compare({}, {}) != 0 then
  537.     abort()
  538.     end if
  539.     y = repeat(repeat(repeat(99, 5), 5), 5)
  540.     if y[3][3][3] != 99 then
  541.     abort()
  542.     end if
  543.     if compare(y[4][4][3..5], repeat(99, 3)) != 0 then
  544.     abort()
  545.     end if
  546.     y[3][2][1..4] = 88
  547.     if compare(y[3][2], {88, 88, 88, 88, 99}) != 0 then
  548.     abort()
  549.     end if
  550. end procedure
  551.  
  552. procedure circularity()
  553. -- test for circular references in internal garbage collector
  554.     object x, y
  555.  
  556.     x = {{"abc", {0, 0, 0}}, "def", 1, 2}
  557.     x[3] = x
  558.     x[1..2] = x[2..3]
  559.     x = append(x, x)
  560.     x = prepend(x, x)
  561.     if compare(x, x) != 0 then
  562.     abort()
  563.     end if
  564.     y = "ABCDE"
  565.     y[2] = repeat(y, 3)
  566.     if compare(y, y) != 0 then
  567.     abort()
  568.     end if
  569. end procedure
  570.  
  571. procedure output()
  572. -- test file output routines
  573.     integer file_no
  574.  
  575.     file_no = open("sanityio.tst", "w")
  576.     if file_no < 0 then
  577.     abort() 
  578.     end if
  579.     puts(file_no, "-- io test\n")
  580.     print(file_no, {1,2,3})
  581.     print(file_no, -99)
  582.     puts(file_no, "{11, {33, {#33}}, 4, 5 }{\t\t}\n")
  583.     puts(file_no, "{}.999 -.999 1.55e00 {11,   22 , {33, 33}, 4, 5  }\n") 
  584.     printf(file_no, "%e", 10000)
  585.     printf(file_no, "%d", -123)
  586.     printf(file_no, "%5.1f", 5+1/2)
  587.     printf(file_no, "%50s\n", {"+99 1001 {1,2,3} 1E-4 {1.002e23,-59e-5,"})
  588.     printf(file_no, "%9e}\t\t-1e-20\t   -.00001e5\n", 59e30)
  589.     puts(file_no, "\"Rob\"\"ert\" \"Craig\"  ")
  590.     puts(file_no, "\"\" \"\\n\" \"\\t\\r\"\t")
  591.     puts(file_no, "\"\\'\\\"\" 'A' '\\n' '\\\"' '\\'' '\\r'\n")
  592.     printf(file_no, "{#%x, ", 291)
  593.     puts(file_no, "\"ABC\"} {'A', 'B', '\\n'}")  
  594.     close(file_no)
  595. end procedure
  596.  
  597. procedure input()
  598. -- test file input routines
  599.     integer file_no
  600.     object line
  601.     integer char
  602.  
  603.     file_no = open("sanityio.tst", "r")
  604.     if file_no < 0 then
  605.     abort()
  606.     end if
  607.     if seek(file_no, 5) then
  608.     abort()
  609.     end if
  610.     if seek(file_no, -1) then
  611.     abort()
  612.     end if
  613.     if seek(file_no, 0) then
  614.     abort()
  615.     end if
  616.     if where(file_no) != 0 then
  617.     abort()
  618.     end if
  619.     line = gets(file_no)
  620.     if compare(line, "-- io test\n") != 0 then
  621.     abort()
  622.     end if
  623.     char = getc(file_no)
  624.     if char != '{' then
  625.     abort()
  626.     end if
  627.     close(file_no)
  628. end procedure
  629.  
  630. procedure testgr()
  631. -- test basic VGA graphics operations
  632.     sequence v
  633.  
  634.     v = video_config()
  635.     if v[VC_XPIXELS] < 100 or v[VC_YPIXELS] < 100 then
  636.     abort()
  637.     end if
  638.     draw_line(1, {{20, 100}, {600, 100}})
  639.     for i = 1 to 200 by 5 do
  640.     pixel(7, {3*i, i})
  641.     if get_pixel({3*i, i}) != 7 then
  642.         abort()
  643.     end if
  644.     end for
  645. end procedure
  646.  
  647. constant TRUE = 1, FALSE = 0
  648.  
  649. procedure testget()
  650. -- test input of Euphoria objects
  651.     object gd
  652.     object x, i
  653.     object results
  654.  
  655.     gd = open("sanityio.tst", "r")
  656.     if gd < 0 or gd > 10 then
  657.     abort()
  658.     end if
  659.     if not sequence(gets(gd)) then
  660.     abort()
  661.     end if
  662.     results = {
  663.      {0, {1,2,3}},
  664.      {0, -99},
  665.      {0, {11, {33, {#33}}, 4, 5}},
  666.      {0, {}},
  667.      {0, {}},
  668.      {0, 0.999},
  669.      {0, -0.999},
  670.      {0, 1.55},
  671.      {0, {11, 22, {33, 33}, 4, 5}},
  672.      {0, 10000},
  673.      {0, -123},
  674.      {0, 5.5},
  675.      {0, 99},
  676.      {0, 1001},
  677.      {0, {1, 2, 3}},
  678.      {0, 0.0001},
  679.      {0, {1.002e+23, -0.00059, 5.9e+31}},
  680.      {0, -1e-20},
  681.      {0, -1},
  682.      {0, "Rob"},
  683.      {0, "ert"},
  684.      {0, "Craig"},
  685.      {0, ""},
  686.      {0, "\n"},
  687.      {0, "\t\r"},
  688.      {0, "\'\""},
  689.      {0, 'A'},
  690.      {0, '\n'},
  691.      {0, '\"'},
  692.      {0, '\''},
  693.      {0, '\r'},
  694.      {0, {#123, "ABC"}},
  695.      {0, {'A', 'B', '\n'}},
  696.      {-#1, 0}
  697.     }
  698.     i = 1
  699.     while TRUE do
  700.     x = get(gd)
  701.     if x[1] = -1 then
  702.         exit
  703.     end if
  704.     same(x, results[i])
  705.     i = i + 1
  706.     end while
  707.     if compare(results[i], {-1, 0}) != 0 then
  708.     puts(2, "wrong number of get values\n")
  709.     end if
  710.     close(gd)
  711. end procedure
  712.  
  713.  
  714. function fib(integer n)
  715. -- fibonacci
  716.     if n < 2 then
  717.     return n
  718.     else
  719.     return fib(n-1) + fib(n-2)
  720.     end if
  721. end function
  722.  
  723. integer rp
  724.  
  725. procedure recursive_proc()
  726. -- a recursively-called procedure
  727.     if rp > 0 then
  728.     rp = rp - 1
  729.     recursive_proc()
  730.     end if
  731. end procedure
  732.  
  733. procedure machine_level()
  734. -- quick test of machine-level routines
  735.     atom addr
  736.  
  737.     addr = allocate(100)
  738.     poke(addr, #C3) -- RET instruction
  739.     if peek(addr) != #C3 then
  740.     abort()
  741.     end if
  742.     call(addr)
  743.     free(addr)
  744.     for x = 0 to +2000000 by 49999 do
  745.         if bytes_to_int(int_to_bytes(x)) != x then
  746.         abort()
  747.         end if
  748.     end for
  749. end procedure
  750.  
  751. global type sorted(sequence x)
  752. -- return TRUE if x is in ascending order
  753.     for i = 1 to length(x)-1 do
  754.     if compare(x[i], x[i+1]) > 0 then
  755.         return FALSE
  756.     end if
  757.     end for
  758.     return TRUE
  759. end type
  760.  
  761. without profile
  762.  
  763. global procedure sanity()
  764. -- main program
  765.     sequence cmd_line
  766.     integer vga
  767.  
  768.     vga = not graphics_mode(18) 
  769.     clear_screen()
  770.     position(12, 20)
  771.     puts(msg, "Euphoria SANITY TEST ... ")
  772.  
  773.     for j = 0 to 8 by 2 do
  774.     if atom(getenv("EUDIR")) then
  775.         puts(1, "EUDIR not set\n")
  776.         abort()
  777.     end if
  778.     cmd_line = command_line()
  779.     if length(cmd_line) < 1 or length(cmd_line) > 10 then
  780.         abort()
  781.     end if
  782.     if length(current_dir()) < 2 then
  783.         abort()
  784.     end if
  785.     if length(dir(".")) < 2 then
  786.         abort()
  787.     end if
  788.     if vga then
  789.         testgr()
  790.     end if
  791.     make_sound()
  792.     same(built_in(), 1)
  793.     atomic_ops()
  794.     overflow()
  795.     floating_pt()
  796.     if compare(sequence_ops(), "BCDE") != 0 then
  797.         puts(msg, "sequence_ops failed\n")
  798.     end if
  799.     sequence_ops2()
  800.     circularity()
  801.     output()
  802.     input()
  803.     testget()
  804.     system("del sanityio.tst", 2)
  805.     machine_level()
  806.     rp = 100
  807.     recursive_proc()
  808.     if rp != 0 then
  809.         puts(msg, "recursive proc failed\n")
  810.     end if
  811.     if fib(20) != 6765 then
  812.         puts(msg, "fib failed\n")
  813.     end if
  814.     if not sorted(sort(-500 + rand(repeat(1000, 1000)))) then
  815.         puts(msg, "standard sort failed\n")
  816.     end if
  817.     if not sorted(sort({"robert", "junko", "dave", "ken", "lurdes"})) then
  818.         puts(msg, "standard general sort failed\n")
  819.     end if
  820.     end for
  821.     printf(msg, "%s\n", {"PASSED (100%)\n\n  <Enter> to continue"})
  822.     if atom(gets(0)) then
  823.     end if
  824.     if graphics_mode(-1) then
  825.     end if
  826.     the_end()    
  827. end procedure
  828.  
  829. integer z
  830.  
  831. -- another for-loop test
  832. z = 0
  833. for j = 1 to 10 do
  834.     z = z + j
  835. end for
  836. if z != 55 then
  837.     abort()
  838. end if
  839.  
  840. sanity()
  841.