1use warnings;
2use strict;
3
4use Test::More tests => 32;
5
6BEGIN { $^H |= 0x20000; }
7
8my $t;
9
10$t = "";
11eval q{
12	use XS::APItest qw(labelconst);
13	$t .= "a";
14	$t .= labelconst b:;
15	$t .= "c";
16};
17is $@, "";
18is $t, "abc";
19
20$t = "";
21eval q{
22	use XS::APItest qw(labelconst);
23	$t .= "a";
24	$t .= "b" . labelconst FOO: . "c";
25	$t .= "d";
26};
27is $@, "";
28is $t, "abFOOcd";
29
30$t = "";
31eval q{
32	use XS::APItest qw(labelconst);
33	$t .= "a";
34	$t .= labelconst FOO :;
35	$t .= "b";
36};
37is $@, "";
38is $t, "aFOOb";
39
40$t = "";
41eval q{
42	use XS::APItest qw(labelconst);
43	$t .= "a";
44	$t .= labelconst F_1B:;
45	$t .= "b";
46};
47is $@, "";
48is $t, "aF_1Bb";
49
50$t = "";
51eval q{
52	use XS::APItest qw(labelconst);
53	$t .= "a";
54	$t .= labelconst _AB:;
55	$t .= "b";
56};
57is $@, "";
58is $t, "a_ABb";
59
60$t = "";
61eval q{
62	use XS::APItest qw(labelconst);
63	no warnings;
64	$t .= "a";
65	$t .= labelconst 1AB:;
66	$t .= "b";
67};
68isnt $@, "";
69is $t, "";
70
71$t = "";
72eval q{
73	use XS::APItest qw(labelconst);
74	$t .= "a";
75	$t .= labelconst :;
76	$t .= "b";
77};
78isnt $@, "";
79is $t, "";
80
81$t = "";
82eval q{
83	use XS::APItest qw(labelconst);
84	$t .= "a";
85	$t .= labelconst ;
86	$t .= "b";
87};
88isnt $@, "";
89is $t, "";
90
91$t = "";
92$t = do("./t/labelconst.aux");
93is $@, "";
94is $t, "FOOBARBAZQUUX";
95
96{
97    use utf8;
98    use open qw( :utf8 :std );
99    
100    $t = "";
101    eval q{
102            use XS::APItest qw(labelconst);
103            $t .= "���";
104            $t .= labelconst ���:;
105            $t .= "���";
106    };
107    is $@, "";
108    is $t, "���������";
109    
110    $t = "";
111    eval q{
112            use XS::APItest qw(labelconst);
113            $t .= "���";
114            $t .= "���" . labelconst �������: . "���";
115            $t .= "���";
116    };
117    is $@, "";
118    is $t, "�������������������";
119    
120    $t = "";
121    eval q{
122            use XS::APItest qw(labelconst);
123            $t .= "���";
124            $t .= labelconst ������� :;
125            $t .= "���";
126    };
127    is $@, "";
128    is $t, "�������������";
129    
130    $t = "";
131    eval q{
132            use XS::APItest qw(labelconst);
133            $t .= "���";
134            $t .= labelconst ���_1���:;
135            $t .= "���";
136    };
137    is $@, "";
138    is $t, "������_1������";
139    
140    $t = "";
141    eval q{
142            use XS::APItest qw(labelconst);
143            $t .= "���";
144            $t .= labelconst _A���:;
145            $t .= "���";
146    };
147    is $@, "";
148    is $t, "���_A������";
149    
150    $t = "";
151    eval q{
152            use XS::APItest qw(labelconst);
153            no warnings;
154            $t .= "���";
155            $t .= labelconst 1A���:;
156            $t .= "���";
157    };
158    isnt $@, "";
159    is $t, "";
160    
161}
162
163{
164    use utf8;
165    $t = "";
166    $t = do("./t/labelconst_utf8.aux");
167    is $@, "";
168    is $t, "�������B��R�����ZQ����X";
169}
170
1711;
172