test: Telex goes in the language table like every other map

The unit suite built a Lang of its own for Telex and loaded telex.map
into it, so the tests that drive the real table had to swap the map in
and out around themselves.  testmapinit loads it where it belongs.
This commit is contained in:
2026-08-17 12:20:39 +09:00
parent 3a90826238
commit e54783dc92
4 changed files with 14 additions and 39 deletions

View File

@@ -52,7 +52,7 @@ vietnamese_state_lifetime(struct ct *t)
Str com;
init();
im.l = &testvi;
im.l = getlang(LangVI);
im.pre = mkstr("as");
im.raw = mkstr("as");
sclear(&com);
@@ -62,7 +62,7 @@ vietnamese_state_lifetime(struct ct *t)
CT_EQ_INT(t, 0, im.raw.n);
init();
im.l = &testvi;
im.l = getlang(LangVI);
im.pre = mkstr("as");
im.raw = mkstr("as");
sclear(&com);
@@ -72,7 +72,7 @@ vietnamese_state_lifetime(struct ct *t)
CT_EQ_INT(t, 0, im.raw.n);
init();
im.l = &testvi;
im.l = getlang(LangVI);
im.pre = mkstr("as");
im.raw = mkstr("as");
sclear(&com);
@@ -357,7 +357,7 @@ engine_vietnamese_client_preedit(struct ct *t)
for(i = 0; i < nelem(cases); i++){
init();
im.l = &testvi;
im.l = getlang(LangVI);
draindraw(nil);
sclear(&com);
for(k = cases[i].keys; *k != '\0'; k++){
@@ -488,7 +488,7 @@ engine_telex_history_bound(struct ct *t)
int i;
init();
im.l = &testvi;
im.l = getlang(LangVI);
sclear(&com);
CT_CHECK(t, keystroke('a', 0, &com));
for(i = 0; i < Maxrunes; i++){
@@ -620,16 +620,9 @@ engine_language_switch_state(struct ct *t)
{ "commit Vietnamese", 't', Mctrl, LangEN, "", "", "á", 0 },
};
char where[80];
Lang *vi;
Trie *saved;
Str com;
int eaten, i;
vi = getlang(LangVI);
if(!CT_CHECK(t, vi != nil))
return;
saved = vi->map;
vi->map = testvi.map;
init();
for(i = 0; i < nelem(steps); i++){
if(steps[i].stale){
@@ -675,7 +668,7 @@ engine_language_switch_state(struct ct *t)
CT_EQ_INT(t, 0, im.pre.n);
}
init();
im.l = &testvi;
im.l = getlang(LangVI);
sclear(&com);
if(typekeys(t, "as", &com)){
CT_CHECK(t, !keystroke('p', Mctrl, &com));
@@ -683,7 +676,6 @@ engine_language_switch_state(struct ct *t)
CT_EQ_INT(t, 0, im.pre.n);
CT_EQ_INT(t, 0, im.raw.n);
}
vi->map = saved;
}
typedef struct Searchfix Searchfix;
@@ -1694,14 +1686,14 @@ engine_emoji_preedit_languages(struct ct *t)
}
init();
im.l = &testvi;
im.l = getlang(LangVI);
sclear(&com);
if(typekeys(t, "as", &com)){
CT_CHECK(t, keystroke('e', Mctrl, &com));
checkstr(t, "committed Telex preedit", "á", &com);
CT_CHECK(t, keystroke(Kesc, 0, &com));
CT_CHECK(t, !search.lang);
CT_EQ_PTR(t, &testvi, im.l);
CT_EQ_PTR(t, getlang(LangVI), im.l);
sclear(&com);
if(typekeys(t, "as", &com)){
impre(&im, &shown);
@@ -2051,8 +2043,6 @@ engine_randomized_stress(struct ct *t)
};
static Rune modes[] = { 't', 'n', 'k', 's', 'v' };
Searchfix f;
Lang *vi;
Trie *vimap;
Keyres res;
Caret pos;
u32int rnd, mod;
@@ -2060,11 +2050,6 @@ engine_randomized_stress(struct ct *t)
void *owner, *owners[3];
int i, j, op;
vi = getlang(LangVI);
if(!CT_CHECK(t, vi != nil))
return;
vimap = vi->map;
vi->map = testvi.map;
emojibegin(&f, 0);
owners[0] = &contexts[0];
owners[1] = &contexts[1];
@@ -2140,7 +2125,6 @@ engine_randomized_stress(struct ct *t)
}
}
searchend(&f);
vi->map = vimap;
}
void