Home | History | Annotate | Line # | Download | only in TEST
test.m4 revision 1.3
      1  1.1    cgd #
      2  1.3  glass # Copyright (c) 1989, 1993
      3  1.3  glass #	The Regents of the University of California.  All rights reserved.
      4  1.3  glass #
      5  1.3  glass # This code is derived from software contributed to Berkeley by
      6  1.3  glass # Ozan Yigit.
      7  1.3  glass #
      8  1.3  glass # Redistribution and use in source and binary forms, with or without
      9  1.3  glass # modification, are permitted provided that the following conditions
     10  1.3  glass # are met:
     11  1.3  glass # 1. Redistributions of source code must retain the above copyright
     12  1.3  glass #    notice, this list of conditions and the following disclaimer.
     13  1.3  glass # 2. Redistributions in binary form must reproduce the above copyright
     14  1.3  glass #    notice, this list of conditions and the following disclaimer in the
     15  1.3  glass #    documentation and/or other materials provided with the distribution.
     16  1.3  glass # 3. All advertising materials mentioning features or use of this software
     17  1.3  glass #    must display the following acknowledgement:
     18  1.3  glass #	This product includes software developed by the University of
     19  1.3  glass #	California, Berkeley and its contributors.
     20  1.3  glass # 4. Neither the name of the University nor the names of its contributors
     21  1.3  glass #    may be used to endorse or promote products derived from this software
     22  1.3  glass #    without specific prior written permission.
     23  1.3  glass #
     24  1.3  glass # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     25  1.3  glass # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26  1.3  glass # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27  1.3  glass # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     28  1.3  glass # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29  1.3  glass # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30  1.3  glass # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31  1.3  glass # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32  1.3  glass # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33  1.3  glass # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34  1.3  glass # SUCH DAMAGE.
     35  1.3  glass #
     36  1.3  glass #	@(#)test.m4	8.1 (Berkeley) 6/6/93
     37  1.3  glass #
     38  1.3  glass 
     39  1.1    cgd # test file for mp (not comprehensive)
     40  1.1    cgd #
     41  1.1    cgd # v7 m4 does not have `decr'.
     42  1.1    cgd #
     43  1.1    cgd define(DECR,`eval($1-1)')
     44  1.1    cgd #
     45  1.1    cgd # include string macros
     46  1.1    cgd #
     47  1.1    cgd include(string.m4)
     48  1.1    cgd #
     49  1.1    cgd # create some fortrash strings for an even uglier language
     50  1.1    cgd #
     51  1.1    cgd string(TEXT, "text")
     52  1.1    cgd string(DATA, "data")
     53  1.1    cgd string(BEGIN, "begin")
     54  1.1    cgd string(END, "end")
     55  1.1    cgd string(IF, "if")
     56  1.1    cgd string(THEN, "then")
     57  1.1    cgd string(ELSE, "else")
     58  1.1    cgd string(CASE, "case")
     59  1.1    cgd string(REPEAT, "repeat")
     60  1.1    cgd string(WHILE, "while")
     61  1.1    cgd string(DEFAULT, "default")
     62  1.1    cgd string(UNTIL, "until")
     63  1.1    cgd string(FUNCTION, "function")
     64  1.1    cgd string(PROCEDURE, "procedure")
     65  1.1    cgd string(EXTERNAL, "external")
     66  1.1    cgd string(FORWARD, "forward")
     67  1.1    cgd string(TYPE, "type")
     68  1.1    cgd string(VAR, "var")
     69  1.1    cgd string(CONST, "const")
     70  1.1    cgd string(PROGRAM, "program")
     71  1.1    cgd string(INPUT, "input")
     72  1.1    cgd string(OUTPUT, "output")
     73  1.1    cgd #
     74  1.1    cgd divert(2)
     75  1.1    cgd diversion #1
     76  1.1    cgd divert(3)
     77  1.1    cgd diversion #2
     78  1.1    cgd divert(4)
     79  1.1    cgd diversion #3
     80  1.1    cgd divert(5)
     81  1.1    cgd diversion #4
     82  1.1    cgd divert(0)
     83  1.1    cgd define(abc,xxx)
     84  1.1    cgd ifdef(`abc',defined,undefined)
     85  1.1    cgd #
     86  1.1    cgd # v7 m4 does this wrong. The right output is 
     87  1.1    cgd # 	this is A vEry lon sEntEnCE
     88  1.1    cgd # see m4 documentation for translit.
     89  1.1    cgd #
     90  1.1    cgd translit(`this is a very long sentence', abcdefg, ABCDEF)
     91  1.1    cgd #
     92  1.1    cgd # include towers-of-hanoi
     93  1.1    cgd #
     94  1.1    cgd include(hanoi.m4)
     95  1.1    cgd #
     96  1.1    cgd # some reasonable set of disks
     97  1.1    cgd #
     98  1.1    cgd hanoi(6)
     99  1.1    cgd #
    100  1.1    cgd # include ackermann's function
    101  1.1    cgd #
    102  1.1    cgd include(ack.m4)
    103  1.1    cgd #
    104  1.1    cgd # something like (3,3) will blow away un*x m4.
    105  1.1    cgd #
    106  1.1    cgd ack(2,3)
    107  1.1    cgd #
    108  1.1    cgd # include a square_root function for fixed nums
    109  1.1    cgd #
    110  1.1    cgd include(sqroot.m4)
    111  1.1    cgd #
    112  1.1    cgd # some square roots.
    113  1.1    cgd #
    114  1.1    cgd square_root(15)
    115  1.1    cgd square_root(100)
    116  1.1    cgd square_root(-4)
    117  1.1    cgd square_root(21372)
    118  1.1    cgd #
    119  1.1    cgd # some textual material for enjoyment.
    120  1.1    cgd #
    121  1.1    cgd [taken from the 'Clemson University Computer Newsletter',
    122  1.1    cgd  September 1981, pp. 6-7]
    123  1.1    cgd      
    124  1.1    cgd I am a wizard in the magical Kingdom of Transformation and I
    125  1.1    cgd slay dragons for a living.  Actually, I am a systems programmer.
    126  1.1    cgd One of the problems with systems programming is explaining to
    127  1.1    cgd non-computer enthusiasts what that is.  All of the terms I use to
    128  1.1    cgd describe my job are totally meaningless to them.  Usually my response
    129  1.1    cgd to questions about my work is to say as little as possible.  For
    130  1.1    cgd instance, if someone asks what happened at work this week, I say
    131  1.1    cgd "Nothing much" and then I change the subject.
    132  1.1    cgd      
    133  1.1    cgd With the assistance of my brother, a mechanical engineer, I have devised
    134  1.1    cgd an analogy that everyone can understand.  The analogy describes the
    135  1.1    cgd "Kingdom of Transformation" where travelers wander and are magically
    136  1.1    cgd transformed.  This kingdom is the computer and the travelers are information.
    137  1.1    cgd The purpose of the computer is to change information to a more meaningful
    138  1.1    cgd forma.  The law of conservation applies here:  The computer never creates
    139  1.1    cgd and never intentionally destroys data.  With no further ado, let us travel
    140  1.1    cgd to the Kingdom of Transformation:
    141  1.1    cgd      
    142  1.1    cgd In a land far, far away, there is a magical kingdom called the Kingdom of
    143  1.1    cgd Transformation.  A king rules over this land and employs a Council of
    144  1.1    cgd Wizardry.  The main purpose of this kingdom is to provide a way for
    145  1.1    cgd neighboring kingdoms to transform citizens into more useful citizens.  This
    146  1.1    cgd is done by allowing the citizens to enter the kingdom at one of its ports
    147  1.1    cgd and to travel any of the many routes in the kingdom.  They are magically
    148  1.1    cgd transformed along the way.  The income of the Kingdom of Transformation
    149  1.1    cgd comes from the many toll roads within its boundaries.
    150  1.1    cgd      
    151  1.1    cgd The Kingdom of Transformation was created when several kingdoms got
    152  1.1    cgd together and discovered a mutual need for new talents and abilities for
    153  1.1    cgd citizens.  They employed CTK, Inc. (Creators of Transformation, Inc.) to
    154  1.1    cgd create this kingdom.  CTK designed the country, its transportation routes,
    155  1.1    cgd and its laws of transformation, and created the major highway system.
    156  1.1    cgd      
    157  1.1    cgd Hazards
    158  1.1    cgd =======
    159  1.1    cgd      
    160  1.1    cgd Because magic is not truly controllable, CTK invariably, but unknowingly,
    161  1.1    cgd creates dragons.  Dragons are huge fire-breathing beasts which sometimes
    162  1.1    cgd injure or kill travelers.  Fortunately, they do not travel, but always
    163  1.1    cgd remain near their den.
    164  1.1    cgd      
    165  1.1    cgd Other hazards also exist which are potentially harmful.  As the roads
    166  1.1    cgd become older and more weatherbeaten, pot-holes will develop, trees will
    167  1.1    cgd fall on travelers, etc.  CTK maintenance men are called to fix these
    168  1.1    cgd problems.
    169  1.1    cgd      
    170  1.1    cgd Wizards
    171  1.1    cgd =======
    172  1.1    cgd      
    173  1.1    cgd The wizards play a major role in creating and maintaining the kingdom but
    174  1.1    cgd get little credit for their work because it is performed secretly.  The
    175  1.1    cgd wizards do not wan the workers or travelers to learn their incantations
    176  1.1    cgd because many laws would be broken and chaos would result.
    177  1.1    cgd      
    178  1.1    cgd CTK's grand design is always general enough to be applicable in many
    179  1.1    cgd different situations.  As a result, it is often difficult to use.  The
    180  1.1    cgd first duty of the wizards is to tailor the transformation laws so as to be
    181  1.1    cgd more beneficial and easier to use in their particular environment.
    182  1.1    cgd      
    183  1.1    cgd After creation of the kingdom, a major duty of the wizards is to search for
    184  1.1    cgd and kill dragons.  If travelers do not return on time or if they return
    185  1.1    cgd injured, the ruler of the country contacts the wizards.  If the wizards
    186  1.1    cgd determine that the injury or death occurred due to the traveler's
    187  1.1    cgd negligence, they provide the traveler's country with additional warnings.
    188  1.1    cgd If not, they must determine if the cause was a road hazard or a dragon.  If
    189  1.1    cgd the suspect a road hazard, they call in a CTK maintenance man to locate the
    190  1.1    cgd hazard and to eliminate it, as in repairing the pothole in the road.  If
    191  1.1    cgd they think that cause was a dragon, then they must find and slay it.
    192  1.1    cgd      
    193  1.1    cgd The most difficult part of eliminating a dragon is finding it.  Sometimes
    194  1.1    cgd the wizard magically knows where the dragon's lair it, but often the wizard
    195  1.1    cgd must send another traveler along the same route and watch to see where he
    196  1.1    cgd disappears.  This sounds like a failsafe method for finding dragons (and a
    197  1.1    cgd suicide mission for thr traveler) but the second traveler does not always
    198  1.1    cgd disappear.  Some dragons eat any traveler who comes too close; others are
    199  1.1    cgd very picky.
    200  1.1    cgd      
    201  1.1    cgd The wizards may call in CTK who designed the highway system and
    202  1.1    cgd transformation laws to help devise a way to locate the dragon.  CTK also
    203  1.1    cgd helps provide the right spell or incantation to slay the dragon. (There is
    204  1.1    cgd no general spell to slay dragons; each dragon must be eliminated with a
    205  1.1    cgd different spell.)
    206  1.1    cgd      
    207  1.1    cgd Because neither CTK nor wizards are perfect, spells to not always work
    208  1.1    cgd correctly.  At best, nothing happens when the wrong spell is uttered.  At
    209  1.1    cgd worst, the dragon becomes a much larger dragon or multiplies into several
    210  1.1    cgd smaller ones.  In either case, new spells must be found.
    211  1.1    cgd      
    212  1.1    cgd If all existing dragons are quiet (i.e. have eaten sufficiently), wizards
    213  1.1    cgd have time to do other things.  They hide in castles and practice spells and
    214  1.1    cgd incatations.  They also devise shortcuts for travelers and new laws of
    215  1.1    cgd transformation.
    216  1.1    cgd      
    217  1.1    cgd Changes in the Kingdom
    218  1.1    cgd ======================
    219  1.1    cgd      
    220  1.1    cgd As new transformation kingdoms are created and old ones are maintained,
    221  1.1    cgd CTK, Inc. is constantly learning new things.  It learns ways to avoid
    222  1.1    cgd creating some of the dragons that they have previously created.  It also
    223  1.1    cgd discovers new and better laws of transformation.  As a result, CTK will
    224  1.1    cgd periodically create a new grand design which is far better than the old.
    225  1.1    cgd The wizards determine when is a good time to implement this new design.
    226  1.1    cgd This is when the tourist season is slow or when no important travelers
    227  1.1    cgd (VIPs) are to arrive.  The kingdom must be closed for the actual
    228  1.1    cgd implementation and is leter reopened as a new and better place to go.
    229  1.1    cgd      
    230  1.1    cgd A final question you might ask is what happens when the number of tourists
    231  1.1    cgd becomes too great for the kingdom to handle in a reasonable period of time
    232  1.1    cgd (i.e., the tourist lines at the ports are too long).  The Kingdom of
    233  1.1    cgd Transformation has three options: (1) shorten the paths that a tourist must
    234  1.1    cgd travel, or (2) convince CTK to develop a faster breed of horses so that the
    235  1.1    cgd travelers can finish sooner, or (3) annex more territories so that the
    236  1.1    cgd kingdom can handle more travelers.
    237  1.1    cgd      
    238  1.1    cgd Thus ends the story of the Kingdom of Transformation.  I hope this has
    239  1.1    cgd explained my job to you:  I slay dragons for a living.
    240  1.1    cgd 
    241  1.1    cgd #
    242  1.1    cgd #should do an automatic undivert..
    243  1.1    cgd #
    244