head	1.2;
access;
symbols
	tcllib-1-13:1.2
	tcllib-1-12:1.2;
locks; strict;
comment	@# @;


1.2
date	2009.04.08.04.08.58;	author andreas_kupries;	state Exp;
branches;
next	1.1;

1.1
date	2009.04.01.04.28.37;	author andreas_kupries;	state Exp;
branches;
next	;


desc
@@


1.2
log
@
        * export.man: Typo fixed.
        * import.man: Ditto.
        * introduction.man: Ditto.
        * include/msgcat.inc: Ditto.
        * include/export/config/html.inc: Ditto.
        * include/import/plugin.inc: Ditto.
        * import_docidx.tcl: Ditto.
        * import_json.tcl: Ditto.
        * tests/parse: Ditto.
@
text
@# -*- tcl -*-
# docidx_parse.testsuite:  tests for the docidx parser.
#
# Copyright (c) 2009 Andreas Kupries <andreas_kupries@@users.sourceforge.net>
# All rights reserved.
#
# RCS: @@(#) $Id: parse,v 1.1 2009/04/01 04:28:37 andreas_kupries Exp $

# -------------------------------------------------------------------------

source [tcllibPath doctools2base/tests/common]
set mytestdir tests/data

# -------------------------------------------------------------------------

# We are checking that the various forms of docidx markup, as can be
# generated by doctools::idx::export::docidx are valid input to the
# docidx parser.
#
# section {} holds the non-canonical input we have to accept and make
# canonical to higher layers.

foreach {k section} {
    0 {}
    1 -ultracompact
    2 -compact
    3 -indented
    4 -aligned
    5 -indalign
} {
    TestFilesProcess $mytestdir ok docidx$section serial-print -> n label input data expected {
	test doctools-idx-parse-${stkimpl}-${setimpl}-${impl}-20.$k.$n "doctools::idx::parse text, $label$section, ok" -setup {
	    # Define a few basic variables and include search paths for
	    # use by the test
	    doctools::idx::parse var load {fox dog lazy jump}
	    doctools::idx::parse include set [TestFilesGlob $mytestdir]
	} -body {
	    doctools::idx::structure print \
		[doctools::idx::parse text $data]
	} -cleanup {
	    doctools::idx::parse include clear
	    doctools::idx::parse var unset *
	} -result $expected
    }

    TestFilesProcess $mytestdir ok docidx$section serial-print -> n label input data expected {
	test doctools-idx-parse-${stkimpl}-${setimpl}-${impl}-21.$k.$n "doctools::idx::parse file, $label$section, ok" -setup {
	    # Define a few basic variables and include search paths for
	    # use by the test
	    doctools::idx::parse var load {fox dog lazy jump}
	    doctools::idx::parse include set [TestFilesGlob $mytestdir]
	} -body {
	    doctools::idx::structure print \
		[doctools::idx::parse file $input]
	} -cleanup {
	    doctools::idx::parse include clear
	    doctools::idx::parse var unset *
	} -result $expected
    }
}

# -------------------------------------------------------------------------

# We test the error messages and codes thrown by the parser for a
# variety of failure possibilities.

TestFilesProcess $mytestdir fail docidx emsg -> n label input data expected {
    test doctools-idx-parse-${stkimpl}-${setimpl}-${impl}-22.$n "doctools::idx::parse, $label, error message" -setup {
	# Define a few basic variables and include search paths for
	# use by the test
	doctools::idx::parse var load {fox dog lazy jump}
	doctools::idx::parse include set [TestFilesGlob $mytestdir]
    } -body {
	doctools::idx::parse text $data
    } -cleanup {
	doctools::idx::parse include clear
	doctools::idx::parse var unset *
    } -returnCodes error -result $expected
}

TestFilesProcess $mytestdir fail docidx ecode -> n label input data expected {
    test doctools-idx-parse-${stkimpl}-${setimpl}-${impl}-23.$n "doctools::idx::parse, $label, error code" -setup {
	# Define a few basic variables and include search paths for
	# use by the test
	doctools::idx::parse var load {fox dog lazy jump}
	doctools::idx::parse include set [TestFilesGlob $mytestdir]
    } -body {
	# Catch and rethrow using the error code as new message.
	catch { doctools::idx::parse text $data }
	set ::errorCode
    } -cleanup {
	doctools::idx::parse include clear
	doctools::idx::parse var unset *
    } -result $expected
}

TestFilesProcess $mytestdir fail docidx emsg -> n label input data expected {
    test doctools-idx-parse-${stkimpl}-${setimpl}-${impl}-24.$n "doctools::idx::parse file, $label, error message" -setup {
	# Define a few basic variables and include search paths for
	# use by the test
	doctools::idx::parse var load {fox dog lazy jump}
	doctools::idx::parse include set [TestFilesGlob $mytestdir]
    } -body {
	catch { [doctools::idx::parse file $input] } msg
	string map [list "\"$input\" " {}] $msg
    } -cleanup {
	doctools::idx::parse include clear
	doctools::idx::parse var unset *
    } -result $expected
}

TestFilesProcess $mytestdir fail docidx ecode -> n label input data expected {
    test doctools-idx-parse-${stkimpl}-${setimpl}-${impl}-25.$n "doctools::idx::parse file, $label, error code" -setup {
	# Define a few basic variables and include search paths for
	# use by the test
	doctools::idx::parse var load {fox dog lazy jump}
	doctools::idx::parse include set [TestFilesGlob $mytestdir]
    } -body {
	# Catch and rethrow using the error code as new message.
	catch { doctools::idx::parse file $input }
	string map [list $input {{}}] $::errorCode
    } -cleanup {
	doctools::idx::parse include clear
	doctools::idx::parse var unset *
    } -result $expected
}

# -------------------------------------------------------------------------
unset mytestdir n label input data expected
return
@


1.1
log
@
	* Doctools version 2, index processing.
@
text
@d7 1
a7 1
# RCS: @@(#) $Id: XOpsControl,v 1.10 2008/11/20 07:26:43 andreas_kupries Exp $
d17 1
a17 1
# generated by doctools::idx(::format::docidx) are valid input to the
@

