Skip to main content
  • Home
  • login
  • Browse the archive

    swh mirror partner logo
swh logo
SoftwareHeritage
Software
Heritage
Mirror
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • 52563f6
  • /
  • util
  • /
  • c-compress-test.pl
Raw File
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:8ea3e045bc4fbee8d377e5500f0199954d9b1fd4
directory badge Iframe embedding
swh:1:dir:7f0a5e8e02998943201dec1ebeb2f1323aa4f692
c-compress-test.pl
#! /usr/bin/env perl
#
# TEST c-compress-pl with a number of examples and what should happen to them

use strict;
use warnings;

use File::Basename;

my @pairs =
    (
     [ <<'_____'
/* A hell of a program */
#def\
ine foo/* bar */ 3
#define bar /* haha "A /* comment */ that should    /* remain" */
#define  haha /* hoho */ "A /* comment */ that should /* remain" */

int main() {
    int x;
    /* one lonely comment */
}
_____
       , <<'_____'
#define foo 3
#define bar that should
#define haha "A /* comment */ that should /* remain" */
int main() {
int x;
}
_____
     ]
    );

my $here = dirname $0;
my $c_compress = "$here/lang-compress.pl";

use FileHandle;
use IPC::Open2;
use Text::Diff;
foreach (@pairs) {
    my $source = $_->[0];
    my $expected = $_->[1];
    my $pid = open2(\*Reader, \*Writer, "perl $c_compress 'C'");
    print Writer $source;
    close Writer;

    local $/ = undef;             # slurp
    my $got = <Reader>;

    if ($got ne $expected) {
        print "MISMATCH:\n", diff \$expected, \$got;
    }
}

ENEA — Copyright (C), ENEA. License: GNU AGPLv3+.
Legal notes  ::  JavaScript license information ::  Web API

back to top