@abaplint/transpiler 1.8.23 → 1.8.26
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.
|
@@ -18,11 +18,11 @@ class HandleDataElement {
|
|
|
18
18
|
fixedValues = doma.getFixedValues();
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
22
|
-
"objectType": "DTEL",
|
|
23
|
-
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
24
|
-
"domain": ${JSON.stringify(obj.getDomainName())},
|
|
25
|
-
"fixedValues": ${JSON.stringify(fixedValues)},
|
|
21
|
+
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
22
|
+
"objectType": "DTEL",
|
|
23
|
+
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
24
|
+
"domain": ${JSON.stringify(obj.getDomainName())},
|
|
25
|
+
"fixedValues": ${JSON.stringify(fixedValues)},
|
|
26
26
|
};`);
|
|
27
27
|
const output = {
|
|
28
28
|
object: {
|
|
@@ -12,10 +12,10 @@ class HandleTable {
|
|
|
12
12
|
return [];
|
|
13
13
|
}
|
|
14
14
|
const type = obj.parseType(reg);
|
|
15
|
-
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
16
|
-
"objectType": "TABL",
|
|
17
|
-
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
18
|
-
"keyFields": ${JSON.stringify(obj.listKeys())},
|
|
15
|
+
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
16
|
+
"objectType": "TABL",
|
|
17
|
+
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
18
|
+
"keyFields": ${JSON.stringify(obj.listKeys())},
|
|
19
19
|
};`);
|
|
20
20
|
const output = {
|
|
21
21
|
object: {
|
|
@@ -11,9 +11,9 @@ class HandleTableType {
|
|
|
11
11
|
return [];
|
|
12
12
|
}
|
|
13
13
|
const type = obj.parseType(reg);
|
|
14
|
-
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
15
|
-
"objectType": "TTYP",
|
|
16
|
-
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
14
|
+
const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
|
|
15
|
+
"objectType": "TTYP",
|
|
16
|
+
"type": ${new transpile_types_1.TranspileTypes().toType(type)},
|
|
17
17
|
};`);
|
|
18
18
|
const output = {
|
|
19
19
|
object: {
|
|
@@ -12,14 +12,14 @@ class DoTranspiler {
|
|
|
12
12
|
const source = new expressions_1.SourceTranspiler(true).transpile(found, traversal).getCode();
|
|
13
13
|
const idSource = unique_identifier_1.UniqueIdentifier.get();
|
|
14
14
|
const id = unique_identifier_1.UniqueIdentifier.get();
|
|
15
|
-
return new chunk_1.Chunk(`const ${idSource} = ${source};
|
|
16
|
-
for (let ${id} = 0; ${id} < ${idSource}; ${id}++) {
|
|
15
|
+
return new chunk_1.Chunk(`const ${idSource} = ${source};
|
|
16
|
+
for (let ${id} = 0; ${id} < ${idSource}; ${id}++) {
|
|
17
17
|
abap.builtin.sy.get().index.set(${id} + 1);`);
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
20
|
const unique = unique_identifier_1.UniqueIdentifier.get();
|
|
21
|
-
return new chunk_1.Chunk(`let ${unique} = 1;
|
|
22
|
-
while (true) {
|
|
21
|
+
return new chunk_1.Chunk(`let ${unique} = 1;
|
|
22
|
+
while (true) {
|
|
23
23
|
abap.builtin.sy.get().index.set(${unique}++);`);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -50,10 +50,10 @@ class ReadTableTranspiler {
|
|
|
50
50
|
if (s.includes("await")) {
|
|
51
51
|
const id = unique_identifier_1.UniqueIdentifier.get();
|
|
52
52
|
prefix += "const " + id + " = " + s + ";\n";
|
|
53
|
-
conds.push("abap.compare.eq(i." + components[i].concatTokens() + ", " + id + ")");
|
|
53
|
+
conds.push("abap.compare.eq(i." + components[i].concatTokens().toLowerCase() + ", " + id + ")");
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
56
|
-
conds.push("abap.compare.eq(i." + components[i].concatTokens() + ", " + s + ")");
|
|
56
|
+
conds.push("abap.compare.eq(i." + components[i].concatTokens().toLowerCase() + ", " + s + ")");
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
extra.push("withKey: (i) => {return " + conds.join(" && ") + ";}");
|
package/build/src/unit_test.js
CHANGED
|
@@ -6,10 +6,10 @@ const abaplint = require("@abaplint/core");
|
|
|
6
6
|
class UnitTest {
|
|
7
7
|
// todo, move this somewhere else, its much more than just unit test relevant
|
|
8
8
|
initializationScript(reg, dbSetup, extraSetup) {
|
|
9
|
-
let ret = `/* eslint-disable import/newline-after-import */
|
|
10
|
-
import runtime from "@abaplint/runtime";
|
|
11
|
-
global.abap = new runtime.ABAP();
|
|
12
|
-
${this.buildImports(reg)}
|
|
9
|
+
let ret = `/* eslint-disable import/newline-after-import */
|
|
10
|
+
import runtime from "@abaplint/runtime";
|
|
11
|
+
global.abap = new runtime.ABAP();
|
|
12
|
+
${this.buildImports(reg)}
|
|
13
13
|
export async function initializeABAP() {\n`;
|
|
14
14
|
if (dbSetup === "") {
|
|
15
15
|
ret += `// no database artifacts, skip DB initialization\n`;
|
|
@@ -27,19 +27,19 @@ export async function initializeABAP() {\n`;
|
|
|
27
27
|
return ret;
|
|
28
28
|
}
|
|
29
29
|
unitTestScriptOpen(reg, _skip, _only) {
|
|
30
|
-
let ret = `/* eslint-disable curly */
|
|
31
|
-
import fs from "fs";
|
|
32
|
-
import path from "path";
|
|
33
|
-
import {fileURLToPath} from "url";
|
|
34
|
-
import {initializeABAP} from "./init.mjs";
|
|
35
|
-
|
|
36
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
37
|
-
|
|
38
|
-
async function run() {
|
|
39
|
-
await initializeABAP();
|
|
40
|
-
let lt_input = new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30})}), {"withHeader":false,"type":"STANDARD","isUnique":false,"keyFields":[]});
|
|
41
|
-
let ls_input = new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30})});
|
|
42
|
-
let ls_result = new abap.types.Structure({list: new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30}), expected: new abap.types.String(), actual: new abap.types.String(), status: new abap.types.String(), runtime: new abap.types.Integer(), message: new abap.types.String(), js_location: new abap.types.String()}), {"withHeader":false,"type":"STANDARD","isUnique":false,"keyFields":[]}), json: new abap.types.String()});
|
|
30
|
+
let ret = `/* eslint-disable curly */
|
|
31
|
+
import fs from "fs";
|
|
32
|
+
import path from "path";
|
|
33
|
+
import {fileURLToPath} from "url";
|
|
34
|
+
import {initializeABAP} from "./init.mjs";
|
|
35
|
+
|
|
36
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
37
|
+
|
|
38
|
+
async function run() {
|
|
39
|
+
await initializeABAP();
|
|
40
|
+
let lt_input = new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30})}), {"withHeader":false,"type":"STANDARD","isUnique":false,"keyFields":[]});
|
|
41
|
+
let ls_input = new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30})});
|
|
42
|
+
let ls_result = new abap.types.Structure({list: new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30}), expected: new abap.types.String(), actual: new abap.types.String(), status: new abap.types.String(), runtime: new abap.types.Integer(), message: new abap.types.String(), js_location: new abap.types.String()}), {"withHeader":false,"type":"STANDARD","isUnique":false,"keyFields":[]}), json: new abap.types.String()});
|
|
43
43
|
`;
|
|
44
44
|
for (const obj of reg.getObjects()) {
|
|
45
45
|
if (reg.isDependency(obj) || !(obj instanceof abaplint.Objects.Class)) {
|
|
@@ -59,44 +59,44 @@ async function run() {
|
|
|
59
59
|
if (m.isForTesting === false) {
|
|
60
60
|
continue;
|
|
61
61
|
}
|
|
62
|
-
ret += ` ls_input.get().class_name.set("${obj.getName()}");
|
|
63
|
-
ls_input.get().testclass_name.set("${def.name.toUpperCase()}");
|
|
64
|
-
ls_input.get().method_name.set("${m.name.toUpperCase()}");
|
|
62
|
+
ret += ` ls_input.get().class_name.set("${obj.getName()}");
|
|
63
|
+
ls_input.get().testclass_name.set("${def.name.toUpperCase()}");
|
|
64
|
+
ls_input.get().method_name.set("${m.name.toUpperCase()}");
|
|
65
65
|
abap.statements.append({source: ls_input, target: lt_input});`;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
ret += `
|
|
71
|
-
|
|
72
|
-
ls_result.set(await abap.Classes["KERNEL_UNIT_RUNNER"].run({it_input: lt_input}));
|
|
73
|
-
fs.writeFileSync(__dirname + path.sep + "output.json", ls_result.get().json.get());
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
run().then(() => {
|
|
77
|
-
process.exit(0);
|
|
78
|
-
}).catch((err) => {
|
|
79
|
-
console.log(err);
|
|
80
|
-
process.exit(1);
|
|
70
|
+
ret += `
|
|
71
|
+
|
|
72
|
+
ls_result.set(await abap.Classes["KERNEL_UNIT_RUNNER"].run({it_input: lt_input}));
|
|
73
|
+
fs.writeFileSync(__dirname + path.sep + "output.json", ls_result.get().json.get());
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
run().then(() => {
|
|
77
|
+
process.exit(0);
|
|
78
|
+
}).catch((err) => {
|
|
79
|
+
console.log(err);
|
|
80
|
+
process.exit(1);
|
|
81
81
|
});`;
|
|
82
82
|
return ret;
|
|
83
83
|
}
|
|
84
84
|
unitTestScript(reg, skip, _only) {
|
|
85
|
-
let ret = `/* eslint-disable curly */
|
|
86
|
-
import fs from "fs";
|
|
87
|
-
import path from "path";
|
|
88
|
-
import {fileURLToPath} from "url";
|
|
89
|
-
import {initializeABAP} from "./init.mjs";
|
|
90
|
-
import runtime from "@abaplint/runtime";
|
|
91
|
-
|
|
92
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
93
|
-
|
|
94
|
-
async function run() {
|
|
95
|
-
await initializeABAP();
|
|
96
|
-
const unit = new runtime.UnitTestResult();
|
|
97
|
-
let clas;
|
|
98
|
-
let locl;
|
|
99
|
-
let meth;
|
|
85
|
+
let ret = `/* eslint-disable curly */
|
|
86
|
+
import fs from "fs";
|
|
87
|
+
import path from "path";
|
|
88
|
+
import {fileURLToPath} from "url";
|
|
89
|
+
import {initializeABAP} from "./init.mjs";
|
|
90
|
+
import runtime from "@abaplint/runtime";
|
|
91
|
+
|
|
92
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
93
|
+
|
|
94
|
+
async function run() {
|
|
95
|
+
await initializeABAP();
|
|
96
|
+
const unit = new runtime.UnitTestResult();
|
|
97
|
+
let clas;
|
|
98
|
+
let locl;
|
|
99
|
+
let meth;
|
|
100
100
|
try {\n`;
|
|
101
101
|
for (const obj of reg.getObjects()) {
|
|
102
102
|
if (reg.isDependency(obj) || !(obj instanceof abaplint.Objects.Class)) {
|
|
@@ -110,9 +110,9 @@ async function run() {
|
|
|
110
110
|
// todo, fix, there might be global test methods
|
|
111
111
|
continue;
|
|
112
112
|
}
|
|
113
|
-
ret += ` {
|
|
114
|
-
const {${def.name}} = await import("./${obj.getName().toLowerCase()}.${obj.getType().toLowerCase()}.testclasses.mjs");
|
|
115
|
-
locl = clas.addTestClass("${def.name}");
|
|
113
|
+
ret += ` {
|
|
114
|
+
const {${def.name}} = await import("./${obj.getName().toLowerCase()}.${obj.getType().toLowerCase()}.testclasses.mjs");
|
|
115
|
+
locl = clas.addTestClass("${def.name}");
|
|
116
116
|
if (${def.name}.class_setup) await ${def.name}.class_setup();\n`;
|
|
117
117
|
for (const m of def.methods) {
|
|
118
118
|
if (m.isForTesting === false) {
|
|
@@ -139,24 +139,24 @@ async function run() {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
ret += `// -------------------END-------------------
|
|
143
|
-
console.log(abap.console.get());
|
|
144
|
-
fs.writeFileSync(__dirname + path.sep + "output.xml", unit.xUnitXML());
|
|
145
|
-
} catch (e) {
|
|
146
|
-
if (meth) {
|
|
147
|
-
meth.fail();
|
|
148
|
-
}
|
|
149
|
-
console.log(abap.console.get());
|
|
150
|
-
fs.writeFileSync(__dirname + path.sep + "output.xml", unit.xUnitXML());
|
|
151
|
-
throw e;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
run().then(() => {
|
|
156
|
-
process.exit(0);
|
|
157
|
-
}).catch((err) => {
|
|
158
|
-
console.log(err);
|
|
159
|
-
process.exit(1);
|
|
142
|
+
ret += `// -------------------END-------------------
|
|
143
|
+
console.log(abap.console.get());
|
|
144
|
+
fs.writeFileSync(__dirname + path.sep + "output.xml", unit.xUnitXML());
|
|
145
|
+
} catch (e) {
|
|
146
|
+
if (meth) {
|
|
147
|
+
meth.fail();
|
|
148
|
+
}
|
|
149
|
+
console.log(abap.console.get());
|
|
150
|
+
fs.writeFileSync(__dirname + path.sep + "output.xml", unit.xUnitXML());
|
|
151
|
+
throw e;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
run().then(() => {
|
|
156
|
+
process.exit(0);
|
|
157
|
+
}).catch((err) => {
|
|
158
|
+
console.log(err);
|
|
159
|
+
process.exit(1);
|
|
160
160
|
});`;
|
|
161
161
|
return ret;
|
|
162
162
|
}
|
package/package.json
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "1.8.
|
|
4
|
-
"description": "Transpiler",
|
|
5
|
-
"main": "build/src/index.js",
|
|
6
|
-
"typings": "build/src/index.d.ts",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/abaplint/transpiler.git"
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"compile": "tsc",
|
|
13
|
-
"publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
14
|
-
"publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
15
|
-
"test": "npm run compile && mocha"
|
|
16
|
-
},
|
|
17
|
-
"mocha": {
|
|
18
|
-
"recursive": true,
|
|
19
|
-
"reporter": "progress",
|
|
20
|
-
"spec": "build/test/**/*.js",
|
|
21
|
-
"require": "source-map-support/register"
|
|
22
|
-
},
|
|
23
|
-
"keywords": [
|
|
24
|
-
"ABAP",
|
|
25
|
-
"abaplint"
|
|
26
|
-
],
|
|
27
|
-
"author": "abaplint",
|
|
28
|
-
"license": "MIT",
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"@abaplint/core": "^2.85.
|
|
31
|
-
"source-map": "^0.7.3"
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@types/chai": "^4.3.0",
|
|
35
|
-
"@types/mocha": "^9.1.0",
|
|
36
|
-
"chai": "^4.3.6",
|
|
37
|
-
"mocha": "^9.2.2",
|
|
38
|
-
"source-map-support": "^0.5.21",
|
|
39
|
-
"typescript": "^4.6.
|
|
40
|
-
}
|
|
41
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@abaplint/transpiler",
|
|
3
|
+
"version": "1.8.26",
|
|
4
|
+
"description": "Transpiler",
|
|
5
|
+
"main": "build/src/index.js",
|
|
6
|
+
"typings": "build/src/index.d.ts",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/abaplint/transpiler.git"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"compile": "tsc",
|
|
13
|
+
"publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
14
|
+
"publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
15
|
+
"test": "npm run compile && mocha"
|
|
16
|
+
},
|
|
17
|
+
"mocha": {
|
|
18
|
+
"recursive": true,
|
|
19
|
+
"reporter": "progress",
|
|
20
|
+
"spec": "build/test/**/*.js",
|
|
21
|
+
"require": "source-map-support/register"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"ABAP",
|
|
25
|
+
"abaplint"
|
|
26
|
+
],
|
|
27
|
+
"author": "abaplint",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@abaplint/core": "^2.85.53",
|
|
31
|
+
"source-map": "^0.7.3"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/chai": "^4.3.0",
|
|
35
|
+
"@types/mocha": "^9.1.0",
|
|
36
|
+
"chai": "^4.3.6",
|
|
37
|
+
"mocha": "^9.2.2",
|
|
38
|
+
"source-map-support": "^0.5.21",
|
|
39
|
+
"typescript": "^4.6.3"
|
|
40
|
+
}
|
|
41
|
+
}
|