/[ascend]/trunk/ascend/compiler/test/test_basics.c
ViewVC logotype

Diff of /trunk/ascend/compiler/test/test_basics.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2347 by jpye, Wed Jan 5 09:24:59 2011 UTC revision 2348 by jpye, Wed Jan 5 11:50:51 2011 UTC
# Line 346  static void test_initialize(void){ Line 346  static void test_initialize(void){
346  #undef TESTFILE  #undef TESTFILE
347  }  }
348    
349    static void test_stop(void){
350        struct module_t *m;
351        int status;
352    
353        Asc_CompilerInit(1);
354        Asc_PutEnv(ASC_ENV_LIBRARY "=models");
355        
356        /* load the file */
357    #define TESTFILE "stop"
358        m = Asc_OpenModule("test/compiler/" TESTFILE ".a4c",&status);
359        CU_ASSERT(status == 0);
360    
361        /* parse it */
362        CU_ASSERT(0 == zz_parse());
363    
364        /* find the model */    
365        CU_ASSERT(FindType(AddSymbol(TESTFILE))!=NULL);
366    
367        /* instantiate it */
368        struct Instance *sim = SimsCreateInstance(AddSymbol(TESTFILE), AddSymbol("sim1"), e_normal, NULL);
369        CU_ASSERT_FATAL(sim!=NULL);
370    
371        /** Call on_load */
372        struct Name *name = CreateIdName(AddSymbol("on_load"));
373    
374        enum Proc_enum pe = Initialize(GetSimulationRoot(sim),name,"sim1", ASCERR, WP_STOPONERR, NULL, NULL);
375        CU_ASSERT(pe!=Proc_all_ok);
376    
377        struct Instance *inst;
378    
379        CU_ASSERT((inst = ChildByChar(GetSimulationRoot(sim),AddSymbol("x"))) && InstanceKind(inst)==REAL_ATOM_INST);
380        CU_ASSERT(RealAtomValue(inst)==2.0);
381    
382        sim_destroy(sim);
383        Asc_CompilerDestroy();
384    #undef TESTFILE
385    }
386    
387    
388  static void test_stoponerror(void){  static void test_stoponfailedassert(void){
389      struct module_t *m;      struct module_t *m;
390      int status;      int status;
391    
# Line 400  static void test_stoponerror(void){ Line 436  static void test_stoponerror(void){
436      T(parse_file) \      T(parse_file) \
437      T(instantiate_file) \      T(instantiate_file) \
438      T(initialize) \      T(initialize) \
439      T(stoponerror)      T(stop) \
440        T(stoponfailedassert)
441    
442  REGISTER_TESTS_SIMPLE(compiler_basics, TESTS)  REGISTER_TESTS_SIMPLE(compiler_basics, TESTS)
443    

Legend:
Removed from v.2347  
changed lines
  Added in v.2348

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22