Permalink
Browse files

Don't use/test dynamic filters for now

  • Loading branch information...
ashb committed Sep 24, 2009
1 parent 42d4956 commit 046efcee91567f1c80cb2d39f63e31285a86bb16
Showing with 91 additions and 75 deletions.
  1. +74 −72 t/data/filter.data
  2. +17 −3 t/filter.js
@@ -1,78 +1,80 @@
#------------------------------------------------------------------------
# test failures
#------------------------------------------------------------------------
-- test --
[% TRY %]
[% FILTER nonfilt %]
blah blah blah
[% END %]
[% CATCH %]
BZZZT: [% error.type %]: [% error.info %]
[% END %]
-- expect --
BZZZT: filter: invalid FILTER entry for 'nonfilt' (not a CODE ref)

-- test --
[% TRY %]
[% FILTER badfact %]
blah blah blah
[% END %]
[% CATCH %]
BZZZT: [% error.type %]: [% error.info %]
[% END %]
-- expect --
BZZZT: filter: invalid FILTER for 'badfact' (not a CODE ref)

-- test --
[% TRY %]
[% FILTER badfilt %]
blah blah blah
[% END %]
[% CATCH %]
BZZZT: [% error.type %]: [% error.info %]
[% END %]
-- expect --
BZZZT: filter: invalid FILTER entry for 'badfilt' (not a CODE ref)

-- test --
[% TRY;
"foo" | barfilt;
CATCH;
"$error.type: $error.info";
END
%]
-- expect --
filter: barfed

-- test --
[% TRY;
"foo" | barfilt(1);
CATCH;
"$error.type: $error.info";
END
%]
-- expect --
dead: deceased

-- test --
[% TRY;
"foo" | barfilt(2);
CATCH;
"$error.type: $error.info";
END
%]
-- expect --
filter: keeled over

-- test --
[% TRY;
"foo" | barfilt(3);
CATCH;
"$error.type: $error.info";
END
%]
-- expect --
unwell: sick as a parrot
#-- test --
#[% TRY %]
#[% FILTER nonfilt %]
#blah blah blah
#[% END %]
#[% CATCH %]
#BZZZT: [% error.type %]: [% error.info %]
#[% END %]
#-- expect --
#BZZZT: filter: invalid FILTER entry for 'nonfilt' (not a function)
#
#-- test --
#[% TRY %]
#[% FILTER badfact %]
#blah blah blah
#[% END %]
#[% CATCH %]
#BZZZT: [% error.type %]: [% error.info %]
#[% END %]
#-- expect --
## I'm not supporting dynamic filters for now
##BZZZT: filter: invalid FILTER for 'badfact' (not a function)
#BZZZT: filter: invalid FILTER entry for 'badfact' (not a function)
#
#-- test --
#[% TRY %]
#[% FILTER badfilt %]
#blah blah blah
#[% END %]
#[% CATCH %]
#BZZZT: [% error.type %]: [% error.info %]
#[% END %]
#-- expect --
#BZZZT: filter: invalid FILTER entry for 'badfilt' (not a function)
#
#-- test --
#[% TRY;
# "foo" | barfilt;
# CATCH;
# "$error.type: $error.info";
# END
#%]
#-- expect --
#filter: barfed
#
#-- test --
#[% TRY;
# "foo" | barfilt(1);
# CATCH;
# "$error.type: $error.info";
# END
#%]
#-- expect --
#dead: deceased
#
#-- test --
#[% TRY;
# "foo" | barfilt(2);
# CATCH;
# "$error.type: $error.info";
# END
#%]
#-- expect --
#filter: keeled over
#
#-- test --
#[% TRY;
# "foo" | barfilt(3);
# CATCH;
# "$error.type: $error.info";
# END
#%]
#-- expect --
#unwell: sick as a parrot


#------------------------------------------------------------------------
@@ -25,7 +25,7 @@ var params = {
outfile : file,
stderr : function () { return stderr },
//despace : bless(\&despace, 'anything'),
widetext : "wide:\x{65e5}\x{672c}\x{8a9e}"
widetext : "wide:\u65e5\u672c\u8a9e"
};

var filters = {
@@ -35,12 +35,15 @@ var filters = {
'censor' : [ censor_factory, 1 ],
'badfact' : [ function() { return 'nonsense' }, 1 ],
'badfilt' : [ 'rubbish', 1 ],
'barfilt' : [ barf_up, 1 ]
'barfilt' : barf_up
};


t.build_tests(require('io').File('t/data/filter.data'),
new Template({
//DBG_OUTPUT_CHUNKS: 1,
//DBG_OUTPUT_FUNC: 1,
//DEBUG: 1,
POST_CHOMP: 1,
FILTERS: filters
}), params);
@@ -57,7 +60,18 @@ function microsloth() {
function censor_factory() {
}

function barf_up() {
function barf_up(ctx, foad) {
if (foad === undefined)
foad = 0;
require('system').stdout.print("barf up", ctx, foad);
if (foad == 0)
return [null, "barfed"];
else if (foad == 1)
return [null, new Template.Exception('dead', 'deceased')];
else if (foad == 2)
throw "keeled over\n";
else
throw new Template.Exception('unwell', 'sick as a parot');
}

function despace(text) {

0 comments on commit 046efce

Please sign in to comment.