Added libextutils-xspp-perl
[pkg-perl] / deb-src / libextutils-xspp-perl / libextutils-xspp-perl-0.07 / t / 075_types.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use warnings;
5 use t::lib::XSP::Test tests => 4;
6
7 run_diff xsp_stdout => 'expected';
8
9 __DATA__
10
11 === Pointer/const pointer type
12 --- xsp_stdout
13 %module{Foo};
14 %package{Foo};
15
16 %typemap{int*}{simple};
17 %typemap{const int*}{simple};
18
19 int* foo();
20 int* boo(const int* a);
21 --- expected
22 MODULE=Foo
23
24 MODULE=Foo PACKAGE=Foo
25
26 int*
27 foo()
28
29 int*
30 boo( a )
31     const int* a
32
33 === Const value/const reference type
34 --- xsp_stdout
35 %module{Foo};
36 %package{Foo};
37
38 %typemap{const std::string}{simple};
39 %typemap{const std::string&}{reference};
40
41 void foo(const std::string a);
42 void boo(const std::string& a);
43 --- expected
44 MODULE=Foo
45
46 MODULE=Foo PACKAGE=Foo
47
48 void
49 foo( a )
50     const std::string a
51
52 void
53 boo( a )
54     std::string* a
55   CODE:
56     boo( *( a ) );
57
58 === Template type
59 --- xsp_stdout
60 %module{Foo};
61 %package{Foo};
62
63 %typemap{const std::vector<int>&}{simple};
64 %typemap{const std::map<int, std::string>}{simple};
65 %typemap{const std::vector&}{reference}; // check type equality
66
67 void foo(const std::vector<int>& a);
68 void boo(const std::map<int, std::string> a);
69 --- expected
70 MODULE=Foo
71
72 MODULE=Foo PACKAGE=Foo
73
74
75 void
76 foo( a )
77     const std::vector< int >& a
78
79 void
80 boo( a )
81     const std::map< int, std::string > a
82 === Template argument transformed to pointer
83 --- xsp_stdout
84 %module{Foo};
85 %package{Foo};
86
87 %typemap{const std::vector<double>&}{reference}; // check type equality
88
89 void foo(const std::vector<double>& a);
90 --- expected
91 MODULE=Foo
92
93 MODULE=Foo PACKAGE=Foo
94
95
96 void
97 foo( a )
98     std::vector< double >* a
99   CODE:
100     foo( *( a ) );