remote-abap-compiler
Version:
Remote ABAP compilation
103 lines (97 loc) • 4.84 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const login_1 = require("./login");
describe("CompilationRequestTest", () => {
it("Test: working", () => __awaiter(this, void 0, void 0, function* () {
const request = login_1.connect();
const source = `class main definition.
public section.
methods run importing out type ref to if_oo_adt_classrun_out.
endclass.
class main implementation.
method run.
out->write( 'Hello World' ).
endmethod.
endclass.`;
const result = yield request.compile(source);
chai_1.expect(result.success).eql(true);
chai_1.expect(result.output).eql("Hello World\n");
}));
it("Test: no main class", () => __awaiter(this, void 0, void 0, function* () {
const request = login_1.connect();
const source = `class main2 definition.
public section.
methods run importing out type ref to if_oo_adt_classrun_out.
endclass.
class main2 implementation.
method run.
out->write( 'Hello World' ).
endmethod.
endclass.`;
const result = yield request.compile(source);
chai_1.expect(result.success).eql(false);
chai_1.expect(result.errors).eql([{ errorMessage: "Missing class named \"MAIN\" with public method \"RUN\".",
line: -1,
offset: -1 }]);
}));
it("Test: no run method", () => __awaiter(this, void 0, void 0, function* () {
const request = login_1.connect();
const source = `class main definition.
public section.
methods run2 importing out type ref to if_oo_adt_classrun_out.
endclass.
class main implementation.
method run2.
out->write( 'Hello World' ).
endmethod.
endclass.`;
const result = yield request.compile(source);
chai_1.expect(result.success).eql(false);
chai_1.expect(result.errors).eql([{ errorMessage: "Missing class named \"MAIN\" with public method \"RUN\".",
line: -1,
offset: -1 }]);
}));
it("Test: no import parameter", () => __awaiter(this, void 0, void 0, function* () {
const request = login_1.connect();
const source = `class main definition.
public section.
methods run.
endclass.
class main implementation.
method run.
endmethod.
endclass.`;
const result = yield request.compile(source);
chai_1.expect(result.success).eql(false);
chai_1.expect(result.errors).eql([{ errorMessage: "The method \"RUN\" of class \"MAIN\" must have exactly one importing parameter" +
" of type \"REF TO IF_OO_ADT_CLASSRUN_OUT\".",
line: -1,
offset: -1 }]);
}));
it("Test: syntax error in user code", () => __awaiter(this, void 0, void 0, function* () {
const request = login_1.connect();
const source = `class main definition.
public section.
methods run importing out type ref to if_oo_adt_classrun_out.
endclass.
class main implementation.
method run.
not_exist.
endmethod.
endclass.`;
const result = yield request.compile(source);
chai_1.expect(result.success).eql(false);
chai_1.expect(result.errors).eql([{ errorMessage: "The statement \"NOT_EXIST\" is invalid. Check the spelling.",
line: 8,
offset: 25 }]);
}));
});