Added gotoExpression tests (from flux branch)
This commit is contained in:
parent
b7520da07d
commit
34b44def2f
1 changed files with 10 additions and 10 deletions
|
|
@ -324,26 +324,26 @@ is($rJSON->lastResponse(), 5, 'goto: finds first if there are duplicates');
|
||||||
# processGotoExpression
|
# processGotoExpression
|
||||||
#
|
#
|
||||||
####################################################
|
####################################################
|
||||||
is($rJSON->processGotoExpression(),
|
is($rJSON->processGotoExpression(),
|
||||||
undef, 'processGotoExpression undef with empty arguments');
|
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');
|
undef, '.. and undef with duff expression');
|
||||||
is($rJSON->processGotoExpression(':'),
|
is($rJSON->processGotoExpression(':'),
|
||||||
undef, '.. and undef with missing target');
|
undef, '.. and undef with missing target');
|
||||||
is($rJSON->processGotoExpression('t1:'),
|
is($rJSON->processGotoExpression('t1:'),
|
||||||
undef, '.. and undef with missing expression');
|
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');
|
{ 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');
|
{ 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');
|
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 ==');
|
{ 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 =});
|
{ 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');
|
{ 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');
|
{ target => 't1', expression => '345 * 10 + 456'}, '..it even works for vars with spaces in their names');
|
||||||
is($rJSON->processGotoExpression('t1: qX + 3', { q1 => '7'}),
|
is($rJSON->processGotoExpression('t1: qX + 3', { q1 => '7'}),
|
||||||
undef, q{..but doesn't like invalid var names});
|
undef, q{..but doesn't like invalid var names});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue