summaryrefslogtreecommitdiffstats
path: root/src/extension/script/bindtest.cpp
blob: 97970381d34c37bfcf5c9a4975bf0a1a40ec9ea6 (plain)
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
#include <stdio.h>

#include "InkscapeScript.h"

#ifndef TRUE
#define TRUE  1
#endif
#ifndef FALSE
#define FALSE 0
#endif

static char *pythonCodeStr =
//"\n"
//"inkscape = _inkscape_py.getInkscape()\n"
"desktop  = inkscape.getDesktop()\n"
"document = desktop.getDocument()\n"
"document.hello()\n"
"";

int testPython()
{
    Inkscape::Extension::Script::InkscapeScript scriptEngine;
    printf("##### Python Test #####\n");
    printf("===== CODE ====\n%s\n==============\n", pythonCodeStr);
    scriptEngine.interpretScript(pythonCodeStr, 
          Inkscape::Extension::Script::InkscapeScript::PYTHON);
    printf("##### End Python #####\n\n");
    return TRUE;
}

static char *perlCodeStr =
//"\n"
//"$inkscape = inkscape_perlc::getInkscape();\n"
"print \"inkscape: '$inkscape'\\n\"; \n"
"$desktop  = $inkscape->getDesktop();\n"
"$document = $desktop->getDocument();\n"
"$document->hello()\n"
//"reverse 'rekcaH lreP rehtonA tsuJ'\n"
"";

int testPerl()
{
    Inkscape::Extension::Script::InkscapeScript scriptEngine;
    printf("##### Perl Test #####\n");
    printf("===== CODE ====\n%s\n==============\n", perlCodeStr);
    scriptEngine.interpretScript(perlCodeStr,
         Inkscape::Extension::Script::InkscapeScript::PERL);
    printf("##### End Perl #####\n\n");
    return TRUE;
}



int doTest()
{
    if (!testPython())
        {
        printf("Failed Python test\n");
        return FALSE;
        }
    if (!testPerl())
        {
        printf("Failed Perl test\n");
        return FALSE;
        }
    return TRUE;
}



int main(int argc, char **argv)
{

    if (doTest())
        printf("Tests succeeded\n");
    else
        printf("Tests failed\n");
    return 0;
}