Changeset 12 for trunk

Show
Ignore:
Timestamp:
08/20/08 11:39:29 (4 years ago)
Author:
fumanchu
Message:

A var name tweak and some doc tweaks.

Location:
trunk/epic
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/epic/epic.sql

    r10 r12  
    4949    1. ALWAYS RAISE EXCEPTION at the end of test procs to rollback! Even if 
    5050        the test passes, RAISE EXCEPTION '[OK]'. You may instead PERFORM the 
    51         Epic functions test.pass(), test.fail(errmsg), test.todo(msg) and 
     51        Epic functions test.pass(), test.fail(msg), test.todo(msg) and 
    5252        test.skip(msg). 
    5353    2. Put your test in the "test" schema. 
     
    104104    * test.assert_less_than(elem_1 anyelement, elem_2 anyelement) 
    105105    * test.assert_less_than_or_equal(elem_1 anyelement, elem_2 anyelement) 
     106     
    106107    * test.assert_rows(row_1 text, row_2 text): 
    107108        Raises an exception if the SELECT statement row_1 != the SELECT statement row_2. 
     
    208209  WHERE pg_namespace.nspname = 'test' 
    209210    AND pg_proc.proname LIKE E'test\_%'; 
     211 
     212 
     213------------------------------ Runners ------------------------------ 
    210214 
    211215 
     
    278282 
    279283 
    280 CREATE OR REPLACE FUNCTION test.finish(result text, errmsg text) RETURNS VOID AS $$ 
     284------------------------------ Pass/fail ------------------------------ 
     285 
     286 
     287CREATE OR REPLACE FUNCTION test.finish(result text, msg text) RETURNS VOID AS $$ 
    281288-- Use this to finish a test. Raises the given result as an exception (for rollback). 
    282289DECLARE 
    283   msg        text; 
    284 BEGIN 
    285   msg := '[' || result || ']'; 
    286   IF errmsg IS NOT NULL THEN 
    287     msg := msg || ' ' || errmsg; 
    288   END IF; 
    289   RAISE EXCEPTION '%', msg; 
    290 END; 
    291 $$ LANGUAGE plpgsql; 
     290  fullmsg        text; 
     291BEGIN 
     292  fullmsg := '[' || result || ']'; 
     293  IF msg IS NOT NULL THEN 
     294    fullmsg := fullmsg || ' ' || msg; 
     295  END IF; 
     296  RAISE EXCEPTION '%', fullmsg; 
     297END; 
     298$$ LANGUAGE plpgsql IMMUTABLE; 
    292299 
    293300 
     
    297304  PERFORM test.finish('OK', msg); 
    298305END; 
    299 $$ LANGUAGE plpgsql; 
     306$$ LANGUAGE plpgsql IMMUTABLE; 
    300307CREATE OR REPLACE FUNCTION test.pass() RETURNS VOID AS $$ 
    301308-- Use this to finish a successful test. Raises exception '[OK]'. 
     
    303310  PERFORM test.finish('OK', NULL); 
    304311END; 
    305 $$ LANGUAGE plpgsql; 
     312$$ LANGUAGE plpgsql IMMUTABLE; 
    306313 
    307314 
     
    311318  PERFORM test.finish('FAIL', msg); 
    312319END; 
    313 $$ LANGUAGE plpgsql; 
     320$$ LANGUAGE plpgsql IMMUTABLE; 
    314321CREATE OR REPLACE FUNCTION test.fail() RETURNS VOID AS $$ 
    315322-- Use this to finish a failed test. Raises exception '[FAIL]'. 
     
    317324  PERFORM test.finish('FAIL', NULL); 
    318325END; 
    319 $$ LANGUAGE plpgsql; 
     326$$ LANGUAGE plpgsql IMMUTABLE; 
    320327 
    321328 
     
    325332  PERFORM test.finish('TODO', msg); 
    326333END; 
    327 $$ LANGUAGE plpgsql; 
     334$$ LANGUAGE plpgsql IMMUTABLE; 
    328335CREATE OR REPLACE FUNCTION test.todo() RETURNS VOID AS $$ 
    329336-- Use this to abort a test as 'todo'. Raises exception '[TODO]'. 
     
    331338  PERFORM test.finish('TODO', NULL); 
    332339END; 
    333 $$ LANGUAGE plpgsql; 
     340$$ LANGUAGE plpgsql IMMUTABLE; 
    334341 
    335342 
     
    339346  PERFORM test.finish('SKIP', msg); 
    340347END; 
    341 $$ LANGUAGE plpgsql; 
     348$$ LANGUAGE plpgsql IMMUTABLE; 
    342349CREATE OR REPLACE FUNCTION test.skip() RETURNS VOID AS $$ 
    343350-- Use this to skip a test. Raises exception '[SKIP]'. 
     
    345352  PERFORM test.finish('SKIP', NULL); 
    346353END; 
    347 $$ LANGUAGE plpgsql; 
    348  
    349  
    350 ------------------------------ Test helpers ------------------------------ 
     354$$ LANGUAGE plpgsql IMMUTABLE; 
     355 
     356 
     357------------------------------ Assertions ------------------------------ 
    351358 
    352359 
     
    520527-- 
    521528-- Both arguments should be SELECT statements yielding a single row or a set of rows. 
     529-- It is common for the 'expected' arg to be sans a FROM clause, and simply SELECT values. 
    522530-- Neither source nor expected need to be sorted. Either may include a trailing semicolon. 
    523531-- 
    524532-- Example: 
    525533--  
    526 --    PERFORM test.assert_row('SELECT first, last, city FROM table1', 
    527 --                            'SELECT ROW(''Davy'', ''Crockett'', NULL)'); 
     534--    PERFORM test.assert_rows('SELECT first, last, city FROM table1', 
     535--                             'SELECT ''Davy'', ''Crockett'', NULL'; 
    528536DECLARE 
    529537  rec     record; 
  • trunk/epic/test/test_results.sql

    r11 r12  
    2020  PERFORM test.fail('test.pass() did not raise the ''[OK]'' exception.'); 
    2121END; 
    22 $$ LANGUAGE plpgsql; 
     22$$ LANGUAGE plpgsql IMMUTABLE; 
    2323 
    2424