Changeset 588
- Timestamp:
- 07/12/08 07:37:29 (4 months ago)
- Files:
-
- trunk/rphp/runtime/CMakeLists.txt (modified) (1 diff)
- trunk/rphp/runtime/rphp_types.cpp (added)
- trunk/rphp/runtime/rphp_types.h (modified) (1 diff)
- trunk/rphp/runtime/test/CMakeLists.txt (modified) (1 diff)
- trunk/rphp/runtime/test/main.cpp (moved) (moved from trunk/rphp/runtime/test/Main.cpp)
- trunk/rphp/runtime/test/phashTestCase.cpp (moved) (moved from trunk/rphp/runtime/test/HashTestCase.cpp) (4 diffs)
- trunk/rphp/runtime/test/phashTestCase.h (moved) (moved from trunk/rphp/runtime/test/HashTestCase.h) (2 diffs)
- trunk/rphp/runtime/test/pvarTestCase.cpp (moved) (moved from trunk/rphp/runtime/var-test.cpp) (2 diffs)
- trunk/rphp/runtime/test/pvarTestCase.h (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/rphp/runtime/CMakeLists.txt
r587 r588 12 12 set(RUNTIME_SRC_FILES 13 13 rphp_hash.cpp 14 rphp_types.cpp 14 15 ) 15 16 16 17 add_library( rphp_runtime SHARED ${RUNTIME_SRC_FILES} ) 17 18 18 # test apps19 add_executable( var-test var-test.cpp )20 target_link_libraries( var-test rphp_runtime ${ICU_LIBRARIES} ${ICU_IO_LIBRARIES} )21 19 22 trunk/rphp/runtime/rphp_types.h
r583 r588 143 143 144 144 145 // non destructive cast (explicit copy) 146 pvar pvar_castToNumber(const pvar p) { 147 148 pvar r = p; 149 boost::apply_visitor(convertToNumber(r), r); 150 return r; 151 152 } 153 154 // TODO: belongs in rphp_operators.cpp 155 pvar pvar_add(const pvar lhs, const pvar rhs) 156 { 157 pvar l,r,result; 158 159 pvarType lhs_type = pvar_getType(lhs); 160 pvarType rhs_type = pvar_getType(rhs); 161 if ( (lhs_type == PVAR_HASH) && (rhs_type == PVAR_HASH) ) { 162 //std::cout << "fixme: concat hashes" << std::endl; 163 result = 0l; 164 } 165 else { 166 // convert to number, then add 167 l = pvar_castToNumber(lhs); 168 //std::cout << "pvar_add: l is " << l << std::endl; 169 r = pvar_castToNumber(rhs); 170 //std::cout << "pvar_add: r is " << r << std::endl; 171 result = pvar_getVal_int(l) + pvar_getVal_int(r); 172 //std::cout << "pvar_add: result is " << result << std::endl; 173 } 174 175 return result; 176 } 145 pvar pvar_castToNumber(const pvar p); 146 pvar pvar_add(const pvar lhs, const pvar rhs); 177 147 178 148 trunk/rphp/runtime/test/CMakeLists.txt
r586 r588 12 12 13 13 # test apps 14 add_executable( RuntimeTestSuite Main.cpp HashTestCase.cpp )15 target_link_libraries( RuntimeTestSuite cppunit rphp_runtime ${ICU_LIBRARIES} ${ICU_IO_LIBRARIES})14 add_executable( rphp_runtime_suite main.cpp phashTestCase.cpp pvarTestCase.cpp ) 15 target_link_libraries( rphp_runtime_suite cppunit rphp_runtime ${ICU_LIBRARIES} ${ICU_IO_LIBRARIES}) trunk/rphp/runtime/test/phashTestCase.cpp
r586 r588 5 5 #include "rphp_runtime.h" 6 6 7 #include " HashTestCase.h"7 #include "phashTestCase.h" 8 8 9 CPPUNIT_TEST_SUITE_REGISTRATION( HashTestCase );9 CPPUNIT_TEST_SUITE_REGISTRATION( phashTestCase ); 10 10 11 void HashTestCase::basic()11 void phashTestCase::basic() 12 12 { 13 13 /* … … 32 32 33 33 /* 34 void HashTestCase::anotherExample()34 void phashTestCase::anotherExample() 35 35 { 36 36 CPPUNIT_ASSERT (1 == 2); 37 37 } 38 38 */ 39 void HashTestCase::setUp()39 void phashTestCase::setUp() 40 40 { 41 41 /* … … 46 46 47 47 /* 48 void HashTestCase::testAdd()48 void phashTestCase::testAdd() 49 49 { 50 50 double result = m_value1 + m_value2; … … 53 53 54 54 55 void HashTestCase::testEquals()55 void phashTestCase::testEquals() 56 56 { 57 57 long* l1 = new long(12); trunk/rphp/runtime/test/phashTestCase.h
r586 r588 1 1 2 #ifndef CPP_UNIT_EXAMPLETESTCASE_H3 #define CPP_UNIT_EXAMPLETESTCASE_H2 #ifndef PHASHTESTCASE_H 3 #define PHASHTESTCASE_H 4 4 5 5 #include <cppunit/extensions/HelperMacros.h> … … 10 10 */ 11 11 12 class HashTestCase : public CPPUNIT_NS::TestFixture12 class phashTestCase : public CPPUNIT_NS::TestFixture 13 13 { 14 CPPUNIT_TEST_SUITE( HashTestCase );14 CPPUNIT_TEST_SUITE( phashTestCase ); 15 15 CPPUNIT_TEST( basic ); 16 16 /* trunk/rphp/runtime/test/pvarTestCase.cpp
r585 r588 6 6 */ 7 7 8 #include <cppunit/config/SourcePrefix.h> 9 #include <iostream> 10 8 11 #include "rphp_runtime.h" 9 #include <iostream> 12 #include "pvarTestCase.h" 13 14 CPPUNIT_TEST_SUITE_REGISTRATION( pvarTestCase ); 10 15 11 16 // generic visitor which can be applied to any pvar … … 76 81 77 82 // driver 78 int main()83 void pvarTestCase::basic() 79 84 { 80 85 rphp::pvar u,t,r;
