3
package PadreTest::Config;
10
my $self = bless {@_}, $class;
13
sub editor_file_size_limit {
24
unless ( $ENV{DISPLAY} or $^O eq 'MSWin32' ) {
25
plan skip_all => 'Needs DISPLAY';
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',
44
plan tests => 9 + scalar keys %MIMES;
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
49
$ENV{PADRE_IS_TEST} = 1;
55
use t::lib::Padre::Editor;
57
use Padre::Document::Perl;
61
my $config = PadreTest::Config->new;
63
# Fake that Perl 6 support is enabled
64
Padre::MimeTypes->add_mime_class( 'application/x-perl6', 'Padre::Document::Perl' );
66
my $editor_1 = t::lib::Padre::Editor->new;
67
my $doc_1 = Padre::Document->new( config => $config );
70
isa_ok( $doc_1, 'Padre::Document' );
71
ok( not( defined $doc_1->filename ), 'no filename' );
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(
81
isa_ok( $doc_3, 'Padre::Document' );
82
isa_ok( $doc_3, 'Padre::Document::Perl' );
83
is( $doc_3->filename, $file_3, 'filename' );
85
foreach my $file ( sort keys %MIMES ) {
86
my $editor = t::lib::Padre::Editor->new;
87
my $doc = Padre::Document->new(
91
is( $doc->guess_mimetype, $MIMES{$file}, "mime of $file" );
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 );
100
$encoding = Padre::Locale::encoding_from_string(q{say "Hello!";});
101
is( $encoding, 'ascii', "Encoding should be ascii for English" );
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" );
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" );
118
'eg/perl5/perl5_with_perl6_example.pod',