From 8bd7f5162870e4b39c7629c1a67a3372402406c9 Mon Sep 17 00:00:00 2001 From: valmat Date: Sat, 29 Mar 2014 01:38:25 +0600 Subject: Fixed test: variables/003-value-types --- tests/cpp/include/variables/003-value-types.h | 50 +++++++++--------- tests/php/phpt/variables/003-value-types.phpt | 72 ++++++++++++++++++++++++++ tests/php/phpt/variables/003-value-types.phpt- | 72 -------------------------- 3 files changed, 96 insertions(+), 98 deletions(-) create mode 100644 tests/php/phpt/variables/003-value-types.phpt delete mode 100644 tests/php/phpt/variables/003-value-types.phpt- (limited to 'tests') diff --git a/tests/cpp/include/variables/003-value-types.h b/tests/cpp/include/variables/003-value-types.h index e1d31b9..d24549b 100644 --- a/tests/cpp/include/variables/003-value-types.h +++ b/tests/cpp/include/variables/003-value-types.h @@ -1,39 +1,37 @@ /** * * Test variables - * 003-value-types.phpt + * 003-value-types.phpt * */ - namespace TestVariables { - /* - * Check type of value - * @param array - */ - void value_types(Php::Parameters ¶ms) { - if (params.size() == 0) { - return; - } - + /* + * Check type of value + * @param array + */ + void value_types(Php::Parameters ¶ms) + { + if (params.size() == 0) return; Php::Value arr = params[0]; + + Php::out << "Null: " << bool2str( arr.get("Null").isNull() ) << std::endl; + Php::out << "Numeric: " << bool2str( arr.get("Numeric").isNumeric()) << std::endl; + Php::out << "Float: " << bool2str( arr.get("Float").isFloat() ) << std::endl; + Php::out << "Bool: " << bool2str( arr.get("Bool").isBool() ) << std::endl; + Php::out << "Array: " << bool2str( arr.get("Array").isArray() ) << std::endl; + Php::out << "Object: " << bool2str( arr.get("Object").isObject() ) << std::endl; + Php::out << "String: " << bool2str( arr.get("String").isString() ) << std::endl; + Php::out << "Resource: " << bool2str( arr.get("Resource").type() == Php::Type::Resource ) << std::endl; + Php::out << "Constant: " << bool2str( arr.get("Constant").type() == Php::Type::Constant ) << std::endl; + Php::out << "ConstantArray: " << bool2str( arr.get("ConstantArray").type() == Php::Type::ConstantArray ) << std::endl; + Php::out << "Callable1: " << bool2str( arr.get("Callable1").isCallable() ) << std::endl; + Php::out << "Callable2: " << bool2str( arr.get("Callable2").isCallable() ) << std::endl; + Php::out << "Callable3: " << bool2str( arr.get("Callable3").isCallable() ) << std::endl; + Php::out << "Callable4: " << bool2str( arr.get("Callable4").isCallable() ) << std::endl; - Php::out << "Null: " << bool2str( arr.get("Null").type() == Php::Type::Null ) << std::endl; - Php::out << "Numeric: " << bool2str( arr.get("Numeric").type() == Php::Type::Numeric ) << std::endl; - Php::out << "Float: " << bool2str( arr.get("Float").type() == Php::Type::Float ) << std::endl; - Php::out << "Bool: " << bool2str( arr.get("Bool").type() == Php::Type::Bool ) << std::endl; - Php::out << "Array: " << bool2str( arr.get("Array").type() == Php::Type::Array ) << std::endl; - Php::out << "Object: " << bool2str( arr.get("Object").type() == Php::Type::Object ) << std::endl; - Php::out << "String: " << bool2str( arr.get("String").type() == Php::Type::String ) << std::endl; - Php::out << "Resource: " << bool2str( arr.get("Resource").type() == Php::Type::Resource ) << std::endl; - Php::out << "Constant: " << bool2str( arr.get("Constant").type() == Php::Type::Constant ) << std::endl; - Php::out << "ConstantArray: " << bool2str( arr.get("ConstantArray").type() == Php::Type::ConstantArray ) << std::endl; - Php::out << "Callable1: " << bool2str( arr.get("Callable1").type() == Php::Type::Callable ) << std::endl; - Php::out << "Callable2: " << bool2str( arr.get("Callable2").type() == Php::Type::Callable ) << std::endl; - Php::out << "Callable3: " << bool2str( arr.get("Callable3").type() == Php::Type::Callable ) << std::endl; - Php::out << "Callable4: " << bool2str( arr.get("Callable4").type() == Php::Type::Callable ) << std::endl; - } + } } diff --git a/tests/php/phpt/variables/003-value-types.phpt b/tests/php/phpt/variables/003-value-types.phpt new file mode 100644 index 0000000..477fbe2 --- /dev/null +++ b/tests/php/phpt/variables/003-value-types.phpt @@ -0,0 +1,72 @@ +--TEST-- +get_complex_array +--SKIPIF-- + +--FILEEOF-- + NULL, + 'Numeric' => 2014, + 'Float' => 3.14, + 'Bool' => true, + 'Array' => array(5,'a' => 33, 'str'), + 'Object' => new stdClass(), + 'String' => 'String', + 'Resource' => 7, + 'Constant' => 5, + 'ConstantArray' => 11, + 'Callable1' => 'ret5', + 'Callable2' => $methodVariable, + 'Callable3' => function () {return 5;}, + 'Callable4' => new CallableClass() +); + +TestVariables\value_types($arr); + +//To check uncomment the following lines: +/* +echo "\n\nCallable1:"; +var_export(is_callable($arr['Callable1'])); +echo PHP_EOL,'Callable2:'; +var_export(is_callable($arr['Callable2'])); +echo PHP_EOL,'Callable3:'; +var_export(is_callable($arr['Callable3'])); +echo PHP_EOL,'Callable4:'; +var_export(is_callable($arr['Callable4'])); +echo PHP_EOL,'No Callable:'; +var_export(is_callable(new stdClass)); +*/ + + +echo PHP_EOL; +--EXPECT-- +Null: Yes +Numeric: Yes +Float: Yes +Bool: Yes +Array: Yes +Object: Yes +String: Yes +Resource: No +Constant: No +ConstantArray: No +Callable1: Yes +Callable2: Yes +Callable3: Yes +Callable4: Yes \ No newline at end of file diff --git a/tests/php/phpt/variables/003-value-types.phpt- b/tests/php/phpt/variables/003-value-types.phpt- deleted file mode 100644 index 477fbe2..0000000 --- a/tests/php/phpt/variables/003-value-types.phpt- +++ /dev/null @@ -1,72 +0,0 @@ ---TEST-- -get_complex_array ---SKIPIF-- - ---FILEEOF-- - NULL, - 'Numeric' => 2014, - 'Float' => 3.14, - 'Bool' => true, - 'Array' => array(5,'a' => 33, 'str'), - 'Object' => new stdClass(), - 'String' => 'String', - 'Resource' => 7, - 'Constant' => 5, - 'ConstantArray' => 11, - 'Callable1' => 'ret5', - 'Callable2' => $methodVariable, - 'Callable3' => function () {return 5;}, - 'Callable4' => new CallableClass() -); - -TestVariables\value_types($arr); - -//To check uncomment the following lines: -/* -echo "\n\nCallable1:"; -var_export(is_callable($arr['Callable1'])); -echo PHP_EOL,'Callable2:'; -var_export(is_callable($arr['Callable2'])); -echo PHP_EOL,'Callable3:'; -var_export(is_callable($arr['Callable3'])); -echo PHP_EOL,'Callable4:'; -var_export(is_callable($arr['Callable4'])); -echo PHP_EOL,'No Callable:'; -var_export(is_callable(new stdClass)); -*/ - - -echo PHP_EOL; ---EXPECT-- -Null: Yes -Numeric: Yes -Float: Yes -Bool: Yes -Array: Yes -Object: Yes -String: Yes -Resource: No -Constant: No -ConstantArray: No -Callable1: Yes -Callable2: Yes -Callable3: Yes -Callable4: Yes \ No newline at end of file -- cgit v1.2.3