Beispiel #1
0
void mw::XMLParserTestFixture::testLoadListInDictionary() {
	CPPUNIT_ASSERT(testVar->getValue().getFloat() == 0.0);		
	
	const char *xml_text =
	"<?xml version=\"1.0\"?>"
	"<monkeyml version=\"1.1\">"
	"  <variable_assignments>"
	"    <variable_assignment variable=\"testVar\">"
	"      <dictionary>"
	"       <dictionary_element>"
	"         <key>one</key>"
	"         <value>"
	"           <list>"
	"             <list_element>"
	"               <value type=\"integer\">11</value>"
	"             </list_element>"
	"             <list_element>"
	"               <value type=\"integer\">12</value>"
	"             </list_element>"
	"           </list>"
	"         </value>"
	"       </dictionary_element>"
	"       <dictionary_element>"
	"         <key>two</key>"
	"         <value>"
	"           <list>"
	"             <list_element>"
	"               <value type=\"integer\">21</value>"
	"             </list_element>"
	"             <list_element>"
	"               <value type=\"integer\">22</value>"
	"             </list_element>"
	"           </list>"
	"         </value>"
	"       </dictionary_element>"
	"      </dictionary>"
	"    </variable_assignment>"
	"  </variable_assignments>"
	"</monkeyml>";
	
	writeToFile(xml_text);
	
	mw::VariableLoad::loadExperimentwideVariables(temp_xml_file_path);
	
	mw::Data sublist1(M_LIST, 2);
	sublist1.setElement(0, mw::Data(11L));
	sublist1.setElement(1, mw::Data(12L));
	
	mw::Data sublist2(M_LIST, 2);
	sublist2.setElement(0, mw::Data(21L));
	sublist2.setElement(1, mw::Data(22L));
	
	mw::Data test_dict(M_DICTIONARY, 2);
	test_dict.addElement("one", sublist1);
	test_dict.addElement("two", sublist2);
	
	
	CPPUNIT_ASSERT(testVar->getValue() == test_dict);			
}
Beispiel #2
0
int main(int argc, char **argv) {
    test_string();
    test_list();
    test_map();
    test_map_stack();
    test_dict();
    printf("Passed\n");
    return 0;
}
Beispiel #3
0
void main()
{
	pybind::initialize( false, false, true );

	bool gc_exist;
	PyObject * gc = pybind::module_import( "gc", gc_exist );

	pybind::call_method( gc, "disable", "()" );

	PyObject * module = pybind::module_init( "Test" );

	pybind::set_currentmodule( module );

	Helper * helper = new Helper;

	pybind::class_<Bar>( "Bar" )
		.def( "foo", &Bar::foo )
		.def( "min", &Bar::min )
		.def_property( "data", &Bar::getData, &Bar::setData )
		.def_proxy_static( "helper_for_script_function", helper, &Helper::helper_for_script_function )
		;

	pybind::class_<Vec2>( "Vec2" )
		.def_constructor( pybind::init<float, float>() )
		.def_member( "x", &Vec2::x )
		.def_member( "y", &Vec2::y )
		;

	Bar * b = new Bar;

	PyObject * py_b = pybind::ptr( b );

	PyObject * g = nullptr;

	bool exist;
	PyObject * m = pybind::module_import( "Test1", exist );

	test_function_decl();
	
	for( uint32_t i = 0; i != 100000; ++i )
	{
		test_dict( i );
		test_list( i );
		test_tuple( i );
		test_function( m, i );
	}

	printf( "done" );
}
Beispiel #4
0
void mw::XMLParserTestFixture::testLoadDictionary() {
	CPPUNIT_ASSERT(testVar->getValue().getFloat() == 0.0);		
	
	const char *xml_text =
	"<?xml version=\"1.0\"?>"
	"<monkeyml version=\"1.1\">"
	"<variable_assignments>"
	"<variable_assignment variable=\"testVar\">"
	"<dictionary>"
	"<dictionary_element>"
	"<key>four</key>"
	"<value type=\"integer\">4</value>"
	"</dictionary_element>"
	"<dictionary_element>"
	"<key>six</key>"
	"<value type=\"integer\">6</value>"
	"</dictionary_element>"
	"</dictionary>"
	"</variable_assignment>"
	"</variable_assignments>"
	"</monkeyml>";
	writeToFile(xml_text);
	
	mw::VariableLoad::loadExperimentwideVariables(temp_xml_file_path);
	
	mw::Data test_dict(M_DICTIONARY, 2);
	test_dict.addElement("four", mw::Data(4L));
	test_dict.addElement("six", mw::Data(6L));
	
	CPPUNIT_ASSERT(testVar->getValue() == test_dict);		
	
	mw::Data test_dict2(M_DICTIONARY, 2);
	test_dict2.addElement("six", mw::Data(6L));
	test_dict2.addElement("four", mw::Data(4L));
	
	CPPUNIT_ASSERT(testVar->getValue() == test_dict2);		
	
	mw::Data test_dict3(M_DICTIONARY, 3);
	test_dict2.addElement("six", mw::Data(6L));
	test_dict2.addElement("four", mw::Data(4L));
	
	CPPUNIT_ASSERT(testVar->getValue() == test_dict2);		
}
Beispiel #5
0
/*scan words from stdin, print total amount for each word by DESC order*/
int main(void) {
    test_dict();
    return 0;
}
Beispiel #6
0
int main()
{
    sio << "short: " << sizeof(short) << "  long: " << sizeof(long)
        << "  long long: " << sizeof(long long) << "  int: " << sizeof(int)
        << "  void*: " << sizeof(void*) << "  float: " << sizeof(float)
        << "  double: " << sizeof(double) << '\n';
    sio << "integer: " << sizeof(integer) << "  memint: " << sizeof(memint)
        << "  real: " << sizeof(real) << "  variant: " << sizeof(variant)
        << "  object: " << sizeof(object) << "  rtobject: " << sizeof(rtobject) << '\n';
    sio << "stateobj: " << sizeof(stateobj) << "  Type: " << sizeof(Type)
        << "  State: " << sizeof(State) << "  opcodes: " << opMaxCode << '\n';

    check(sizeof(memint) == sizeof(void*));
    check(sizeof(memint) == sizeof(size_t));

#ifdef SHN_64
    check(sizeof(integer) == 8);
    check(sizeof(variant) <= 16);
#else
    check(sizeof(integer) == 4);
    check(sizeof(variant) <= 12);
#endif

    initRuntime();
    initTypeSys();
    initVm();

    int exitcode = 0;
    try
    {
        test_common();
        test_object();
        test_ordset();
        test_bytevec();
        test_string();
        test_strutils();
        test_podvec();
        test_vector();
        test_dict();
        test_set();
        test_symtbl();
        test_variant();
        test_fifos();
        test_parser();
//        test_typesys();
//        test_codegen();
    }
    catch (exception& e)
    {
        fprintf(stderr, "Exception: %s\n", e.what());
        exitcode = 201;
    }

    doneVm();
    doneTypeSys();
    doneRuntime();

    if (object::allocated != 0)
    {
        fprintf(stderr, "Error: object::allocated = %d\n", object::allocated);
        exitcode = 202;
    }

    return exitcode;
}