Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.6.24, bugfix, IS SUPPLIED and boolc() #512

Merged
merged 4 commits into from Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@abaplint/transpiler-cli",
"version": "1.6.23",
"version": "1.6.25",
"description": "Transpiler - Command Line Interface",
"bin": {
"abap_transpile": "./abap_transpile"
Expand All @@ -22,7 +22,7 @@
"author": "abaplint",
"license": "MIT",
"devDependencies": {
"@abaplint/transpiler": "^1.6.23",
"@abaplint/transpiler": "^1.6.25",
"@types/glob": "^7.1.4",
"glob": "^7.1.7",
"@types/progress": "^2.0.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/runtime/package.json
@@ -1,6 +1,6 @@
{
"name": "@abaplint/runtime",
"version": "1.6.23",
"version": "1.6.25",
"description": "Transpiler - Runtime",
"main": "build/src/index.js",
"typings": "build/src/index.d.ts",
Expand Down
11 changes: 8 additions & 3 deletions packages/runtime/src/builtin/boolc.ts
@@ -1,6 +1,11 @@
import {String} from "../types";

export function boolc(input: boolean) {
const val = input === true ? "X" : "";
return new String().set(val);
export function boolc(input: boolean | undefined) {
if (input === true) {
return new String().set("X");
} else if (input === false || input === undefined) {
return new String().set("");
} else {
return new String().set("X");
}
}
4 changes: 4 additions & 0 deletions packages/runtime/src/statements/loop.ts
Expand Up @@ -23,6 +23,7 @@ export function* loop(table: Table | FieldSymbol | undefined, options?: ILoopOpt
const loopFrom = options?.from && options?.from.get() > 0 ? options.from.get() - 1 : 0;
let loopTo = options?.to && options.to.get() < length ? options.to.get() : length;
const loopIndex = table.startLoop(loopFrom);
let entered = false;

try {
const array = table.array();
Expand All @@ -47,11 +48,14 @@ export function* loop(table: Table | FieldSymbol | undefined, options?: ILoopOpt

yield current;

entered = true;
loopIndex.index++;
loopTo = options?.to && options.to.get() < array.length ? options.to.get() : array.length;
}
} finally {
table.unregisterLoop(loopIndex);
// @ts-ignore
abap.builtin.sy.get().subrc.set(entered ? 0 : 4);
}

}
2 changes: 1 addition & 1 deletion packages/transpiler/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/transpiler/package.json
@@ -1,6 +1,6 @@
{
"name": "@abaplint/transpiler",
"version": "1.6.23",
"version": "1.6.25",
"description": "Transpiler",
"main": "build/src/index.js",
"typings": "build/src/index.d.ts",
Expand Down
32 changes: 32 additions & 0 deletions test/operators/comparison.ts
Expand Up @@ -432,6 +432,38 @@ FORM run.
lcl_bar=>moo( opt = 1 ).
ENDFORM.

START-OF-SELECTION.
PERFORM run.`;
const js = await run(code);
const f = new AsyncFunction("abap", js);
await f(abap);
expect(abap.console.get()).to.equal("no\nyes\nyes");
});

it("IS SUPPLIED with boolc()", async () => {
const code = `
CLASS lcl_bar DEFINITION.
PUBLIC SECTION.
CLASS-METHODS moo
IMPORTING opt TYPE i OPTIONAL.
ENDCLASS.

CLASS lcl_bar IMPLEMENTATION.
METHOD moo.
IF boolc( opt IS SUPPLIED ) = abap_true.
WRITE / 'yes'.
ELSE.
WRITE / 'no'.
ENDIF.
ENDMETHOD.
ENDCLASS.

FORM run.
lcl_bar=>moo( ).
lcl_bar=>moo( 1 ).
lcl_bar=>moo( opt = 1 ).
ENDFORM.

START-OF-SELECTION.
PERFORM run.`;
const js = await run(code);
Expand Down
2 changes: 1 addition & 1 deletion test/statements/loop.ts
Expand Up @@ -268,7 +268,7 @@ describe("Running statements - LOOP", () => {
expect(abap.console.get()).to.equal("2-2.3-4.5-2.6-7.8-2.9-3.\n6-7.27-7.30-3.\n18-5.24-4.27-7.30-3.");
});

it.skip("LOOP should set sy-subrc", async () => {
it("LOOP should set sy-subrc", async () => {
const code = `
DATA tab TYPE STANDARD TABLE OF i WITH DEFAULT KEY.
APPEND 2 TO tab.
Expand Down