]> git.sesse.net Git - xml-template/commitdiff
Add a new "attribute3" test, for testing undef/NULL/None behaviour (new
authorsgunderson@bigfoot.com <>
Wed, 4 Oct 2006 01:02:48 +0000 (03:02 +0200)
committersgunderson@bigfoot.com <>
Wed, 4 Oct 2006 01:02:48 +0000 (03:02 +0200)
in spec, all fail).

perl/attribute3.pl [new file with mode: 0644]
php/attribute3.php [new file with mode: 0644]
python/attribute3.py [new file with mode: 0644]
tests/reference/attribute3.xml [new file with mode: 0644]
tests/test.sh

diff --git a/perl/attribute3.pl b/perl/attribute3.pl
new file mode 100644 (file)
index 0000000..1924c03
--- /dev/null
@@ -0,0 +1,14 @@
+#! /usr/bin/perl
+use XML::Template;
+
+my $doc = XML::Template::process_file('../xml/clone.xml', {
+       'color' => 'blue',
+       '#things' => XML::Template::alternate('li/class', [
+               { 'li' => 'Raindrops on roses' },
+               { 'li' => 'Whiskers on kittens' },
+               undef,
+               { 'li' => 'Bright copper kettles' },
+               { 'li' => 'Warm, woolen mittens'},
+       ], 'odd', 'even')
+});
+print $doc->toString;
diff --git a/php/attribute3.php b/php/attribute3.php
new file mode 100644 (file)
index 0000000..f4fa718
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+require('xml-template.php');
+
+$doc = XML_Template_process_file('../xml/clone.xml', array(
+       'color' => 'blue',
+       '#things' => XML_Template_alternate('li/class', array(
+               array( 'li' => 'Raindrops on roses' ),
+               array( 'li' => 'Whiskers on kittens' ),
+               NULL,
+               array( 'li' => 'Bright copper kettles' ),
+               array( 'li' => 'Warm, woolen mittens' ),
+       ), array('odd', 'even'))
+));
+print $doc->dump_mem();
+?>
diff --git a/python/attribute3.py b/python/attribute3.py
new file mode 100644 (file)
index 0000000..9c6ffbf
--- /dev/null
@@ -0,0 +1,14 @@
+#! /usr/bin/python
+import xmltemplate
+
+doc = xmltemplate.process_file("../xml/clone.xml", {
+       "color": "blue",
+       "#things": xmltemplate.alternate("li/class", [
+               { "li": "Raindrops on roses" },
+               { "li": "Whiskers on kittens" },
+               None,
+               { "li": "Bright copper kettles" },
+               { "li": "Warm, woolen mittens"},
+       ], "odd", "even")
+});
+print doc.toxml()
diff --git a/tests/reference/attribute3.xml b/tests/reference/attribute3.xml
new file mode 100644 (file)
index 0000000..d972834
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+  <head>
+    <title>Cloning test</title>
+  </head>
+  <body>
+     <p>My favourite color is blue; I like that very much.
+       All my favourite things:</p>
+    <ul>
+      <li class="odd">Raindrops on roses</li>
+      <li class="even">Whiskers on kittens</li>
+      <li class="odd">Bright copper kettles</li>
+      <li class="even">Warm, woolen mittens</li>
+    </ul>
+  </body>
+</html>
index 19c6cf989dfbddf67eaa921bc8558a9c1d187d27..38ab5e4a7336f9919aca5bd3bf1c58f7e4ee1713 100755 (executable)
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 if [ -z "$TESTS" ]; then
-       TESTS="passthru simple clone include attribute attribute2 attribute-empty"
+       TESTS="passthru simple clone include attribute attribute2 attribute3 attribute-empty"
 fi
 if [ -z "$LANGUAGES" ]; then
        LANGUAGES="perl php python"