1use warnings;
2use strict;
3
4use Test::More tests => 18;
5
6BEGIN { $^H |= 0x20000; }
7
8my $t;
9
10$t = "";
11eval q{
12	use XS::APItest qw(scopelessblock);
13	$t .= "a";
14	scopelessblock {
15		$t .= "b";
16	}
17	$t .= "c";
18};
19is $@, "";
20is $t, "abc";
21
22$t = "";
23eval q{
24	use XS::APItest qw(scopelessblock);
25	$t .= "a";
26	scopelessblock {
27		my $t = "z";
28		$t .= "b";
29	}
30	$t .= "c";
31};
32is $@, "";
33is $t, "a";
34
35$t = "";
36eval q{
37	use XS::APItest qw(scopelessblock);
38	my $f = 1.5;
39	$t .= "a(".($f+$f).")";
40	scopelessblock {
41		use integer;
42		$t .= "b(".($f+$f).")";
43	}
44	$t .= "c(".($f+$f).")";
45};
46is $@, "";
47is $t, "a(3)b(2)c(2)";
48
49$t = "";
50eval q{
51	use XS::APItest qw(scopelessblock);
52	our $z = "z";
53	$t .= "a$z";
54	scopelessblock {
55		local $z = "y";
56		$t .= "b$z";
57	}
58	$t .= "c$z";
59};
60is $@, "";
61is $t, "azbycy";
62
63$t = "";
64eval q{
65	use XS::APItest qw(scopelessblock);
66	$t .= "A";
67	do {
68		$t .= "a";
69		scopelessblock {
70			$t .= "b";
71		}
72		$t .= "c";
73	};
74	$t .= "B";
75};
76is $@, "";
77is $t, "AabcB";
78
79$t = "";
80eval q|
81	use XS::APItest qw(scopelessblock);
82	$t .= "a";
83	scopelessblock {
84		$t .= "b";
85	]
86	$t .= "c";
87|;
88isnt $@, "";
89is $t, "";
90
91$SIG{__WARN__} = sub { };
92$t = "";
93eval q|
94	use XS::APItest qw(scopelessblock);
95	$t .= "a";
96	scopelessblock {
97		$t .= "b";
98	)
99	$t .= "c";
100|;
101isnt $@, "";
102is $t, "";
103
104$t = "";
105eval q{
106	use XS::APItest qw(scopelessblock);
107	{ $t .= "a"; }
108	scopelessblock {
109		{ $t .= "b"; }
110	}
111	{ $t .= "c"; }
112};
113is $@, "";
114is $t, "abc";
115
116$t = "";
117eval q{
118	use XS::APItest qw(scopelessblock);
119	$t .= "A";
120	do {
121		{ $t .= "a"; }
122		scopelessblock {
123			{ $t .= "b"; }
124		}
125		{ $t .= "c"; }
126	};
127	$t .= "B";
128};
129is $@, "";
130is $t, "AabcB";
131
1321;
133