This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Document Carp's global variables + provide tests
[perl5.git] / ext / Devel / PPPort / PPPort.xs
CommitLineData
0a7c7f4f
JH
1
2#include "EXTERN.h"
3#include "perl.h"
4#include "XSUB.h"
5
6#define NEED_newCONSTSUB
7#include "ppport.h"
8
9/* Global Data */
10
44284200 11#define MY_CXT_KEY "Devel::PPPort::_guts" XS_VERSION
0a7c7f4f
JH
12
13typedef struct {
14 /* Put Global Data in here */
15 int dummy;
16} my_cxt_t;
17
18START_MY_CXT
19
20void test1(void)
21{
44284200 22 newCONSTSUB(gv_stashpv("Devel::PPPort", FALSE), "test_value_1", newSViv(1));
0a7c7f4f
JH
23}
24
25extern void test2(void);
26extern void test3(void);
27
44284200 28MODULE = Devel::PPPort PACKAGE = Devel::PPPort
0a7c7f4f
JH
29
30BOOT:
31{
32 MY_CXT_INIT;
33 /* If any of the fields in the my_cxt_t struct need
34 to be initialised, do it here.
35 */
36 MY_CXT.dummy = 42 ;
37}
38
39void
40test1()
41
42void
43test2()
44
45void
46test3()
47
48int
49test4()
50 CODE:
51 {
52 SV * sv = newSViv(1);
20d72259 53 newRV_inc(sv);
0a7c7f4f
JH
54 RETVAL = (SvREFCNT(sv) == 2);
55 }
56 OUTPUT:
57 RETVAL
58
59int
60test5()
61 CODE:
62 {
63 SV * sv = newSViv(2);
20d72259 64 newRV_noinc(sv);
0a7c7f4f
JH
65 RETVAL = (SvREFCNT(sv) == 1);
66 }
67 OUTPUT:
68 RETVAL
69
70SV *
71test6()
72 CODE:
73 {
74 RETVAL = (newSVsv(&PL_sv_undef));
75 }
76 OUTPUT:
77 RETVAL
78
79SV *
80test7()
81 CODE:
82 {
83 RETVAL = (newSVsv(&PL_sv_yes));
84 }
85 OUTPUT:
86 RETVAL
87
88SV *
89test8()
90 CODE:
91 {
92 RETVAL = (newSVsv(&PL_sv_no));
93 }
94 OUTPUT:
95 RETVAL
96
97int
98test9(string)
99 char * string;
100 CODE:
101 {
102 PL_na = strlen(string);
103 RETVAL = PL_na;
104 }
105 OUTPUT:
106 RETVAL
107
108
109SV*
110test10(value)
111 int value
112 CODE:
113 {
114 RETVAL = (newSVsv(boolSV(value)));
115 }
116 OUTPUT:
117 RETVAL
118
119
120SV*
121test11(string, len)
122 char * string
123 int len
124 CODE:
125 {
126 RETVAL = newSVpvn(string, len);
127 }
128 OUTPUT:
129 RETVAL
130
131SV*
132test12()
133 CODE:
134 {
135 RETVAL = newSVsv(DEFSV);
136 }
137 OUTPUT:
138 RETVAL
139
140int
141test13()
142 CODE:
143 {
144 RETVAL = SvTRUE(ERRSV);
145 }
146 OUTPUT:
147 RETVAL
148
149int
150test14()
151 CODE:
152 {
153 dMY_CXT;
154 RETVAL = (MY_CXT.dummy == 42);
155 ++ MY_CXT.dummy ;
156 }
157 OUTPUT:
158 RETVAL
159
160int
161test15()
162 CODE:
163 {
164 dMY_CXT;
165 RETVAL = (MY_CXT.dummy == 43);
166 }
167 OUTPUT:
168 RETVAL
169