PageRenderTime 100ms CodeModel.GetById 40ms app.highlight 9ms RepoModel.GetById 31ms app.codeStats 0ms

/t/php/md5.t

https://github.com/bschmalhofer/pipp
Unknown | 85 lines | 64 code | 21 blank | 0 comment | 0 complexity | aa551282919580bcf8eefdb617e6f5cd MD5 | raw file
 1# Copyright (C) 2008, The Perl Foundation.
 2
 3=head1 NAME
 4
 5t/php/md5.t - Standard Library md5
 6
 7=head1 SYNOPSIS
 8
 9    % perl t/harness t/php/md5.t
10
11=head1 DESCRIPTION
12
13Tests PHP Standard Library md5
14(implemented in F<languages/pipp/src/common/php_md5.pir>).
15
16See L<http://www.php.net/manual/en/ref.strings.php>.
17
18=cut
19
20use strict;
21use warnings;
22
23use FindBin;
24use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";
25
26use Test::More     tests => 5;
27use Pipp::Test;
28
29
30language_output_is( 'Pipp', <<'CODE', <<'OUT', 'md5(msg)' );
31<?php
32  echo md5('message digest'), "\n";
33?>
34CODE
35f96b697d7cb7938d525a2f31aaf161d0
36OUT
37
38language_output_is( 'Pipp', <<'CODE', <<'OUT', 'md5(msg, FALSE)' );
39<?php
40  echo md5('message digest', FALSE), "\n";
41?>
42CODE
43f96b697d7cb7938d525a2f31aaf161d0
44OUT
45
46language_output_is( 'Pipp', <<'CODE', <<'OUT', 'md5(msg, TRUE)' );
47<?php
48  $md = md5('message digest', TRUE);
49  echo gettype($md), "\n";
50  echo strlen($md), "\n";
51?>
52CODE
53string
5416
55OUT
56
57unlink 'file.txt' if -f 'file.txt';
58open my $X, '>', 'file.txt';
59print {$X} 'message digest';
60close $X;
61
62language_output_is( 'Pipp', <<'CODE', <<'OUT', 'md5_file(file)' );
63<?php
64  echo md5_file('file.txt'), "\n";
65?>
66CODE
67f96b697d7cb7938d525a2f31aaf161d0
68OUT
69
70unlink 'file.txt' if -f 'file.txt';
71
72language_output_is( 'Pipp', <<'CODE', <<'OUT', 'md5_file(nofile)' );
73<?php
74  echo md5_file('nofile.txt'), "\n";
75?>
76CODE
77
78OUT
79
80# Local Variables:
81#   mode: cperl
82#   cperl-indent-level: 4
83#   fill-column: 100
84# End:
85# vim: expandtab shiftwidth=4: