summaryrefslogtreecommitdiff
path: root/testWorkspace/slimTest.pl
blob: afd72e9cb429ebd7908afe932dc4f2823ad4c02a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# mainTest.pl uses a variety of non-core things (e.g. Moo/Moose) as well as recent Perl Constructs (e.g. signatures)
# slimTest.pl is for testing with a barebones Perl 5.8

use strict;
use warnings;
use utf8;
use FindBin qw($Bin);
use File::Spec;
use lib "$Bin";
# These are system test modules
use Data::Dumper;                    # Module details. Dumper is auto-exported
use Cwd qw(fast_abs_path);           # fast_abs_path is pure perl.
use MIME::Base64 qw(encode_base64);  # encode_base64 is XS, so the best we can do is find the .pm

# Workspace modules
use MyLib::NamedPackage qw(exported_sub imported_constant $our_variable);
use MyLib::MyClass;
use MyLib::MyOtherClass;
use MyLib::NonPackage;
use MyLib::DBI;
use MySubClass;

use constant MYCONSTANT => 6;

my $my_scalar = 1;
my @my_array = (2,2);
my $array_ref = [3,3];
my %my_hash = ("Four"=>4);
my $hash_ref = {"Five"=>5};
my $üτfⅷ = 8;
my $üτfⅷ = 9; # 2nd declaration to test warnings.

print "\n------ Variables --------\n";
print $my_scalar;
print ${my_scalar};

print $my_array[0];
print "@my_array";
print $array_ref->[0];
print $$array_ref[0];
print "@$array_ref";
print $my_hash{"Four"};
print %my_hash;
print $hash_ref->{"Five"};
print $$hash_ref{"Five"};
print $üτfⅷ;

{
    # Run this on severity 3 to see the butchered utf-8 name via Variables::ProhibitReusedNames. It does work though
    my $üτfⅷ = 2;
}

print MYCONSTANT;

LABEL1: for (0..4) {
    LABEL2: foreach my $lexLoopDuplicate (0..4) {
        next LABEL2 if $lexLoopDuplicate > 2;
        last LABEL1;
    }
}

foreach my $lexLoopDuplicate (1..3){
    print $lexLoopDuplicate;
}

for (my $cStyleLoopVar = 0; $cStyleLoopVar <= 2; $cStyleLoopVar++){
    print "$cStyleLoopVar";
}

print imported_constant . "\n";

print $our_variable . "\n";

sub same_script_sub {
    my $functionVar = shift;
    print "$functionVar\n";
}


print "\n------ Subs --------\n";
same_script_sub("FooSix");
SameFilePackage::same_file_package_sub();
duplicate_sub_name();
nonpackage_sub();
exported_sub();
MyLib::NamedPackage::non_exported_sub();
MyLib::NamedPackage::duplicate_sub_name();
MyLib::SubPackage::subpackage_mod();

print Dumper(\%my_hash);
print fast_abs_path($0) . "\n";
print encode_base64($0) . "\n";

print "\n ------ Methods and Attributes ------\n";

my $testObj = MyLib::MyClass->new();
$testObj->overridden_method();

my $subObj = MySubClass->new();
$subObj->overridden_method();
$subObj->inherited_method();

my $otherObj = MyLib::MyOtherClass->new();
$otherObj->unique_method_name();
$otherObj->duplicate_method_name();

my $unknownObj = $otherObj;
$unknownObj->duplicate_method_name();

my $hiddenPackObj = MyLib::SubPackage->new();

my $dbh2 = MyLib::DBI->connect();


print "\nDone with test script\n";

package SameFilePackage; ## no critic (package)

sub same_file_package_sub {
    print "In same_file_package_sub\n";
}