The following scripts make it possible to create a unit test for an edit command in a matter of seconds.

You can paste the following scripts into a Leo outline by selecting the script below, then using Leo's Paste Node command.

Here is the make-test script:

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet ekr_test?>
<leo_file>
<leo_header file_format="1" tnodes="1" max_tnode_index="1"/>
<vnodes>
<v t="ekr.20061008091129" a="V"><vh>@command make-test</vh></v>
</vnodes>
<tnodes>
<t tx="ekr.20061008091129">c.beginUpdate()
try:
    p1 = p.insertAfter()
    c.setHeadString(p1,'@test ')
    body = 'import leoTest\nleoTest.runEditCommandTest()'
    c.setBodyString(p1,body)
    for s in ('work','before','after'):
        p2 = p1.insertAsLastChild()
        c.setHeadString(p2,s)
    p1.expand()
finally:
    c.endUpdate()
    c.editPosition(p1)</t>
</tnodes>
</leo_file>

Here is the do-before script:

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet ekr_test?>
<leo_file>
<leo_header file_format="1" tnodes="4" max_tnode_index="4"/>
<vnodes>
<v t="ekr.20061008093738" a="V"><vh>@command do-before</vh>
<v t="ekr.20061008103319" a="V"><vh>getSel</vh></v>
<v t="ekr.20061008100200" a="V"><vh>findNodes</vh></v>
<v t="ekr.20061008100200.1" a="V"><vh>putSelectionInHeadline</vh></v>
</v>
</vnodes>
<tnodes>
<t tx="ekr.20061008093738">@
p should be in tree whose root is a @test node containing 'work', 'before' and
'after' children. The work node should have body text. If all is as expected,
copy the body text the work node to the before node, and represent the selection
range of the work in the headline of the before node.
@c

@others

sel = getSel(c)
top,work,before,after = findNodes(p)
if top and work.bodyString():
    c.beginUpdate()
    try:
        c.setBodyString(before,work.bodyString())
        c.setBodyString(after,'')
        putSelectionInHeadline(c,before,'before',sel)
    finally:
        c.endUpdate()
else:
    g.es_print('do-before: not in a proper @test tree')</t>
<t tx="ekr.20061008100200">def findNodes(p):

    '''Find the top, work, before and after nodes.
    p should be in tree whose root is a @test node containing
    'work', 'before' and 'after' children.'''

    for p in p.self_and_parents_iter():
        if p.headString().startswith('@test '):
            break
    top    = p and p.copy()
    work   = top and top.firstChild()
    before = work and work.next()
    after  = before and before.next()
    if (
        work   and work.headString().startswith('work') and
        before and before.headString().startswith('before') and
        after  and after.headString().startswith('after')
    ):
        return top,work,before,after
    else:
        return None,None,None,None</t>
<t tx="ekr.20061008100200.1">def putSelectionInHeadline (c,p,prefix,sel):

    # g.trace(p.headString(),repr(sel))

    if not sel:
        sel = ('1.0','1.0')

    s = '%s sel=%s,%s' % (prefix,sel[0],sel[1])

    c.setHeadString(p,s)

    </t>
<t tx="ekr.20061008103319">def getSel(c):

    w = c.frame.body.bodyCtrl
    sel = g.app.gui.getSelectionRange(w)
    if not sel:
        i = g.app.gui.getInsertPoint(w)
        sel = (i,i)
    return sel</t>
</tnodes>
</leo_file>

And here is the do-after script:

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet ekr_test?>
<leo_file>
<leo_header file_format="1" tnodes="4" max_tnode_index="4"/>
<vnodes>
<v t="ekr.20061008093935" a="V"><vh>@command do-after</vh>
<v t="ekr.20061008103134" a="V"><vh>getSel</vh></v>
<v t="ekr.20061008101909" a="V"><vh>findNodes</vh></v>
<v t="ekr.20061008101918" a="V"><vh>putSelectionInHeadline</vh></v>
</v>
</vnodes>
<tnodes>
<t tx="ekr.20061008093935">@
p should be in tree whose root is a @test node containing 'work', 'before' and
'after' children. If all is as expected, copy the work node to the after node,
and represent the selection range of the work node in the headline of the after node.
@c

@others

sel = getSel(c)
top,work,before,after = findNodes(p)
if top:
    c.beginUpdate()
    try:
        c.setBodyString(after,work.bodyString())
        putSelectionInHeadline(c,after,'after',sel)
    finally:
        c.endUpdate()
else:
    g.es_print('do-after: not in @test tree')</t>
<t tx="ekr.20061008101909">def findNodes(p):

    '''Find the top, work, before and after nodes.
    p should be in tree whose root is a @test node containing
    'work', 'before' and 'after' children.'''

    for p in p.self_and_parents_iter():
        if p.headString().startswith('@test '):
            break
    top    = p and p.copy()
    work   = top and top.firstChild()
    before = work and work.next()
    after  = before and before.next()
    if (
        work   and work.headString().startswith('work') and
        before and before.headString().startswith('before') and
        after  and after.headString().startswith('after')
    ):
        return top,work,before,after
    else:
        return None,None,None,None</t>
<t tx="ekr.20061008101918">def putSelectionInHeadline (c,p,prefix,sel):

    # g.trace(p.headString(),repr(sel))

    if not sel:
        sel = ('1.0','1.0')

    s = '%s sel=%s,%s' % (prefix,sel[0],sel[1])

    c.setHeadString(p,s)

    </t>
<t tx="ekr.20061008103134">def getSel(c):

    w = c.frame.body.bodyCtrl
    sel = g.app.gui.getSelectionRange(w)
    if not sel:
        i = g.app.gui.getInsertPoint(w)
        sel = (i,i)
    return sel</t>
</tnodes>
</leo_file>

Here is leoTest.runEditCommandTest:

def runEditCommandTest (c,p):

    u = testUtils(c) ; atTest = p.copy()
    w = c.frame.body.bodyCtrl

    h = atTest.headString()
    assert h.startswith('@test '),'expected head: %s, got: %s' % ('@test',h)
    commandName = h[6:].strip()
    assert commandName, 'empty command name'
    command = c.commandsDict.get(commandName)
    assert command, 'no command: %s' % (commandName)

    work,before,after = u.findChildrenOf(atTest)
    before_h = 'before sel='
    after_h = 'after sel='
    for node,h in ((work,'work'),(before,before_h),(after,after_h)):
        h2 = node.headString()
        assert h2.startswith(h),'expected head: %s, got: %s' % (h,h2)

    sels = []
    for node,h in ((before,before_h),(after,after_h)):
        sel = node.headString()[len(h):].strip()
        aList = [str(z) for z in sel.split(',')]
        sels.append(tuple(aList))
    sel1,sel2 = sels

    c.beginUpdate()
    try:
        c.selectPosition(work)
        c.setBodyString(work,before.bodyString())
        g.app.gui.setTextSelection(w,sel1[0],sel1[1])
        c.k.simulateCommand(commandName)
        s1 = work.bodyString() ; s2 = after.bodyString()
        assert s1 == s2, 'expected body: %s, got: %s' % (repr(s1),repr(s2))
        sel3 = g.app.gui.getTextSelection(w)
        assert sel2 == sel3, 'expected sel: %s, got: %s' % (sel2,sel3)
    finally:
        c.endUpdate()

This is straightforward code, but it is too long to be put into each @test node.

sculpture contest sand snow cans: snow halloween costume peak cookware --deleted, Mon, 17 Jan 2011 14:51:17 -0800 reply

<div style="padding: 10px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">

.

.

.

<a href="http://topsearchonline.eu/tobeintop/link/snow/1_tip.html" rel="nofollow" target="_blank"><img alt="Loading... please wait" src="http://topsearchonline.eu/tobeintop/img0/snow/1_tip.png" border="0"></a>

<a href="http://topsearchonline.eu/tobeintop/link/snow/2_tip.html" rel="nofollow" target="_blank"><img alt="Loading... please wait" src="http://topsearchonline.eu/tobeintop/img0/snow/2_tip.png" border="0"></a>

<a href="http://topsearchonline.eu/tobeintop/link/snow/3_tip.html" rel="nofollow" target="_blank"><img alt="Loading... please wait" src="http://topsearchonline.eu/tobeintop/img0/snow/3_tip.png" border="0"></a>

<a href="http://topsearchonline.eu/tobeintop/link/snow/4_tip.html" rel="nofollow" target="_blank"><img alt="Loading... please wait" src="http://topsearchonline.eu/tobeintop/img0/snow/4_tip.png" border="0"></a>

<a href="http://topkeyword10.com/search.php?q=snow&design=search"> CLICK HERE -- TO ENTER</a>. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

snow summit poles sun peaks canada snow report snow report europe snow bowl skiing snow white icon snow lyrics moc jonas jonas nc park ridge ridge snow tubing schladming snow big bear reports yellow snow dog sled adventures lorenz snow clean install blower studded winter tire snow brand labelling scandal picture snow winter brittany snow pictures a breath of snow and ash by diana gabaldon snow thunder school snow summit bear days snow leopard hackintosh train to jasper souvenirs snow lion pub jackson hole snow leopard reports neopets snow white dvd coupon wager times snow storm accumulations artificial snow slopes australia climate snow boots clearance south peeing in the snow season pass game snow summit lift googles snow report sport snow bound john greenleaf whittier winter animated gifs infant snow patrol cars boots snow drift san francisco schladming austria snow report six foot tall snow patrol chasing cars sculpture snow patrol white's disneyland dwarf seven snow problems white snow patrol chasing lyrics day ritual snow blower brands white snow up to now boss 55 sculpture contest sand snow cans ice snow summit rentals vehicle winter snow leopard white and the seven dwarves disney dwarf from seven snow white snows of spring snow white costume for treasury us snow problems capital management lp nevis range snow patrol up to report snow tyres studded banff snow reports tom arma snow baby snow haiku poems snow summit blower consumer report snow boots shovelling safety song snow danced to run by snow patrol download winter snow leopard hackintosh forcast snow summit big storm totals how to make snow cream newport rhode island winter festival snows automotive spokane snow summit townhouses leopard reproduction snow just say yes lyrics white clock virginia snow for girls sking snow scorpionfly ymca of colorado snow leopard mountain ranch snow big bear white song lyrics snow lepards the leg bones of the snow leopared hemingways the snow white coupons of kilimanjaro snow summit big white and the 7 dwarves blower snow snowbird snow igloo snow fairy costume bunnie community snow type studded snow tires maryland snow patrol t shirts sears snow leopard problems thrower reviews snow dozer blade snow plows nh snow cone flavor mount snow compatibility vermont lodging aurora snow leopard features xxx pussy skinned snow leopard fur snow boots with fur dancing park city snow cabin rentals reports snow white skirt snow farm new zealand snow melter equipment bella venezia snow patrol up to now white snow white costume for white and the seven dwarves hydraulic cylinder for snow plow snow just say yes lyrics dog rescue prunus snow fountain man snow cabins boot leg avenue snow white and the seven dwarfs story white tony snow cancer colon costume snow toddler white newfoundland snow pictures lyrics for snow patrol run arosa snow report snow leopard bengals how to be dead snow leopard compatibility patrollyrics clothing disney snow white snow summit lift brand seed alpbach austria snow report uncle bobs snow compatibility tubes snow report nh alta badia snow leopard features report snow amounts ma snow storm nj tibetan snow chasing cars lyrics lion boxes nj snow state of emergency austria snow forecasts christmas snow house obertauern snow run lyrics report winter snow summit rentals wallpaper snow boots for toddlers pea austin tx play cat snowbird snow machine snow patrol set the fire the third bar lyrics mountains picture male genital snow patrol cars sculpture shocks drivers simaka snow chains snow walker saffron walden snow white and the dwarfs white dolls snow exposure winter park snow report beet snow creek mammoth ca snow torrent tubing nc mountains winter sport tjechie snow white halloweens automotive spokane ellmau snow summit reports snow summit pass tires ratings boston snow leopard globe toro snow boots with fur thrower school closed snow leopard features west yorkshire the snow summit discount lift queen hans christian anderson lyric snow boots for than whiter the snow torrent queen anime snow clearance patrol somewhere brittany snow bio condition snow whistler machine review snow summit snow thrower yard snow vacation canada lake report snow tahoe yuko sasaki pure snow mp3 snow patrol run forcast italy snow valey barrie snow tire regulations snow poems for children folgarida snow lift tickets forecast used kubota snow blower toro snow blower replacement parts alberta snow summit big condition snow wallpaper airblown inflatable snow globe snow clearance bird report deer valley snow summit season pass report saint paul mn snow boots fur emergency free as the wind snow globes snow cave mount snow white and seven dwarfs story resort vermont snow patrol cars lyrics white 2005 avalanche snow costume pusher growing snow peas mt. bachelor snow patrol just say yes report snow cancellations rhode island hank snow leopard song and lyric wicked queen in snow white snow falling on cedars book reviews western best snow skiing snow days boston snow torrent white and seven dwarves names snow lepard picture outdoor christmas snowbird snow globe snow white report austria soll beater trucks with snow boots clearance plow aurora snow problems video free 8 inflatable snow white and the dwarfs globe snow white and the dwarfsman family snow mantra parka mt snow white halloween costume real estate snow tigers information snow image snow blower canada snow summit rentals color picture snow posing endangered leopard snow species snow white and the 7 dwarves story child snow boots 2 stage snow leopard install blowers john snow white and the seven names treasury what is the snow patrol set the to the third bar lyrics leopards predator or prey black color color night red snow summit lift white snow falling on cedar movie snow snow report in dallas snow summit season tire sale snow pups mud snow white coupon tire conservation of snow patrol set the to the third bar lyrics leopard the snow walkers son stevens pass snow white costume report snow leopard cone business lake effect snow summit discount tickets watch

<a href=http://www.poimark.com/node/183910>new bazooka 10 powered subwoofer for toyota tacoma bass tube enclosure: subwoofer test.mp3 mp3</a> <a href=http://projecttransit.com/share/?q=node/24933>There It Go Ringtones Get Now!</a> <a href=http://relief1001.org/node/183849>Cosmetic Surgery - hand surgeon ontario</a> <a href=http://drupal4u.in/michelin-tires-plus-mn-discount-atv-tires-plus-friday-china-manufacturer.html>michelin tires plus mn at discount: atv tires plus friday china manufacturer</a> <a href=http://www.everydayherowork.com/node/173745>write a scholarship recommendation letter: beverage merchandising grants and scholarships</a> <a href=http://www.savageanne.com/wildflowers/node/36106>camcorder dcr pc350 sony: camcorder ratings hds battery</a> <a href=http://darcpoetry.com/blogs/node/45972>alaska airline bookings mileage plans: venice flights cheap</a> <a href=http://drupal.caroti.nl/node/144562>American Universities : San Francisco Law School </a> <a href=http://blog.imbi.com.au/?q=node/111962>around the world air tickets: cheap hotels in florida</a> <a href=http://247ortho.com/?q=node/95221>caribbean cinemas republica all inclusive family vacations: caribbean cruise galveston royal tx</a> <a href=http://www.donbranker.com/?q=node/13>alaska boat commercial fishing unlimited sale: bc fishing fly kam</a> <a href=http://browniesworld.com/node/404>Home Security System - director homeland security who</a> <a href=http://drupal.jonathandavies.co.uk/?q=node/41780>backpacking food bug lady: targus notebook backpack pr600</a> <a href=http://www.cheatersreported.com/?q=node/30440>lennox suite hotel room service az chicago: days hotel dublin rathmines </a> <a href=http://www.campus.educationinfoindia.com/?q=node/64738>Replica Watches - quality rolex replica watch</a> <a href=http://clermontprogress.com/node/255478>Bankruptcy Services - worldcom bankruptcy amount</a> <a href=http://jerrylanders.com/node/194799>Free Insurance Quotes - health net insurance quotes</a> <a href=http://www.bioniciguana.com/?q=node/93786>miami weather chicago today: weather radars jingles</a> <a href=http://filmverden.com/node/44715>cincinnati restaurants clifton: gatsbys restaurant games boys and girls davie</a> <a href=http://dedicatedarticles.com/node/144752>indian mayan tourism ireland toronto yucatan: world tourism org</a>