Tcl Source Code

Check-in [927b8c4de9]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:For msgcat, select modernizations from Patrick Fradin + -debug fix.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-5-branch
Files: files | file ages | folders
SHA1: 927b8c4de9d967441821c92395e9ab0270cc3fda
User & Date: dgp 2013-01-30 20:49:03
Context
2013-01-30
21:34
For traces, select modernizations from Patrick Fradlin. check-in: 8062ae03bd user: dgp tags: core-8-5-branch
20:51
For Parse/eval & msgcat, select modernizations from Patrick Fradin + -debug fix check-in: 886f2784c1 user: dgp tags: trunk
20:49
For msgcat, select modernizations from Patrick Fradin + -debug fix. check-in: 927b8c4de9 user: dgp tags: core-8-5-branch
20:42
For Parse/eval, select modernizations from Patrick Fradin. check-in: 529efda549 user: dgp tags: core-8-5-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tests/msgcat.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# Note that after running these tests, entries will be left behind in the
# message catalogs for locales foo, foo_BAR, and foo_BAR_baz.

package require Tcl 8.2
if {[catch {package require tcltest 2}]} {
    puts stderr "Skipping tests in [info script].  tcltest 2 required."
    return
}
if {[catch {package require msgcat 1.5.0}]} {
    puts stderr "Skipping tests in [info script].  No msgcat 1.5.0 found to test."
    return







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# Note that after running these tests, entries will be left behind in the
# message catalogs for locales foo, foo_BAR, and foo_BAR_baz.

package require Tcl 8.5
if {[catch {package require tcltest 2}]} {
    puts stderr "Skipping tests in [info script].  tcltest 2 required."
    return
}
if {[catch {package require msgcat 1.5.0}]} {
    puts stderr "Skipping tests in [info script].  No msgcat 1.5.0 found to test."
    return
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
    foreach setVars [PowerSet $envVars] { 
	set result [string tolower [lindex $setVars 0]]
	if {[string length $result] == 0} {
	    if {[info exists ::tcl::mac::locale]} {
		set result [string tolower \
			[msgcat::ConvertLocale $::tcl::mac::locale]]
	    } else {
		if {([info sharedlibextension] == ".dll")
			&& ![catch {package require registry}]} {
		    # Windows and Cygwin have other ways to determine the
		    # locale when the environment variables are missing
		    # and the registry package is present
		    continue
		}
		set result c
	    }
	}
	test msgcat-0.$count [list \
	    locale initialization from environment variables $setVars \
	] -setup {
	    variable var
	    foreach var $envVars {
		catch {variable $var $::env($var)}
		catch {unset ::env($var)}
	    }
	    foreach var $setVars {
		set ::env($var) $var
	    }
	    interp create [namespace current]::i
	    i eval [list package ifneeded msgcat [package provide msgcat] \
		    [package ifneeded msgcat [package provide msgcat]]]
	    i eval package require msgcat
	} -cleanup {
	    interp delete [namespace current]::i
	    foreach var $envVars {
		catch {unset ::env($var)}
		catch {set ::env($var) [set [namespace current]::$var]}
	    }
	} -body {i eval msgcat::mclocale} -result $result
	incr count
    }
    catch {unset result}
    
    # Could add tests of initialization from Windows registry here.
    # Use a fake registry package.

    # Tests msgcat-1.*: [mclocale], [mcpreferences]

    test msgcat-1.3 {mclocale set, single element} -setup {







|















|











|





|







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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
    foreach setVars [PowerSet $envVars] { 
	set result [string tolower [lindex $setVars 0]]
	if {[string length $result] == 0} {
	    if {[info exists ::tcl::mac::locale]} {
		set result [string tolower \
			[msgcat::ConvertLocale $::tcl::mac::locale]]
	    } else {
		if {([info sharedlibextension] eq ".dll")
			&& ![catch {package require registry}]} {
		    # Windows and Cygwin have other ways to determine the
		    # locale when the environment variables are missing
		    # and the registry package is present
		    continue
		}
		set result c
	    }
	}
	test msgcat-0.$count [list \
	    locale initialization from environment variables $setVars \
	] -setup {
	    variable var
	    foreach var $envVars {
		catch {variable $var $::env($var)}
		unset -nocomplain ::env($var)
	    }
	    foreach var $setVars {
		set ::env($var) $var
	    }
	    interp create [namespace current]::i
	    i eval [list package ifneeded msgcat [package provide msgcat] \
		    [package ifneeded msgcat [package provide msgcat]]]
	    i eval package require msgcat
	} -cleanup {
	    interp delete [namespace current]::i
	    foreach var $envVars {
		unset -nocomplain ::env($var)
		catch {set ::env($var) [set [namespace current]::$var]}
	    }
	} -body {i eval msgcat::mclocale} -result $result
	incr count
    }
    unset -nocomplain result
    
    # Could add tests of initialization from Windows registry here.
    # Use a fake registry package.

    # Tests msgcat-1.*: [mclocale], [mcpreferences]

    test msgcat-1.3 {mclocale set, single element} -setup {
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
		mclocale $locale
	    } -body {
		mc $string
	    } -result $result($loc,$string)
	    incr count
	}
    }
    catch {unset result}

    # Tests msgcat-4.*: [mcunknown]

    test msgcat-4.2 {mcunknown, default} -setup {
	mcset foo unk1 "unknown 1"
	variable locale [mclocale]
	mclocale foo







|







320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
		mclocale $locale
	    } -body {
		mc $string
	    } -result $result($loc,$string)
	    incr count
	}
    }
    unset -nocomplain result

    # Tests msgcat-4.*: [mcunknown]

    test msgcat-4.2 {mcunknown, default} -setup {
	mcset foo unk1 "unknown 1"
	variable locale [mclocale]
	mclocale foo
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
	    mclocale $locale
	} -body {
	    return [mc k2][mc k3]
	} -result v2v3

    removeFile l2.msg $msgdir2
    removeDirectory msgdir2
    removeFile l3.msg $msgdir3
    removeDirectory msgdir3

    cleanupTests
}
namespace delete ::msgcat::test
return








<







651
652
653
654
655
656
657

658
659
660
661
662
663
664
	    mclocale $locale
	} -body {
	    return [mc k2][mc k3]
	} -result v2v3

    removeFile l2.msg $msgdir2
    removeDirectory msgdir2

    removeDirectory msgdir3

    cleanupTests
}
namespace delete ::msgcat::test
return