Permalink
Browse files

Removes code duplication between value_or_default() function and its …

…v() alias; adding some tests [#9 state:resolved]
  • Loading branch information...
Fabrice Luraine
Fabrice Luraine committed Jul 1, 2009
1 parent 88838d1 commit 9c48e03f774f53a0e8b9dfb426bda1f2c277ed00
Showing with 8 additions and 2 deletions.
  1. +1 −1 lib/limonade.php
  2. +7 −1 tests/main.php
View
@@ -1434,7 +1434,7 @@ function value_or_default($value, $default)
*/
function v($value, $default)
{
return empty($value) ? $default : $value;
return call_user_func('value_or_default', $value, $default);
}
/**
View
@@ -134,7 +134,13 @@ function test_main_require_once_dir()
function test_main_value_or_default()
{
# TODO test value_or_default
assert_equal(value_or_default(10, 20), 10);
assert_equal(value_or_default(0, 20), 20);
assert_equal(value_or_default(null, 20), 20);
assert_equal(value_or_default('hello', 'world'), 'hello');
assert_equal(value_or_default('', 'world'), 'world');
assert_equal(value_or_default(10, 20), v(10, 20));
assert_equal(value_or_default(0, 20), v(0, 20));
}
function test_main_file_path()

0 comments on commit 9c48e03

Please sign in to comment.