// ..\Tests\700-require-ensure\606-inherit-require-indexer.cobra.cs // Generated by Cobra // on 12/26/2006 6:06:03 PM using System; using System.Collections.Generic; using System.IO; using System.Text; using Cobra.Lang; public class RequireInBothA : Object { // 1 // 3 public virtual int this[int key] { // 3 get{ // 3 if (CobraCore._willCheckRequire) { // 4 require_Item_get_2296_RequireInBothA(key); } bool _lh_canEnsure = true; int _lh_result_1001 = 0; try { return _lh_result_1001=key; // 5 } catch { _lh_canEnsure = false; throw; } finally { // ensure if (_lh_canEnsure) { if (CobraCore._willCheckEnsure) { // 3 ensure_Item_get_2296_RequireInBothA(_lh_result_1001,key); } } } } } protected void require_Item_get_2296_RequireInBothA(int key) { // 3 if (!(key>0)) throw new RequireException("..\\Tests\\700-require-ensure\\606-inherit-require-indexer.cobra", 4, "key GT 0", this); // 4 } protected void ensure_Item_get_2296_RequireInBothA(int _lh_result_1001,int key) { // 3 } static RequireInBothA() { RunTestsIfNeeded(); } private static bool __didStartTests = false; public static void RunTestsIfNeeded() { if (!__didStartTests) RunTests(); } public static void RunTests() { __didStartTests = true; CobraImp.TestBegan("RequireInBothA"); CobraImp.TestEnded("RequireInBothA"); } } // class RequireInBothA public class RequireInBothB : RequireInBothA { // 7 // 10 public override int this[int keyy] { // 10 get{ // 10 if (CobraCore._willCheckRequire) { // 11 try { require_Item_get_2309_RequireInBothB(keyy); } catch (RequireException re1) { try { require_Item_get_2296_RequireInBothA(keyy); } catch (RequireException re2) { re1.Next = re2; throw re1; } } } bool _lh_canEnsure = true; int _lh_result_1001 = 0; try { return _lh_result_1001=keyy; // 13 } catch { _lh_canEnsure = false; throw; } finally { // ensure if (_lh_canEnsure) { if (CobraCore._willCheckEnsure) { // 10 ensure_Item_get_2309_RequireInBothB(_lh_result_1001,keyy); ensure_Item_get_2296_RequireInBothA(_lh_result_1001,keyy); } } } } } protected void require_Item_get_2309_RequireInBothB(int keyy) { // 10 if (!(keyy==0)) throw new RequireException("..\\Tests\\700-require-ensure\\606-inherit-require-indexer.cobra", 11, "keyy EQ 0", this); // 11 } protected void ensure_Item_get_2309_RequireInBothB(int _lh_result_1001,int keyy) { // 10 } static RequireInBothB() { RunTestsIfNeeded(); } private static bool __didStartTests = false; public static new void RunTestsIfNeeded() { if (!__didStartTests) RunTests(); } public static new void RunTests() { __didStartTests = true; CobraImp.TestBegan("RequireInBothB"); CobraImp.TestEnded("RequireInBothB"); } } // class RequireInBothB public class NoRequireInBaseA : Object { // 16 // 18 public virtual int this[int i] { // 18 get{ // 18 if (CobraCore._willCheckRequire) { // 18 require_Item_get_2321_NoRequireInBaseA(i); } bool _lh_canEnsure = true; int _lh_result_1001 = 0; try { return _lh_result_1001=i; // 19 } catch { _lh_canEnsure = false; throw; } finally { // ensure if (_lh_canEnsure) { if (CobraCore._willCheckEnsure) { // 18 ensure_Item_get_2321_NoRequireInBaseA(_lh_result_1001,i); } } } } } protected void require_Item_get_2321_NoRequireInBaseA(int i) { // 18 } protected void ensure_Item_get_2321_NoRequireInBaseA(int _lh_result_1001,int i) { // 18 } static NoRequireInBaseA() { RunTestsIfNeeded(); } private static bool __didStartTests = false; public static void RunTestsIfNeeded() { if (!__didStartTests) RunTests(); } public static void RunTests() { __didStartTests = true; CobraImp.TestBegan("NoRequireInBaseA"); CobraImp.TestEnded("NoRequireInBaseA"); } } // class NoRequireInBaseA public class NoRequireInBaseB : NoRequireInBaseA { // 21 // 24 public override int this[int i] { // 24 get{ // 24 if (CobraCore._willCheckRequire) { // 25 try { require_Item_get_2330_NoRequireInBaseB(i); } catch (RequireException re1) { try { require_Item_get_2321_NoRequireInBaseA(i); } catch (RequireException re2) { re1.Next = re2; throw re1; } } } bool _lh_canEnsure = true; int _lh_result_1001 = 0; try { return _lh_result_1001=i; // 28 } catch { _lh_canEnsure = false; throw; } finally { // ensure if (_lh_canEnsure) { if (CobraCore._willCheckEnsure) { // 24 ensure_Item_get_2330_NoRequireInBaseB(_lh_result_1001,i); ensure_Item_get_2321_NoRequireInBaseA(_lh_result_1001,i); } } } } } protected void require_Item_get_2330_NoRequireInBaseB(int i) { // 24 if (!(i>0)) throw new RequireException("..\\Tests\\700-require-ensure\\606-inherit-require-indexer.cobra", 26, "i GT 0", this); // 26 } protected void ensure_Item_get_2330_NoRequireInBaseB(int _lh_result_1001,int i) { // 24 } static NoRequireInBaseB() { RunTestsIfNeeded(); } private static bool __didStartTests = false; public static new void RunTestsIfNeeded() { if (!__didStartTests) RunTests(); } public static new void RunTests() { __didStartTests = true; CobraImp.TestBegan("NoRequireInBaseB"); CobraImp.TestEnded("NoRequireInBaseB"); } } // class NoRequireInBaseB public class NoRequireInDerivedA : Object { // 31 // 33 public virtual int this[int i] { // 33 get{ // 33 if (CobraCore._willCheckRequire) { // 34 require_Item_get_2342_NoRequireInDerivedA(i); } bool _lh_canEnsure = true; int _lh_result_1001 = 0; try { return _lh_result_1001=i; // 35 } catch { _lh_canEnsure = false; throw; } finally { // ensure if (_lh_canEnsure) { if (CobraCore._willCheckEnsure) { // 33 ensure_Item_get_2342_NoRequireInDerivedA(_lh_result_1001,i); } } } } } protected void require_Item_get_2342_NoRequireInDerivedA(int i) { // 33 if (!(i>0)) throw new RequireException("..\\Tests\\700-require-ensure\\606-inherit-require-indexer.cobra", 34, "i GT 0", this); // 34 } protected void ensure_Item_get_2342_NoRequireInDerivedA(int _lh_result_1001,int i) { // 33 } static NoRequireInDerivedA() { RunTestsIfNeeded(); } private static bool __didStartTests = false; public static void RunTestsIfNeeded() { if (!__didStartTests) RunTests(); } public static void RunTests() { __didStartTests = true; CobraImp.TestBegan("NoRequireInDerivedA"); CobraImp.TestEnded("NoRequireInDerivedA"); } } // class NoRequireInDerivedA public class NoRequireInDerivedB : NoRequireInDerivedA { // 38 // 41 public override int this[int i] { // 41 get{ // 41 if (CobraCore._willCheckRequire) { // 41 try { require_Item_get_2342_NoRequireInDerivedA(i); } catch (RequireException re1) { throw re1; } } bool _lh_canEnsure = true; int _lh_result_1001 = 0; try { return _lh_result_1001=i; // 42 } catch { _lh_canEnsure = false; throw; } finally { // ensure if (_lh_canEnsure) { if (CobraCore._willCheckEnsure) { // 41 ensure_Item_get_2355_NoRequireInDerivedB(_lh_result_1001,i); ensure_Item_get_2342_NoRequireInDerivedA(_lh_result_1001,i); } } } } } protected void require_Item_get_2355_NoRequireInDerivedB(int i) { // 41 } protected void ensure_Item_get_2355_NoRequireInDerivedB(int _lh_result_1001,int i) { // 41 } static NoRequireInDerivedB() { RunTestsIfNeeded(); } private static bool __didStartTests = false; public static new void RunTestsIfNeeded() { if (!__didStartTests) RunTests(); } public static new void RunTests() { __didStartTests = true; CobraImp.TestBegan("NoRequireInDerivedB"); CobraImp.TestEnded("NoRequireInDerivedB"); } } // class NoRequireInDerivedB public class Test : Object { // 45 public static void Main() { // 47 if (CobraCore._willCheckRequire) { // 47 require_Main_2359_Test(); } // locals RequireException re = null; RequireInBothA a1 = null; int i = 0; RequireInBothB b1 = null; NoRequireInBaseB b2 = null; NoRequireInDerivedB b3 = null; RequireInBothB b4 = null; bool _lh_canEnsure = true; try { a1=(new RequireInBothA()); // 48 i=(a1[1]); // 49 bool _lh_expect_1001 = false; // 50 try { // 51 i=(a1[0]); // 51 } catch (RequireException) { // exactly what is expected _lh_expect_1001 = true; } catch (Exception _lh_expect_1002) { throw new ExpectException(typeof(RequireException), _lh_expect_1002); } if (!_lh_expect_1001) throw new ExpectException(typeof(RequireException), null); b1=(new RequireInBothB()); // 52 i=(b1[1]); // 53 i=(b1[0]); // 54 bool _lh_expect_1003 = false; // 55 try { // 56 i=(b1[(-1)]); // 56 } catch (RequireException) { // exactly what is expected _lh_expect_1003 = true; } catch (Exception _lh_expect_1004) { throw new ExpectException(typeof(RequireException), _lh_expect_1004); } if (!_lh_expect_1003) throw new ExpectException(typeof(RequireException), null); b2=(new NoRequireInBaseB()); // 58 i=(b2[1]); // 59 i=(b2[0]); // 60 b3=(new NoRequireInDerivedB()); // 62 bool _lh_expect_1005 = false; // 63 try { // 64 i=(b3[0]); // 64 } catch (RequireException) { // exactly what is expected _lh_expect_1005 = true; } catch (Exception _lh_expect_1006) { throw new ExpectException(typeof(RequireException), _lh_expect_1006); } if (!_lh_expect_1005) throw new ExpectException(typeof(RequireException), null); b4=(new RequireInBothB()); // 67 try{ // 69 i=(b4[(-1)]); // 69 } catch (RequireException _lh_catch_1008){ // 71 re = _lh_catch_1008; if (CobraCore._willCheckAssert && !(CobraImp.IsNot((re.Next),null))) throw new AssertException("..\\Tests\\700-require-ensure\\606-inherit-require-indexer.cobra", 71, "re DOT next ISNOT nil", null); // 71 if (CobraCore._willCheckAssert && !(CobraImp.Is((re.Next.Next),null))) throw new AssertException("..\\Tests\\700-require-ensure\\606-inherit-require-indexer.cobra", 72, "re DOT next DOT next IS nil", null); // 72 } } catch { _lh_canEnsure = false; throw; } finally { // ensure if (_lh_canEnsure) { if (CobraCore._willCheckEnsure) { // 47 ensure_Main_2359_Test(); } } } } static protected void require_Main_2359_Test() { } static protected void ensure_Main_2359_Test() { } static Test() { RunTestsIfNeeded(); } private static bool __didStartTests = false; public static void RunTestsIfNeeded() { if (!__didStartTests) RunTests(); } public static void RunTests() { __didStartTests = true; CobraImp.TestBegan("Test"); CobraImp.TestEnded("Test"); } } // class Test