Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 86 lines (73 sloc) 1.809 kB
b45b3da @abw Added test for XS unicode problems (not fixed)
authored
1 #============================================================= -*-perl-*-
2 #
3 # t/stash-xs-unicode.t
4 #
5 # Template script to test unicode data with the XS Stash
6 #
7 # Written by Andy Wardley <abw@wardley.org> based on code provided
8 # by Максим Вуец.
9 #
10 # Copyright (C) 1996-2009 Andy Wardley. All Rights Reserved.
11 #
12 # This is free software; you can redistribute it and/or modify it
13 # under the same terms as Perl itself.
14 #
15 #========================================================================
16
17 use strict;
18 use warnings;
19 use lib qw( ./lib ../lib ../blib/lib ../blib/arch ./blib/lib ./blib/arch );
20 use utf8;
21 use Template;
22 use Template::Test;
23
45c1dfe @abw Fixed XS Stash UTF8 bug
authored
24 BEGIN {
25 unless ($] > 5.007) {
26 skip_all("perl < 5.8 can't do unicode well enough\n");
27 }
28 }
29
b45b3da @abw Added test for XS unicode problems (not fixed)
authored
30 eval {
31 require Template::Stash::XS;
32 };
33 if ($@) {
34 warn $@;
62cebf8 @abw Forced t/stash-xs-unicode.t test to skip all if XS stash not avilable
authored
35 skip_all('cannot load Template::Stash::XS');
b45b3da @abw Added test for XS unicode problems (not fixed)
authored
36 }
37
38 binmode STDOUT, ':utf8';
39
45c1dfe @abw Fixed XS Stash UTF8 bug
authored
40 $Template::Config::STASH = 'Template::Stash::XS';
41
b45b3da @abw Added test for XS unicode problems (not fixed)
authored
42 my $data = {
43 ascii => 'key',
44 utf8 => 'ключ',
45 hash => {
45c1dfe @abw Fixed XS Stash UTF8 bug
authored
46 key => 'value',
b45b3da @abw Added test for XS unicode problems (not fixed)
authored
47 ключ => 'значение'
48 },
49 str => 'щука'
50 };
51
52
677ffb7 @abw Deleted some cruft from t/stash-xs-unicode.t
authored
53 test_expect(\*DATA, undef, $data);
b45b3da @abw Added test for XS unicode problems (not fixed)
authored
54
55 __DATA__
56 -- test --
57 -- name ASCII key --
58 ascii = [% ascii %]
59 hash.$ascii = [% hash.$ascii %]
60 -- expect --
61 ascii = key
62 hash.$ascii = value
63
64 -- test --
65 -- name UTF8 length --
66 str.length = [% str.length %]
67 -- expect --
68 str.length = 4
69
70 -- test --
45c1dfe @abw Fixed XS Stash UTF8 bug
authored
71 -- name UTF8 key fetch --
b45b3da @abw Added test for XS unicode problems (not fixed)
authored
72 utf8 = [% utf8 %]
45c1dfe @abw Fixed XS Stash UTF8 bug
authored
73 hash.$utf8 = hash.[% utf8 %] = [% hash.$utf8 %]
b45b3da @abw Added test for XS unicode problems (not fixed)
authored
74 -- expect --
75 utf8 = ключ
45c1dfe @abw Fixed XS Stash UTF8 bug
authored
76 hash.$utf8 = hash.ключ = значение
b45b3da @abw Added test for XS unicode problems (not fixed)
authored
77
45c1dfe @abw Fixed XS Stash UTF8 bug
authored
78 -- test --
79 -- name UTF8 key assign --
80 [% value = hash.$utf8; hash.$value = utf8 -%]
81 value = [% value %]
82 hash.$value = hash.[% value %] = [% hash.$value %]
83 -- expect --
84 value = значение
85 hash.$value = hash.значение = ключ
Something went wrong with that request. Please try again.