~ubuntu-branches/ubuntu/saucy/padre/saucy-proposed

« back to all changes in this revision

Viewing changes to t/70_document.t

  • Committer: Package Import Robot
  • Author(s): Dominique Dumont, gregor herrmann, Dominique Dumont
  • Date: 2012-01-04 12:04:20 UTC
  • mfrom: (1.3.3)
  • Revision ID: package-import@ubuntu.com-20120104120420-i5oybqwf91m1d3il
Tags: 0.92.ds1-1
[ gregor herrmann ]
* Remove debian/source/local-options; abort-on-upstream-changes
  and unapply-patches are default in dpkg-source since 1.16.1.
* Swap order of alternative (build) dependencies after the perl
  5.14 transition.

[ Dominique Dumont ]
* Imported Upstream version 0.92.ds1
* removed fix-spelling patch (applied upstream)
* lintian-override: use wildcard to avoid listing a gazillion files
* updated size of some 'not-real-man-page' entries
* rules: remove dekstop cruft (replaced by a file provided in debian
  directory)
* control: removed Breaks statement. Add /me to uploaders. Updated
  dependencies
* rules: make sure that non-DFSG file (i.e. the cute butterfly, sigh)
  is not distributed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
package PadreTest::Config;
 
4
 
 
5
use strict;
 
6
use warnings;
 
7
 
 
8
sub new {
 
9
        my $class = shift;
 
10
        my $self = bless {@_}, $class;
 
11
}
 
12
 
 
13
sub editor_file_size_limit {
 
14
        return 500000;
 
15
}
 
16
 
 
17
package main;
 
18
 
 
19
use strict;
 
20
use warnings;
 
21
use Test::More;
 
22
 
 
23
BEGIN {
 
24
        unless ( $ENV{DISPLAY} or $^O eq 'MSWin32' ) {
 
25
                plan skip_all => 'Needs DISPLAY';
 
26
                exit 0;
 
27
        }
 
28
}
 
29
 
 
30
# Test files
 
31
my %MIMES = (
 
32
        'eg/perl5/hello_world.pl'         => 'application/x-perl',
 
33
        'eg/perl5/perl5.pod'              => 'text/x-pod',
 
34
        'eg/perl5_with_perl6_example.pod' => 'text/x-pod',
 
35
        'eg/perl6/perl6.pod'              => 'text/x-pod',
 
36
        'eg/xml/xml_example'              => 'text/xml',
 
37
        'eg/tcl/hello_tcl'                => 'application/x-tcl',
 
38
        'eg/tcl/portable_tcl'             => 'application/x-tcl',
 
39
        'eg/ruby/hello_world.rb'          => 'application/x-ruby',
 
40
        'eg/ruby/hello_world_rb'          => 'application/x-ruby',
 
41
        'eg/python/hello_py'              => 'text/x-python',
 
42
);
 
43
 
 
44
plan tests => 9 + scalar keys %MIMES;
 
45
 
 
46
# This should only be used to skip dependencies out of the Document.pm - scope
 
47
# which are not required for testing, like Padre->ide. Never skip larger blocks
 
48
# with this!
 
49
$ENV{PADRE_IS_TEST} = 1;
 
50
 
 
51
use Test::NoWarnings;
 
52
use Encode     ();
 
53
use File::Spec ();
 
54
use t::lib::Padre;
 
55
use t::lib::Padre::Editor;
 
56
use Padre::Document;
 
57
use Padre::Document::Perl;
 
58
use Padre::MimeTypes;
 
59
use Padre::Locale ();
 
60
 
 
61
my $config = PadreTest::Config->new;
 
62
 
 
63
# Fake that Perl 6 support is enabled
 
64
Padre::MimeTypes->add_mime_class( 'application/x-perl6', 'Padre::Document::Perl' );
 
65
 
 
66
my $editor_1 = t::lib::Padre::Editor->new;
 
67
my $doc_1 = Padre::Document->new( config => $config );
 
68
 
 
69
SCOPE: {
 
70
        isa_ok( $doc_1, 'Padre::Document' );
 
71
        ok( not( defined $doc_1->filename ), 'no filename' );
 
72
}
 
73
 
 
74
my $editor_3 = t::lib::Padre::Editor->new;
 
75
my $file_3   = File::Spec->rel2abs( File::Spec->catfile( 'eg', 'hello_world.pl' ) );
 
76
my $doc_3    = Padre::Document->new(
 
77
        filename => $file_3,
 
78
        config   => $config,
 
79
);
 
80
 
 
81
isa_ok( $doc_3, 'Padre::Document' );
 
82
isa_ok( $doc_3, 'Padre::Document::Perl' );
 
83
is( $doc_3->filename, $file_3, 'filename' );
 
84
 
 
85
foreach my $file ( sort keys %MIMES ) {
 
86
        my $editor = t::lib::Padre::Editor->new;
 
87
        my $doc    = Padre::Document->new(
 
88
                filename => $file,
 
89
                config   => $config,
 
90
        );
 
91
        is( $doc->guess_mimetype, $MIMES{$file}, "mime of $file" );
 
92
}
 
93
 
 
94
# The following tests are for verifying that
 
95
# "ticket #889: Padre saves non-ASCII characters as \x{XXXX}"
 
96
# does not happen again
 
97
my ( $encoding, $content );
 
98
 
 
99
# English (ASCII)
 
100
$encoding = Padre::Locale::encoding_from_string(q{say "Hello!";});
 
101
is( $encoding, 'ascii', "Encoding should be ascii for English" );
 
102
 
 
103
# Russian (UTF-8)
 
104
$content = q{say "Превед!";};
 
105
Encode::_utf8_on($content);
 
106
$encoding = Padre::Locale::encoding_from_string($content);
 
107
is( $encoding, 'utf8', "Encoding should be utf8 for Russian" );
 
108
 
 
109
# Arabic (UTF-8)
 
110
$content = q{say "مرحبا!"; };
 
111
Encode::_utf8_on($content);
 
112
$encoding = Padre::Locale::encoding_from_string($content);
 
113
is( $encoding, 'utf8', "Encoding should be utf8 for Arabic" );
 
114
 
 
115
END {
 
116
        unlink for
 
117
                'eg/hello_world.pl',
 
118
                'eg/perl5/perl5_with_perl6_example.pod',
 
119
                ;
 
120
}