"Fossies" - the Fresh Open Source Software Archive

Member "RPerl-5.002000/lib/RPerl/Test/TypeCheckingOn/all_types_good.pl" (30 Aug 2019, 4473 Bytes) of package /linux/misc/RPerl-5.002000.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "all_types_good.pl": 4.001000_vs_4.002000.

    1 #!/usr/bin/env perl
    2 
    3 # [[[ PREPROCESSOR ]]]
    4 # <<< EXECUTE_SUCCESS: '1' >>>
    5 
    6 # [[[ HEADER ]]]
    7 use RPerl;
    8 use strict;
    9 use warnings;
   10 our $VERSION = 0.002_000;
   11 
   12 # [[[ CRITICS ]]]
   13 ## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls)  # USER DEFAULT 1: allow numeric values & print operator
   14 ## no critic qw(RequireInterpolationOfMetachars)  # USER DEFAULT 2: allow single-quoted control characters & sigils
   15 
   16 # [[[ INCLUDES ]]]
   17 use RPerl::Test::TypeCheckingOn::AllTypes;
   18 
   19 # [[[ OPERATIONS ]]]
   20 
   21 my RPerl::Test::TypeCheckingOn::AllTypes $alltypes_object = RPerl::Test::TypeCheckingOn::AllTypes->new();
   22 $alltypes_object->check_class();
   23 $alltypes_object->check_class_integer(23);
   24 
   25 check_integer(0);
   26 check_integer(1);
   27 check_integer(555_555);
   28 check_integer(-1);
   29 check_integer(-555_555);
   30 
   31 check_number(0);
   32 check_number(1);
   33 check_number(555_555);
   34 check_number(-1);
   35 check_number(-555_555);
   36 check_number(0.123_456);
   37 check_number(1.123_456);
   38 check_number(555_555.123_456);
   39 check_number(-1.123_456);
   40 check_number(-555_555.123_456);
   41 
   42 check_string(q{});
   43 check_string('0');
   44 check_string('a');
   45 check_string('0123abcd');
   46 check_string(q{0123abcd});
   47 check_string('0123abcd\\n');
   48 check_string(q{0123abcd\\n});
   49 check_string("0123abcd\n");
   50 check_string('0123$abcd');
   51 check_string(q{0123$abcd});
   52 
   53 check_arrayref( [] );
   54 check_arrayref( [0] );
   55 check_arrayref( [0.123] );
   56 check_arrayref( ['abcd'] );
   57 check_arrayref( [ 0, 0, 0 ] );
   58 check_arrayref( [ 0.123, 0.123, 0.123 ] );
   59 check_arrayref( [ 'abcd', 'abcd', 'abcd' ] );
   60 check_arrayref( [ 0, -0.123_456, 'abcd' ] );
   61 check_arrayref( [   0, -0.123_456, 'abcd', [ 2, 4, 6, 8 ], { a => 'hello', b => 'howdy', c => 'ahoy' } ] );
   62 
   63 check_integer_arrayref( [] );
   64 check_integer_arrayref( [0] );
   65 check_integer_arrayref( [ 0, 1, 2, 3 ] );
   66 check_integer_arrayref( [ -999_999, 0, 1, 2, 3 ] );
   67 
   68 check_number_arrayref( [] );
   69 check_number_arrayref( [0] );
   70 check_number_arrayref( [ 0, 1, 2, 3 ] );
   71 check_number_arrayref( [ -999_999, 0, 1, 2, 3 ] );
   72 check_number_arrayref( [0.123] );
   73 check_number_arrayref( [ 0.123, 1.123, 2.123, 3.123 ] );
   74 check_number_arrayref( [ -999_999.123_456, 0.123, 1, 2, 3 ] );
   75 
   76 my number_arrayref $input_1 = [ -999_999, 0.0,  0.0,  0.0 ];
   77 my number_arrayref $input_2 = [ -999_999, 3.0,  4.0,  12.0 ];
   78 my number_arrayref $input_3 = [ -999_999, 23.0, 42.0, 2_112.0 ];
   79 check_number_arrayrefs( $input_1, $input_2, $input_3 );
   80 
   81 check_string_arrayref( [] );
   82 check_string_arrayref( ['0'] );
   83 check_string_arrayref( [ '0', 'a', '0123abcd' ] );
   84 check_string_arrayref( [ '0', 'a', '0123abcd', q{0}, q{a}, q{0123abcd} ] );
   85 check_string_arrayref( [ '0\\n', '$a', '0123$abcd', q{0}, q{a\\n}, q{0123abcd\\n} ] );
   86 check_string_arrayref( [ "0\n", "a\n", "0123abcd\n" ] );
   87 
   88 check_hashref( {} );
   89 check_hashref( { a => 0 } );
   90 check_hashref( { a => 0.123 } );
   91 check_hashref( { a => 'abcd' } );
   92 check_hashref( { a => 0, b => 0, c => 0 } );
   93 check_hashref( { a => 0.123, b => 0.123, c => 0.123 } );
   94 check_hashref( { a => 'abcd', b => 'abcd', c => 'abcd' } );
   95 check_hashref( {   a => 0, b => -0.123_456, c => 'abcd', d => [ 2, 4, 6, 8 ], e => { a => 'hello', b => 'howdy', c => 'ahoy' } } );
   96 check_integer_hashref( {} );
   97 check_integer_hashref( { a => 0 } );
   98 check_integer_hashref( { a => 0, b => 1, c => 2, d => 3 } );
   99 check_integer_hashref( { aa => -999_999, a => 0, b => 1, c => 2, d => 3 } );
  100 
  101 check_number_hashref( {} );
  102 check_number_hashref( { a => 0 } );
  103 check_number_hashref( { a => 0, b => 1, c => 2, d => 3 } );
  104 check_number_hashref( { aa => -999_999, a => 0, b => 1, c => 2, d => 3 } );
  105 check_number_hashref( { a => 0.123 } );
  106 check_number_hashref( { a => 0.123, b => 1.123, c => 2.123, d => 3.123 } );
  107 check_number_hashref( { aa => -999_999.123_456, a => 0.123, b => 1, c => 2, d => 3 } );
  108 
  109 my number_hashref $input_4 = { a => -999_999, b => 0.0, c => 0.0, d => 0.0 };
  110 my number_hashref $input_5 = { a => -999_999, b => 3.0, c => 4.0, d => 12.0 };
  111 my number_hashref $input_6 = { a => -999_999, b => 23.0, c => 42.0, d => 2_112.0 };
  112 check_number_hashrefs( $input_4, $input_5, $input_6 );
  113 
  114 check_string_hashref( {} );
  115 check_string_hashref( { a => '0' } );
  116 check_string_hashref( { a => '0', b => 'a', c => '0123abcd' } );
  117 check_string_hashref( {   a => '0', b => 'a', c => '0123abcd', d => q{0}, e => q{a}, f => q{0123abcd} } );
  118 check_string_hashref( {   a => '0\\n', b => '$a', c => '0123$abcd', d => q{0}, e => q{a\\n}, f => q{0123abcd\\n} } );
  119 check_string_hashref( {   a => "0\n", b => "a\n", c => "0123abcd\n" });
  120 
  121 print "1\n";