-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test for XS unicode problems (not fixed)
git-svn-id: svn://svn.tt2.org/tt/Template2/trunk@1225 d5a88997-0a34-4036-9ed2-92fb5d660d91
- Loading branch information
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#============================================================= -*-perl-*- | ||
# | ||
# t/stash-xs-unicode.t | ||
# | ||
# Template script to test unicode data with the XS Stash | ||
# | ||
# Written by Andy Wardley <abw@wardley.org> based on code provided | ||
# by Максим Вуец. | ||
# | ||
# Copyright (C) 1996-2009 Andy Wardley. All Rights Reserved. | ||
# | ||
# This is free software; you can redistribute it and/or modify it | ||
# under the same terms as Perl itself. | ||
# | ||
#======================================================================== | ||
|
||
use strict; | ||
use warnings; | ||
use lib qw( ./lib ../lib ../blib/lib ../blib/arch ./blib/lib ./blib/arch ); | ||
use utf8; | ||
use Template; | ||
use Template::Test; | ||
|
||
eval { | ||
require Template::Stash::XS; | ||
}; | ||
if ($@) { | ||
warn $@; | ||
skip_all('cannot load Template::Stash::XS'); | ||
} | ||
|
||
binmode STDOUT, ':utf8'; | ||
|
||
# XXX: uncomment this to make Template work properly | ||
#$Template::Config::STASH = 'Template::Stash'; | ||
|
||
my $data = { | ||
ascii => 'key', | ||
utf8 => 'ключ', | ||
hash => { | ||
key => 'value', | ||
ключ => 'значение' | ||
}, | ||
str => 'щука' | ||
}; | ||
|
||
|
||
test_expect(\*DATA, undef, $data); | ||
|
||
__DATA__ | ||
-- test -- | ||
-- name ASCII key -- | ||
ascii = [% ascii %] | ||
hash.$ascii = [% hash.$ascii %] | ||
-- expect -- | ||
ascii = key | ||
hash.$ascii = value | ||
-- test -- | ||
-- name UTF8 length -- | ||
str.length = [% str.length %] | ||
-- expect -- | ||
str.length = 4 | ||
-- stop -- | ||
This test fails. A trivial attempt at fixing the XS Stash didn't work. Needs a proper look. | ||
-- test -- | ||
-- name UTF8 key -- | ||
utf8 = [% utf8 %] | ||
hash.$utf8 = [% hash.$utf8 %] | ||
-- expect -- | ||
utf8 = ключ | ||
hash.$utf8 = значение | ||