|
1 | 1 | import assert from "assert";
|
2 | 2 | import tmp from 'tmp';
|
3 |
| -import util from 'util'; |
| 3 | +import util, { TextDecoder } from 'util'; |
4 | 4 | import { Uri, workspace } from "vscode";
|
5 | 5 | import { TestSuite } from ".";
|
6 | 6 | import { Tools } from "../api/Tools";
|
7 | 7 | import { instance } from "../instantiate";
|
8 | 8 | import { CommandResult } from "../typings";
|
| 9 | +import { getMemberUri } from "../filesystems/qsys/QSysFs"; |
9 | 10 |
|
10 | 11 | export const ContentSuite: TestSuite = {
|
11 | 12 | name: `Content API tests`,
|
@@ -594,5 +595,37 @@ export const ContentSuite: TestSuite = {
|
594 | 595 | assert.deepStrictEqual(resultB.OBJTEXT, "Code for i test");
|
595 | 596 | }
|
596 | 597 | },
|
| 598 | + { |
| 599 | + name: `Write tab to member using SQL`, test: async () => { |
| 600 | + const lines = [ |
| 601 | + `if (a) {`, |
| 602 | + `\tcoolstuff();\t`, |
| 603 | + `}` |
| 604 | + ].join(`\n`); |
| 605 | + |
| 606 | + const connection = instance.getConnection(); |
| 607 | + const config = instance.getConfig()!; |
| 608 | + |
| 609 | + assert.ok(config.enableSourceDates, `Source dates must be enabled for this test.`); |
| 610 | + |
| 611 | + const tempLib = config!.tempLibrary; |
| 612 | + |
| 613 | + await connection!.runCommand({ command: `CRTSRCPF FILE(${tempLib}/TABTEST) RCDLEN(112)`, noLibList: true }); |
| 614 | + await connection!.runCommand({ command: `ADDPFM FILE(${tempLib}/TABTEST) MBR(THEBADONE) SRCTYPE(HELLO)` }); |
| 615 | + |
| 616 | + const theBadOneUri = getMemberUri({library: tempLib, file: `TABTEST`, name: `THEBADONE`, extension: `HELLO`}); |
| 617 | + |
| 618 | + // We have to read it first to create the alias! |
| 619 | + await workspace.fs.readFile(theBadOneUri); |
| 620 | + |
| 621 | + await workspace.fs.writeFile(theBadOneUri, Buffer.from(lines, `utf8`)); |
| 622 | + |
| 623 | + const memberContentBuf = await workspace.fs.readFile(theBadOneUri); |
| 624 | + const fileContent = new TextDecoder().decode(memberContentBuf) |
| 625 | + |
| 626 | + assert.strictEqual(fileContent, lines); |
| 627 | + |
| 628 | + } |
| 629 | + } |
597 | 630 | ]
|
598 | 631 | };
|
0 commit comments