fix some stuff for integration with luatex
[mplib] / src / texk / web2c / mpdir / tests / test.lua
1
2 -- There are two interfaces:
3 -- new * run
4 -- or
5 -- new * execute^1 * finish
6
7 if false then 
8   mpx = mp.new({ini_version = true, command_line = "plain \\dump"})
9   print (mpx:run());
10   mpx = nil;
11 end
12
13 dofile("/opt/tex/texmf-local/tex/context/base/l-table.lua");
14
15 function dorun (m, s) 
16   local v = m:execute(s)
17 --  print ('<<term:'..v.term..'>>')
18   print ('<<log:'..v.log..'>>')
19   if v.fig then
20      for _,gs in ipairs(v.fig) do
21            local b = gs:objects()
22        for _,vv in ipairs(b) do
23                   print(vv, vv.type, table.serialize(vv.path), table.serialize(vv.color))
24        end
25 --       print(gs:postscript())
26      end
27   end
28 end
29
30 -- chunks have to have 'complete file' nesting state
31 local lines = {
32  "prologues:=3;",
33  "path p;",
34  "p = (0,0){right}..(20,100)..(50,60)..(75,50)...(25,25)..cycle;",
35  "pickup pencircle scaled 2;",
36  "beginfig(1); fill p withcolor (1,0,0); draw p dashed evenly; endfig;",
37  "beginfig(2); fill p withcolor (0,1,0); draw p dashed evenly; endfig;",
38  "beginfig(3); fill p withcolor (0,0,1); draw p dashed evenly; endfig;",
39  "beginfig(4); fill p withcolor (1,1,0); draw p dashed evenly; endfig;",
40  [[beginfig(5); fill p withcolor (1,0,1); draw p dashed evenly; endfig; 
41    beginfig(6); fill p withcolor (0,1,1); draw p dashed evenly; endfig;]],
42  "beginfig(7); label(\"stuff\", (0,0)); endfig;",
43 }
44
45 function finder (a,b,c)
46    print(a,b,c)
47    if a == "mpost.map" then
48      return "/opt/tex/texmf-local/fonts/map/pdftex/pdftex.map"
49    end
50    if a =="cmr10.tfm" then
51      return "/opt/tex/texmf/fonts/tfm/public/cm/cmr10.tfm"
52    end
53    return a
54 end
55
56 mpx = mp.new({mem_name = "plain.mem", 
57               command_line = "\\relax ", 
58               find_file = finder})
59
60 for _,l in ipairs(lines) do
61    dorun (mpx, l)
62 end
63
64 v = mpx:finish();
65