proskomma-core 0.9.12 → 0.9.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/wrapper.mjs +1 -1
- package/{index.js → index.cjs} +1 -1
- package/package.json +2 -2
- package/babel.config.js +0 -18
- package/test/code/main/bad.cjs +0 -79
- package/test/code/main/basics.cjs +0 -534
- package/test/code/main/block.cjs +0 -586
- package/test/code/main/block_scope_numbers.cjs +0 -31
- package/test/code/main/blocks_with_atts.cjs +0 -150
- package/test/code/main/blocks_with_cv.cjs +0 -250
- package/test/code/main/break.cjs +0 -73
- package/test/code/main/checksum.cjs +0 -36
- package/test/code/main/cl_global.cjs +0 -35
- package/test/code/main/class_for_fragment.cjs +0 -18
- package/test/code/main/clean_usfm.cjs +0 -46
- package/test/code/main/cp_vp.cjs +0 -158
- package/test/code/main/custom.cjs +0 -124
- package/test/code/main/cv.cjs +0 -249
- package/test/code/main/cvMatching.cjs +0 -155
- package/test/code/main/cv_indexes.cjs +0 -189
- package/test/code/main/cv_navigation.cjs +0 -124
- package/test/code/main/document.cjs +0 -382
- package/test/code/main/empty_blocks.cjs +0 -71
- package/test/code/main/entries.cjs +0 -402
- package/test/code/main/export_lexing_regexes.cjs +0 -19
- package/test/code/main/fig.cjs +0 -67
- package/test/code/main/filter.cjs +0 -222
- package/test/code/main/glossary.cjs +0 -36
- package/test/code/main/graft_headings.cjs +0 -36
- package/test/code/main/graft_introduction.cjs +0 -96
- package/test/code/main/graft_note.cjs +0 -104
- package/test/code/main/graft_rems.cjs +0 -34
- package/test/code/main/graft_sidebars.cjs +0 -62
- package/test/code/main/graft_title.cjs +0 -36
- package/test/code/main/hello.cjs +0 -105
- package/test/code/main/import_document.cjs +0 -22
- package/test/code/main/import_usfm_int.cjs +0 -48
- package/test/code/main/item_groups.cjs +0 -133
- package/test/code/main/items_with_cv.cjs +0 -311
- package/test/code/main/milestone_attributes.cjs +0 -163
- package/test/code/main/mixed_sequence_documents.cjs +0 -137
- package/test/code/main/mixed_sequences.cjs +0 -217
- package/test/code/main/modify_sequence.cjs +0 -29
- package/test/code/main/multiple_chapters.cjs +0 -58
- package/test/code/main/multiple_content.cjs +0 -105
- package/test/code/main/mutate_add.cjs +0 -180
- package/test/code/main/mutate_delete.cjs +0 -236
- package/test/code/main/mutate_rehash.cjs +0 -68
- package/test/code/main/mutate_tags.cjs +0 -90
- package/test/code/main/mutate_update.cjs +0 -538
- package/test/code/main/selectors.cjs +0 -289
- package/test/code/main/sequence.cjs +0 -361
- package/test/code/main/serialize.cjs +0 -104
- package/test/code/main/spans.cjs +0 -51
- package/test/code/main/split_long_tokens.cjs +0 -30
- package/test/code/main/standard_vrs.cjs +0 -76
- package/test/code/main/subclass.cjs +0 -25
- package/test/code/main/table.cjs +0 -119
- package/test/code/main/tags.cjs +0 -248
- package/test/code/main/token_alignment.cjs +0 -84
- package/test/code/main/trees.cjs +0 -211
- package/test/code/main/tribos.cjs +0 -865
- package/test/code/main/tsv.cjs +0 -385
- package/test/code/main/usx_ref.cjs +0 -65
- package/test/code/main/verse_mapping.cjs +0 -252
- package/test/code/main/verse_range.cjs +0 -31
- package/test/code/main/word_likes.cjs +0 -41
- package/test/code/utils/byte_array.cjs +0 -271
- package/test/code/utils/canons.cjs +0 -20
- package/test/code/utils/generate_id.cjs +0 -17
- package/test/code/utils/graft_defs.cjs +0 -16
- package/test/code/utils/inspect.cjs +0 -130
- package/test/code/utils/items.cjs +0 -56
- package/test/code/utils/push_succinct.cjs +0 -69
- package/test/code/utils/scope_defs.cjs +0 -79
- package/test/code/utils/serialize.cjs +0 -28
- package/test/code/utils/splice.cjs +0 -67
- package/test/code/utils/tags.cjs +0 -69
- package/test/code/utils/versification.cjs +0 -249
- package/test/lib/load.js +0 -110
- package/test/skipped_code/diff.js +0 -53
- package/test/test_data/inputBlockSpec/dodson.json +0 -1654
- package/test/test_data/inputBlockSpec/kv.json +0 -326
- package/test/test_data/inputBlockSpec/mk1.json +0 -1019
- package/test/test_data/inputBlockSpec/table.json +0 -170
- package/test/test_data/tree/genealogy.json +0 -55
- package/test/test_data/tree/jude.json +0 -15965
- package/test/test_data/tsv/en_tn_66-JUD.tsv +0 -75
- package/test/test_data/tsv/twl_JUD.tsv +0 -144
- package/test/test_data/usfm/1pe_webbe.usfm +0 -13
- package/test/test_data/usfm/66-JUD-ust.usfm +0 -1089
- package/test/test_data/usfm/78-GALspavbl.usfm +0 -10
- package/test/test_data/usfm/add_test.usfm +0 -15
- package/test/test_data/usfm/backslash.usfm +0 -4
- package/test/test_data/usfm/cl.usfm +0 -14
- package/test/test_data/usfm/cp_vp.usfm +0 -8
- package/test/test_data/usfm/custom.usfm +0 -13
- package/test/test_data/usfm/en_ust_oba.usfm +0 -875
- package/test/test_data/usfm/en_ust_psa_1.usfm +0 -20
- package/test/test_data/usfm/fig.usfm +0 -3
- package/test/test_data/usfm/filter.usfm +0 -7
- package/test/test_data/usfm/footnote.usfm +0 -11
- package/test/test_data/usfm/frt.usfm +0 -4
- package/test/test_data/usfm/headings.usfm +0 -7
- package/test/test_data/usfm/hello.usfm +0 -8
- package/test/test_data/usfm/int.usfm +0 -7
- package/test/test_data/usfm/milestone_attributes.usfm +0 -7
- package/test/test_data/usfm/milestone_attributes_default.usfm +0 -7
- package/test/test_data/usfm/no_break_space.usfm +0 -4
- package/test/test_data/usfm/no_mt.usfm +0 -6
- package/test/test_data/usfm/rems.usfm +0 -6
- package/test/test_data/usfm/section_intros.usfm +0 -26
- package/test/test_data/usfm/sidebars.usfm +0 -25
- package/test/test_data/usfm/slash_in_att.usfm +0 -6
- package/test/test_data/usfm/soft_line_break.usfm +0 -4
- package/test/test_data/usfm/spans.usfm +0 -5
- package/test/test_data/usfm/split_long_tokens.usfm +0 -6
- package/test/test_data/usfm/table.usfm +0 -18
- package/test/test_data/usfm/table_at_end.usfm +0 -11
- package/test/test_data/usfm/table_in_intro.usfm +0 -22
- package/test/test_data/usfm/table_no_end_cells.usfm +0 -18
- package/test/test_data/usfm/tit_kitchen_sink.usfm +0 -73
- package/test/test_data/usfm/titus_template.usfm +0 -58
- package/test/test_data/usfm/ugnt_3jn.usfm +0 -265
- package/test/test_data/usfm/ult_3jn.usfm +0 -335
- package/test/test_data/usfm/unknown.usfm +0 -5
- package/test/test_data/usfm/ust_psa.usfm +0 -29
- package/test/test_data/usfm/ust_psa_verse_ranges.usfm +0 -24
- package/test/test_data/usfm/ust_psa_with_ts.usfm +0 -29
- package/test/test_data/usfm/verse_breaks_in_blocks.usfm +0 -20
- package/test/test_data/usfm/verse_range.usfm +0 -7
- package/test/test_data/usfm/web_ecc.usfm +0 -391
- package/test/test_data/usfm/web_psa51.usfm +0 -71
- package/test/test_data/usfm/whitespace.usfm +0 -12
- package/test/test_data/usfm/xref.usfm +0 -11
- package/test/test_data/usx/bad_element.usx +0 -2
- package/test/test_data/usx/cp_vp.usx +0 -12
- package/test/test_data/usx/diff1.usx +0 -59
- package/test/test_data/usx/diff2.usx +0 -74
- package/test/test_data/usx/douay_rheims_ecc.usx +0 -58
- package/test/test_data/usx/douay_rheims_psa.usx +0 -5366
- package/test/test_data/usx/douay_rheims_psa_40_60.usx +0 -666
- package/test/test_data/usx/douay_rheims_rut.usx +0 -26
- package/test/test_data/usx/esg3.usx +0 -47
- package/test/test_data/usx/fig.usx +0 -6
- package/test/test_data/usx/milestone_attributes.usx +0 -11
- package/test/test_data/usx/not_nfc18_glo.usx +0 -9
- package/test/test_data/usx/not_nfc18_phm.usx +0 -24
- package/test/test_data/usx/opt_break.usx +0 -10
- package/test/test_data/usx/sidebars.usx +0 -29
- package/test/test_data/usx/table.usx +0 -23
- package/test/test_data/usx/web_psa.usx +0 -8489
- package/test/test_data/usx/web_psa150.usx +0 -33
- package/test/test_data/usx/web_psa_40_60.usx +0 -1079
- package/test/test_data/usx/web_rut.usx +0 -95
- package/test/test_data/usx/web_rut_1.usx +0 -17
- package/test/test_data/utils/douay_rheims.vrs +0 -520
- package/test/test_data/utils/douay_rheims_PSA.usx +0 -5366
- package/test/test_data/utils/serialize_example.json +0 -91
- package/test/test_data/utils/truncated_versification.vrs +0 -29
- package/test/test_data/utils/web_rut_items.json +0 -2977
- package/test/test_data/utils/webbe.vrs +0 -395
- package/test/test_data/utils/webbe_PSA.usx +0 -8489
- package/test/test_data/vrs/douay_rheims.vrs +0 -520
- package/test/test_data/vrs/truncated_versification.vrs +0 -27
- package/test/test_data/vrs/webbe.vrs +0 -397
- package/webpack.prod.js +0 -50
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const test = require('tape');
|
|
3
|
-
const fs = require('fs-extra');
|
|
4
|
-
const { utils } = require('../../../src/index.cjs');
|
|
5
|
-
const ByteArray = utils.ByteArray;
|
|
6
|
-
const { unpackEnum } = utils.succinct;
|
|
7
|
-
const { inspectEnum, inspectSuccinct } = utils.inspect;
|
|
8
|
-
const { enumStringIndex, enumRegexIndexTuples } = utils.enums;
|
|
9
|
-
|
|
10
|
-
const testGroup = 'Inspect';
|
|
11
|
-
|
|
12
|
-
const serialized = fs.readJsonSync(path.resolve(__dirname, '../../test_data/utils/serialize_example.json'));
|
|
13
|
-
|
|
14
|
-
test(
|
|
15
|
-
`enum array (${testGroup})`,
|
|
16
|
-
function (t) {
|
|
17
|
-
try {
|
|
18
|
-
t.plan(Object.keys(serialized.enums).length);
|
|
19
|
-
|
|
20
|
-
for (const enumString of Object.values(serialized.enums)) {
|
|
21
|
-
const ba = new ByteArray();
|
|
22
|
-
ba.fromBase64(enumString);
|
|
23
|
-
const enumArray = unpackEnum(ba);
|
|
24
|
-
t.ok(enumArray);
|
|
25
|
-
}
|
|
26
|
-
} catch (err) {
|
|
27
|
-
console.log(err);
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
test(
|
|
33
|
-
`enum entries (${testGroup})`,
|
|
34
|
-
function (t) {
|
|
35
|
-
try {
|
|
36
|
-
t.plan(Object.keys(serialized.enums).length);
|
|
37
|
-
|
|
38
|
-
for (const [category, enumString] of Object.entries(serialized.enums)) {
|
|
39
|
-
const ba = new ByteArray();
|
|
40
|
-
ba.fromBase64(enumString);
|
|
41
|
-
const enumStrings = unpackEnum(ba);
|
|
42
|
-
const inspected = inspectEnum(enumString);
|
|
43
|
-
// console.log("***", category, "***");
|
|
44
|
-
// console.log(inspected);
|
|
45
|
-
t.ok(inspected);
|
|
46
|
-
}
|
|
47
|
-
} catch (err) {
|
|
48
|
-
console.log(err);
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
test(
|
|
54
|
-
`succinct (${testGroup})`,
|
|
55
|
-
function (t) {
|
|
56
|
-
try {
|
|
57
|
-
t.plan(12);
|
|
58
|
-
const doc = Object.values(serialized.docs)[0];
|
|
59
|
-
const mainSequence = doc.sequences[doc.mainId];
|
|
60
|
-
|
|
61
|
-
for (const block of mainSequence.blocks) {
|
|
62
|
-
for (const [category, succinct] of Object.entries(block)) {
|
|
63
|
-
const inspected = inspectSuccinct(succinct, serialized.enums);
|
|
64
|
-
// console.log("***", category, "***");
|
|
65
|
-
// console.log(inspected);
|
|
66
|
-
t.ok(inspected);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
} catch (err) {
|
|
70
|
-
console.log(err);
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
test(
|
|
76
|
-
`enum index (${testGroup})`,
|
|
77
|
-
function (t) {
|
|
78
|
-
try {
|
|
79
|
-
t.plan(Object.entries(serialized.enums).length);
|
|
80
|
-
|
|
81
|
-
for (const [category, enumString] of Object.entries(serialized.enums)) {
|
|
82
|
-
const ba = new ByteArray();
|
|
83
|
-
ba.fromBase64(enumString);
|
|
84
|
-
const enumValues = unpackEnum(ba);
|
|
85
|
-
let allGood = true;
|
|
86
|
-
let count = 0;
|
|
87
|
-
|
|
88
|
-
for (const enumValue of enumValues) {
|
|
89
|
-
const enumIndex = enumStringIndex(ba, enumValue);
|
|
90
|
-
|
|
91
|
-
if (enumIndex < 0) {
|
|
92
|
-
allGood = false;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (enumIndex !== count) {
|
|
97
|
-
allGood = false;
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
count += 1;
|
|
101
|
-
}
|
|
102
|
-
t.ok(allGood);
|
|
103
|
-
}
|
|
104
|
-
} catch (err) {
|
|
105
|
-
console.log(err);
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
test(
|
|
111
|
-
`enum regex indexes (${testGroup})`,
|
|
112
|
-
function (t) {
|
|
113
|
-
try {
|
|
114
|
-
const expectedTokens = ['you', 'your', 'young', 'yourself', 'You', 'Your'];
|
|
115
|
-
t.plan(1 + expectedTokens.length);
|
|
116
|
-
const enumString = serialized.enums.wordLike;
|
|
117
|
-
const ba = new ByteArray();
|
|
118
|
-
ba.fromBase64(enumString);
|
|
119
|
-
const enumIndexes = enumRegexIndexTuples(ba, 'You');
|
|
120
|
-
const foundTokens = enumIndexes.map(ei => ei[1]);
|
|
121
|
-
t.equal(foundTokens.length, expectedTokens.length);
|
|
122
|
-
|
|
123
|
-
for (const expectedToken of expectedTokens) {
|
|
124
|
-
t.ok(foundTokens.includes(expectedToken));
|
|
125
|
-
}
|
|
126
|
-
} catch (err) {
|
|
127
|
-
console.log(err);
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
);
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
const deepEqual = require('deep-equal');
|
|
3
|
-
|
|
4
|
-
const { utils } = require('../../../src/index.cjs');
|
|
5
|
-
const { itemObjects2Arrays, itemArrays2Objects } = utils.itemDefs;
|
|
6
|
-
|
|
7
|
-
const itemObjects = [
|
|
8
|
-
{
|
|
9
|
-
type: 'token',
|
|
10
|
-
subType: 'wordLike',
|
|
11
|
-
payload: 'Hello',
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
type: 'scope',
|
|
15
|
-
subType: 'start',
|
|
16
|
-
payload: 'blockTag/p',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
type: 'graft',
|
|
20
|
-
subType: 'footnote',
|
|
21
|
-
payload: 'abcdefg',
|
|
22
|
-
},
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
const itemArrays = [
|
|
26
|
-
['token', 'wordLike', 'Hello'],
|
|
27
|
-
['scope', 'start', 'blockTag/p'],
|
|
28
|
-
['graft', 'footnote', 'abcdefg'],
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
const testGroup = 'item arrays and objects';
|
|
32
|
-
|
|
33
|
-
test(
|
|
34
|
-
`Arrays to Objects (${testGroup})`,
|
|
35
|
-
function (t) {
|
|
36
|
-
try {
|
|
37
|
-
t.plan(1);
|
|
38
|
-
const newObjects = itemArrays2Objects(itemArrays);
|
|
39
|
-
t.ok(deepEqual(itemObjects, newObjects));
|
|
40
|
-
} catch (err) {
|
|
41
|
-
console.log(err);
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
test(
|
|
47
|
-
`Objects to Arrays (${testGroup})`,
|
|
48
|
-
function (t) {
|
|
49
|
-
try {
|
|
50
|
-
t.plan(1);
|
|
51
|
-
t.ok(deepEqual(itemArrays, itemObjects2Arrays(itemObjects)));
|
|
52
|
-
} catch (err) {
|
|
53
|
-
console.log(err);
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
);
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
|
|
3
|
-
const { utils } = require('../../../src/index.cjs');
|
|
4
|
-
const ByteArray = utils.ByteArray;
|
|
5
|
-
const {
|
|
6
|
-
pushSuccinctTokenBytes, pushSuccinctGraftBytes, pushSuccinctScopeBytes,
|
|
7
|
-
} = utils.succinct;
|
|
8
|
-
|
|
9
|
-
const testGroup = 'Push Succinct';
|
|
10
|
-
|
|
11
|
-
test(
|
|
12
|
-
`Token (${testGroup})`,
|
|
13
|
-
function (t) {
|
|
14
|
-
try {
|
|
15
|
-
t.plan(2);
|
|
16
|
-
const ba = new ByteArray(1);
|
|
17
|
-
pushSuccinctTokenBytes(ba, 2, 299);
|
|
18
|
-
t.equal(ba.byte(1), 2);
|
|
19
|
-
t.equal(ba.nByte(2), 299);
|
|
20
|
-
} catch (err) {
|
|
21
|
-
console.log(err);
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
test(
|
|
27
|
-
`Graft (${testGroup})`,
|
|
28
|
-
function (t) {
|
|
29
|
-
try {
|
|
30
|
-
t.plan(2);
|
|
31
|
-
const ba = new ByteArray(1);
|
|
32
|
-
pushSuccinctGraftBytes(ba, 10, 299);
|
|
33
|
-
t.equal(ba.byte(1), 10);
|
|
34
|
-
t.equal(ba.nByte(2), 299);
|
|
35
|
-
} catch (err) {
|
|
36
|
-
console.log(err);
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
test(
|
|
42
|
-
`Scope (${testGroup})`,
|
|
43
|
-
function (t) {
|
|
44
|
-
try {
|
|
45
|
-
t.plan(2);
|
|
46
|
-
const ba = new ByteArray(1);
|
|
47
|
-
pushSuccinctScopeBytes(ba, 3, 2, [567]);
|
|
48
|
-
t.equal(ba.byte(1), 2);
|
|
49
|
-
t.equal(ba.nByte(2), 567);
|
|
50
|
-
} catch (err) {
|
|
51
|
-
console.log(err);
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
test(
|
|
57
|
-
`Scope missing args (${testGroup})`,
|
|
58
|
-
function (t) {
|
|
59
|
-
try {
|
|
60
|
-
t.plan(3);
|
|
61
|
-
const ba = new ByteArray(1);
|
|
62
|
-
t.throws(() => pushSuccinctScopeBytes(ba, undefined, 2, [567]));
|
|
63
|
-
t.throws(() => pushSuccinctScopeBytes(ba, 3, undefined, [567]));
|
|
64
|
-
t.throws(() => pushSuccinctScopeBytes(ba, 3, 2, undefined));
|
|
65
|
-
} catch (err) {
|
|
66
|
-
console.log(err);
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
);
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/* eslint-disable require-await */
|
|
2
|
-
const test = require('tape');
|
|
3
|
-
const { utils } = require('../../../src/index.cjs');
|
|
4
|
-
const {
|
|
5
|
-
scopeEnum, scopeEnumLabels, labelForScope, nComponentsForScope,
|
|
6
|
-
} = utils.scopeDefs;
|
|
7
|
-
|
|
8
|
-
const testGroup = 'Scope Def';
|
|
9
|
-
|
|
10
|
-
test(
|
|
11
|
-
`scopeEnum (${testGroup})`,
|
|
12
|
-
async function (t) {
|
|
13
|
-
try {
|
|
14
|
-
t.plan(1);
|
|
15
|
-
t.equal(scopeEnum['chapter'], 2);
|
|
16
|
-
} catch (err) {
|
|
17
|
-
console.log(err);
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
test(
|
|
23
|
-
`scopeEnumLabels (${testGroup})`,
|
|
24
|
-
async function (t) {
|
|
25
|
-
try {
|
|
26
|
-
t.plan(1);
|
|
27
|
-
t.equal(scopeEnumLabels[2], 'chapter');
|
|
28
|
-
} catch (err) {
|
|
29
|
-
console.log(err);
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
test(
|
|
35
|
-
`labelForScope (${testGroup})`,
|
|
36
|
-
async function (t) {
|
|
37
|
-
try {
|
|
38
|
-
t.plan(19);
|
|
39
|
-
t.equal(labelForScope('blockTag', ['p']), 'blockTag/p');
|
|
40
|
-
t.equal(labelForScope('inline', ['f']), 'inline/f');
|
|
41
|
-
t.equal(labelForScope('chapter', ['1']), 'chapter/1');
|
|
42
|
-
t.equal(labelForScope('verses', ['1-3']), 'verses/1-3');
|
|
43
|
-
t.equal(labelForScope('verse', ['2']), 'verse/2');
|
|
44
|
-
t.equal(labelForScope('span', ['nd']), 'span/nd');
|
|
45
|
-
t.equal(labelForScope('table', []), 'table');
|
|
46
|
-
t.equal(labelForScope('cell', ['thr2-3']), 'cell/colHeading/right/2');
|
|
47
|
-
t.equal(labelForScope('milestone', ['zaln']), 'milestone/zaln');
|
|
48
|
-
t.equal(labelForScope('spanWithAtts', ['w']), 'spanWithAtts/w');
|
|
49
|
-
t.equal(labelForScope('attribute', ['milestone', 'zaln', 'x-content', '0']), 'attribute/milestone/zaln/x-content/0');
|
|
50
|
-
t.equal(labelForScope('orphanTokens'), 'orphanTokens');
|
|
51
|
-
t.equal(labelForScope('hangingGraft'), 'hangingGraft');
|
|
52
|
-
t.equal(labelForScope('pubChapter', ['1']), 'pubChapter/1');
|
|
53
|
-
t.equal(labelForScope('pubVerse', ['1']), 'pubVerse/1');
|
|
54
|
-
t.equal(labelForScope('altChapter', ['1']), 'altChapter/1');
|
|
55
|
-
t.equal(labelForScope('altVerse', ['1']), 'altVerse/1');
|
|
56
|
-
t.equal(labelForScope('esbCat', ['x']), 'esbCat/x');
|
|
57
|
-
t.throws(() => labelForScope('banana'));
|
|
58
|
-
} catch (err) {
|
|
59
|
-
console.log(err);
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
test(
|
|
65
|
-
`nComponentsForScope (${testGroup})`,
|
|
66
|
-
async function (t) {
|
|
67
|
-
try {
|
|
68
|
-
t.plan(5);
|
|
69
|
-
t.equal(nComponentsForScope('table'), 1);
|
|
70
|
-
t.equal(nComponentsForScope('blockTag'), 2);
|
|
71
|
-
t.equal(nComponentsForScope('cell'), 4);
|
|
72
|
-
t.equal(nComponentsForScope('attribute'), 6);
|
|
73
|
-
t.throws(() => nComponentsForScope('banana'));
|
|
74
|
-
} catch (err) {
|
|
75
|
-
console.log(err);
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
);
|
|
79
|
-
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const test = require('tape');
|
|
3
|
-
const fs = require('fs-extra');
|
|
4
|
-
const { Validator } = require('proskomma-json-tools');
|
|
5
|
-
|
|
6
|
-
const { utils } = require('../../../src/index.cjs');
|
|
7
|
-
|
|
8
|
-
const testGroup = 'Validate Schema';
|
|
9
|
-
|
|
10
|
-
test(
|
|
11
|
-
`Validate valid document (${testGroup})`,
|
|
12
|
-
function (t) {
|
|
13
|
-
try {
|
|
14
|
-
t.plan(3);
|
|
15
|
-
const serialized = fs.readJsonSync(path.resolve(__dirname, '..', '..', 'test_data', 'utils', 'serialize_example.json'));
|
|
16
|
-
t.ok(serialized);
|
|
17
|
-
const validationReport = new Validator().validate('proskomma',
|
|
18
|
-
'succinct',
|
|
19
|
-
'0.2.0',
|
|
20
|
-
serialized
|
|
21
|
-
);
|
|
22
|
-
t.ok(validationReport.isValid);
|
|
23
|
-
t.equal(validationReport.errors, null);
|
|
24
|
-
} catch (err) {
|
|
25
|
-
console.log(err);
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
);
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
|
|
3
|
-
const { utils } = require('../../../src/index.cjs');
|
|
4
|
-
const ByteArray = utils.ByteArray;
|
|
5
|
-
const {
|
|
6
|
-
pushSuccinctTokenBytes, pushSuccinctGraftBytes, pushSuccinctScopeBytes,
|
|
7
|
-
} = utils.succinct;
|
|
8
|
-
|
|
9
|
-
const testGroup = 'Splice';
|
|
10
|
-
|
|
11
|
-
test(
|
|
12
|
-
`Delete Item (${testGroup})`,
|
|
13
|
-
function (t) {
|
|
14
|
-
try {
|
|
15
|
-
t.plan(4);
|
|
16
|
-
const ba = new ByteArray(1);
|
|
17
|
-
pushSuccinctTokenBytes(ba, 1, 299);
|
|
18
|
-
pushSuccinctGraftBytes(ba, 10, 143);
|
|
19
|
-
pushSuccinctScopeBytes(ba, 3, 2, [567]);
|
|
20
|
-
const firstLength = ba.byte(0) & 0x0000003F;
|
|
21
|
-
const secondLength = ba.byte(firstLength) & 0x0000003F;
|
|
22
|
-
const thirdLength = ba.byte(firstLength + secondLength) & 0x0000003F;
|
|
23
|
-
t.equal(firstLength + secondLength + thirdLength, ba.length);
|
|
24
|
-
ba.deleteItem(firstLength);
|
|
25
|
-
const newFirstLength = ba.byte(0) & 0x0000003F;
|
|
26
|
-
const newSecondLength = ba.byte(newFirstLength) & 0x0000003F;
|
|
27
|
-
t.equal(firstLength, newFirstLength);
|
|
28
|
-
t.equal(thirdLength, newSecondLength);
|
|
29
|
-
t.equal(newFirstLength + newSecondLength, ba.length);
|
|
30
|
-
} catch (err) {
|
|
31
|
-
console.log(err);
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
test(
|
|
37
|
-
`Insert (${testGroup})`,
|
|
38
|
-
function (t) {
|
|
39
|
-
try {
|
|
40
|
-
t.plan(7);
|
|
41
|
-
const ba = new ByteArray(8);
|
|
42
|
-
pushSuccinctTokenBytes(ba, 1, 299);
|
|
43
|
-
pushSuccinctScopeBytes(ba, 3, 2, [567]);
|
|
44
|
-
const tokenLength = ba.byte(0) & 0x0000003F;
|
|
45
|
-
const scopeLength = ba.byte(tokenLength) & 0x0000003F;
|
|
46
|
-
t.equal(tokenLength + scopeLength, ba.length);
|
|
47
|
-
const iba = new ByteArray(1);
|
|
48
|
-
pushSuccinctGraftBytes(iba, 10, 143);
|
|
49
|
-
ba.insert(tokenLength, iba);
|
|
50
|
-
const firstLength = ba.byte(0) & 0x0000003F;
|
|
51
|
-
const secondLength = ba.byte(firstLength) & 0x0000003F;
|
|
52
|
-
const thirdLength = ba.byte(firstLength + secondLength) & 0x0000003F;
|
|
53
|
-
t.equal(firstLength, tokenLength);
|
|
54
|
-
t.equal(secondLength, iba.length);
|
|
55
|
-
t.equal(thirdLength, scopeLength);
|
|
56
|
-
t.equal(firstLength + secondLength + thirdLength, ba.length);
|
|
57
|
-
const iba2 = new ByteArray(1);
|
|
58
|
-
pushSuccinctGraftBytes(iba2, 5, 47);
|
|
59
|
-
ba.insert(firstLength + secondLength + thirdLength, iba2);
|
|
60
|
-
const fourthLength = ba.byte(firstLength + secondLength + thirdLength) & 0x0000003F;
|
|
61
|
-
t.equal(fourthLength, iba2.length);
|
|
62
|
-
t.equal(firstLength + secondLength + thirdLength + fourthLength, ba.length);
|
|
63
|
-
} catch (err) {
|
|
64
|
-
console.log(err);
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
);
|
package/test/code/utils/tags.cjs
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/* eslint-disable require-await */
|
|
2
|
-
const test = require('tape');
|
|
3
|
-
const { utils } = require('../../../src/index.cjs');
|
|
4
|
-
const {
|
|
5
|
-
validateTags, validateTag, addTag, removeTag,
|
|
6
|
-
} = utils.tags;
|
|
7
|
-
|
|
8
|
-
const testGroup = 'Tags';
|
|
9
|
-
|
|
10
|
-
test(
|
|
11
|
-
`Validate Tag (${testGroup})`,
|
|
12
|
-
async function (t) {
|
|
13
|
-
try {
|
|
14
|
-
t.plan(2);
|
|
15
|
-
t.doesNotThrow(() => validateTag('foo'));
|
|
16
|
-
t.throws(() => validateTag('foo!'));
|
|
17
|
-
} catch (err) {
|
|
18
|
-
console.log(err);
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
test(
|
|
24
|
-
`Validate Tags (${testGroup})`,
|
|
25
|
-
async function (t) {
|
|
26
|
-
try {
|
|
27
|
-
t.plan(2);
|
|
28
|
-
t.doesNotThrow(() => validateTags(['foo', 'baa']));
|
|
29
|
-
t.throws(() => validateTags(['foo', 'baa!']));
|
|
30
|
-
} catch (err) {
|
|
31
|
-
console.log(err);
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
test(
|
|
37
|
-
`Add Tag (${testGroup})`,
|
|
38
|
-
async function (t) {
|
|
39
|
-
try {
|
|
40
|
-
t.plan(5);
|
|
41
|
-
let tags = new Set(['foo', 'baa']);
|
|
42
|
-
t.doesNotThrow(() => addTag(tags,'frob'));
|
|
43
|
-
t.equal(tags.size, 3);
|
|
44
|
-
t.ok(tags.has('frob'));
|
|
45
|
-
t.throws(() => addTag(tags, 'fooie!'));
|
|
46
|
-
t.equal(tags.size, 3);
|
|
47
|
-
} catch (err) {
|
|
48
|
-
console.log(err);
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
test(
|
|
54
|
-
`Remove Tag (${testGroup})`,
|
|
55
|
-
async function (t) {
|
|
56
|
-
try {
|
|
57
|
-
t.plan(6);
|
|
58
|
-
let tags = new Set(['foo', 'baa']);
|
|
59
|
-
t.doesNotThrow(() => removeTag(tags,'frob'));
|
|
60
|
-
t.equal(tags.size, 2);
|
|
61
|
-
t.doesNotThrow(() => removeTag(tags,'foo'));
|
|
62
|
-
t.equal(tags.size, 1);
|
|
63
|
-
t.throws(() => removeTag(tags, 'fooie!'));
|
|
64
|
-
t.equal(tags.size, 1);
|
|
65
|
-
} catch (err) {
|
|
66
|
-
console.log(err);
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
);
|