mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-12 03:45:34 +00:00
feat(web/engine): basic store explosion test relocated
This commit is contained in:
parent
7462f1707e
commit
3e417fa4c4
4 changed files with 51 additions and 26 deletions
|
|
@ -184,7 +184,7 @@ namespace com.keyman.text {
|
|||
_AnyIndices: number[] = []; // AnyIndex - array of any/index match indices
|
||||
|
||||
// Must be accessible to some of the keyboard API methods.
|
||||
activeKeyboard: any;
|
||||
activeKeyboard: keyboards.Keyboard;
|
||||
activeDevice: EngineDeviceSpec;
|
||||
|
||||
variableStoreSerializer?: VariableStoreSerializer;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ test-headless ( ) {
|
|||
FLAGS="$FLAGS --reporter mocha-teamcity-reporter"
|
||||
fi
|
||||
|
||||
npm run mocha -- --recursive $FLAGS ./tests/cases/*.js
|
||||
npm run mocha -- --recursive $FLAGS ./tests/cases/
|
||||
}
|
||||
|
||||
# Build test dependency
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
var assert = require('chai').assert;
|
||||
let fs = require('fs');
|
||||
let vm = require('vm');
|
||||
|
||||
let KeyboardProcessor = require('../../../dist');
|
||||
let KMWRecorder = require('../../../../tools/recorder/dist/nodeProctor');
|
||||
|
||||
// Required initialization setup.
|
||||
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.
|
||||
|
||||
describe('Engine - Stores', function() {
|
||||
var toSupplementaryPairString = function(code){
|
||||
var H = Math.floor((code - 0x10000) / 0x400) + 0xD800;
|
||||
var L = (code - 0x10000) % 0x400 + 0xDC00;
|
||||
|
||||
return String.fromCharCode(H, L);
|
||||
}
|
||||
|
||||
it('Store \'Explosion\'', function() {
|
||||
let processor = new KeyboardProcessor();
|
||||
// A 'hollow' Keyboard that only follows default rules. That said, we need a Keyboard
|
||||
// instance to host cache data for our exploded store tests.
|
||||
processor.activeKeyboard = new com.keyman.keyboards.Keyboard();
|
||||
|
||||
// Function defined at top of file; creates supplementary pairs for extended Unicode codepoints.
|
||||
var u = toSupplementaryPairString;
|
||||
|
||||
var STORES = [
|
||||
{smp: false, in: "apple", out: ['a','p','p','l','e']},
|
||||
//In JS-escaped form: "\\ud804\\udd12\\ud804\\udd0d\\ud804\\udd0f\\ud804\\udd10\\ud804\\udd0a\\ud804\\udd05"
|
||||
//(Supplementary pairs, copied from the easy_chakma keyboard.)
|
||||
{smp: true, in: "𑄒𑄍𑄏𑄐𑄊𑄅", out: ["𑄒","𑄍","𑄏","𑄐","𑄊","𑄅"]},
|
||||
// Built in-line via function. Looks functionally equivalent to "apple", but with SMP characters.
|
||||
{smp: true, in: (u(0x1d5ba)+u(0x1d5c9)+u(0x1d5c9)+u(0x1d5c5)+u(0x1d5be)),
|
||||
out: [u(0x1d5ba), u(0x1d5c9), u(0x1d5c9), u(0x1d5c5), u(0x1d5be)]}
|
||||
];
|
||||
|
||||
for(var i=0; i < STORES.length; i++) {
|
||||
var s = STORES[i];
|
||||
|
||||
String.kmwEnableSupplementaryPlane(s.smp);
|
||||
var result = processor.keyboardInterface._ExplodeStore(s.in);
|
||||
assert.sameOrderedMembers(result, s.out, "Failure exploding " + (s.smp ? "SMP" : "non-SMP") + " string value \"" + s.in + "\"");
|
||||
}
|
||||
String.kmwEnableSupplementaryPlane(false);
|
||||
});
|
||||
|
||||
// TODO: Migrate a Node-based copy of the variable store tests here as well.
|
||||
});
|
||||
|
|
@ -789,30 +789,6 @@ describe('Engine', function() {
|
|||
fixture.cleanup();
|
||||
});
|
||||
|
||||
it('Store \'Explosion\'', function() {
|
||||
// Function defined at top of file; creates supplementary pairs for extended Unicode codepoints.
|
||||
var u = toSupplementaryPairString;
|
||||
|
||||
var STORES = [
|
||||
{smp: false, in: "apple", out: ['a','p','p','l','e']},
|
||||
//In JS-escaped form: "\\ud804\\udd12\\ud804\\udd0d\\ud804\\udd0f\\ud804\\udd10\\ud804\\udd0a\\ud804\\udd05"
|
||||
//(Supplementary pairs, copied from the easy_chakma keyboard.)
|
||||
{smp: true, in: "𑄒𑄍𑄏𑄐𑄊𑄅", out: ["𑄒","𑄍","𑄏","𑄐","𑄊","𑄅"]},
|
||||
// Built in-line via function. Looks functionally equivalent to "apple", but with SMP characters.
|
||||
{smp: true, in: (u(0x1d5ba)+u(0x1d5c9)+u(0x1d5c9)+u(0x1d5c5)+u(0x1d5be)),
|
||||
out: [u(0x1d5ba), u(0x1d5c9), u(0x1d5c9), u(0x1d5c5), u(0x1d5be)]}
|
||||
];
|
||||
|
||||
for(var i=0; i < STORES.length; i++) {
|
||||
var s = STORES[i];
|
||||
|
||||
String.kmwEnableSupplementaryPlane(s.smp);
|
||||
var result = keyman.core.keyboardInterface._ExplodeStore(s.in);
|
||||
assert.sameOrderedMembers(result, s.out, "Failure exploding " + (s.smp ? "SMP" : "non-SMP") + " string value \"" + s.in + "\"");
|
||||
}
|
||||
String.kmwEnableSupplementaryPlane(false);
|
||||
});
|
||||
|
||||
// Tests "stage 1" of fullContextMatch - ensuring that a proper context index map is built.
|
||||
it('Extended Context Mapping', function() {
|
||||
var inputElem = document.getElementById('singleton');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue