# stubs_writer.test -*- tcl -*-
#
# $Id: stubs::writer.test,v 1.8 2010/07/06 19:39:00 andreas_kupries Exp $

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

source [file join [file dirname [info script]] support testutilities.tcl]

testsNeedTcl     8.4
testsNeedTcltest 2

support {
    useLocal lib/lassign84/lassign.tcl  lassign84
    useLocal lib/dict84/dict.tcl     dict84

    useLocal lib/stubs_container/container.tcl stubs::container
    useLocal lib/stubs_reader/reader.tcl       stubs::reader
    useLocal lib/stubs_genframe/genframe.tcl   stubs::gen
}
testing {
    useLocal lib/stubs_writer/writer.tcl stubs::writer
}

# -------------------------------------------------------------------------
# gen

test stubs-writer-1.0 {gen, wrong\#args} -setup {
} -body {
    stubs::writer::gen
} -cleanup {
} -returnCodes error -result {wrong # args: should be "stubs::writer::gen table"}

test stubs-writer-1.1 {gen, wrong\#args} -setup {
} -body {
    stubs::writer::gen T x
} -cleanup {
} -returnCodes error -result {wrong # args: should be "stubs::writer::gen table"}

# -------------------------------------------------------------------------
## Representation overview for lots of declarations.

test stubs-writer-2.0 {text, empty} -setup {
    set T [stubs::container::new]
} -body {
    stubs::reader::text T {}
    stubs::writer::gen $T
} -cleanup {
    unset T
} -result {# UNKNOWN.decls -- -*- tcl -*-
#
#	This file contains the declarations for all public functions
#	that are exported by the "UNKNOWN" library via its stubs table.
#

library   UNKNOWN
# END UNKNOWN}

test stubs-writer-2.1 {text, basic types} -setup {
    set T [stubs::container::new]
} -body {
    stubs::reader::text T {
        library buf
        interface buf
        hooks {bufInt memchan}
        declare 0 generic {
            int Buf_IsInitialized (Tcl_Interp *interp)
        }
    }
    stubs::writer::gen $T
} -cleanup {
    unset T
} -result {# buf.decls -- -*- tcl -*-
#
#	This file contains the declarations for all public functions
#	that are exported by the "buf" library via its stubs table.
#

library   buf

interface buf
hooks {bufInt memchan}

declare 0 generic {
    int Buf_IsInitialized (Tcl_Interp * interp)
}

# END buf}

test stubs-writer-2.2 {text, void} -setup {
    set T [stubs::container::new]
} -body {
    stubs::reader::text T {
        library buf
        interface buf
        hooks {bufInt memchan}
        declare 0 generic {
            int Buf_IsInitialized (void)
        }
    }
    stubs::writer::gen $T
} -cleanup {
    unset T
} -result {# buf.decls -- -*- tcl -*-
#
#	This file contains the declarations for all public functions
#	that are exported by the "buf" library via its stubs table.
#

library   buf

interface buf
hooks {bufInt memchan}

declare 0 generic {
    int Buf_IsInitialized (void)
}

# END buf}

test stubs-writer-2.3 {text, void via missing arguments} -setup {
    set T [stubs::container::new]
} -body {
    stubs::reader::text T {
        library buf
        interface buf
        hooks {bufInt memchan}
        declare 0 generic {
            int Buf_IsInitialized ()
        }
    }
    stubs::writer::gen $T
} -cleanup {
    unset T
} -result {# buf.decls -- -*- tcl -*-
#
#	This file contains the declarations for all public functions
#	that are exported by the "buf" library via its stubs table.
#

library   buf

interface buf
hooks {bufInt memchan}

declare 0 generic {
    int Buf_IsInitialized (void)
}

# END buf}

test stubs-writer-2.4 {text, var-args function} -setup {
    set T [stubs::container::new]
} -body {
    stubs::reader::text T {
        library tcl
        interface tcl
        declare 0 {
            void Tcl_Panic(const char *format, ...)
        }
    }
    stubs::writer::gen $T
} -cleanup {
    unset T
} -result {# tcl.decls -- -*- tcl -*-
#
#	This file contains the declarations for all public functions
#	that are exported by the "tcl" library via its stubs table.
#

library   tcl

interface tcl

declare 0 generic {
    void Tcl_Panic (const char * format, ...)
}

# END tcl}

test stubs-writer-2.5 {text, array-flag} -setup {
    set T [stubs::container::new]
} -body {
    stubs::reader::text T {
        library tcl
        interface tcl
	declare 0 {
	    Tcl_Obj *Tcl_ConcatObj(int objc, Tcl_Obj *const objv[])
	}
    }
    stubs::writer::gen $T
} -cleanup {
    unset T
} -result {# tcl.decls -- -*- tcl -*-
#
#	This file contains the declarations for all public functions
#	that are exported by the "tcl" library via its stubs table.
#

library   tcl

interface tcl

declare 0 generic {
    Tcl_Obj * Tcl_ConcatObj (int objc, Tcl_Obj *const objv[])
}

# END tcl}

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

testsuiteCleanup

# Local variables:
# mode: tcl
# indent-tabs-mode: nil
# End:
