@needle-tools/needle-component-compiler 1.9.4 → 1.10.1

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.
package/test/helpers.ts DELETED
@@ -1,72 +0,0 @@
1
- import { compile } from "../src/component-compiler";
2
- import { expect } from 'chai';
3
- import * as fs from "fs";
4
- import { debuglog } from "util";
5
-
6
- class TestOptions {
7
- ignoreWhiteSpace: boolean = true;
8
- }
9
-
10
- export function testCompile(code: string): string | null {
11
-
12
- const res = compile(code, "test", null, false);
13
- const output = res?.length > 0 ? res[0] : "";
14
-
15
- return output;
16
-
17
- }
18
-
19
- function compareByLine(output: string, expected: string) {
20
- const splitCode = /\r?\n/;
21
-
22
- if (output == null) {
23
-
24
- expect(expected).to.equal(output);
25
- }
26
- else {
27
-
28
- const outputLines = output.split(splitCode);
29
- const expectedLines = expected.split(splitCode);
30
- for (let i = 0; i < outputLines.length; i++) {
31
- const outputLine = outputLines[i].trim();
32
- const expectedLine = expectedLines[i].trim();
33
- expect(outputLine).to.equal(expectedLine, `Line ${i} does not match`);
34
- }
35
- }
36
-
37
- }
38
-
39
- export function compareCodegen(id: string, input: string, expected: string) {
40
- const baseDir = "test/codegen";
41
- if (!fs.existsSync(baseDir))
42
- fs.mkdirSync(baseDir);
43
- const dir = `${baseDir}/${id}`;
44
- if (!fs.existsSync(dir))
45
- fs.mkdirSync(dir);
46
- fs.writeFileSync(`${dir}\\input.ts`, input);
47
- const result = testCompile(input);
48
- if (result !== null)
49
- fs.writeFileSync(`${dir}\\output.cs`, result);
50
- fs.writeFileSync(`${dir}\\expected.cs`, expected);
51
-
52
- compareByLine(result, expected);
53
-
54
- // expect(result).to.equal(expected);
55
- }
56
-
57
- export function compareCodegenWithDefaultContext(id: string, input: string, expected: string) {
58
-
59
-
60
- expected = `// NEEDLE_CODEGEN_START
61
- // auto generated code - do not edit directly
62
-
63
- #pragma warning disable
64
-
65
- namespace Needle.Typescript.GeneratedComponents
66
- {
67
- \t` + expected + `
68
- }
69
-
70
- // NEEDLE_CODEGEN_END`;
71
- return compareCodegen(id, input, expected);
72
- }