Ignore:
Timestamp:
Oct 24, 2003, 9:19:00 AM (22 years ago)
Author:
bird
Message:

Extended testcase.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/testcase/throw.cpp

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r834 r835  
    2222    }
    2323
     24    int getthrow() const throw(int)
     25    {
     26        throw(2);
     27        return i;
     28    }
    2429};
    2530
    2631
    2732static foo  o2(2);
     33static bar  o3(3);
    2834
    2935int main()
     
    3844        rc++;
    3945        fprintf(stderr, "o2 failed\n");
     46    }
     47    try
     48    {
     49        rc += o2.getthrow();
     50        printf("error: foo::getthrow() didn't throw!\n");
     51    }
     52    catch (int e)
     53    {
     54        fprintf(stderr, "foo caught e=%d (ok)\n", e);
    4055    }
    4156
     
    5267    {
    5368        fprintf(stderr, "foo caught e=%d (ok)\n", e);
     69    }
     70
     71
     72    /* static bar - external implementation */
     73    if (o3.get() == 3)
     74        fprintf(stderr, "o3 ok\n");
     75    else
     76    {
     77        rc++;
     78        fprintf(stderr, "o3 failed\n");
     79    }
     80    try
     81    {
     82        rc += o3.getThrow();
     83        printf("error: bar:getThrow() didn't throw!\n");
     84    }
     85    catch (expt e)
     86    {
     87        fprintf(stderr, "foo caught e=%d (ok)\n", e.get());
    5488    }
    5589
Note: See TracChangeset for help on using the changeset viewer.