Debian Codegraph @

dojox/string/tests/BidiEngine/BidiEngineMapsTest.js

raw symbols SCIP
1 define(["doh/runner", "dojox/string/BidiEngine"], function(doh, BidiEngine) {
2
3 var txt1 = "\u05d0\u05d1\u05d2 123 ABC 456.";
4 var lengthErr = "Wrong length of the map";
5 var contErr = "Wrong content of the map";
6 var engine = new BidiEngine();
7 var result;
8
9 doh.register("BidiEngine Maps and Levels Test",
10 [
11 {
12 name: "(1) Maps: implicit ltr -> visual ltr",
13 runTest: function (t) {
14 result = engine.bidiTransform(txt1, "ILYNN", "VLNNN");
15 t.is(engine.sourceToTarget.length, result.length, lengthErr);
16 t.is(engine.targetToSource.length, txt1.length, lengthErr);
17 dojo.forEach(engine.sourceToTarget, function (val, ind) {
18 t.is(txt1.charAt(val), result.charAt(ind), contErr);
19 });
20 dojo.forEach(engine.targetToSource, function (val, ind) {
21 t.is(txt1.charAt(ind), result.charAt(val), contErr);
22 });
23 }
24 },
25 {
26 name: "(2) Maps: implicit ltr -> visual rtl",
27 runTest: function (t) {
28 result = engine.bidiTransform(txt1, "ILYNN", "VRNNN");
29 t.is(engine.sourceToTarget.length, result.length, lengthErr);
30 t.is(engine.targetToSource.length, txt1.length, lengthErr);
31 dojo.forEach(engine.sourceToTarget, function (val, ind) {
32 t.is(txt1.charAt(val), result.charAt(ind), contErr);
33 });
34 dojo.forEach(engine.targetToSource, function (val, ind) {
35 t.is(txt1.charAt(ind), result.charAt(val), contErr);
36 });
37 }
38 },
39 {
40 name: "(3) Maps: implicit rtl -> visual ltr",
41 runTest: function (t) {
42 result = engine.bidiTransform(txt1, "IRYNN", "VLNNN");
43 t.is(engine.sourceToTarget.length, result.length, lengthErr);
44 t.is(engine.targetToSource.length, txt1.length, lengthErr);
45 dojo.forEach(engine.sourceToTarget, function (val, ind) {
46 t.is(txt1.charAt(val), result.charAt(ind), contErr);
47 });
48 dojo.forEach(engine.targetToSource, function (val, ind) {
49 t.is(txt1.charAt(ind), result.charAt(val), contErr);
50 });
51 }
52 },
53 {
54 name: "(4) Maps: implicit rtl -> visual rtl",
55 runTest: function (t) {
56 result = engine.bidiTransform(txt1, "ILYNN", "VRNNN");
57 t.is(engine.sourceToTarget.length, result.length, lengthErr);
58 t.is(engine.targetToSource.length, txt1.length, lengthErr);
59 dojo.forEach(engine.sourceToTarget, function (val, ind) {
60 t.is(txt1.charAt(val), result.charAt(ind), contErr);
61 });
62 dojo.forEach(engine.targetToSource, function (val, ind) {
63 t.is(txt1.charAt(ind), result.charAt(val), contErr);
64 });
65 }
66 },
67 {
68 name: "(5) Levels: ltr",
69 runTest: function (t) {
70 result = engine.bidiTransform(txt1, "ILYNN", "VRNNN");
71 t.is(engine.levels.join(""), "1111222000000000", contErr);
72 }
73 },
74 {
75 name: "(6) Levels: rtl",
76 runTest: function (t) {
77 result = engine.bidiTransform(txt1, "IRYNN", "VLNNN");
78 t.is(engine.levels.join(""), "1111222122222221", contErr);
79 }
80 }
81 ]);
82 });