6.10.10.2.3.1. Begin/end test

6.10.10.2.3.1. Begin/end test

Start data section to interscript/tests/test_beginend.pak[1]
     1: @head(1,'Begin/End test')
     2: We test the @begin and @end commands with a simple scoping test.
     3: First, a level is set to 1, and we create a class with
     4: a destructor and an object thereof.
     5: @class X:
     6:    def __init__(self, level, weaver):
     7:      self.level = level
     8:      self.weaver = weaver
     9:    def __del__(self):
    10:      self.weaver.writeline('X object of level '+str(self.level)+' destroyed.')
    11:  level=1
    12:  x = X(level, get_weaver())
    13: @weave('Level is '+str(level)+'. ')
    14: @p()
    15: Now, a new block.
    16: @begin()
    17: Check old value of level.
    18: @weave('Level is '+str(level)+'. ')
    19: Now set level to 2, and create another class object.
    20: @level = 2
    21: @x = X(level,get_weaver())
    22: @weave('Level is '+str(level)+'. ')
    23: @p()
    24: Finally we end the block here. This should kill the inner class object.
    25: @end()
    26: @p()
    27: Back in the old block we test the level.
    28: @weave('Level is '+str(level)+'. ')
    29: That's the simple test. Now, the outer class object should die.
End data section to interscript/tests/test_beginend.pak[1]
We can look at the html results at ../tests/test_beginend.html