summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2003-10-21 00:23:33 (GMT)
committerKevin B Kenny <kennykb@acm.org>2003-10-21 00:23:33 (GMT)
commit069e6b39be18f68043fb7389188c1e8d2a6afb06 (patch)
tree2ed74cd43101586ffe55de9721f1354589548214 /tests
parent7c7a39a26c9bd772bf26ae6fd1be320d392d10db (diff)
downloadtcl-069e6b39be18f68043fb7389188c1e8d2a6afb06.zip
tcl-069e6b39be18f68043fb7389188c1e8d2a6afb06.tar.gz
tcl-069e6b39be18f68043fb7389188c1e8d2a6afb06.tar.bz2
TIP #156: Language-Neutral Root Locale for Msgcat
Diffstat (limited to 'tests')
-rw-r--r--tests/msgcat.test51
1 files changed, 31 insertions, 20 deletions
diff --git a/tests/msgcat.test b/tests/msgcat.test
index 96a0ace..dac4a98 100644
--- a/tests/msgcat.test
+++ b/tests/msgcat.test
@@ -12,15 +12,15 @@
# Note that after running these tests, entries will be left behind in the
# message catalogs for locales foo, foo_BAR, and foo_BAR_baz.
#
-# RCS: @(#) $Id: msgcat.test,v 1.12 2003/03/26 22:55:44 dgp Exp $
+# RCS: @(#) $Id: msgcat.test,v 1.13 2003/10/21 00:23:34 kennykb Exp $
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.3}]} {
- puts stderr "Skipping tests in [info script]. No msgcat 1.3 found to test."
+if {[catch {package require msgcat 1.4}]} {
+ puts stderr "Skipping tests in [info script]. No msgcat 1.4 found to test."
return
}
@@ -111,7 +111,7 @@ namespace eval ::msgcat::test {
mclocale $locale
} -body {
mcpreferences
- } -result en
+ } -result {en {}}
test msgcat-1.6 {mclocale set, two elements} -setup {
variable locale [mclocale]
@@ -137,7 +137,7 @@ namespace eval ::msgcat::test {
mclocale $locale
} -body {
mcpreferences
- } -result {en_us en}
+ } -result {en_us en {}}
test msgcat-1.9 {mclocale set, three elements} -setup {
variable locale [mclocale]
@@ -163,7 +163,7 @@ namespace eval ::msgcat::test {
mclocale $locale
} -body {
mcpreferences
- } -result {en_us_funky en_us en}
+ } -result {en_us_funky en_us en {}}
# Tests msgcat-2.*: [mcset], [mcmset], namespace partitioning
@@ -246,12 +246,13 @@ namespace eval ::msgcat::test {
# (e.g. en_UK) will search less specific locales
# (e.g. en) for translation strings.
#
- # Do this for the 12 permutations of
+ # Do this for the 15 permutations of
# locales: {foo foo_BAR foo_BAR_baz}
- # strings: {ov1 ov2 ov3 ov4}
- # locale foo defines ov1, ov2, ov3
- # locale foo_BAR defines ov2, ov3
- # locale foo_BAR_BAZ defines ov3
+ # strings: {ov0 ov1 ov2 ov3 ov4}
+ # locale ROOT defines ov0, ov1, ov2, ov3
+ # locale foo defines ov1, ov2, ov3
+ # locale foo_BAR defines ov2, ov3
+ # locale foo_BAR_BAZ defines ov3
# (ov4 is defined in none)
# So,
# ov3 should be resolved in foo, foo_BAR, foo_BAR_baz
@@ -264,16 +265,23 @@ namespace eval ::msgcat::test {
variable count 2
variable result
array set result {
- foo,ov1 ov1_foo foo,ov2 ov2_foo foo,ov3 ov3_foo foo,ov4 ov4
- foo_BAR,ov1 ov1_foo foo_BAR,ov2 ov2_foo_BAR foo_BAR,ov3 ov3_foo_BAR
- foo_BAR,ov4 ov4 foo_BAR_baz,ov1 ov1_foo foo_BAR_baz,ov2 ov2_foo_BAR
+ foo,ov0 ov0_ROOT foo,ov1 ov1_foo foo,ov2 ov2_foo
+ foo,ov3 ov3_foo foo,ov4 ov4
+ foo_BAR,ov0 ov0_ROOT foo_BAR,ov1 ov1_foo foo_BAR,ov2 ov2_foo_BAR
+ foo_BAR,ov3 ov3_foo_BAR foo_BAR,ov4 ov4
+ foo_BAR_baz,ov0 ov0_ROOT foo_BAR_baz,ov1 ov1_foo
+ foo_BAR_baz,ov2 ov2_foo_BAR
foo_BAR_baz,ov3 ov3_foo_BAR_baz foo_BAR_baz,ov4 ov4
}
variable loc
variable string
foreach loc {foo foo_BAR foo_BAR_baz} {
- foreach string {ov1 ov2 ov3 ov4} {
+ foreach string {ov0 ov1 ov2 ov3 ov4} {
test msgcat-3.$count {mcset, overlap} -setup {
+ mcset {} ov0 ov0_ROOT
+ mcset {} ov1 ov1_ROOT
+ mcset {} ov2 ov2_ROOT
+ mcset {} ov3 ov3_ROOT
mcset foo ov1 ov1_foo
mcset foo ov2 ov2_foo
mcset foo ov3 ov3_foo
@@ -364,9 +372,12 @@ namespace eval ::msgcat::test {
# Tests msgcat-5.*: [mcload]
- variable locales {foo foo_BAR foo_BAR_baz}
+ variable locales {{} foo foo_BAR foo_BAR_baz}
makeDirectory msgdir
foreach loc $locales {
+ if { $loc eq {} } {
+ set loc ROOT
+ }
makeFile "::msgcat::mcset $loc abc abc-$loc" \
[string tolower [file join msgdir $loc.msg]]
}
@@ -379,12 +390,12 @@ namespace eval ::msgcat::test {
mclocale $locale
} -body {
mcload [file join [temporaryDirectory] msgdir]
- } -result $count
+ } -result [expr { $count+1 }]
incr count
}
# Even though foo_BAR_notexist does not exist,
- # foo_BAR and foo should be loaded.
+ # foo_BAR, foo and the root should be loaded.
test msgcat-5.4 {mcload} -setup {
variable locale [mclocale]
mclocale foo_BAR_notexist
@@ -392,7 +403,7 @@ namespace eval ::msgcat::test {
mclocale $locale
} -body {
mcload [file join [temporaryDirectory] msgdir]
- } -result 2
+ } -result 3
test msgcat-5.5 {mcload} -setup {
variable locale [mclocale]
@@ -401,7 +412,7 @@ namespace eval ::msgcat::test {
mclocale $locale
} -body {
mcload [file join [temporaryDirectory] msgdir]
- } -result 0
+ } -result 1
test msgcat-5.6 {mcload} -setup {
variable locale [mclocale]