harmonyc 0.16.4 → 0.18.0

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/model/Router.d.ts DELETED
@@ -1,22 +0,0 @@
1
- import type { Branch } from './model.ts';
2
- export declare class Router<N> {
3
- outs: N[];
4
- index: number;
5
- random: () => number;
6
- started: Set<N>;
7
- covered: Set<N>;
8
- constructor(outs: N[], seed?: string);
9
- next(): N;
10
- get incompleteCount(): number;
11
- }
12
- type N = Branch;
13
- export declare class Routers {
14
- private root;
15
- routers: Map<Branch, Router<Branch>>;
16
- constructor(root: N);
17
- discover(branch: N): void;
18
- get(branch: N): Router<Branch>;
19
- nextWalk(): Branch[];
20
- getIncompleteCount(): number;
21
- }
22
- export {};
package/model/Router.js DELETED
@@ -1,54 +0,0 @@
1
- import { xmur3 } from "../util/xmur3.js";
2
- export class Router {
3
- constructor(outs, seed = 'TODO') {
4
- this.outs = outs;
5
- this.index = 0;
6
- this.started = new Set();
7
- this.covered = new Set();
8
- this.random = xmur3(seed);
9
- }
10
- next() {
11
- if (this.outs.length === 0)
12
- throw new Error('internal error: no outs');
13
- if (this.index < this.outs.length)
14
- return this.outs[this.index++];
15
- else
16
- return this.outs[this.random() % this.outs.length];
17
- }
18
- get incompleteCount() {
19
- return this.outs.length - this.index;
20
- }
21
- }
22
- export class Routers {
23
- constructor(root) {
24
- this.root = root;
25
- this.routers = new Map();
26
- this.discover(root);
27
- }
28
- discover(branch) {
29
- const successors = branch.successors;
30
- if (!this.routers.has(branch)) {
31
- this.routers.set(branch, new Router(successors));
32
- }
33
- for (const s of successors)
34
- this.discover(s);
35
- }
36
- get(branch) {
37
- if (!this.routers.has(branch)) {
38
- this.routers.set(branch, new Router(branch.successors));
39
- }
40
- return this.routers.get(branch);
41
- }
42
- nextWalk() {
43
- const walk = [];
44
- let current = this.root;
45
- while (current.successors.length) {
46
- current = this.get(current).next();
47
- walk.push(current);
48
- }
49
- return walk;
50
- }
51
- getIncompleteCount() {
52
- return Array.from(this.routers.values()).reduce((sum, r) => sum + r.incompleteCount, 0);
53
- }
54
- }
package/model/model.d.ts DELETED
@@ -1,205 +0,0 @@
1
- export interface CodeGenerator {
2
- feature(feature: Feature): void;
3
- testGroup(group: TestGroup): void;
4
- test(test: Test): void;
5
- phrase(phrase: Phrase): void;
6
- step(action: Action, responses: Response[]): void;
7
- errorStep(action: Action, errorResponse: ErrorResponse): void;
8
- setVariable(action: SetVariable): void;
9
- saveToVariable(response: SaveToVariable): void;
10
- stringLiteral(text: string, opts: {
11
- withVariables: boolean;
12
- }): string;
13
- codeLiteral(src: string): string;
14
- stringParamDeclaration(index: number): string;
15
- variantParamDeclaration(index: number): string;
16
- }
17
- export interface Location {
18
- line: number;
19
- column: number;
20
- fileName: string;
21
- }
22
- export declare class Feature {
23
- name: string;
24
- root: Section;
25
- prelude: string;
26
- constructor(name: string);
27
- get tests(): Test[];
28
- get testGroups(): (TestGroup | Test)[];
29
- toCode(cg: CodeGenerator): void;
30
- }
31
- export declare abstract class Branch {
32
- parent?: Branch;
33
- children: Branch[];
34
- isFork: boolean;
35
- isEnd: boolean;
36
- location?: Location;
37
- abstract get isEmpty(): boolean;
38
- constructor(children?: Branch[]);
39
- setFork(isFork: boolean): this;
40
- setFeature(feature: Feature): this;
41
- addChild<C extends Branch>(child: C, index?: number): C;
42
- get isLeaf(): boolean;
43
- get successors(): Branch[];
44
- get nextNonForkAncestorSibling(): Branch | undefined;
45
- get nextSibling(): Branch | undefined;
46
- get siblingIndex(): number;
47
- toString(): string;
48
- replaceWith(newBranch: Branch): this;
49
- switch(_i: number): this;
50
- }
51
- export declare class Step extends Branch {
52
- action: Action;
53
- responses: Response[];
54
- state?: State;
55
- constructor(action: Action, responses?: Response[], children?: Branch[], isFork?: boolean);
56
- get phrases(): Phrase[];
57
- toCode(cg: CodeGenerator): void;
58
- setFeature(feature: Feature): this;
59
- headToString(): string;
60
- toString(): string;
61
- get isEmpty(): boolean;
62
- switch(i: number): this;
63
- }
64
- export declare class State {
65
- text: string;
66
- constructor(text?: string);
67
- }
68
- export declare class Label {
69
- text: string;
70
- constructor(text?: string);
71
- get isEmpty(): boolean;
72
- }
73
- export declare class Section extends Branch {
74
- label: Label;
75
- constructor(label?: Label, children?: Branch[], isFork?: boolean);
76
- toString(): string;
77
- get isEmpty(): boolean;
78
- }
79
- export declare abstract class Part {
80
- toSingleLineString(): string;
81
- }
82
- export declare class DummyKeyword extends Part {
83
- text: string;
84
- constructor(text?: string);
85
- toString(): string;
86
- }
87
- export declare class Word extends Part {
88
- text: string;
89
- constructor(text?: string);
90
- toString(): string;
91
- }
92
- export declare class Repeater extends Part {
93
- choices: Part[][];
94
- constructor(choices: Part[][]);
95
- toString(): string;
96
- toSingleLineString(): string;
97
- }
98
- export declare class Switch extends Part {
99
- choices: Part[];
100
- constructor(choices: Part[]);
101
- toString(): string;
102
- toSingleLineString(): string;
103
- }
104
- export declare class Router extends Part {
105
- choices: Repeater[];
106
- constructor(choices: Repeater[]);
107
- toString(): string;
108
- toSingleLineString(): string;
109
- }
110
- export declare abstract class Arg extends Part {
111
- abstract toCode(cg: CodeGenerator): string;
112
- abstract toDeclaration(cg: CodeGenerator, index: number): string;
113
- }
114
- export declare class StringLiteral extends Arg {
115
- text: string;
116
- constructor(text?: string);
117
- toString(): string;
118
- toSingleLineString(): string;
119
- toCode(cg: CodeGenerator): string;
120
- toDeclaration(cg: CodeGenerator, index: number): string;
121
- }
122
- export declare class Docstring extends StringLiteral {
123
- toCode(cg: CodeGenerator): string;
124
- toString(): string;
125
- toSingleLineString(): string;
126
- }
127
- export declare class CodeLiteral extends Arg {
128
- src: string;
129
- constructor(src?: string);
130
- toString(): string;
131
- toCode(cg: CodeGenerator): string;
132
- toDeclaration(cg: CodeGenerator, index: number): string;
133
- }
134
- export declare abstract class Phrase {
135
- parts: Part[];
136
- feature: Feature;
137
- location?: Location;
138
- abstract get kind(): string;
139
- constructor(parts: Part[]);
140
- setFeature(feature: Feature): this;
141
- get keyword(): "When" | "Then";
142
- get args(): Arg[];
143
- get isEmpty(): boolean;
144
- abstract toCode(cg: CodeGenerator): void;
145
- toString(): string;
146
- toSingleLineString(): string;
147
- switch(i: number): Phrase;
148
- }
149
- export declare class Action extends Phrase {
150
- kind: string;
151
- toCode(cg: CodeGenerator): void;
152
- }
153
- export declare class Response extends Phrase {
154
- saveToVariable?: SaveToVariable | undefined;
155
- kind: string;
156
- constructor(parts: Part[], saveToVariable?: SaveToVariable | undefined);
157
- get isEmpty(): boolean;
158
- toString(): string;
159
- toSingleLineString(): string;
160
- toCode(cg: CodeGenerator): void;
161
- }
162
- export declare class ErrorResponse extends Response {
163
- message: StringLiteral | undefined;
164
- constructor(message: StringLiteral | undefined);
165
- toCode(cg: CodeGenerator): void;
166
- }
167
- export declare class SetVariable extends Action {
168
- variableName: string;
169
- value: Arg;
170
- constructor(variableName: string, value: Arg);
171
- toCode(cg: CodeGenerator): void;
172
- }
173
- export declare class SaveToVariable extends Part {
174
- variableName: string;
175
- constructor(variableName: string);
176
- toCode(cg: CodeGenerator): void;
177
- toString(): string;
178
- get words(): string[];
179
- }
180
- export declare class Precondition extends Branch {
181
- state: State;
182
- constructor(state?: string);
183
- get isEmpty(): boolean;
184
- }
185
- export declare function makeTests(root: Branch): Test[];
186
- export declare class Test {
187
- branches: Branch[];
188
- testNumber?: string;
189
- labels: string[];
190
- constructor(branches: Branch[]);
191
- get steps(): Step[];
192
- get last(): Step;
193
- get name(): string;
194
- toCode(cg: CodeGenerator): void;
195
- toString(): string;
196
- switch(j: number): Test;
197
- }
198
- export declare function makeGroups(tests: Test[]): (Test | TestGroup)[];
199
- export declare class TestGroup {
200
- name: string;
201
- items: (Test | TestGroup)[];
202
- constructor(name: string, items: (Test | TestGroup)[]);
203
- toString(): string;
204
- toCode(cg: CodeGenerator): void;
205
- }