modernc.org/knuth@v0.0.4/mf/testdata/trap.mf (about)

     1  % This is a diabolical test file for MF84. Don't get stuck.
     2  if not known inimf: .inimf.=.0. % next lines are skipped if format loaded
     3    inimf; nonstopmode; tracingtitles:=day; showstopping:=year; hppp:=1000;
     4    << == >> ::: || `` '' -- !! ?? ## && @@ $$ [[ ]] {{ }} . (( 5.5.5 )) ++ "..";
     5    begingroup save =; let=,; save,; newinternal $=,; let ):=, endgroup;
     6    let year=month; showvariable errorstopmode,readstring,2,"2",,,(,),<<,year;
     7    tracingrestores:=tracingcommands:=.00000762939453125; % that's 2^(-17)
     8    if tracingcommands>0:tracingcommands:=if not cycle "":1.1 forever;fi;
     9    tracingcommands:=2.1 exitif tracingcommands>2 endfor; showtoken |=:|>;
    10    tracingedges:=1/.00001; tracingequations:=$+1; p~=tracingedges+.00001;
    11    interim tracingspecs:=tracingpens:=tracingchoices:=tracingstats:=
    12    warningcheck:=tracingoutput:=tracingmacros:=1; $:=ASCII""; $:=x; p~:=p~;
    13    delimiters (); delimiters begintext endtext; vardef foo(text t)=t enddef;
    14    def lig(text t,|)=ligtable0::for *=1step1until60:0kern boundarychar+*,endfor
    15    skipto0;ligtable t:t|0,skipto255;boundarychar:=boundarychar+51.29999enddef;
    16    foo begintext interim proofing:=(-.5; shipout nullpicture; special"3" endtext;
    17    for n=tracingpens step 1 until proofing:fi endfor showstats; let!!=skipto;
    18    path p~; p~=(0,0)..controls (15,4) and (-15,-12)..(4,0);  everyjob /*\;;
    19    vardef /*\`'@#=message @ & str#@ &jobname&char ASCII'`&str@#!enddef;
    20    let next=dump; vardef `'='` enddef; def '`="\*/" enddef;
    21  elseif known"": `'pass[2.]; outer\; let next=\; delimiters ^~7! fi
    22  next\; % the second pass will now compute silently; the first pass will halt
    23  batchmode; ^~7,endgroup pausing:=1; exitif p exitif boolean pen pencircle endfor
    24  scantokens begingroup message char0&"watch this"; "pair p[],';"&char-1endgroup
    25  path p[][]p,w,qw; qw=(1,-2)..(2,-1)..(2.5,0.5)..(1,2)..(turningnumber',2.5);
    26  numeric p[][]; p[[ [$] ]]=10000000000000000; "this string constant is incomplete
    27  string foo[]p,p~if true:[]; p~000=char34&char200&char34;
    28  boolean p[]~,boolean fi.boolean; showvariable boolean; def\\= =end enddef;
    29  picture e[]e[], e[], p~[]~[][]; show length scantokens p~0;
    30  pen p~[]~,q["a",qq; p~1~=q=pencircle scaled mexp(-3016.57654);
    31  transform p,pp0; if p=p:qq=makepen((1,0)..cycle) xscaled hex "1000";fi
    32  qq:=makepen((0,0)..(1,0)..(0,1)..(0,0)..(1,0)..(0,1)..cycle);
    33  vardef p[][]p~ begintext suffix a,b endtext())suffix@=show #@; p.a.b() enddef;
    34  expandafter let\endtext\\; outer endtext,\,;;qq:=pencircle scaled 4.5 yscaled 2;
    35  (6,12)-p7=(0,1)transformed p=(2/(x-x),3/0)transformed p;
    36  p1\2p=p007=begintext if string p~[$]: p.1.2-p.1.199999,1 endtext transformed p;
    37  showstopping:=0;showvariable p; p=p; let [[=begingroup; let ]]=endgroup;
    38  (xxpart p+.002,yxpart p)=1[p1,p2]=(5,y+.00001)=(5,y)=(yypart p,xypart p);
    39  reverse(p~..cycle) transformed p=p2. 3.p;
    40  p[000000000001]2p~(,[2]3p~,-)=p~1~2[pausing];
    41  vardef p~[]@# tertiary t:=if p@ @=@ @p fi; vardef p[][]p~[]=BAD; inner ;;
    42  show p~[-2]~[3000,x]++4000>path p3; showvariable p,P;
    43  numeric p[]~; p3~=2alpha; p[1/$]~=3beta;
    44  begingroup save p; showvariable p; 3beta=1]]; showvariable p;
    45  def//expr;=enddef;def!primary!false):!fi enddef;
    46  def _aa__ secondary _a_=if(true enddef; qq:=makepen(qw..(qw scaled$)..cycle);
    47  primarydef _**__=[[show _*__]] enddef;
    48  secondarydef _***__=expandafter __ scantokens"**oct"_ enddef;
    49  // //pencircle slanted length p~**makepen reverse subpath p7-p2 of
    50   (p7{p2}..controls _aa__ not odd.1(15) and known p or !p2and-p2..{1,1}(-p2
    51   {curl- +1)..tension atleast1..cycle sqrt2++sqrt2***[[]];
    52  [[interim proofing:=charcode:=-20.5;chardp:=-2048;shipout nullpicture]];
    53  if charexists -275.50002>known p0 0p=known p~: randomseed charcode; fi
    54  randomseed:="goof"; a[($,18++1+-+18),(2,3)]=b[(3,2),(1,$);
    55  show (^+1,~+2) slanted-1 yscaled-2 zscaled-(3,4), p transformed(pp xscaled 9),
    56   pp shifted (1,2) transformed(p transformed p), -_[0][1,2]; show
    57  floor sind mlog sqrt mexp200cosd angle(normaldeviate,uniformdeviate-chardp);
    58  string s[]; s1=s2=s4; s3=s5; s1=s2; if s1<=s4<>(s1<>s3):show[[char34=s2:=s3]]fi;
    59  substring penoffset point.1of.p~of[[pencircle]]rotated1080/2/1/3of decimal
    60   directiontime postcontrol-1.5of(p~&cycle)-precontrol1/2of p~(p~)=s1:=s4:=s4;
    61  path p~[]; p~1=p2{length"  "}&cycle; p~1=p2=p~0; p2..controls-p2..cycle=p~2;(p7
    62  ..tension1.2..p~[length p~2]..p~2&{0,1}p2..tension1and atleast1..cycle)..tension
    63   x..{curl1}-p7{curl hex "IsBad"}..tension.75and.74999..p2{0,1}&p2{_,'}..cycle:=p
    64   ~4; subpath(-9,9)of subpath(3.5001,7.00001)of p~4=p~6;
    65  show p~6, directiontime(1,2) of p~6, directiontime(1,-1.00001) of p~6;
    66  p~3=(0,0)..controls (1,1) and (0,1)..(1,0); show p2..p2{p7}&{$,$}cycle,
    67   (directiontime(1,1) of subpath(.314159,1) of p~3)[.314159,1];
    68  p~5=(subpath(0,.25)of p~3&subpath(.25,1)of p~3)shifted begintext1,0;
    69  p~3:=2/3'zscaled'{p~3}..controls(2,2/3(3))and penoffset(1/2x,y)of(0,1)(1,0);
    70  show p~3 intersectiontimes reverse p~3, point.17227 of p~3, point1-.28339of p~3;
    71  show point xpart(p~5 intersectiontimes p~5 shifted (.01,0))of p~5-
    72   point ypart(p~5 intersectiontimes p~5 shifted (.01,0))of p~5;
    73  [[interim tracingedges:=1; e[-1+-+ -1.00001]=nullpicture; addto e1 also[[
    74  addto e0 doublepath p~5 scaled 3 withpen q; e0=e1=e2; cull e1 dropping (0,.1);
    75  nullpicture]];show e1 shifted(4089,-4095), e2 shifted(-4095,4092)shifted (-3,0),
    76  e2 shifted(4089,-4095)]];addto e1 also  e2 shifted(-2,$); e1:=e1 shifted(-4,$);
    77  addto e0 also e1rotated89.999+e1scaled$; show e0 xscaled-10 yscaled2 xscaled82
    78  yscaled683;addto e1 doublepath (0,9) withweight-3 withweight turningnumber p~6
    79   withpen pencircle xscaled(oct"180"++1) rotated-angle(64,$) shifted (9,8)
    80   withpen makepen(($,$)..(1,0)..(1,1)..($,0)..($,$)&cycle)xscaled4095.49999;
    81  show e1, totalweight e1; chardp:=charcode:=5; xoffset:=-1.5; shipout e1;
    82  showstats; addto e2doublepath p~ yscaled1/60; e3:=e2 yscaled 0;
    83  autorounding:=2; addto e3doublepath(.5,0)..(3.5,1.5)withweight2;
    84  tracingspecs:=0; q:=makepen((1,1)..cycle) yscaled 1.5;
    85  p~8=(($,yy)rotated p{0,1}..{0,$}(1,0){0,$}..cycle)scaled2shifted(1000.49,9);
    86  turningcheck:=1;addto e2doublepath p~8 withpen q withweight p withpen cycle p;
    87  [[interim autorounding:=xx=.1; addto e2 contour p~8 withpen q withweight2]];
    88  chardx:=chardp:=charext:=-14.5;shipout-(-e0-e2)+e2shifted(0,6turningnumber p~8);
    89  p~9=(0,0)..(1,.5)..(5,1.5)..(7,2.5)..(12,3.5)..(13,4);addto e3 doublepath p~9;
    90  smoothing:=1; addto e3 doublepath p~9; addto e3 doublepath (-4095,0)..tension
    91  3/4 and 999..(0,2); show e3 rotated-90, (e0+e0) rotated90$ rotated90;
    92  if "a" if "ab">"b" elseif path reverse (3,4): >="aa":foo elseif fi "bar"
    93  else if '-(1,yy)<': :fi else def dup text t=[[t;save enddef;def|suffix$=,$
    94  enddef; def||tertiary p=show substring p of("a" enddef;||(2,$)&"bc");
    95  tertiarydef x++y=[[dup showtoken x;]];def quote x expr z of y=z enddef;
    96   texts(quote x=(y+0)y+y)("xx",foo(x))=0]] enddef; def texts(text t,tt)expr?=
    97   for n:=,for n"yy":n,length if false:endfor tt,t,:if string n:forsuffixes n=
    98   foo1,[foo(n)],':show t,tt|(n;exitif not('<='+(?,yy)) endfor for m= :+endfor
    99    for m=alpha step-1.1 3$: +m endfor fi endfor enddef; show (0,0){curl2}..
   100   subpath(23.3,4.5)of p~9{curl3}..($,$){curl4}..cycle;numspecial p~++2+3;[[
   101  let?=if;save if,\;def if=endinput?enddef;def texts=input enddef;texts trap ]];
   102  dup[[def texts secondary x=primarydef y++y=x@y enddef; showtoken++;x enddef]]\;
   103  proofing:=1;texts:="a"&"b";% strings "yy" and "ab" no longer appear in memory
   104  texts-1.00001a1=-(a2+a3+a4+a5+a6);-(a3,a2)/.99999=-(a4+a5+[[showdependencies;
   105  a6]],a3+a4+a5+a6)]]; 1.00001a4+1=a5+a6; alpha:=.9alpha+7; showdependencies;
   106  a5=a6=2/3-a6; cull e1 dropping($,4a5)withweight1.5; charcode:=chardp:=27;
   107  openwindow 3 from (0,0) to (0,0) at "whoops"; addto p; shipout p; cull p;
   108  openwindow -.5 from ($,$) to ($,$) at (0,0); special p; numspecial "p";
   109  openwindow 15.49999 from (0,32*1024) to (1,31*1057) at (0,0); shipout e1;
   110  openwindow 5 from (0,length((0,0){0,0})) to (4,2) at ($,1);
   111  openwindow 6 from (length($,0),1) to (3,10) at (-5,2);
   112  display nullpicture; display p inwindow 3; display p inwindow 6;
   113  display e1 inwindow 6; cull e0 dropping (0.1,4095.999999) withweight 3.5
   114  withweight-3.5; display e0 inwindow 5.5; addto e0 also p; addto e0 contour 0;
   115  display e0 inwindow 5.49999; addto e0 contour p~9;
   116  display e1 inwindow 3+3; display e0e0 inwindow[[vardef e[]e=enddef;6]];
   117  addto e0 also e1; display e0 inwindow 5; ligtable||:255|=:|>>0,skipto0;
   118  display e1 inwindow 15; display e1 inwindow 6;
   119  show [[interim tracingcommands:=0; lig("g")(=:|); lig("h":"i")(|=:);
   120  lig("j")(|=:>);lig("k")(=:|>); lig("l")(|=:|>)]];
   121  b1:=c.a[ [[let c=++;vardef b=enddef;1]] ]; ligtable"m":0=:0,skipto5;
   122  !!; errhelp 0; errmessage "Be like Jane";
   123  errhelp "He%%%lp%"; errmessage""; errhelp ""; errmessage "Another";
   124  headerbyte 0; headerbyte(48.5)substring(-9,9)of"long"; for\=0:\
   125  headerbyte 9:2a6,"q"; fontdimen 9:2a6,"q"; fontdimen 1:2048;
   126  fontmaking:=1; extensible 5 5,"c"255.5,"d"; charlist 0:5:"a":"d";
   127  ligtable255:255::"a"=:"b","d" kern -2048,"c":0:99.5:"e"|=:|"f",0kern';
   128  ligtable 5:0; def clear(text x)=interim x:=$ enddef; clear(hppp); vppp=0;
   129  [[clear(tracingmacros); clear(tracingcommands); clear(tracingoutput\;
   130   clear(proofing);designsize:=.99999;charcode:=ASCII char-418.5;vppp:=designsize;
   131   def dp expr d = charcode:=charcode+1; chardp:=d; shipout nullpicture enddef;
   132   dp 13; dp 12; dp 0; dp 21; dp -2; dp 17; dp 11; dp 3; charic:=-1000; dp -1;
   133   dp 25; dp 31; dp 19; dp 7; charwd:=256; chardy:=6; dp 23; dp 30]];
   134  def f(suffix@@)(expr a,b)(text t)=numeric w; show a; % wipes out the old w
   135  addto @@ contour (0,0)..(2,0)..(1,$)..(1,1)..cycle withpen qq; % strange path
   136  addto @@ doublepath (0,0){1,1}..{2,1}(2,1) withpen qq; % carefully chosen
   137  addto @@ doublepath(($,$){1,0}..(1,1){1,0})scaled.5 withpen nullpen;
   138  cull @@ keeping (4,4) withweight1.5; enddef; def g(suffix$)=show $ enddef;
   139  addto e0 contour (0,0){1,0}..{1,0}(1,0){0,$}..{0,1}cycle withpen qq;
   140  f(e[3,w); g(e3,transformed p,penoffset-(1,1.3)of(pencircle scaled20 yscaled-.5),
   141   directiontime (0,1) of ((0,0)..controls(1,1)and($,1)..(3,0)),
   142   point 3.14159 of p~9 intersectiontimes subpath (3.14159,4) of p~9,
   143   (($,1.1)..(1,$)) intersectiontimes precontrol$ of (0,0);
   144  addto e3 doublepath(-4094.99998,0)..(4094.99998,-.00001) withpen penoffset 0 of
   145  pencircle; addto e3 also e3 shifted (0,257); ,"flushed with pride"; numeric xx;
   146  def f(expr x,y,z)=showdependencies;tracingcapsules:=1;showdependencies;show
   147   1/3(3,6)*((x+y)+(y-x)), (1,1)/sqrt2 zscaled (x+1,x+2) - (x+1,x+2) rotated 45,
   148   (0,1) zscaled (1,y+2)-(1,y+2) rotated 90 enddef; f((xx+1)/.3,(yy-1)/.5,(xx,0));
   149  '=(1000o3-4000(o1-o2)+4000o2+9,-.01o3+3ooo+
   150   [[oo=9/10(o2+o4+o5-20);o4=o5=8/9(o1+.5o2); o6=-.0001o2;showdependencies;
   151    numeric o[];xpart(alfa,[[pair alfa;0]])]])=-2/3[[save p;(p$,1-p$)]];
   152  xoffset:=yoffset:=4000[[oo=.5ooo=2*-1/2(ooo+[[numeric ooo;1]]);oo]];
   153  for @=angle(sqrt$,mlog$):charext:=uniformdeviate$;charht:=2048;granularity:=-8;
   154  addto e3 contour (0,-100)..tension 500..(100,-99)..tension 3000..cycle;
   155  tracingoutput:=@; shipout e3; special "bye"; interim char 99 = "c"; true=false;
   156  [[clear(tracingcommands); charcode:=ASCII char 269-13; shipout+nullpicture;
   157  "careful" quote for for = @ step 200 until 2*2600: &" METAFONT" endfor;]];
   158  scrollmode; "hello again"&char31; save p; fillin:=-.043;
   159  def f expr x=let )=]; let [=(; show _ enddef; begingroup tracingspecs:=1;
   160  show nullpen, makepath.qq, makepath(q rotated1), makepath pencircle rotated $;
   161  addto e0 doublepath (0,2){0,$}..{0,$}(0,1)..{1,0}(3,0)..(4,0){1,0}..cycle
   162   withpen makepen((0,0)..(5,2.9)..(4,3)..cycle); tracingonline:=1; f xx[1);
   163  showdependencies; qq:=q; showstats; bye endtext
   164  % things not tested:
   165  % interaction (error insertion/deletion, interrupts, \pausing, files not there)
   166  % date, time; initialization of random number generator without randomseed
   167  % system-dependent parsing of file names, areas, extensions
   168  % certain error messages, especially fatal ones
   169  % things that can't happen in INIMF
   170  % unusual cases of fixed-point arithmetic