#!/bin/env perl

use strict;
use warnings;

print <<'END-OF-TEXT';
\set ECHO all

-- Test round-trip equivalence of parsed and deparsed numbers
-- This file is auto-generated by deparse-generate.pl

END-OF-TEXT

my @types = qw( numeric float8 int );
for my $type (@types)
{
	my $i = 0;
	for my $sign ('-', '')
    {
        for my $cast_type (@types)
        {
            for my $literal (
                qq{a < ${sign}1},
                qq{a < '${sign}1'},
                qq{a < ${sign}1::$cast_type},
                qq{a < (${sign}1)::$cast_type},
                qq{a < ${sign}1.1},
                qq{a < '${sign}1.1'},
                qq{a < ${sign}1.1::$cast_type},
                qq{a < (${sign}1.1)::$cast_type},
                qq{a < '${sign}nan'},
                qq{a < '${sign}inf'},
                qq{a < ${sign}null::$cast_type},
            )
            {
                ++$i;
                my $table = "test_deparse_${type}_$i";
                print "CREATE TABLE $table (a $type CHECK ($literal));\n";
                print "SELECT pg_get_constraintdef(pc.oid) FROM pg_constraint pc WHERE conname = '${table}_a_check';\n";
            }
        }
	}
	print "\n";
}

print "-- End of test\n";
