Skip to content
This repository has been archived by the owner on Jun 9, 2018. It is now read-only.

Commit

Permalink
convert tests to PIR (from Perl)
Browse files Browse the repository at this point in the history
  • Loading branch information
fperrad committed Nov 6, 2009
1 parent 14487d8 commit 66df44d
Show file tree
Hide file tree
Showing 12 changed files with 357 additions and 310 deletions.
21 changes: 8 additions & 13 deletions build/Makefile.in
Expand Up @@ -62,10 +62,6 @@ BUILD_CLEANUPS := \
#IF(win32): parrot-xml.iss \
#IF(win32): "setup-parrot-*.exe" \
TEST_CLEANUPS := \
"t/*.xml" \
"t/*.out"

# the default target
build: xml.pbc sax/xml/xml.pbc handler/xmlwriter/xmlwriter.pbc

Expand Down Expand Up @@ -125,23 +121,22 @@ help:
@echo ""

test: build
$(PERL) -I$(LIB_DIR)/tools/lib t/harness
prove --exec=$(PARROT) t//*.t

install:
-$(MKPATH) $(LIB_DIR)/languages/xml
$(CP) xml.pbc $(LIB_DIR)/languages/xml/xml.pbc
#install:
# -$(MKPATH) $(LIB_DIR)/languages/xml
# $(CP) xml.pbc $(LIB_DIR)/languages/xml/xml.pbc

uninstall:
$(RM_RF) $(LIB_DIR)/languages/xml
#uninstall:
# $(RM_RF) $(LIB_DIR)/languages/xml

testclean:
$(RM_F) $(TEST_CLEANUPS)

clean:
$(RM_F) $(TEST_CLEANUPS) $(BUILD_CLEANUPS)
$(RM_F) $(BUILD_CLEANUPS)

realclean:
$(RM_F) $(TEST_CLEANUPS) $(BUILD_CLEANUPS) Makefile
$(RM_F) $(BUILD_CLEANUPS) Makefile

distclean: realclean

Expand Down
35 changes: 20 additions & 15 deletions t/00-sanity.t
@@ -1,35 +1,40 @@
#! perl
#! /usr/local/bin/parrot
# Copyright (C) 2009, Parrot Foundation.

=head1 some XML examples

=head2 Synopsis

% perl t/00-sanity.t
% parrot t/00-sanity.t

=head2 Description

First tests in order to check infrastructure.

=cut

use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../lib", "$FindBin::Bin";
.sub 'main' :main
load_bytecode 'xml.pir'

use Parrot::Test tests => 1;
use Test::More;
.include 'test_more.pir'

language_output_is( 'xml', <<'CODE', <<'OUT', 'ex1' );
<elt>content</elt>
CODE
plan(1)

test_1()
.end

.sub 'test_1'
$S1 = <<'XML'
<elt>content</elt>
OUT
XML
$S0 = 'xml_to_xml'($S1)
is($S0, $S1, 'ex1')
.end


# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4:
# vim: expandtab shiftwidth=4 ft=pir:

50 changes: 27 additions & 23 deletions t/10-comment.t
@@ -1,45 +1,49 @@
#! perl
#! /usr/local/bin/parrot
# Copyright (C) 2009, Parrot Foundation.

=head1 Comment

=head2 Synopsis

% perl t/10-comment.t
% parrot t/10-comment.t

=cut

use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../lib", "$FindBin::Bin";
.sub 'main' :main
load_bytecode 'xml.pir'

use Parrot::Test tests => 2;
use Test::More;
.include 'test_more.pir'

language_output_is( 'xml', <<'CODE', <<'OUT', 'some comments' );
<!-- first comment --><elt><!-- other comment --></elt><!-- final comment -->
CODE
plan(2)

test_1()
test_2()
.end

.sub 'test_1'
$S1 = <<'XML'
<!-- first comment --><elt><!-- other comment --></elt><!-- final comment -->
OUT
XML
$S0 = 'xml_to_xml'($S1)
is($S0, $S1, 'some comments')
.end

language_output_is( 'xml', <<'CODE', <<'OUT', 'some comments' );
<elt>
<!--
multi-line comment
-->
</elt>
CODE
.sub 'test_2'
$S1 = <<'XML'
<elt>
<!--
multi-line comment
-->
</elt>
OUT
XML
$S0 = 'xml_to_xml'($S1)
is($S0, $S1, 'some comments')
.end


# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4:
# vim: expandtab shiftwidth=4 ft=pir:

44 changes: 27 additions & 17 deletions t/11-pi.t
@@ -1,37 +1,47 @@
#! perl
#! /usr/local/bin/parrot
# Copyright (C) 2009, Parrot Foundation.

=head1 Processing Instruction

=head2 Synopsis

% perl t/11-pi.t
% parrot t/11-pi.t

=cut

use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../lib", "$FindBin::Bin";
.sub 'main' :main
load_bytecode 'xml.pir'

use Parrot::Test tests => 2;
use Test::More;
.include 'test_more.pir'

language_output_is( 'xml', <<'CODE', <<'OUT', 'some PI' );
<?first_pi?><elt><?other_pi?></elt><?final_pi?>
CODE
plan(2)

test_1()
test_2()
.end

.sub 'test_1'
$S1 = <<'XML'
<?first_pi?><elt><?other_pi?></elt><?final_pi?>
OUT
XML
$S0 = 'xml_to_xml'($S1)
is($S0, $S1, 'some PI')
.end

language_output_is( 'xml', <<'CODE', <<'OUT', 'with data' );
.sub 'test_2'
$S1 = <<'XML'
<?first_pi 42?><elt><?other_pi with many words ?></elt><?final_pi 42?>
CODE
XML
$S0 = 'xml_to_xml'($S1)
is($S0, <<'OUT', 'with data')
<?first_pi 42?><elt><?other_pi with many words ?></elt><?final_pi 42?>
OUT
.end


# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4:
# vim: expandtab shiftwidth=4 ft=pir:

46 changes: 27 additions & 19 deletions t/12-cdata.t
@@ -1,37 +1,45 @@
#! perl
#! /usr/local/bin/parrot
# Copyright (C) 2009, Parrot Foundation.

=head1 CDATA Sections

=head2 Synopsis

% perl t/12-cdata.t
% parrot t/12-cdata.t

=cut

use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../lib", "$FindBin::Bin";
.sub 'main' :main
load_bytecode 'xml.pir'

use Parrot::Test tests => 2;
use Test::More;
.include 'test_more.pir'

language_output_is( 'xml', <<'CODE', <<'OUT', 'cdata' );
<elt><![CDATA[content]]></elt>
CODE
plan(2)

test_1()
test_2()
.end

.sub 'test_1'
$S1 = <<'XML'
<elt><![CDATA[content]]></elt>
OUT
XML
$S0 = 'xml_to_xml'($S1)
is($S0, $S1, 'cdata')
.end

language_output_is( 'xml', <<'CODE', <<'OUT', 'cdata' );
.sub 'test_2'
$S1 = <<'XML'
<elt><![CDATA[ <>&'" ]]></elt>
CODE
<elt><![CDATA[ <>&'" ]]></elt>
OUT
XML
$S0 = 'xml_to_xml'($S1)
is($S0, $S1, 'cdata')
.end
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4:
# vim: expandtab shiftwidth=4 ft=pir:
51 changes: 34 additions & 17 deletions t/13-xmldecl.t
@@ -1,46 +1,63 @@
#! perl
#! /usr/local/bin/parrot
# Copyright (C) 2009, Parrot Foundation.

=head1 XML Declaration

=head2 Synopsis

% perl t/13-xmldecl.t
% parrot t/13-xmldecl.t

=cut

use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../lib", "$FindBin::Bin";
.sub 'main' :main
load_bytecode 'xml.pir'

use Parrot::Test tests => 3;
use Test::More;
.include 'test_more.pir'

language_output_is( 'xml', <<'CODE', <<'OUT', 'version' );
plan(3)

test_version()
test_encoding()
test_standalone()
.end

.sub 'test_version'
$S1 = <<'XML'
<?xml version='1.0'?><elt>content</elt>
CODE
XML
$S0 = 'xml_to_xml'($S1)
is($S0, <<'OUT', 'version')
<?xml version="1.0"?>
<elt>content</elt>
OUT
.end

language_output_is( 'xml', <<'CODE', <<'OUT', 'encoding' );
.sub 'test_encoding'
$S1 = <<'XML'
<?xml version='1.0' encoding='utf-8'?><elt>content</elt>
CODE
XML
$S0 = 'xml_to_xml'($S1)
is($S0, <<'OUT', 'encoding')
<?xml version="1.0" encoding="utf-8"?>
<elt>content</elt>
OUT
.end

language_output_is( 'xml', <<'CODE', <<'OUT', 'standalone' );
.sub 'test_standalone'
$S1 = <<'XML'
<?xml version='1.0' standalone="yes"?><elt>content</elt>
CODE
XML
$S0 = 'xml_to_xml'($S1)
is($S0, <<'OUT', 'standalone')
<?xml version="1.0" standalone="yes"?>
<elt>content</elt>
OUT
.end


# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4:
# vim: expandtab shiftwidth=4 ft=pir:

0 comments on commit 66df44d

Please sign in to comment.