File: convlib.test

package info (click to toggle)
tclx8.4 8.4.1-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,800 kB
  • sloc: ansic: 14,863; tcl: 2,090; sh: 265; makefile: 159
file content (80 lines) | stat: -rw-r--r-- 2,543 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#
# convlib.test
#
# Tests for tcl.tlib convert_lib routine.
#---------------------------------------------------------------------------
# Copyright 1992-1999 Karl Lehenbauer and Mark Diekhans.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
# that the above copyright notice appear in all copies.  Karl Lehenbauer and
# Mark Diekhans make no representations about the suitability of this
# software for any purpose.  It is provided "as is" without express or
# implied warranty.
#------------------------------------------------------------------------------
# $Id: convlib.test,v 1.2 2002/04/02 02:29:43 hobbs Exp $
#------------------------------------------------------------------------------
#

if {[cequal [info procs Test] {}]} {
    source [file join [file dirname [info script]] testlib.tcl]
}

catch {file delete -force convlib.tmp}
file mkdir convlib.tmp

# Create a temporary source files and generate an index.

loop num 0 5 {
    set fh [open convlib.tmp/tmp${num}.tcl w]
    puts $fh "proc LoadProc${num}A {} {return @LoadProc${num}A@}"
    puts $fh "proc LoadProc${num}B {} {return @LoadProc${num}B@}"
    close $fh
}

set fh [open convlib.tmp/init.tcl w]
puts $fh "proc InitTcl {} {return @InitTcl@}"
close $fh

auto_mkindex convlib.tmp *.tcl

# Proc that validates the library by executing procs out of it.

proc LibValidate {testid testname} {
    loop num 0 5 {
        Test $testid.1 $testname {
            LoadProc${num}A
        } 0 "@LoadProc${num}A@"
        Test $testid.2 $testname {
            LoadProc${num}B
        } 0 "@LoadProc${num}B@"
        Test $testid.3 $testname {
            InitTcl
        } 1 {invalid command name "InitTcl"}
    }
}

#
# Now convert and load the library, see if we can actually use it.
#

Test convlib-1.1 {Convert library tests} {
    TestRemove convlib.tmp/tmp.tlib file delete convlib.tmp/tmp.tndx
    convert_lib convlib.tmp/tclIndex convlib.tmp/tmp  "init.tcl"
    list [file exists convlib.tmp/tmp.tlib] [file exists convlib.tmp/tmp.tndx]
} 0 {1 1}

Test convlib-1.2 {Convert library tests} {
    TestRemove convlib.tmp/tmp.tlib file delete convlib.tmp/tmp.tndx
    convert_lib convlib.tmp/tclIndex convlib.tmp/tmp.tlib "init.tcl"
    list [file exists convlib.tmp/tmp.tlib] [file exists convlib.tmp/tmp.tndx]
} 0 {1 1}

loadlibindex convlib.tmp/tmp.tlib
LibValidate convlib-1.3 {Convert library tests}

TestRemove convlib.tmp

# cleanup
::tcltest::cleanupTests
return