The problem: Regression Testing. Create a series of tests that prove software is operating correctly.
The solution:
Note: You can cut and paste these code fragments into the code pane of the Glee interpreter and experiment as you go along to see the actual operations live.
The Glee code:
$$=======================================================
'test'#op{ $$ The Tester
$$=======================================================
''=> #csexact => #csglee;
'{',l__,'}' #x #crccsws => x__x; x__x=r__=>s_a_m_e;
:?(s_a_m_e){'passed:'l__$}
:: {('!'%%60)(13
#asc)('failed:')
(l__)(';
got:') (x__x)('; want:')(r__)$}
;};
$$=======================================================
'='%%40=>b$;'Calibrating the tests:'$;b$;
$$=======================================================
{$R__$r (2.._2) + __=>x; 0=>y;x test y;};
$$-------------------------------------------------------
{$R__$r 1 2 3 + (6 5 4) __=>x; 0=>y;x test y;};
$$-------------------------------------------------------
{$R__$r _2 0 3 - __ =>x; 0=>y;x test y;};
$$-------------------------------------------------------
$$=======================================================
b$;'A test run after calibration (and code change):'$;b$;
$$=======================================================
{$R__$r (2.._2) + __ =>x; 65278 =>y;x test y;};
$$-------------------------------------------------------
{$R__$r 1 3 2 + (6 5 4) __ =>x; 458752 =>y;x test y;};
$$-------------------------------------------------------
{$R__$r _2 0 3 - __ =>x; 50330880 =>y;x test y;};
$$=======================================================
The Output:
========================================
Calibrating the tests:
========================================
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
failed: (2.._2) + ; got:65278; want:0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
failed: 1 2 3 + (6 5 4) ; got:458752; want:0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
failed: _2 0 3 - ; got:50330880; want:0
========================================
A test run after calibration (and code change):
========================================
passed: (2.._2) +
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
failed: 1 3 2 + (6 5 4) ; got:235408897; want:458752
passed: _2 0 3 -
The play-by-play:
$$=======================================================
'test'#op{ $$ The Tester
$$=======================================================
''=> #csexact => #csglee;
'{',l__,'}' #x #crccsws =r__ =>s_a_m_e;
:?(s_a_m_e){'passed:'l__$}
:: {('!'%%60)(10
#asc)('failed:')
(l__)(';
got:') (x__x)('; want:')(r__)$}
;};
I use this technique to regression test the entire Glee website. It allows me to play fast-and-loose with my code changes and still maintain confidence that I have not created failure where I once enjoyed success.
This completes the example. To better understand these operators and other things you can do with them, consult the operator pages according to the type of data you see being operated on.