From 34b44def2fa3fdfd3287db00d53d07d943a686a1 Mon Sep 17 00:00:00 2001 From: Patrick Donelan Date: Wed, 14 Jan 2009 06:14:37 +0000 Subject: [PATCH] Added gotoExpression tests (from flux branch) --- t/Asset/Wobject/Survey/ResponseJSON.t | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/t/Asset/Wobject/Survey/ResponseJSON.t b/t/Asset/Wobject/Survey/ResponseJSON.t index a75f5b47c..803cac720 100644 --- a/t/Asset/Wobject/Survey/ResponseJSON.t +++ b/t/Asset/Wobject/Survey/ResponseJSON.t @@ -324,26 +324,26 @@ is($rJSON->lastResponse(), 5, 'goto: finds first if there are duplicates'); # processGotoExpression # #################################################### -is($rJSON->processGotoExpression(), +is($rJSON->processGotoExpression(), undef, 'processGotoExpression undef with empty arguments'); -is($rJSON->processGotoExpression('blah-dee-blah-blah'), +is($rJSON->processGotoExpression('blah-dee-blah-blah'), undef, '.. and undef with duff expression'); -is($rJSON->processGotoExpression(':'), +is($rJSON->processGotoExpression(':'), undef, '.. and undef with missing target'); -is($rJSON->processGotoExpression('t1:'), +is($rJSON->processGotoExpression('t1:'), undef, '.. and undef with missing expression'); -cmp_deeply($rJSON->processGotoExpression('t1: 1'), +cmp_deeply($rJSON->processGotoExpression('t1: 1'), { target => 't1', expression => '1'}, 'works for simple numeric expression'); -cmp_deeply($rJSON->processGotoExpression('t1: 1 - 23 + 456 * (78 / 9.0)'), +cmp_deeply($rJSON->processGotoExpression('t1: 1 - 23 + 456 * (78 / 9.0)'), { target => 't1', expression => '1 - 23 + 456 * (78 / 9.0)'}, 'works for expression using all algebraic tokens'); is($rJSON->processGotoExpression('t1: 1 + &'), undef, '.. but disallows expression containing non-whitelisted token'); -cmp_deeply($rJSON->processGotoExpression('t1: 1 = 3'), +cmp_deeply($rJSON->processGotoExpression('t1: 1 = 3'), { target => 't1', expression => '1 == 3'}, 'converts single = to =='); -cmp_deeply($rJSON->processGotoExpression('t1: 1 != 3 <= 4 >= 5'), +cmp_deeply($rJSON->processGotoExpression('t1: 1 != 3 <= 4 >= 5'), { target => 't1', expression => '1 != 3 <= 4 >= 5'}, q{..but doesn't mess with other ops containing =}); -cmp_deeply($rJSON->processGotoExpression('t1: q1 + q2 * q3 - 4', { q1 => 11, q2 => 22, q3 => 33}), +cmp_deeply($rJSON->processGotoExpression('t1: q1 + q2 * q3 - 4', { q1 => 11, q2 => 22, q3 => 33}), { target => 't1', expression => '11 + 22 * 33 - 4'}, 'substitues q for value'); -cmp_deeply($rJSON->processGotoExpression('t1: a silly var name * 10 + another var name', { 'a silly var name' => 345, 'another var name' => 456}), +cmp_deeply($rJSON->processGotoExpression('t1: a silly var name * 10 + another var name', { 'a silly var name' => 345, 'another var name' => 456}), { target => 't1', expression => '345 * 10 + 456'}, '..it even works for vars with spaces in their names'); is($rJSON->processGotoExpression('t1: qX + 3', { q1 => '7'}), undef, q{..but doesn't like invalid var names});