Code

r11512@tres: ted | 2006-04-24 21:36:08 -0700
[inkscape.git] / src / extension / script / bindtest.cpp
2 #include <stdio.h>
4 #include "InkscapeScript.h"
6 #ifndef TRUE
7 #define TRUE  1
8 #endif
9 #ifndef FALSE
10 #define FALSE 0
11 #endif
13 static char *pythonCodeStr =
14 //"\n"
15 //"inkscape = _inkscape_py.getInkscape()\n"
16 "desktop  = inkscape.getDesktop()\n"
17 "document = desktop.getDocument()\n"
18 "document.hello()\n"
19 "";
21 int testPython()
22 {
23     Inkscape::Extension::Script::InkscapeScript scriptEngine;
24     printf("##### Python Test #####\n");
25     printf("===== CODE ====\n%s\n==============\n", pythonCodeStr);
26     scriptEngine.interpretScript(pythonCodeStr, 
27           Inkscape::Extension::Script::InkscapeScript::PYTHON);
28     printf("##### End Python #####\n\n");
29     return TRUE;
30 }
32 static char *perlCodeStr =
33 //"\n"
34 //"$inkscape = inkscape_perlc::getInkscape();\n"
35 "print \"inkscape: '$inkscape'\\n\"; \n"
36 "$desktop  = $inkscape->getDesktop();\n"
37 "$document = $desktop->getDocument();\n"
38 "$document->hello()\n"
39 //"reverse 'rekcaH lreP rehtonA tsuJ'\n"
40 "";
42 int testPerl()
43 {
44     Inkscape::Extension::Script::InkscapeScript scriptEngine;
45     printf("##### Perl Test #####\n");
46     printf("===== CODE ====\n%s\n==============\n", perlCodeStr);
47     scriptEngine.interpretScript(perlCodeStr,
48          Inkscape::Extension::Script::InkscapeScript::PERL);
49     printf("##### End Perl #####\n\n");
50     return TRUE;
51 }
55 int doTest()
56 {
57     if (!testPython())
58         {
59         printf("Failed Python test\n");
60         return FALSE;
61         }
62     if (!testPerl())
63         {
64         printf("Failed Perl test\n");
65         return FALSE;
66         }
67     return TRUE;
68 }
72 int main(int argc, char **argv)
73 {
75     if (doTest())
76         printf("Tests succeeded\n");
77     else
78         printf("Tests failed\n");
79     return 0;
80 }