-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathtest.ps
More file actions
859 lines (688 loc) · 12.9 KB
/
test.ps
File metadata and controls
859 lines (688 loc) · 12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
%test.ps
% testing examples borrowed from the Operator Details in the PLRM, 1ed.
%traceon
%/break { currentfile flushfile } def
/failcount 0 def
/fail {
(FAIL\n) print
/failcount failcount 1 add def
%break
} def
/check {
{} %{ (success\n) print }
//fail
ifelse
} def
%(test: loading graphics...)=
%flush
%(*){=}128 string filenameforall
%(../../data)
%DATA_DIR (/graphics.ps) strcat run initgraphics
%loadgraphics %graphics support is now always loaded
(Stack should be clear -V-\n)=
pstack
( -^-\n)=
clear
[ ] ==
%traceon
[ ] type /arraytype eq check
{ ] } stopped { $error /errorname get /unmatchedmark eq check }{ fail } ifelse
/= cvx =
{ = } stopped { $error /errorname get /stackunderflow eq check }{ fail } ifelse
/== cvx ==
{ == } stopped { end $error /errorname get /stackunderflow ne {fail} if }{ fail } ifelse
(abs)=
4.5 abs 4.5 eq check
-3 abs 3 eq check
0 abs 0 eq check
(add)=
3 4 add 7 eq check
9.9 1.1 add 11.0 eq check
(aload)=
[23 (ab) -6] aload
type /arraytype eq exch
type /integertype eq and exch
type /stringtype eq and exch
type /integertype eq and check
(anchorsearch)=
%(1)=
(abbc) (ab) anchorsearch
true eq exch
(ab) eq and exch
(bc) eq and check
%(2)=
(abbc) (bb) anchorsearch
false eq exch
(abbc) eq and check
%(3)=
(abbc) (bc) anchorsearch
false eq exch
(abbc) eq and check
%(4)=
(abbc) (B) anchorsearch
false eq exch
(abbc) eq and check
(and)=
true true and true eq check
true false and false eq check
false true and false eq check
false false and false eq check
99 1 and 1 eq check
52 7 and 4 eq check
%arc
%arcn
%arcto
(array)=
3 array dup type /arraytype eq check
aload pop null eq exch
null eq and exch
null eq and check
%ashow
(astore)=
(a) (bcd) (ef) 3 array astore type /arraytype eq check
(atan)=
(1: 0 1 atan 0.0 eq check) ==
0 1 atan 0.0 eq check
(2: 1 0 atan 90.0 eq check) ==
1 0 atan 90.0 eq check
(3: -100 0 atan 270.0 eq check) ==
-100 0 atan 270.0 eq check
(4: 4 4 atan 45.0 eq check) ==
4 4 atan 45.0 eq check
%awidthshow
%banddevice
(begin)=
2 dict dup begin currentdict eq check
(bind)=
{ add } bind 0 get type /operatortype eq check
(bitshift)=
7 3 bitshift 56 eq check
142 -3 bitshift 17 eq check
(bytesavailable)=
currentfile bytesavailable =
%cachestatus
(ceiling)=
3.2 ceiling 4.0 eq check
-4.8 ceiling -4.0 eq check
99 ceiling 99 eq check
%charpath
(clear)=
7 8 6 7 5 9 0 7 6 4 6 8 77 8 6 9 7 8 6 clear
count 0 eq check
(cleartomark)=
777 [ 8 7 6 5 4 cleartomark
777 eq check
%clip
(clippath)=
clear clippath {}{}{}{} pathforall
count 0 gt check
clear
%(closefile)=
%closepath
%concat
(concatmatrix)=
matrix matrix matrix concatmatrix
aload pop
0 eq check
0 eq check
1 eq check
0 eq check
0 eq check
1 eq check
(copy)=
1 2 3 2 copy
count 5 eq check
3 eq check
2 eq check
3 eq check
2 eq check
1 eq check
1 2 3 0 copy
count 3 eq check
clear
/a1 [1 2 3] def
a1 dup length array copy aload pop
3 eq check
2 eq check
1 eq check
%copypage
(cos)=
0 cos 1.0 eq check
90 cos 0.0 eq check
(count)=
clear count 0 eq check
clear 1 2 3 count 3 eq check
clear
(countdictstack)=
countdictstack =
(countexecstack)=
countexecstack =
(counttomark)=
1 mark 2 3 counttomark 2 eq check
clear
1 mark counttomark 0 eq check
clear
%currentcacheparams
%currentdash
(currentdict)=
currentdict ==
(currentfile)=
currentfile ==
(currentflat)=
currentflat 0 ne check
%currentfont
%currentgray
%currenthsbcolor
%currentlinecap
%currentlinejoin
(currentlinewidth)=
currentlinewidth 0 ge check
(currentmatrix)=
matrix currentmatrix
false exch {
0 ne or
} forall true eq check % at least one non-zero value
%currentmiterlimit
%currentpacking
(currentpoint)=
5 5 moveto
currentpoint count 2 eq check
clear
%currentrgbcolor
%currentscreen
%currenttransfer
%curveto
(cvi)=
(1: (3.3E1) cvi 33 eq check)=
(3.3E1) cvi 33 eq check
(2: -47.8 cvi -47 eq check)=
-47.8 cvi -47 eq check
(3: 520.9 cvi 520 eq check)=
520.9 cvi 520 eq check
(cvlit)=
{mul} cvlit xcheck false eq check
(cvn)=
(abc) cvn /abc eq check
(abc) cvx cvn xcheck check
(cvr)=
(3.3E1) cvr 33.0 eq check
(cvrs)=
/str 10 string def
100 8 str cvrs (144) eq check
200 16 str cvrs dup (C8) eq exch (c8) eq or check
(cvs)=
/str 20 string def
(1: 123 456 add str cvs (579) eq check)=
123 456 add str cvs (579) eq check
(2: mark str cvs (-nostringval-) eq)=
mark str cvs (-nostringval-) eq
(2: mark str cvs (--nostringval--) eq)=
mark str cvs (--nostringval--) eq
(2: mark str cvs (-mark-) eq or or check)=
mark str cvs (-mark-) eq
or or check
(cvx)=
[/mul cvx]cvx xcheck true eq check
(def)=
/ncnt 1 def ncnt 1 eq check
/ncnt ncnt 1 add def ncnt 2 eq check
(defaultmatrix)=
matrix defaultmatrix
false exch {
0 ne or
} forall true eq check % at least one non-zero value
%definefont
(dict)=
1 dict type /dicttype eq check
%/dictfull
%(dictstack)=
%/dictstackoverflow
%/dictstackunderflow
(div)=
(1: 3 2 div 1.5 eq check)=
3 2 div 1.5 eq check
(2: 4 2 div 2.0 eq check)=
4 2 div 2.0 eq check
%dtransform
1 1 matrix dtransform
1 eq check
1 eq check
(dup)=
5 dup 5 eq check
5 eq check
%(echo)=
(end)=
end
currentdict userdict eq check
%eoclip
%eofill
(eq)=
(1: 4.0 4 eq check)=
4.0 4 eq check
(2: (abc) (abc) eq check)=
(abc) (abc) eq check
(3: (abc) /abc eq check)=
(abc) /abc eq check
(4: [1 2 3] dup eq check)=
[1 2 3] dup eq check
(5: [1 2 3] [1 2 3] eq check)=
[1 2 3] [1 2 3] eq false eq check
%erasepage
(errordict)=
errordict type /dicttype eq check
(exch)=
1 2 exch
1 eq {
2 eq check
}{
pop fail
} ifelse
(exec)=
(3 2 add) cvx exec 5 eq check
3 2 /add exec
/add eq exch
2 eq and exch
3 eq and check
3 2 /add cvx exec 5 eq check
%(execstack)=
%execstackoverflow
(executeonly)=
(string) executeonly rcheck false eq check
(exit)=
{exit false check}loop
(exp)=
(1: 9 0.5 exp 3.0 eq check)=
9 0.5 exp 3.0 eq check
(2: -9 -1 exp -0.111111 eq check)=
-9 -1 exp -0.111111 eq check
(false)=
false not check
%(file)=
%fill
%findfont
%flattenpath
(floor)=
3.2 floor 3.0 eq check
-4.8 floor -5.0 eq check
99 floor 99 eq check
%(flush)=
%(flushfile)=
%FontDirectory
(for)=
(1: 0 1 1 4 {add} for 10 eq check)=
0 1 1 4 {add} for 10 eq check
(2: 1 2 6 {} for)=
1 2 6 {} for
5 eq exch
3 eq and exch
1 eq and check
(3: 3 -.5 1 {} for)=
3 -.5 1 {} for
1.0 eq exch
1.5 eq and exch
2.0 eq and exch
2.5 eq and exch
3.0 eq and check
(forall)=
(1: 0 [13 29 3 -8 21] {add} forall 58 eq check)=
0 [13 29 3 -8 21] {add} forall 58 eq check
(a)=
/d 2 dict def
(b)=
d /abc 123 put
(c)=
d /xyz (test) put
(2: d {} forall)=
d {} forall
dup 123 eq {
pop
/abc eq exch
(test) eq and exch
/xyz eq and check
}{
(test) eq exch
/xyz eq and exch
123 eq and exch
/abc eq and check
} ifelse
%framedevice
(ge)=
(1: 4.2 4 ge check)=
4.2 4 ge check
(2: (abc) (d) ge check)=
(abc) (d) ge check
(3: (aba) (ab) ge check)=
(aba) (ab) ge check
(4: (aba) (aba) ge check)=
(aba) (aba) ge check
(get)=
[31 41 59] 0 get 31 eq check
[0 (a mixed-type array) [] {add 2 div}] 2 get length 0 eq check
/mykey (myvalue) def
currentdict /mykey get (myvalue) eq check
(abc) 1 get 98 eq check
(a) 0 get 97 eq check
(getinterval)=
[9 8 7 6 5] 1 3 getinterval aload pop
6 eq exch
7 eq and exch
8 eq and check
(abcde) 1 3 getinterval (bcd) eq check
(abcde) 0 0 getinterval () eq check
(grestore grestoreall gsave)=
matrix currentmatrix aload pop
gsave gsave 2 2 matrix scale setmatrix
grestore grestoreall
matrix currentmatrix aload pop
%pstack
7 -1 roll eq check
6 -1 roll eq check
5 -1 roll eq check
4 -1 roll eq check
3 -1 roll eq check
eq check
%(gt)=
%handleerror
(identmatrix)=
matrix identmatrix aload pop
0 eq check
0 eq check
1 eq check
0 eq check
0 eq check
1 eq check
(idiv)=
3 2 idiv 1 eq check
4 2 idiv 2 eq check
-5 2 idiv -2 eq check
%idtransform
(if)=
3 4 lt {(3 is less than 4)} if
(3 is less than 4) { eq check } stopped not check
(ifelse)=
4 3 lt {(TruePart)} {(FalsePart)} ifelse
(FalsePart) eq check
%image
%imagemask
(index)=
(a)(b)(c)(d) 0 index (d) eq check
3 index (a) eq check
clear
%initclip
%initgraphics
%initmatrix
%interrupt
%invalidaccess
%invalidfileaccess
%invalidfont
%invalidrestore
%invertmatrix
%ioerror
%itransform
(known)=
/mydict 5 dict def
mydict /total 0 put
mydict /total known check
mydict /badname known not check
%kshow
%(le)=
(length)=
[1 2 4] length 3 eq check
[] length 0 eq check
/ar 20 array def ar length 20 eq check
/mydict 5 dict def
mydict length 0 eq check
mydict /firstkey (firstvalue) put
mydict length 1 eq check
(abc\n) length 4 eq check
() length 0 eq check
%limitcheck
%lineto
(ln)=
10 ln 2.30259 eq check
100 ln 4.60517 eq check
(load)=
/avg {add 2 div} def
/avg load 1 get 2 eq check
(log)=
10 log 1.0 eq check
100 log 2.0 eq check
%(loop)=
%(lt)=
%makefont
(mark)=
mark [ eq check
%matrix
(maxlength)=
/mydict 8 dict def
mydict length 0 eq check
mydict maxlength 10 eq check
(mod)=
5 3 mod 2 eq check
5 2 mod 1 eq check
-5 3 mod -2 eq check
%moveto
%(mul)=
%(ne)=
(neg)=
4.5 neg -4.5 eq check
-3 neg 3 eq check
%newpath
%(noaccess)=
%nocurrentpoint
(not)=
(1:)=
true not false eq check
(2:)=
false not true eq check
(3:)=
52 not -53 eq check
(null)=
null 1 array 0 get eq check
%nulldevice
(or)=
true true or true eq check
true false or true eq check
false true or true eq check
false false or false eq check
17 5 or 21 eq check
%packedarray
%pathbbox
%pathforall
(pop)=
1 2 3 pop 2 eq check clear
1 2 3 pop pop 1 eq check
%(print)=
%(prompt)=
%(pstack)=
(put)=
(1:)=
/ar [5 17 3 8] def
ar 2 (abcd) put
ar aload pop
8 eq exch
(abcd) eq and check clear
(2:)=
/d 5 dict def
d /abc 123 put
d {} forall
123 eq exch
/abc eq and check
(3:)=
/st (abc) def
st 0 65 put
st (Abc) eq check
(putinterval)=
(1:)=
/ar [5 8 2 7 3] def
ar 1 [(a) (b) (c)] putinterval
ar aload pop
3 eq exch
(c) eq and exch
(b) eq and exch
(a) eq and exch
5 eq and check
(2:)=
/st (abc) def
st 1 (de) putinterval
st (ade) eq check
%(quit)=
(rand)=
rand type /integertype eq check
rand rand eq not check
%rangecheck
%(rcheck)=
%rcurveto
%(read)=
(readhexstring)=
{currentfile 3 string readhexstring}exec
616263
check (abc) eq check
{currentfile 3 string readhexstring}exec
303132
check (012) eq check
%(readline)=
%(readonly)=
(readstring)=
{currentfile 3 string readstring}exec
abc
(1:)= pstack
check (abc) eq check
DATA_DIR(/readstring.ps)strcat run
(2:)= pstack
not check 0 3 getinterval (abc) eq check
%renderbands
(repeat)=
4{(abc)}repeat count 4 eq check
1 2 3 4 3 {pop} repeat 1 eq check
4 {} repeat (abc) eq check
mark 0 {(won't happen)} repeat mark eq check
clear
%resetfile
%(restore)=
%reversepath
%rlineto
%rmoveto
(roll)=
(a)(b)(c) 3 -1 roll (a) ne {fail} if clear
(a)(b)(c) 3 1 roll (b) ne {fail} if clear
(a)(b)(c) 3 0 roll (c) ne {fail} if clear
%rotate
(round)=
(1: 3.2 round 3.0 ne check)=
3.2 round 3.0 eq check
(2: 6.5 round 7.0 ne check)=
6.5 round 7.0 eq check
(3: -4.8 round -5.0 ne check)=
-4.8 round -5.0 eq check
(4: -6.5 round -6.0 ne check)=
-6.5 round -6.0 eq check
(5: 99 round 99 ne check)=
99 round 99 eq check
%(rrand)=
%(run)=
breakhere
(save)=
/saveobj save def
saveobj restore
%scale
%scalefont
(search)=
(1: (abbc) (ab) search not {fail} if clear)=
(abbc) (ab) search not {fail} if clear
(2: (abbc) (bb) search not {fail} if clear)=
(abbc) (bb) search not {fail} if clear
(3: (abbc) (bc) search not {fail} if clear)=
(abbc) (bc) search not {fail} if clear
(4: (abbc) (B) search {fail} if clear)=
(abbc) (B) search {fail} if clear
%setcachedevice
%setcachelimit
%setcacheparams
%setcharwidth
%setdash
%setflat
%setfont
%setgray
%sethsbcolor
%setlinecap
%setlinejoin
%setlinewidth
%setmatrix
%setmiterlimit
%setpacking
%setrgbcolor
%setscreen
%settransfer
%show
%showpage
%(sin)=
%(sqrt)=
%(srand)=
%(stack)=
%stackoverflow
%stackunderflow
%StandardEncoding
%(start)=
%status
%stop
(stopped)=
%breakhere
{ ... } stopped check
(store)=
/abc 123 store
/abc where {}{currentdict} ifelse /abc 123 put
abc 123 ne {fail} if
%(string)=
%stringwidth
%stroke
%strokepath
%(sub)=
%syntaxerror
%(systemdict)=
%timeout
(token)=
(15(St1) {1 2 add}) token not {fail} if 15 eq check
token not {fail} if (St1) eq check
token not {fail} if type /arraytype eq check
token not check
%transform
%translate
%(true)=
(truncate)=
3.2 truncate 3.0 eq check
-4.8 truncate -4.0 eq check
99 truncate 99 eq check
%(type)=
%typecheck
%undefined
%undefinedfilename
%undefinedresult
%unmatchedmark
%unregistered
%(userdict)=
%usertime
%version
%VMerror
%vmstatus
%(wcheck)=
%(where)=
%widthshow
%(write)=
%(writehexstring)=
%(writestring)=
%(xcheck)=
(xor)=
true true xor false eq check
true false xor true eq check
false true xor true eq check
false false xor false eq check
7 3 xor 4 eq check
12 3 xor 15 eq check
%DATA_DIR(/testdraw.ps)strcat run
failcount 0 eq {
(SUCCESS)=
}{
failcount =only ( FAILs) =
} ifelse
%traceon