1 # tests shared between t/op/caller.t and ext/XS/APItest/t/op.t
7 is(hint_fetch('dooot'), undef);
8 is(hint_fetch('thikoosh'), undef);
9 ok(!hint_exists('dooot'));
10 ok(!hint_exists('thikoosh'));
11 if ($::testing_caller) {
12 is(hint_fetch('dooot', 1), 54);
17 is(hint_fetch('dooot'), 6 * 7);
18 if ($::testing_caller) {
19 is(hint_fetch('dooot', 1), 54);
25 is(hint_fetch('dooot'), undef);
26 ok(hint_exists('dooot'));
31 is(hint_fetch('dooot'), undef);
32 ok(!hint_exists('dooot'));
33 if ($::testing_caller) {
34 is(hint_fetch('dooot', 1), 54);
38 is(hint_fetch('dooot'), undef);
39 is(hint_fetch('thikoosh'), undef);
42 $^H{thikoosh} = "SKREECH";
44 if ($::testing_caller) {
45 is(hint_fetch('dooot'), 1);
47 is(hint_fetch('thikoosh'), "SKREECH");
57 is(hint_fetch('dooot'), 54);
58 is(hint_fetch('thikoosh'), "SKREECH");
63 is(hint_fetch('dooot'), undef);
64 ok(!hint_exists('dooot'));
65 is(hint_fetch('thikoosh'), "SKREECH");
69 is(hint_fetch('dooot'), 6 * 7);
70 is(hint_fetch('thikoosh'), "SKREECH");
72 is(hint_fetch('dooot'), 6 * 7);
73 is(hint_fetch('thikoosh'), "SKREECH");
76 print "# which now works inside evals\n";
82 is(hint_fetch('dooot'), 6 * 7);
84 eval "is(hint_fetch('dooot'), 6 * 7); 1" or die $@;
86 eval <<'EOE' or die $@;
87 is(hint_fetch('dooot'), 6 * 7);
88 eval "is(hint_fetch('dooot'), 6 * 7); 1" or die $@;
92 is(hint_fetch('dooot'), 54);
93 eval "is(hint_fetch('dooot'), 54); 1" or die $@;
94 eval 'BEGIN { $^H{dooot} = -1; }; 1' or die $@;
95 is(hint_fetch('dooot'), 54);
96 eval "is(hint_fetch('dooot'), 54); 1" or die $@;
102 $^H{dooot} = "FIP\0FOP\0FIDDIT\0FAP";
104 is(hint_fetch('dooot'), "FIP\0FOP\0FIDDIT\0FAP", "Can do embedded 0 bytes");
107 $^H{dooot} = chr 256;
109 is(hint_fetch('dooot'), chr 256, "Can do Unicode");
114 is(hint_fetch('dooot'), -42, "Can do IVs");
119 cmp_ok(hint_fetch('dooot'), '>', 42, "Can do UVs");
123 my ($k1, $k2, $k3, $k4);
139 is(hint_fetch($k1), 2, "UTF-8 or not, it's the same");
140 if ($::testing_caller) {
141 # Perl_refcounted_he_fetch() insists that you have the key correctly
142 # normalised for the way hashes store them. As this one isn't
143 # normalised down to bytes, it won't t work with
144 # Perl_refcounted_he_fetch()
145 is(hint_fetch($k2), 2, "UTF-8 or not, it's the same");
147 is(hint_fetch($k3), 3, "Octect sequences and UTF-8 are distinct");
148 is(hint_fetch($k4), 4, "Octect sequences and UTF-8 are distinct");
154 ($k1, $k2, $k3) = ("\0", "\0\0", "\0\0\0");
160 is(hint_fetch($k1), 1, "Keys with the same hash value don't clash");
161 is(hint_fetch($k2), 2, "Keys with the same hash value don't clash");
162 is(hint_fetch($k3), 3, "Keys with the same hash value don't clash");
170 is(hint_fetch($k1), "a", "Keys with the same hash value don't clash");
171 is(hint_fetch($k2), "b", "Keys with the same hash value don't clash");
172 is(hint_fetch($k3), "c", "Keys with the same hash value don't clash");