BEGIN;

CREATE SCHEMA test;
CREATE EXTENSION pg_doctest SCHEMA test;

CREATE SCHEMA foo;

-- These tests are correct
CREATE OR REPLACE FUNCTION foo.plus ( a INT, b INT)
RETURNS INT
AS $func$
        --           >>> select        foo.plus(1,1)
  -- 2
-- >>>  SELECT foo.plus(NULL,9)
  -- NULL
        -- >>> SELECt  foo.plus(0,000)
        -- 0
  SELECT a+b;
$func$
  LANGUAGE SQL
;

-- These tests will fail
CREATE OR REPLACE FUNCTION foo.minus ( a INT, b INT)
RETURNS INT
AS $func$
  -- >>> SELECT foo.minus(1,1)
  -- 2
-- >>> SELECT foo.minus(NULL,9)
-- NULL
  SELECT a-b;
$func$
  LANGUAGE SQL
;

SELECT call, passed FROM test.test_schema('foo');

SELECT * FROM test.run('foo');

DROP SCHEMA foo CASCADE;

ROLLBACK;
