go-vise

Constrained Size Output Virtual Machine
Info | Log | Files | Refs | README | LICENSE

commit 1ef012594c494b700d350e9a42b911561bac4121
parent d8a7dcec31129c6708914dbee3eae2f94a92416f
Author: lash <dev@holbrook.no>
Date:   Sun,  1 Sep 2024 18:52:43 +0100

Add multilanguage test in db

Diffstat:
Mdb/db.go | 6++++++
Mdb/db_test.go | 20+++++++++++++++++++-
2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/db/db.go b/db/db.go @@ -45,6 +45,7 @@ type Db interface { // SetPrefix sets the storage context prefix to use for consecutive Get and Put operations. SetPrefix(pfx uint8) // SetSession sets the session context to use for consecutive Get and Put operations. + // // Session only affects the following datatypes: // * DATATYPE_STATE // * DATATYPE_USERSTART @@ -55,6 +56,11 @@ type Db interface { // Safe returns true if db is safe for use with a vm. Safe() bool // SetLanguage sets the language context to use on consecutive gets or puts + // + // Language only affects the following datatypes: + // * DATATYPE_MENU + // * DATATYPE_TEMPLATE + // * DATATYPE_STATICLOAD SetLanguage(*lang.Language) } diff --git a/db/db_test.go b/db/db_test.go @@ -34,8 +34,9 @@ type testFunc func() testVector var ( tests = []testFunc{ -// generateSessionTestVectors, + generateSessionTestVectors, generateLanguageTestVectors, + generateMultiLanguageTestVectors, } dataTypeDebug = map[uint8]string{ DATATYPE_BIN: "bytecode", @@ -197,6 +198,23 @@ func generateLanguageTestVectors() testVector { tv.add(DATATYPE_BIN, "foo", "beeffeed", "", "beeffeed", "nor") tv.add(DATATYPE_TEMPLATE, "foo", "tinkywinky", "", "tinkywinky", "") tv.add(DATATYPE_TEMPLATE, "foo", "dipsy", "", "dipsy", "nor") + tv.add(DATATYPE_MENU, "foo", "lala", "", "lala", "") + tv.add(DATATYPE_MENU, "foo", "pu", "", "pu", "nor") + tv.add(DATATYPE_STATICLOAD, "foo", "bar", "", "bar", "") + tv.add(DATATYPE_STATICLOAD, "foo", "baz", "", "baz", "nor") + tv.add(DATATYPE_STATE, "foo", "xyzzy", "", "plugh", "") + tv.add(DATATYPE_STATE, "foo", "plugh", "", "plugh", "nor") + tv.add(DATATYPE_USERDATA, "foo", "itchy", "", "scratchy", "") + tv.add(DATATYPE_USERDATA, "foo", "scratchy", "", "scratchy", "nor") + return tv +} + +func generateMultiLanguageTestVectors() testVector { + tv := testVector{c: make(map[string]*testCase), s: "multilanguage"} + tv.add(DATATYPE_TEMPLATE, "foo", "tinkywinky", "", "pu", "") + tv.add(DATATYPE_TEMPLATE, "foo", "dipsy", "", "dipsy", "nor") + tv.add(DATATYPE_TEMPLATE, "foo", "lala", "", "lala", "swa") + tv.add(DATATYPE_TEMPLATE, "foo", "pu", "", "pu", "") return tv }