From 49db5f5704835b7336c67ecf4ba14a5a5f3a8527 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 28 Sep 2012 17:33:47 -0500 Subject: remove test numbers --- t/001-basic.t | 18 ------------------ t/002-expressions.t | 34 ---------------------------------- t/003-safestring.t | 35 ----------------------------------- t/004-helpers.t | 47 ----------------------------------------------- t/basic.t | 18 ++++++++++++++++++ t/expressions.t | 34 ++++++++++++++++++++++++++++++++++ t/helpers.t | 47 +++++++++++++++++++++++++++++++++++++++++++++++ t/safestring.t | 35 +++++++++++++++++++++++++++++++++++ 8 files changed, 134 insertions(+), 134 deletions(-) delete mode 100644 t/001-basic.t delete mode 100644 t/002-expressions.t delete mode 100644 t/003-safestring.t delete mode 100644 t/004-helpers.t create mode 100644 t/basic.t create mode 100644 t/expressions.t create mode 100644 t/helpers.t create mode 100644 t/safestring.t (limited to 't') diff --git a/t/001-basic.t b/t/001-basic.t deleted file mode 100644 index 28d54c1..0000000 --- a/t/001-basic.t +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More; - -use Text::Handlebars; - -my $tx = Text::Handlebars->new; - -is( - $tx->render_string( - 'Hello, {{dialect}} world!', - { dialect => 'Handlebars' }, - ), - 'Hello, Handlebars world!', -); - -done_testing; diff --git a/t/002-expressions.t b/t/002-expressions.t deleted file mode 100644 index 730196f..0000000 --- a/t/002-expressions.t +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More; - -use Text::Handlebars; - -my $tx = Text::Handlebars->new; - -is( - $tx->render_string( - '

{{title}}

', - { title => 'Xslate rocks' }, - ), - '

Xslate rocks

', -); - -is( - $tx->render_string( - '

{{article.title}}

', - { article => { title => 'Hash references rock' } }, - ), - '

Hash references rock

', -); - -is( - $tx->render_string( - '

{{article/title}}

', - { article => { title => 'Deprecated syntax does not' } }, - ), - '

Deprecated syntax does not

', -); - -done_testing; diff --git a/t/003-safestring.t b/t/003-safestring.t deleted file mode 100644 index 27d9ac1..0000000 --- a/t/003-safestring.t +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More; - -use Text::Handlebars; -use Text::Xslate 'mark_raw'; - -my $tx = Text::Handlebars->new; - -is( - $tx->render_string( - '

{{title}}

{{{body}}}

', - { title => 'My New Post', body => 'This is my first post!' }, - ), - '

My New Post

This is my first post!

', -); - -is( - $tx->render_string( - '

{{title}}

{{{body}}}

', - { title => 'All About

Tags', body => 'This is a post about <p> tags' }, - ), - '

All About <p> Tags

This is a post about <p> tags

', -); - -is( - $tx->render_string( - '

{{title}}

{{{body}}}

', - { title => mark_raw('All About <p> Tags'), body => 'This is a post about <p> tags' }, - ), - '

All About <p> Tags

This is a post about <p> tags

', -); - -done_testing; diff --git a/t/004-helpers.t b/t/004-helpers.t deleted file mode 100644 index 55b3b5a..0000000 --- a/t/004-helpers.t +++ /dev/null @@ -1,47 +0,0 @@ -use strict; -use warnings; -use Test::More; -use Text::Xslate; - -my $tx = Text::Xslate->new(syntax => 'Handlebars'); - -# XXX I'm not sure how helpers should be registered in Perl -# in JS, it's global which is crappy -# Text::Xslate->new has a "function" parameter for registering helpers -Handlebars->registerHelper(noop => sub { - my ($context, $options) = @_; - return $options->{fn}->($context); -}); - -is( - $tx->render_string( - '

{{title}}

{{#noop}}{{body}}{{/noop}}

', - { title => 'A', body => 'the first letter' }, - ), - '

A

the first letter

', -); - -Handlebars->registerHelper(list => sub { - my ($items, $options) = @_; - my $out = ""; -}); - -is( - $tx->render_string( - '{{#list people}}{{firstName}} {{lastName}}{{/list}}', - { people => [ - { firstName => 'Jesse', lastName => 'Luehrs' }, - { firstName => 'Shawn', lastName => 'Moore' }, - { firstName => 'Stevan', lastName => 'Little' }, - ] }, - ), - '', -); - -done_testing; diff --git a/t/basic.t b/t/basic.t new file mode 100644 index 0000000..28d54c1 --- /dev/null +++ b/t/basic.t @@ -0,0 +1,18 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +use Text::Handlebars; + +my $tx = Text::Handlebars->new; + +is( + $tx->render_string( + 'Hello, {{dialect}} world!', + { dialect => 'Handlebars' }, + ), + 'Hello, Handlebars world!', +); + +done_testing; diff --git a/t/expressions.t b/t/expressions.t new file mode 100644 index 0000000..730196f --- /dev/null +++ b/t/expressions.t @@ -0,0 +1,34 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +use Text::Handlebars; + +my $tx = Text::Handlebars->new; + +is( + $tx->render_string( + '

{{title}}

', + { title => 'Xslate rocks' }, + ), + '

Xslate rocks

', +); + +is( + $tx->render_string( + '

{{article.title}}

', + { article => { title => 'Hash references rock' } }, + ), + '

Hash references rock

', +); + +is( + $tx->render_string( + '

{{article/title}}

', + { article => { title => 'Deprecated syntax does not' } }, + ), + '

Deprecated syntax does not

', +); + +done_testing; diff --git a/t/helpers.t b/t/helpers.t new file mode 100644 index 0000000..55b3b5a --- /dev/null +++ b/t/helpers.t @@ -0,0 +1,47 @@ +use strict; +use warnings; +use Test::More; +use Text::Xslate; + +my $tx = Text::Xslate->new(syntax => 'Handlebars'); + +# XXX I'm not sure how helpers should be registered in Perl +# in JS, it's global which is crappy +# Text::Xslate->new has a "function" parameter for registering helpers +Handlebars->registerHelper(noop => sub { + my ($context, $options) = @_; + return $options->{fn}->($context); +}); + +is( + $tx->render_string( + '

{{title}}

{{#noop}}{{body}}{{/noop}}

', + { title => 'A', body => 'the first letter' }, + ), + '

A

the first letter

', +); + +Handlebars->registerHelper(list => sub { + my ($items, $options) = @_; + my $out = ""; +}); + +is( + $tx->render_string( + '{{#list people}}{{firstName}} {{lastName}}{{/list}}', + { people => [ + { firstName => 'Jesse', lastName => 'Luehrs' }, + { firstName => 'Shawn', lastName => 'Moore' }, + { firstName => 'Stevan', lastName => 'Little' }, + ] }, + ), + '', +); + +done_testing; diff --git a/t/safestring.t b/t/safestring.t new file mode 100644 index 0000000..27d9ac1 --- /dev/null +++ b/t/safestring.t @@ -0,0 +1,35 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +use Text::Handlebars; +use Text::Xslate 'mark_raw'; + +my $tx = Text::Handlebars->new; + +is( + $tx->render_string( + '

{{title}}

{{{body}}}

', + { title => 'My New Post', body => 'This is my first post!' }, + ), + '

My New Post

This is my first post!

', +); + +is( + $tx->render_string( + '

{{title}}

{{{body}}}

', + { title => 'All About

Tags', body => 'This is a post about <p> tags' }, + ), + '

All About <p> Tags

This is a post about <p> tags

', +); + +is( + $tx->render_string( + '

{{title}}

{{{body}}}

', + { title => mark_raw('All About <p> Tags'), body => 'This is a post about <p> tags' }, + ), + '

All About <p> Tags

This is a post about <p> tags

', +); + +done_testing; -- cgit v1.2.3-54-g00ecf