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:
@@ -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
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
/* Included after dat.h and fn.h (or after the source under test). */
|
||||
#include "cutest/cutest.h"
|
||||
|
||||
extern Lang testvi;
|
||||
|
||||
/*
|
||||
* A test's stand-in for imthread: handles engine requests from keyc,
|
||||
* tracing each one first. Requests whose op is holdop (every request
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
Channel *drawc;
|
||||
Channel *keyc;
|
||||
Lang testvi;
|
||||
|
||||
void
|
||||
die(char *fmt, ...)
|
||||
@@ -45,20 +44,16 @@ erealloc(void *p, ulong n)
|
||||
static void
|
||||
testmapinit(void)
|
||||
{
|
||||
Lang *jp, *kata;
|
||||
Lang *jp, *kata, *vi;
|
||||
|
||||
jp = getlang(LangJP);
|
||||
kata = getlang(LangJPK);
|
||||
if(jp == nil || kata == nil)
|
||||
vi = getlang(LangVI);
|
||||
if(jp == nil || kata == nil || vi == nil)
|
||||
die("test language is not registered");
|
||||
jp->map = trieopen("../map/hira.map");
|
||||
kata->map = trieopen("../map/kata.map");
|
||||
memset(&testvi, 0, sizeof testvi);
|
||||
testvi.lang = LangVI;
|
||||
testvi.mapname = "telex";
|
||||
testvi.trans = transvi;
|
||||
testvi.back = backvi;
|
||||
testvi.map = trieopen("../map/telex.map");
|
||||
vi->map = trieopen("../map/telex.map");
|
||||
}
|
||||
|
||||
#ifndef STRESS
|
||||
@@ -170,8 +165,6 @@ threadmain(int argc, char **argv)
|
||||
trieclose(langs[i].map);
|
||||
langs[i].map = nil;
|
||||
}
|
||||
trieclose(testvi.map);
|
||||
testvi.map = nil;
|
||||
chanfree(drawc);
|
||||
chanfree(keyc);
|
||||
threadexitsall(status == 0 ? nil : "tests failed");
|
||||
|
||||
@@ -8,7 +8,7 @@ typevi(struct ct *t, char *keys, char *want)
|
||||
Str out, raw;
|
||||
|
||||
raw = mkstr(keys);
|
||||
transstr(&testvi, nil, &raw, &out);
|
||||
transstr(getlang(LangVI), nil, &raw, &out);
|
||||
checkstr(t, keys, want, &out);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ vietnamese_backspace(struct ct *t)
|
||||
|
||||
for(i = 0; i < nelem(cases); i++){
|
||||
memset(&state, 0, sizeof state);
|
||||
state.l = &testvi;
|
||||
state.l = getlang(LangVI);
|
||||
state.pre = mkstr(cases[i].pre);
|
||||
state.raw = mkstr(cases[i].raw);
|
||||
backvi(&state);
|
||||
|
||||
Reference in New Issue
Block a user