-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parser setup functions and tests for source files
Signed-off-by: worksofliam <[email protected]>
- Loading branch information
1 parent
bda3061
commit b241c0c
Showing
4 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
p*.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
**free | ||
|
||
dcl-s text char(20); | ||
|
||
text = 'Hello, world!'; | ||
|
||
dsply text; | ||
|
||
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import setupParser, { getSourcesContent, getSourcesList } from "../parserSetup"; | ||
import { test, expect, describe } from "vitest"; | ||
import path from "path"; | ||
|
||
const parser = setupParser(); | ||
|
||
// The purpose of this file is to test the parser against all the sources in the sources directory to ensure it doesn't crash. | ||
|
||
test("Source Directory Tests", async () => { | ||
const list = await getSourcesList(); | ||
|
||
for (const source of list) { | ||
const basename = path.basename(source); | ||
const baseContent = await getSourcesContent(source); | ||
|
||
// These are typing tests. Can the parser accept half documents without crashing? | ||
|
||
let content = ``; | ||
|
||
let baseContentSplitUpIntoPieces = []; | ||
const pieceSize = Math.ceil(baseContent.length / 20); | ||
for (let i = 0; i < baseContent.length; i += pieceSize) { | ||
baseContentSplitUpIntoPieces.push(baseContent.slice(i, i + pieceSize)); | ||
} | ||
|
||
for (let i = 0; i < baseContentSplitUpIntoPieces.length; i++) { | ||
content += baseContentSplitUpIntoPieces[i]; | ||
|
||
await parser.getDocs(basename, content, {collectReferences: true, ignoreCache: true, withIncludes: true}); | ||
} | ||
} | ||
}); |