[Jifty-commit] r2347 - Template-Declare/t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Dec 8 10:01:27 EST 2006
Author: audreyt
Date: Fri Dec 8 10:01:27 2006
New Revision: 2347
Modified:
Template-Declare/t/arg-declaration-styles.t
Template-Declare/t/trivial.t
Log:
* Fix tests to agree with code ;)
Modified: Template-Declare/t/arg-declaration-styles.t
==============================================================================
--- Template-Declare/t/arg-declaration-styles.t (original)
+++ Template-Declare/t/arg-declaration-styles.t Fri Dec 8 10:01:27 2006
@@ -1,67 +1,66 @@
use warnings;
use strict;
-
package TestApp::UI;
use base qw/Template::Declare/;
use Template::Declare::Tags;
template content => sub {
- with( id => 'body' ), div {
- outs('This is my content');
- };
+ with( id => 'body' ), div {
+ outs('This is my content');
+ };
};
template content_curly => sub {
- div {
- { id is 'body'}
- outs('This is my content');
- }
+ div {
+ { id is 'body' }
+ outs('This is my content');
+ }
};
template content_explicit => sub {
- div {
- attr { id is 'body' }
- outs('This is my content');
- }
+ div {
+ attr { id is 'body' }
+ outs('This is my content');
+ }
};
template content_mixed1 => sub {
- div {
- { class is 'text'}
- attr { style => 'red', id is 'body' }
- outs('This is my red body text');
- }
+ div {
+ { class is 'text' }
+ attr { style => 'red', id is 'body' }
+ outs('This is my red body text');
+ }
};
template content_mixed2 => sub {
- with ( class => 'text'), div {
- { id is 'body'}
- attr { style => 'red' }; # Semicolon is intentional here
- outs('This is my red body text');
- }
+ with( class => 'text' ), div {
+ { id is 'body' }
+ attr { style => 'red' }; # Semicolon is intentional here
+ outs('This is my red body text');
+ }
};
template content_withs => sub {
- with ( class => 'text', id=>'body', style => 'red'), div {
- outs('This is my red body text');
- }
+ with( class => 'text', id => 'body', style => 'red' ), div {
+ outs('This is my red body text');
+ }
};
template content_curlies => sub {
- div {
- { class is 'text', id is 'body', style is 'red'}
- outs('This is my red body text');
- }
+ div {
+ { class is 'text', id is 'body', style is 'red' }
+ outs('This is my red body text');
+ }
};
template content_attrs => sub {
- div {
- attr { class => 'text', id => 'body', style => 'red' }
- outs('This is my red body text');
- }
+ div {
+ attr { class => 'text', id => 'body', style => 'red' }
+ outs('This is my red body text');
+ }
};
package Template::Declare::Tags;
@@ -72,17 +71,19 @@
local $self = {};
bless $self, 'TestApp::UI';
-for (qw(content content_curly content_explicit)){
-local $Template::Declare::Tags::BUFFER;
-ok_content(show($_),$_);
+for (qw(content content_curly content_explicit)) {
+ local $Template::Declare::Tags::BUFFER;
+ ok_content( show($_), $_ );
}
-for (qw(content_mixed1 content_mixed2 content_attrs content_withs content_curlies)){
-local $Template::Declare::Tags::BUFFER;
-ok_multicontent(show($_),$_);
+for (
+ qw(content_mixed1 content_mixed2 content_attrs content_withs content_curlies)
+ )
+{
+ local $Template::Declare::Tags::BUFFER;
+ ok_multicontent( show($_), $_ );
}
-
sub ok_lint {
my $html = shift;
@@ -91,32 +92,34 @@
$lint->parse($html);
is( $lint->errors, 0, "Lint checked clean" );
foreach my $error ( $lint->errors ) {
+
#diag( $error->as_string );
}
}
-sub ok_multicontent{
-my $simple = shift;
-my $test = shift;
-ok($simple =~ 'This is my red body text');
-ok ($simple =~ qr{^<div (.*?)>This is my red body text\s*</div>$}m, $test);
-ok ($simple =~ qr{class="text"}, $test);
-ok ($simple =~ qr{style="red"}, $test);
-ok ($simple =~ qr{id="body"}, $test);
-#diag ($simple);
-ok_lint($simple);
+sub ok_multicontent {
+ my $simple = shift;
+ my $test = shift;
+ like( $simple, qr{This is my red body text}, $test );
+ like( $simple, qr{^<div (.*?)>This is my red body text\s*</div>$}m, $test );
+ like( $simple, qr{class="text"}, $test );
+ like( $simple, qr{style="red"}, $test );
+ like( $simple, qr{id="body"}, $test );
+
+ #diag ($simple);
+ ok_lint($simple);
}
+sub ok_content {
+ my $simple = shift;
+ my $test = shift;
+ like( $simple, qr{This is my content}, $test );
+ like( $simple, qr{<div id="body">This is my content\s*</div>}, $test );
-sub ok_content{
-my $simple = shift;
-my $test =shift;
-ok($simple =~ 'This is my content');
-ok ($simple =~ qr{<div id="body">This is my content\s*</div>},$test);
-#diag ($simple);
-ok_lint($simple);
+ #diag ($simple);
+ ok_lint($simple);
}
1;
Modified: Template-Declare/t/trivial.t
==============================================================================
--- Template-Declare/t/trivial.t (original)
+++ Template-Declare/t/trivial.t Fri Dec 8 10:01:27 2006
@@ -10,33 +10,32 @@
template simple => sub {
html {
- head { };
+ head { }
body {
- show 'content';
+ show 'content'
}
}
};
template content => sub {
- with( id => 'body' ), div {
- outs('This is my content');
- };
+ div { attr { id => 'body' }
+ outs('This is my content')
+ }
};
template wrapper => sub {
my ( $title, $coderef) = (@_);
- outs('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
+ outs '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
with ( xmlns => "http://www.w3.org/1999/xhtml", 'xml:lang' => "en"),
html {
head {
- with ( 'http-equiv' => "content-type", 'content' => "text/html; charset=utf-8"),
- meta { };
- with ( name => "robots", content => "all"), meta { };
- title { outs($title) };
- };
+ meta { attr { 'http-equiv' => "content-type", 'content' => "text/html; charset=utf-8" } }
+ meta { attr { name => 'robots', content => 'all' } }
+ title { outs($title) }
+ }
body {
$coderef->();
}
@@ -54,91 +53,86 @@
with( id => 'syntax' ), div {
div {
- with(
- href => "#",
- onclick =>
- "Element.toggle('syntax_content');return(false);"
- ),
- a {
- b {'Wiki Syntax Help'};
- }
+ a { attr { href => '#', onclick => "Element.toggle('syntax_content');return(false);" }
+ b {'Wiki Syntax Help'}
+ }
};
with( id => 'syntax_content' ), div {
- h3 {'Phrase Emphasis'};
+ h3 {'Phrase Emphasis'}
code {
- b { '**bold**'; };
- i {'_italic_'};
- };
-
- h3 {'Links'};
-
- code {'Show me a [wiki page](WikiPage)'};
- code {'An [example](http://url.com/ "Title")'};
- h3 {'Headers'};
+ b { '**bold**' }
+ i {'_italic_'}
+ }
+
+ h3 {'Links'}
+
+ code {'Show me a [wiki page](WikiPage)'}
+ code {'An [example](http://url.com/ "Title")'}
+ h3 {'Headers'}
pre {
code {
join( "\n",
'# Header 1',
'## Header 2',
- '###### Header 6' );
+ '###### Header 6' )
}
- };
- h3 {'Lists'};
- p {'Ordered, without paragraphs:'};
+ }
+ h3 {'Lists'}
+ p {'Ordered, without paragraphs:'}
pre {
- code { join( "\n", '1. Foo', '2. Bar' ); };
- };
- p {' Unordered, with paragraphs:'};
+ code { join( "\n", '1. Foo', '2. Bar' ) }
+ }
+ p {'Unordered, with paragraphs:'}
pre {
code {
join( "\n",
'* A list item.',
'With multiple paragraphs.',
- '* Bar' );
+ '* Bar' )
}
- };
- h3 {'Code Spans'};
+ }
+ h3 {'Code Spans'}
p {
code {'`<code>`'}
- . 'spans are delimited by backticks.';
- };
+ . 'spans are delimited by backticks.'
+ }
- h3 {'Preformatted Code Blocks'};
+ h3 {'Preformatted Code Blocks'}
p {
- 'Indent every line of a code block by at least 4 spaces.';
- };
+ 'Indent every line of a code block by at least 4 spaces.'
+ }
pre {
code {
'This is a normal paragraph.' . "\n\n" . "\n"
. ' This is a preformatted' . "\n"
- . ' code block.';
- };
- };
+ . ' code block.'
+ }
+ }
- h3 {'Horizontal Rules'};
+ h3 {'Horizontal Rules'}
p {
- 'Three or more dashes: ' . code {'---'};
- };
+ 'Three or more dashes: ' . code {'---'}
+ }
address {
- '(Thanks to <a href="http://daringfireball.net/projects/markdown/dingus">Daring Fireball</a>)';
+ '(Thanks to <a href="http://daringfireball.net/projects/markdown/dingus">Daring Fireball</a>)'
}
}
- };
+ }
script {
qq{
// javascript flyout by Eric Wilhelm
// TODO use images for minimize/maximize button
// Is there a way to add a callback?
- Element.toggle('syntax_content');
- };
- };
+ Element.toggle('syntax_content')
+ }
+ }
}
- );
+ )
};
package Template::Declare::Tags;
More information about the Jifty-commit
mailing list